// JavaScript Document - used for validation with contact.aspx

var radio_selection = "" ;

function display_confirm()
{

	out = "\""; // replace this
	add = "\'"; // with this


	myWindow = window.open("", "Confirm","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=450,height=400") ;


	subject = document.getElementById('subject').value
	//subject = document.mail.subject.value
	while (subject.indexOf(out)>-1) {
		pos= subject.indexOf(out);
		subject = "" + (subject.substring(0, pos) + add +
		subject.substring((pos + out.length), subject.length));
	}

	comments = document.getElementById('comments').value
    //comments = document.mail.comments.value
	while (comments.indexOf(out)>-1) {
		pos= comments.indexOf(out);
		comments = "" + (comments.substring(0, pos) + add +
		comments.substring((pos + out.length), comments.length));
	}

	username = document.getElementById('username').value
    //username = document.mail.username.value
	while (username.indexOf(out)>-1) {
		pos= username.indexOf(out);
		username = "" + (username.substring(0, pos) + add +
		username.substring((pos + out.length), username.length));
	}

	lastname = document.getElementById('lastname').value
    //lastname = document.mail.lastname.value
	while (lastname.indexOf(out)>-1) {
		pos= lastname.indexOf(out);
		lastname = "" + (lastname.substring(0, pos) + add +
		lastname.substring((pos + out.length), lastname.length));
	}

	address = document.getElementById('address').value
    //address = document.mail.address.value
	while (address.indexOf(out)>-1) {
		pos= address.indexOf(out);
		address = "" + (address.substring(0, pos) + add +
		address.substring((pos + out.length), address.length));
	}

	city = document.getElementById('city').value
    //city = document.mail.city.value
	while (city.indexOf(out)>-1) {
		pos= city.indexOf(out);
		city = "" + (city.substring(0, pos) + add +
		city.substring((pos + out.length), city.length));
	}

	state = document.getElementById('state').value
    //state = document.mail.state.value
	while (state.indexOf(out)>-1) {
		pos= state.indexOf(out);
		state = "" + (state.substring(0, pos) + add +
		state.substring((pos + out.length), state.length));
	}

	zip = document.getElementById('zip').value
    //zip = document.mail.zip.value
	while (zip.indexOf(out)>-1) {
		pos= zip.indexOf(out);
		zip = "" + (zip.substring(0, pos) + add +
		zip.substring((pos + out.length), zip.length));
	}
	
	country = document.getElementById('country').value
    //country = document.mail.country.value
	while (country.indexOf(out)>-1) {
		pos= country.indexOf(out);
		country = "" + (country.substring(0, pos) + add +
		country.substring((pos + out.length), country.length));
	}

	from = document.getElementById('from').value
	//from = document.mail.from.value

	myWindow.document.open() ;
	myWindow.document.write('<HTML><HEAD>') ;
	myWindow.document.write('\n' +'<TITLE>NIDDK Confirm</TITLE>') ;
	myWindow.document.write('\n' +'</HEAD>') ;
	myWindow.document.write('\n' +'<BODY BGCOLOR="#FFFFFF">') ;


	myWindow.document.write('\n' + '<FORM METHOD="POST" ACTION="emailSent.aspx">') ;

	myWindow.document.write('\n' +'<H3>Here is the email address you provided: </H3>') ;
	myWindow.document.write('\n' + from +'<BR>') ;

	//myWindow.document.write('\n' +'<INPUT TYPE="HIDDEN" NAME="Return-HTML" value="mail_end.htm">') ;
	myWindow.document.write('\n' +'<INPUT TYPE="HIDDEN" NAME="To" value="ndic@info.niddk.nih.gov">') ;
	myWindow.document.write('\n' +'<INPUT TYPE="HIDDEN" NAME="From" value=') ;
	myWindow.document.write('"'+ from +'">') ;
	myWindow.document.write('\n' +'<INPUT TYPE="HIDDEN" NAME="Subject" value=') ;
	myWindow.document.write('"email request: ' + subject +'">') ;
	myWindow.document.write('\n' +'<INPUT TYPE="HIDDEN" NAME="Body" value="') ;
	myWindow.document.write('\n' + comments) ;
	myWindow.document.write('\n' + 'username: ' + username) ;
	myWindow.document.write('\n' + 'lastname: ' + lastname) ;
	myWindow.document.write('\n' + 'address: ' + address) ;
	myWindow.document.write('\n' + 'city: ' + city) ;
	myWindow.document.write('\n' + 'state: ' + state) ;
	myWindow.document.write('\n' + 'zip: ' + zip) ;
	myWindow.document.write('\n' + 'country: ' + country) ;
	myWindow.document.write('">') ;

	myWindow.document.write('\n' +'<P><FONT SIZE="+1"><B>Is it complete and correct?<BR>  (If not, click the "No" button and resubmit the form.)</B></FONT><P>') ;
	myWindow.document.write('\n' +'<CENTER><B><FONT SIZE="+1"><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Yes">&nbsp;<INPUT TYPE="RESET" NAME="cancel" VALUE="No" onClick=self.close()></FONT></B></CENTER>') ;
	myWindow.document.write('\n' +'</FORM>') ;
	myWindow.document.write('\n' +'</BODY>') ;
	myWindow.document.write('\n' +'</HTML>') ;
	myWindow.document.close() ;

}


function check_mistake()
{	

	if((document.getElementById('from').value == "") || document.getElementById('from').value == null)
	{
		alert("Please enter your email address.") ;
		document.getElementById('from').focus();
	}
	/*if ((document.mail.from1.value == "") || document.mail.from1.value == null)
	{
		alert("Please enter your email address.") ;
	}*/
	else if (radio_selection == "yes")
	{
		if ((document.getElementById('username').value == "") || document.getElementById('username').value == null)
		{
			alert("Please enter your first name.") ;
			document.getElementById('username').focus();
		}
		
		else if ((document.getElementById('lastname').value == "") || document.getElementById('lastname').value == null)
		{
			alert("Please enter your last name.") ;
			document.getElementById('lastname').focus();
		}
		
		else if ((document.getElementById('address').value == "") || document.getElementById('address').value == null)
		{
			alert("Please enter your address.") ;
			document.getElementById('address').focus();
		}
		
		else if ((document.getElementById('city').value == "") || document.getElementById('city').value == null)
		{
			alert("Please enter your city.") ;
			document.getElementById('city').focus();
		}
		
		else if ((document.getElementById('state').value == "") || document.getElementById('state').value == null)
		{
			alert("Please enter your state or province.") ;
			document.getElementById('state').focus();
		}
		
		else if ((document.getElementById('zip').value == "") || document.getElementById('zip').value == null)
		{
			alert("Please enter your zip code.") ;
			document.getElementById('zip').focus();
		}
		
		else if ((document.getElementById('country').value == "") || document.getElementById('country').value == null)
		{
			alert("Please enter your country.") ;
			document.getElementById('country').focus();
		}
	
		else
		{
			display_confirm() ;
		}
	}
	else
	{
		display_confirm() ;
	}

}

//-->

