// JavaScript Document
  function confirmMsg(msg){
	if(!confirm(msg)){
		return false;
	} else {
		return true;
	}
}

function poplinks_cert(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=850,left=0,top=0,resizable=no,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}


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;
}

function restownerlogin_validate()
{
	     var txtusername = document.frm_restownerlogin.txtusername.value;
		 if (txtusername == "" )
		 { 
			 alert ("Please enter Your Username");
			 document.frm_restownerlogin.txtusername.focus();
			 return false;
		 }
		 var txtpassword = document.frm_restownerlogin.txtpassword.value;
		 if (txtpassword == "" )
		 { 
			 alert ("Please enter Your Password");
			 document.frm_restownerlogin.txtpassword.focus();
			 return false;
		 }	
		 
}
function loginvalidator()
{
	     var username = document.frm_loginvalidator.username.value;
		 if (username == "" )
		 { 
			 alert ("Please enter Your Username");
			 document.frm_loginvalidator.username.focus();
			 return false;
		 }
		 var password = document.frm_loginvalidator.password.value;
		 if (password == "" )
		 { 
			 alert ("Please enter Your Password");
			 document.frm_loginvalidator.password.focus();
			 return false;
		 }	
		 /*PasswordStr = document.frm_loginvalidator.password.value;
		 if (parseInt(PasswordStr.length) < 6 )
		 { 
			 alert ("Password must be of minimum six Characters");
			 document.frm_loginvalidator.password.focus();
			 return false;
		 }*/
		 
}
function pass_validate()
{
	     var oldpassword = document.form_change.oldpassword.value;
		 if (oldpassword == "" )
		 { 
			 alert ("Please enter Your Old Password");
			 document.form_change.oldpassword.focus();
			 return false;
		 }
		 var newpassword = document.form_change.newpassword.value;
		 if (newpassword == "" )
		 { 
			 alert ("Please enter Your New Password");
			 document.form_change.newpassword.focus();
			 return false;
		 }
		 var confirmpassword = document.form_change.confirmpassword.value;
		 if (confirmpassword == "" )
		 { 
			 alert ("Please enter Your Confirm Password");
			 document.form_change.confirmpassword.focus();
			 return false;
		 }
		 var confirmpassword = document.form_change.confirmpassword.value;
		 if (document.form_change.confirmpassword.value != document.form_change.newpassword.value)
		 { 
			 alert ("Paasword and Confirm Password must be same");
			 document.form_change.confirmpassword.focus();
			 return false;
		 }
}





function checkout_validate()
{    

      var email = document.frm_checkout.email.value;
	  if (email == "")
	   { 
		 alert ("Please enter the Email Address");
		 document.frm_checkout.email.focus();
		 return false;
	   }	
	  if (!validateEmail(document.frm_checkout.email.value,1,1)) 
	   {
		 document.frm_checkout.email.focus();
		 return false;
	  }
	
	  var name = document.frm_checkout.name.value;
		 if (name == "" )
		 { 
			 alert ("Please enter the full Name");
			 document.frm_checkout.name.focus();
			 return false;
		 }
		 var address1 = document.frm_checkout.address1.value;
		 if (address1 == "" )
		 { 
			 alert ("Please enter the Address");
			 document.frm_checkout.address1.focus();
			 return false;
		 }
		 var city = document.frm_checkout.city.value;
		 if (city == "" )
		 { 
			 alert ("Please enter the City");
			 document.frm_checkout.city.focus();
			 return false;
		 }
		 var state = document.frm_checkout.state.value;
		 if (state == "Select" )
		 { 
			 alert ("Please Choose the State");
			 document.frm_checkout.state.focus();
			 return false;
		 }
		 var zipcode = document.frm_checkout.zipcode.value;
		 if (zipcode == "" )
		 { 
			 alert ("Please enter the Zipcode");
			 document.frm_checkout.zipcode.focus();
			 return false;
		 }
		 var country = document.frm_checkout.country.value;
		 if (country == "" )
		 { 
			 alert ("Please enter the Country");
			 document.frm_checkout.country.focus();
			 return false;
		 }
		 
		 
		  var country = document.frm_checkout.country.value;
		 if (country == "" )
		 { 
			 alert ("Please enter the Country");
			 document.frm_checkout.country.focus();
			 return false;
		 }
		  var country = document.frm_checkout.country.value;
		 if (country == "" )
		 { 
			 alert ("Please enter the Country");
			 document.frm_checkout.country.focus();
			 return false;
		 }
		  var country = document.frm_checkout.country.value;
		 if (country == "" )
		 { 
			 alert ("Please enter the Country");
			 document.frm_checkout.country.focus();
			 return false;
		 }
/*		 if (document.frm_checkout.payment[0].checked == true)
		 {
			  var account = document.frm_checkout.account.value;
				 if (account == "" )
				 { 
					 alert ("Please enter the Account Nimber");
					 document.frm_checkout.account.focus();
					 return false;
				 }
				 if(document.frm_checkout.term.checked == false)
				 { 
					 alert ("Please agree Terms and Conditions");
					 document.frm_checkout.term.focus();
					 return false;
				 }
		 } else {*/
			 
				 if(document.frm_checkout.term_pay.checked == false)
				 { 
					 alert ("Please agree Terms and Conditions");
					 document.frm_checkout.term_pay.focus();
					 return false;
				 }			 
			 
		// }
			  
 }
		
		

