// Confirmation Function

function confirmMsg(msg){
	if(!confirm(msg)){
		return false;

	} else {
		return true;

	}
}


//newsletter validation
function newsletter_validate_unsubsribe(){
	//alert(document.unsubsribe_newsletter.email.value);
	if(!validateEmail(document.unsubsribe_newsletter.email.value,1,1))
	{
	  // document.subsribe_newsletter.email.focus();
	  // document.unsubsribe_newsletter.email.focus();
	   return false;
	}
	return true;
}
function newsletter_validate_subsribe(){
	//alert(document.subsribe_newsletter.email.value,1,1);
	if(!validateEmail(document.subsribe_newsletter.email.value,1,1))
	{
	  // document.subsribe_newsletter.email.focus();
	  // document.unsubsribe_newsletter.email.focus();
	   return false;
	}
	return true;
}
function CheckPhoneNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789()-+ "
	var i = 0
	if (TheNumber=="") {
		// Return false if number is empty
		valid = 0
	}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
// Note: Remove the comments from the following line to see this
// for loop in action.
// alert(TheNumber.charAt(i) + " is no good.")
			valid = 0
		} // End if statement
	} // End for loop
	return valid
}
function verifyFields(formName) { 
	if(formName.name.value == "") { 
		alert('Please enter your name.');
		formName.name.focus();
		return false;
	}
	if (CheckPhoneNumber(formName.phone.value) == 0) { 
		alert('That is not a valid phone number.');
		formName.phone.focus();
		return false;
	}
	if(CheckPhoneNumber(formName.fax.value) == 0) { 
		alert('Please enter your fax number.');
		formName.fax.focus();
		return false;
	}
	if(formName.jtitle.value == "") { 
		alert('Please enter your job title.');
		formName.jtitle.focus();
		return false;
	}
	if(formName.email.value == "") { 
		alert('Please enter your e-mail address.');
		formName.email.focus();
		return false;
	}
	if(formName.cname.value == "") { 
		alert('Please enter your cpmpany name.');
		formName.cname.focus();
		return false;
	}
	if(formName.caddress.value == "") { 
		alert('Please enter your company\'s address.');
		formName.caddress.focus();
		return false;
	}
	if(formName.ccity.value == "") { 
		alert('Please enter your city.');
		formName.ccity.focus();
		return false;
	}
	if(formName.cstate.value == "") { 
		alert('Please enter your state or province.');
		formName.cstate.focus();
		return false;
	}
	if(formName.czip.value == "") { 
		alert('Please enter your zip or postal code.');
		formName.czip.focus();
		return false;
	}
}

function sendtofriend_validate(){
	if(sendtofriend.from.value == "") { 
		alert('Please enter your name.');
		sendtofriend.from.focus();
		return false;
	}
	if(!validateEmail(document.sendtofriend.femail.value,1,1))
	{
	   document.sendtofriend.femail.focus();
	   return false;
	}
	if(!validateEmail(document.sendtofriend.to.value,1,1))
	{
	   document.sendtofriend.to.focus();
	   return false;
	}
	return true;
}


//Email Validation Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}

startList = function() {

	// code for IE
	if(!document.body.currentStyle) return;
	var subs = document.getElementsByName('submenu');
	for(var i=0; i<subs.length; i++) {
		var li = subs[i].parentNode;
		if(li && li.lastChild.style) {
			li.onmouseover = function() {
				this.lastChild.style.visibility = 'visible';
			}
			li.onmouseout = function() {
				this.lastChild.style.visibility = 'hidden';
			}
		}
	}
}
window.onload=startList;