﻿var xmlDoc = null ;


function SendEmail(id){

if (document.subEmail.Name.value == ''){
tieto.innerHTML = '';
tieto.innerHTML = 'Enter your name';
return false;

}else if (document.subEmail.Email.value == ''){
tieto.innerHTML = '';
tieto.innerHTML = 'Enter email';
return false;


}else{

tieto.innerHTML = 'Sending email...';
document.subEmail.Email.disabled = true;
document.subEmail.Name.disabled = true;

var Name = document.subEmail.Name.value;
var Email = document.subEmail.Email.value; 

if (typeof window.ActiveXObject != 'undefined' ) {
	xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
	xmlDoc.onreadystatechange = naytatieto ;
} else {
	xmlDoc = new XMLHttpRequest();
	xmlDoc.onload = naytatieto ;
}
xmlDoc.open( "GET", "SendToFriend.asp?n="+Name+"&e="+Email+"&id="+id, true );
xmlDoc.send( null );

}

}

function naytatieto(){
if ( xmlDoc.readyState != 4 ) return ;
var teksti=xmlDoc.responseText;
tieto.innerHTML = teksti;
document.getElementById('EmailForm').style.display = 'none';
//document.temp1.nappula.value = 'Reset password';
//document.temp1.nappula.disabled = false;


}

function Tyhjaa(){
tieto.innerHTML = '';
document.subEmail.Email.value = '';
}

function EmailBlock(doWhat){
  var TamaKohta = document.getElementById('EmailFriend');
    TamaKohta.style.display = doWhat;
    
    if (doWhat == 'block'){
    var TamaKohta2 = document.getElementById('EmailForm');
    TamaKohta2.style.display = doWhat;
    tieto.innerHTML = '';
    document.subEmail.Email.disabled = false;
    document.subEmail.Name.disabled = false;
    document.subEmail.Email.value = '';
    document.subEmail.Name.value = '';
    }
}