/*function giftqty_validate()
{
	     var quantity = document.frm_giftqty.quantity.value;
		 if (quantity == "" )
		 { 
			 alert ("Please enter the Quantity");
			 document.frm_giftqty.quantity.focus();
			 return false;
		 }
		 if(document.frm_giftqty.quantity.value == 0)
	        {
			alert("Quantity  must not be Zero");
			document.frm_giftqty.quantity.focus();
			return false;
	        }
			if (isNaN(document.frm_giftqty.quantity.value))
	         { 
		 alert ("Quantity  must be numeric");
		 document.frm_giftqty.quantity.focus();
		 return false;
	         }
		 if(document.frm_giftqty.price.value == "")
	        {
			alert("Choose Price");
			document.frm_giftqty.price.focus();
			return false;
	        }
			 
}*/


function makevisible(cur,which){
strength=(which==0)? 1 : 0.4

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*170
}


function survey_validate() {
	
	  var name = document.survey.name.value;
		 if (name == "" )
		 { 
			 alert ("Please enter the full Name");
			 document.survey.name.focus();
			 return false;
		 }
	
	
      var email = document.survey.email.value;
	  if (email == "")
	   { 
		 alert ("Please enter the Email Address");
		 document.survey.email.focus();
		 return false;
	   }	
	  if (!validateEmail(document.survey.email.value,1,1)) 
	   {
		 document.survey.email.focus();
		 return false;
	  }
	

	  var name = document.survey.comments.value;
		 if (name == "" )
		 { 
			 alert ("Please enter the Comments");
			 document.survey.comments.focus();
			 return false;
		 }	
}

function certqty_validate()
{
	     var quantity = document.frm_certqty.quantity.value;
		 if (quantity == "" )
		 { 
			 alert ("Please enter the Quantity");
			 document.frm_certqty.quantity.focus();
			 return false;
		 }
		 if(document.frm_certqty.quantity.value == 0)
	        {
			alert("Quantity  must not be Zero");
			document.frm_certqty.quantity.focus();
			return false;
	        }
			if (isNaN(document.frm_certqty.quantity.value))
	         { 
		 alert ("Quantity  must be numeric");
		 document.frm_certqty.quantity.focus();
		 return false;
	         }
		 var price = document.frm_certqty.price.value;
		 if (price == "Value/Price" )
		 { 
			 alert ("Please enter the Value/Price");
			 document.frm_certqty.price.focus();
			 return false;
		 }
}
function corporatecertqty_validate()
{

	     var quantity = document.frm_corcertqty.quantity.value;
		 if (quantity == "" )
		 { 
			 alert ("Please enter the Quantity");
			 document.frm_corcertqty.quantity.focus();
			 return false;
		 }
		 if(document.frm_corcertqty.quantity.value == 0)
	        {
			alert("Quantity  must not be Zero");
			document.frm_corcertqty.quantity.focus();
			return false;
	        }
			if (isNaN(document.frm_corcertqty.quantity.value))
	         { 
		 alert ("Quantity  must be numeric");
		 document.frm_corcertqty.quantity.focus();
		 return false;
	         }
		 var price = document.frm_corcertqty.price.value;
		 if (price == "" )
		 { 
			 alert ("Please Choose the Value/Price");
			 document.frm_corcertqty.price.focus();
			 return false;
		 }
}
function certquantity_validate()
{
	     var quantity = document.frm_certqty.quantity.value;
		 if (quantity == "" )
		 { 
			 alert ("Please enter the Quantity");
			 document.frm_certqty.quantity.focus();
			 return false;
		 }
		 if(document.frm_certqty.quantity.value == 0)
	        {
			alert("Quantity  must not be Zero");
			document.frm_certqty.quantity.focus();
			return false;
	        }
			if (isNaN(document.frm_certqty.quantity.value))
	         { 
		 alert ("Quantity  must be numeric");
		 document.frm_certqty.quantity.focus();
		 return false;
	         }
		 var price = document.frm_certqty.price.value;
		 if (price == "" )
		 { 
			 alert ("Please Choose the Value/Price");
			 document.frm_certqty.price.focus();
			 return false;
		 }
}
function cart_validation()
{
	     var discount = document.frm_cart.discount.value;
		 if (discount == "" )
		 { 
			 alert ("Please enter the Discount");
			 document.frm_cart.discount.focus();
			 return false;
		 }
}

