/************************************************************
 * fn: submit.js
 * dt: 24OCT06@1646h, 22SEP06@1019h
 * by: dan concepcion
 * --------------------------------------------------------
 * This file adds the html for the newsletter signup form. It 
 * is placed in this file to make changing the code easier in
 * cases where it would be needed to be changed universally.
 ************************************************************/

var prefix = "";

function getSignUpBox(){
	getSignUpBox2(0);
}

function getSignUpBox2(choice, thepage){	
	var htmlcode = '<span>';
	if(choice == 0) {
		calling_pg = "index.html";
		prefix="";
	}
	
	if(choice == 1) {
		prefix = "../html/";
		calling_pg = thepage + ".htm";
	} else prefix = "";
	
	htmlcode += '<form name="nlsuFrm" action="';
	
	if(choice == 1) htmlcode += '../';
	
	htmlcode += 'process/newsletter_subscribe.asp" method="post" onsubmit="return submitForm(this);">';
	htmlcode += '<input name="callingForm" type="hidden" value="newsletter" />';
	htmlcode += '<input name="calling_pg" type="hidden" value="../html/news.htm" />'; //' + prefix + calling_pg + '" />';
	htmlcode += '<input name="txtRequiredInputs" type="hidden" value="txtEmailBox-2" />';
	htmlcode += '<input type="hidden" name="process" value="true" />';

	htmlcode += '<table width="400" border="0" cellspacing="0" cellpadding="0" align="right">';
	htmlcode += '<tr><td style="padding:0 0 11px 0;">Sign up for our Newsletter <b>:</b></td>';
	htmlcode += '<td><input id="txtEmailBox" name="txtEmailBox" type="text" tabindex="1" size="25" ';
	htmlcode += 'maxlength="250" style="border: 1px solid #000000; margin: 0 0 7px 0;" /></td>';
	htmlcode += '<td><INPUT type="image" name="submit" src="/images/btn_submit.jpg" border="0" alt="Submit your email address for our Newsletter" width="56" height="18" hspace="0" vspace="0" align="middle" style="padding:0 25px 7px 0;"></td>';
	htmlcode += '</tr></table></form></span>';
	//alert('calling_pg: ' + calling_pg);
	document.write(htmlcode);	
} 


function submitForm (theForm) {
  if (!validateForm(theForm))  { 
  		return false
   }
}


function submitform2(){
	//var theLink = prefix + 'admin/thankyou.php";
	if(check4ValidEmail()) { document.nlsuFrm.submit(); alert('This is after the submit statement!'); }
	//window.open(theLink,"","top=100,left=400,width=400,height=300,status=no,toolbar=no,title=no,menu=no");
	else {
		alert('Please enter a valid email address.');
		document.nlsuFrm.txtEmailBox.value = "";
		//document.nlsuFrm.txtEmailBox.focus();
	}
}
 
function check4ValidEmail()
{
	var x = document.nlsuFrm.txtEmail.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(x);
}





//  page 