function zipsearch_validate()
{    

      var zipcode = document.form_zip.zipcode.value;
	  if (zipcode == "")
	   { 
		 alert ("Please enter the Zipcode");
		 document.form_zip.zipcode.focus();
		 return false;
	   }	
}
function fstatesearch_validate()
{    

      var state = document.frm_fstate.state.value;
	  if (state == "Choose")
	   { 
		 alert ("Please Choose the State");
		 document.frm_fstate.state.focus();
		 return false;
	   }	
}
function pass_validate()
{    
      var username = document.form_change.username.value;
	  if (username == "")
	   { 
		 alert ("Please Choose the Username");
		 document.form_change.username.focus();
		 return false;
	   }	
	   
      var password = document.form_change.password.value;
	  if (password == "")
	   { 
		 alert ("Please Choose the Password");
		 document.form_change.password.focus();
		 return false;
	   }
}
function staffs_validate()
{  
      var username = document.frm_addstaffs.username.value;
	  if (username == "")
	   { 
	     alert ("Please enter the Username");
		 document.frm_addstaffs.username.focus();
		 return false;
	   }	
	    var password = document.frm_addstaffs.password.value;
	  if (password == "")
	   { 
		 alert ("Please enter the Password");
		 document.frm_addstaffs.password.focus();
		 return false;
	   }	
	   var email = document.frm_addstaffs.email.value;
	  if (email == "")
	   { 
		 alert ("Please enter the Email Address");
		 document.frm_addstaffs.email.focus();
		 return false;
	   }	
	  if (!validateEmail(document.frm_addstaffs.email.value,1,1)) 
	   {
		 document.frm_addstaffs.email.focus();
		 return false;
	  }
}

function validno_validate()
{  
      var certno = document.frm_validno.certno.value;
	  if (certno == "")
	   { 
	     alert ("Please enter the Cetificate Validate Number");
		 document.frm_validno.certno.focus();
		 return false;
	   }	
}

function giftvalidno_validate()
{  
      var certno = document.frm_giftvalidno.certno.value;
	  if (certno == "")
	   { 
	     alert ("Please enter the Validate Number");
		 document.frm_giftvalidno.certno.focus();
		 return false;
	   }	
}

function validateno_validate()
{  

      var person = document.frm_validno.person.value;
	  if (person == "")
	   { 
	     alert ("Please enter the Validate Number");
		 document.frm_validno.person.focus();
		 return false;
	   }	
}

function membervalid()
{  
             	NameLength = document.frm_memvalid.name.length;
				if(NameLength > 1){
				for(NameIndex = 0; NameIndex < NameLength; NameIndex++ ){
						if(document.frm_memvalid.name[NameIndex].value == ""){
						alert ("Please enter the Member Name");
						document.frm_memvalid.name[NameIndex].focus();
						 return false;
						}
					 
					  if(document.frm_memvalid.mailid[NameIndex].value == ""){
					  alert ("Please enter the Mailid");
					  document.frm_memvalid.mailid[NameIndex].focus();
					  return false;
					  }
					  if (!validateEmail(document.frm_memvalid.mailid[NameIndex].value,1,1)) 
					   {
						document.frm_memvalid.mailid[NameIndex].focus();
						return false;
					  }
		       	 }
			 }
				
}
function customer_validate()
{  
      var mailto = document.frm_addcustomer.mailto.value;
	  if (mailto == "Select")
	   { 
	     alert ("Please Choose the Mailto field");
		 document.frm_addcustomer.mailto.focus();
		 return false;
	   }	
	    var subject = document.frm_addcustomer.subject.value;
	  if (subject == "")
	   { 
		 alert ("Please enter the subject");
		 document.frm_addcustomer.subject.focus();
		 return false;
	   }	
	   var message = document.frm_addcustomer.message.value;
	  if (message == "")
	   { 
		 alert ("Please enter the Message");
		 document.frm_addcustomer.message.focus();
		 return false;
	   }	
	  if(document.frm_addcustomer.sendmail[0].checked == false && document.frm_addcustomer.sendmail[1].checked == false )
		{
		alert("Please select any one of the Option");
		return false;
		}
		 if(document.frm_addcustomer.sendmail[0].checked == true  )
		{
		var specificdate = document.frm_addcustomer.specificdate.value;
	  if (specificdate == "")
	   { 
		 alert ("Please Pcik the specificdate From the date picker");
		 document.frm_addcustomer.specificdate.focus();
		 return false;
	   }
		}

}


function addcustomer_validate()
{  
      var cusname = document.frm_addcustomer.cusname.value;
	  if (cusname == "")
	   { 
	     alert ("Please Choose the Customer Name");
		 document.frm_addcustomer.cusname.focus();
		 return false;
	   }	
	    var email = document.frm_addcustomer.email.value;
	  if (email == "")
	   { 
		 alert ("Please enter the Email Address");
		 document.frm_addcustomer.email.focus();
		 return false;
	   }	
	  if (!validateEmail(document.frm_addcustomer.email.value,1,1)) 
	   {
		 document.frm_addcustomer.email.focus();
		 return false;
	  }
	   var dob = document.frm_addcustomer.dob.value;
	  if (dob == "")
	   { 
		 alert ("Please pick the date of birth from the date picker");
		 document.frm_addcustomer.dob.focus();
		 return false;
	   }
	   var anniversary = document.frm_addcustomer.anniversary.value;
	  if (anniversary == "")
	   { 
		 alert ("Please pick the Anniversary date from the date picker");
		 document.frm_addcustomer.anniversary.focus();
		 return false;
	   }
	   var zipcode = document.frm_addcustomer.zipcode.value;
	  if (zipcode == "")
	   { 
		 alert ("Please enter the Zipcode");
		 document.frm_addcustomer.zipcode.focus();
		 return false;
	   }
	  /* var daysbeforesend = document.frm_addcustomer.daysbeforesend.value;
	  if (daysbeforesend == "Select")
	   { 
		 alert ("Please Select the Days before send");
		 document.frm_addcustomer.daysbeforesend.focus();
		 return false;
	   }*/
	  if(document.frm_addcustomer.mailsendondate[0].checked == false && document.frm_addcustomer.mailsendondate[1].checked == false)
		{
		alert("Please select any one of the Option");
		return false;
		}
		

}

window.onload = function (){
	runSlideShow();
}

function emptyList( box ) 


{
	while ( box.options.length ) box.options[0] = null;
}

function fillList( box, arr ) 
{
	for ( i = 0; i < arr[0].length; i++ ) 
	{
		option = new Option( arr[0][i], arr[0][i+1] );
		box.options[box.length] = option;
		i=i+1;
	}
	//num=box.length;
	box.selectedIndex=0;
}

function changeList(box) 
{
	//alert(box.options[box.selectedIndex].value);
	list = lists[box.options[box.selectedIndex].value];
	if(box.options[box.selectedIndex].value != "" && box.options[box.selectedIndex].value != "choose")
	{
		emptyList(box.form.city);
		fillList( box.form.city, list );
	}
}


function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

