// JavaScript Document
function redirect(url)
{
	window.location.href=url;
}
function frontsearch()
{
	document.frm_search.action="search.php";
	document.frm_search.submit();
}
function submitCategoryForm() {
	var list = document.form.list;
	theList="";
	// start with a "?" to make it look like a real query-string
	for (i = 0; i <= list.options.length-1; i++) { 
	theList += list.options[i].text;
	// a "&" only BETWEEN the items, so not at the end
	if (i != list.options.length-1) theList += "&;";
	}
	document.form.priority.value=theList;
	document.form.action="index.php?task=eventcategoryorder";
	}
	
function admin_validation(){
var txtUsername=document.Login.txtUsername.value;
	 if(txtUsername == "")
			 {
			 alert("User name is empty");
			 document.Login.txtUsername.focus();
			 return false;
			 }
var txtPassword=document.Login.txtPassword.value;
	 if(txtPassword == ""){
			 alert("Password is empty");
			 document.Login.txtPassword.focus();
			 return false;
	}
}
function newsletter_validate()
{
	var txtPassword=document.frm_newsletter.email.value;
	 if(txtPassword == ""){
			 alert("Please enter the email");
			 document.frm_newsletter.email.focus();
			 return false;
	}
	if (!validateEmail(document.frm_newsletter.email.value,1,1)) 
	{
		document.frm_newsletter.email.focus();
		return false;
	}	
	return true;
}


function confirmMsg(msg){
	if(!confirm(msg)){
		return false;

	} else {
		return true;

	}
}
function showhide(){
		if (!(document.checkout.chkDelivery.checked)){
		delistyle=document.getElementById("delivery");
		    if(delistyle){
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById("delivery");
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
	}

function indexebook_validate(){
	if(document.frm_ebook.txt_name.value == "")
	{
		alert("Please enter the Name");
		document.frm_ebook.txt_name.focus();
		return false;
	}
	if (!validateEmail(document.frm_ebook.txt_email.value,1,1)) 
	{
		document.frm_ebook.txt_email.focus();
		return false;
	}

}

function subscribe_validate(){
	if (!validateEmail(document.subscribe.email.value,1,1)) 
	{
		document.subscribe.email.focus();
		return false;
	}

}
function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=500,left=0,top=0,resizable=yes,scrollbars=no');
	if (window.focus) {newwindow.focus()}
}
function poplinkpage(url)
{
	newwindow=window.open(url,'ImageDisplay','height=600,width=500,left=0,top=0,resizable=yes,scrollbars=no');
	if (window.focus) {newwindow.focus()}
}


function popservices(url)
{
	newwindow=window.open(url,'ImageDisplay','height=625,width=600,left=0,top=0,resizable=yes,scrollbars=no');
	if (window.focus) {newwindow.focus()}
}

//Validation for form registration
function formvalidation(){
	if(document.frm_updateform.txt_heading.value == "")
	{
		alert("Enter the form heading");
		document.frm_updateform.txt_heading.focus();
		return false;
	}
	if(document.frm_updateform.txt_noofreg.value == "")
	{
		alert("Enter the number of registration allowed");
		document.frm_updateform.txt_noofreg.focus();
		return false;
	}
	if(isNaN(document.frm_updateform.txt_noofreg.value ))
	{
		alert("Enter the number of registration allowed in numeric value");
		document.frm_updateform.txt_noofreg.value = "";
		document.frm_updateform.txt_noofreg.focus();
		return false;
	}
	if(document.frm_updateform.eventfromdate.value == "")
	{
		alert("Choose the start date in date picker");
		document.frm_updateform.eventfromdate.focus();
		return false;
	}
	var evtdate = document.frm_updateform.eventfromdate.value;
	currentdate= new Date();
	curmonth = currentdate.getMonth() + 1;
	var curdate =  curmonth + "/" + currentdate.getDate() + "/" + currentdate.getFullYear();		
	if (!date_valid(curdate,evtdate)) 
	{
			alert ("Choose the statrt date greater than the today's date in date picker.");
			document.frm_updateform.eventfromdate.value == "";
			document.frm_updateform.eventfromdate.focus();
			return false;
	}
	if(document.frm_updateform.eventtodate.value == "")
	{
		alert("Choose the end date in date picker");
		document.frm_updateform.eventtodate.focus();
		return false;
	}
	if(document.frm_updateform.eventfromdate.value != "" && document.frm_updateform.eventtodate.value!="")
	if(!date_valid(document.frm_updateform.eventfromdate.value,document.frm_updateform.eventtodate.value)) 
	{
		alert ("Please choose the end date is greater than start date in date picker.");
		document.frm_updateform.eventtodate.value = "";
		document.frm_updateform.eventtodate.focus();
		return false;
	}
	if (!(document.frm_updateform.rdo_regtype[0].checked) && !(document.frm_updateform.rdo_regtype[1].checked))
	{
		alert ("Select the registration type.");
		return false;
	}
	if (document.frm_updateform.rdo_regtype[1].checked){
		if (!validateEmail(document.frm_updateform.payemail.value,1,1)) 
		{
			document.frm_updateform.payemail.focus();
			return false;
		}
		if(document.frm_updateform.payamount.value == "")
		{
			alert("Enter the pay amount");
			document.frm_updateform.payamount.focus();
			return false;
		}
		if(document.frm_updateform.paycurrency.value == "")
		{
			alert("Enter the pay currency");
			document.frm_updateform.paycurrency.focus();
			return false;
		}
		if(document.frm_updateform.discount.value == "")
		{
			alert("Choose the discount");
			document.frm_updateform.discount.focus();
			return false;
		}
	}
	if(document.frm_updateform.formname.value == "")
	{
		alert("Enter the form name");
		document.frm_updateform.formname.focus();
		return false;
	}
	if (!validateEmail(document.frm_updateform.email.value,1,1)) 
	{
		document.frm_updateform.email.focus();
		return false;
	}
}

//Function to get the color
function ChangeColor(s,dest)
  {
  	var newcolor=showModalDialog("../../include/select_color.html","","resizable: no; help: no; status: no; scroll: no;");
	if(newcolor != null)
	document.getElementById(s).value="#"+newcolor;
	document.getElementById(dest).style.background="#"+newcolor;
  }

/*function openwin(){
	document.viewcart.action="modifycart.php?pinserid="+document.viewcart.pid.value;
	document.viewcart.submit();
	}*/
	
function showcredit(){
	var chklen = document.checkout.ONE.length;
	for(index = 0; index < chklen ; index++){
		
				 if (document.checkout.ONE[index].checked){
						if(document.checkout.ONE[index].value == "AN"){
							cardstyle=document.getElementById("creditcard");
								if(cardstyle){
								cardstyle.style.display="block";
								cardstyle.style.visibility="visible";
								}				
							}//End of If
							else {
							cardstyle=document.getElementById("creditcard");
								if(cardstyle){
								cardstyle.style.display="none";
								cardstyle.style.visibility="hidden";
								}
							}//End of Else
				}//End of If
		} //End of For
}
//script validation for date 
function date_valid(txt_Disfrom,txt_Disto){
	var stdate=txt_Disfrom.split("/");
	var enddate=txt_Disto.split("/");
	var prostdate = new Date();
	prostdate.setFullYear(stdate[2]);
	prostdate.setMonth(stdate[0]-1);
	prostdate.setDate(stdate[1]);
	
	var proenddate = new Date();
	proenddate.setFullYear(enddate[2]);
	proenddate.setMonth(enddate[0]-1);
	proenddate.setDate(enddate[1]);
	
	var startingdate = prostdate.getTime();
	var endingdate = proenddate.getTime();

	if(startingdate > endingdate)
	{
		return false;
	}
	return true;
}


//Function for Department
function changecat_events(){
	var catname=document.frm_viewevents.catid.value;
		if (catname=="All"){
				window.location.href="index.php?task=eventview";
		}
		else{
				window.location.href="index.php?task=eventview&calmode="+document.frm_viewevents.catid.value;
		}
	}

//Add More Fields
function insertMoreUpload_form() 
{ 
	var nUploads = parseInt(document.getElementById('NumberOfUploads').value)+1;		 
	var tbody = document.getElementById("tabUpload").getElementsByTagName("tbody")[1]; 
	var row = document.createElement("TR"); 

	//insert second <td>
	var cell2 = document.createElement("TD");
	//cell2.setAttribute("colspan","2");
	cell2.setAttribute("valign","middle");
	cell2.setAttribute("align","center");
	//File
	var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","labelname" + nUploads);
	eInput.setAttribute("id","Label");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-serif; text-decoration:none;");	
	cell2.appendChild(eInput);
	
	// append all <td> to <tr>
	//insert second <td>
	var cell3 = document.createElement("TD");
	cell3.setAttribute("valign","middle");
	cell3.setAttribute("align","center");
	//File
	/*var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","fieldtype" + nUploads);
	eInput.setAttribute("id","fieldtype" + nUploads);
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");	
	cell3.appendChild(eInput);*/
	
	//File
	listarray = new Array("TextBox","TextArea","ListBox","RadioButton","CheckBox","FileField");
	var eInput = document.createElement("select"); 
	eInput.setAttribute("name","fieldtype" + nUploads);
	eInput.setAttribute("id","Type");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");
		var doc = eInput.ownerDocument;
		if (!doc)
			doc = eInput.document;
		for(listindex = 0; listindex < 6; listindex++){
			var opt = doc.createElement('OPTION');
			opt.value = listarray[listindex];
			opt.text = listarray[listindex];
			eInput.options.add(opt,listindex);
		}

	//eInput.new Option("TextBox","TextBox");
	cell3.appendChild(eInput);
	
	

	var cell4 = document.createElement("TD");
	//cell2.setAttribute("colspan","2");
	cell4.setAttribute("valign","top");
	cell4.setAttribute("align","center");
	//File
	var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","fieldvalue" + nUploads);
	eInput.setAttribute("id","FieldValue");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");	
	cell4.appendChild(eInput);
	

	row.appendChild(cell2); 
	row.appendChild(cell3); 
	row.appendChild(cell4); 
	tbody.appendChild(row);
	document.frm_updateform.NumberOfUploads.value = nUploads;
	return false;
}


//image Gallery
function addimg_validate(){
	if (document.addimage.filename.value == "") 
		{
				alert ("Please Browse the Image name.");
				document.addimage.filename.focus();
				return false;
		}
}

 function showState(passcountry){
		if (document.getElementById(passcountry).value == "United States of America"){
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="block";
				postate.style.visibility="visible";
			}
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="none";
				pootherstate.style.visibility="hidden";
			}
		}
		else{
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="block";
				pootherstate.style.visibility="visible";
			}
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="none";
				postate.style.visibility="hidden";
			}
		}
	}


//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;
}

 //Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

//script validation for date 
function date_valid(dateissue,dateissue2){
	var stdate=dateissue.split("/");
	var enddate=dateissue2.split("/");
	var prostdate = new Date();
	prostdate.setFullYear(stdate[2]);
	prostdate.setMonth(stdate[0]-1);
	prostdate.setDate(stdate[1]);
	
	var proenddate = new Date();
	proenddate.setFullYear(enddate[2]);
	proenddate.setMonth(enddate[0]-1);
	proenddate.setDate(enddate[1]);
	
	var startingdate = prostdate.getTime();
	var endingdate = proenddate.getTime();

	if(startingdate > endingdate)
	{
		return false;
	}
	return true;
}



//Move the Settings
function move(index,to) {
		var list = document.form.list;
		var total = list.options.length-1;
		if (index == -1) return false;
		if (to == +1 && index == total) return false;
		if (to == -1 && index == 0) return false;
		var items = new Array;
		var values = new Array;
		for (i = total; i >= 0; i--) {
		items[i] = list.options[i].text;
		values[i] = list.options[i].value;
		}
		for (i = total; i >= 0; i--) {
		if (index == i) {
		list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
		list.options[i] = new Option(items[i + to], values[i]);
		i--;
		}
		else {
		list.options[i] = new Option(items[i], values[i]);
		   }
		}
		list.focus();
}



function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length < 1 || month < 1 || month > 12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length < 1 || day < 1 || day > 31 || (month==2 && day > daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year < minYear || year > maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
} 

//Validation for ebook
function ebook_validate(){
	if(document.ebook.txt_name.value==""){
		alert("Please enter the Name");
		document.ebook.txt_name.focus();
		return false;
	}
	if (!validateEmail(document.ebook.txt_email.value,1,1)) 
	{
		document.ebook.txt_email.focus();
		return false;
	}

}
function loginpage_validate(){
var txtUsername=document.login.txtUsername.value;
	 if(txtUsername == "")
			 {
			 alert("User name is empty");
			 document.login.txtUsername.focus();
			 return false;
			 }
var txtPassword=document.login.txtPassword.value;
	 if(txtPassword == ""){
			 alert("Password is empty");
			 document.login.txtPassword.focus();
			 return false;
	}
}

function recommend_validate(){
var frndname=document.tell_story.frndname.value;
	 if(frndname == "")
			 {
			 alert("Enter Recommend this we bsite to name");
			 document.tell_story.frndname.focus();
			 return false;
			 }
	if (!validateEmail(document.tell_story.frndemail.value,1,1)) 
	{
		document.tell_story.frndemail.focus();
		return false;
	}
	
	var yourname=document.tell_story.yourname.value;
	 if(yourname == "")
			 {
			 alert("Enter Recommendation coming from name");
			 document.tell_story.yourname.focus();
			 return false;
			 }
	if (!validateEmail(document.tell_story.youremail.value,1,1)) 
	{
		document.tell_story.youremail.focus();
		return false;
	}
}

//validate for  Add product

function openwin(){
	 	var len=document.viewcart.ONE.length;
		   var flag=0;
		  	for(var index=0;index<len;index++)
			{
			quantity = document.viewcart.ONE[index].value;
			stockvalue = document.viewcart.STOCK[index].value;
				if( (quantity == "")  || isNaN(quantity) || (quantity == 0) || (quantity.indexOf("-") >= 0) || (quantity.indexOf(".") >= 0) || (quantity > 65535) )
				{
							alert("Type the valid quantity");
							document.viewcart.ONE[index].focus();
							return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.viewcart.ONE[index].focus();
						return false;
				}
						
			}
	document.viewcart.action="modifycart.php";
	document.viewcart.submit();
	}
	
function openwindow(){
	document.viewcart.action="deletecart.php";
	document.viewcart.submit();
}
//validation for register validations(admin reg & frontregister page)
function register_validate()
{
	 var emailid = document.frm_register.txtEmail.value;
	 if (emailid == "")
	 { 
		 alert ("Please enter the Email Address");
		 document.frm_register.txtEmail.focus();
		 return false;
	 }	
	 if(!validateEmail(document.frm_register.txtEmail.value,1,1))
	{
	   document.frm_register.txtEmail.focus();
	   return false;
	}
	 if (document.frm_register.txtPassword.value == "")
	 {
		alert("Enter the password");
		document.frm_register.txtPassword.focus();
		return false;
	 }
	 if (document.frm_register.txtConfirmPassword.value == "")
	 {
		alert("Enter the confirm password");
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	  if (document.frm_register.txtPassword.value != document.frm_register.txtConfirmPassword.value)
	 {
		alert("Enter the same password");
		document.frm_register.txtConfirmPassword.value="";
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	if (document.frm_register.txtFirst.value == "")
	 {
		alert("Enter the first name");
		document.frm_register.txtFirst.focus();
		return false;
	 }
	 if (document.frm_register.txtLast.value == "")
	 {
		alert("Enter the last name");
		document.frm_register.txtLast.focus();
		return false;
	 }
	 if (document.frm_register.txtPostcode1.value == "")
	 {
		alert("Enter the Apt No / Street Address");
		document.frm_register.txtPostcode1.focus();
		return false;
	 }

	if(document.frm_register.txtPostCountry.value == "Choose")
		{
		   alert("Select the country");
		   document.frm_register.txtPostCountry.focus();
		   return false;
		}
	 if (document.frm_register.txtPostState.value == "")
	 {
		alert("Enter the Post State");
		document.frm_register.txtPostState.focus();
		return false;
	 }
	 if (document.frm_register.txtPostZip2.value == "")
	 {
		alert("Enter the zipcode");
		document.frm_register.txtPostZip2.focus();
		return false;
	 }
	
	if(!(document.frm_register.chkDelivery.checked))
		{
		    if(document.frm_register.txtDelicode1.value=="")
			{
			   alert("Enter the delivery Apt No / Street Address");
			   document.frm_register.txtDelicode1.focus();
			   return false;
			} 
			if(document.frm_register.txtDelicode2.value=="")
			{
			   alert("Enter the delivery address line2");
			   document.frm_register.txtDelicode2.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCity.value=="")
			{
			   alert("Enter the city");
			   document.frm_register.txtDeliCity.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCountry.value == "Choose")
			{
			   alert("Select the country");
			   document.frm_register.txtDeliCountry.focus();
			   return false;
			}
			if(document.frm_register.txtDeliState.value=="")
			{
			   alert("Enter the state");
			   document.frm_register.txtDeliState.focus();
			   return false;
			}
			if(document.frm_register.txtDeliZip.value=="")
			{
			   alert("Enter the zipcode");
			   document.frm_register.txtDeliZip.focus();
			   return false;
			}
			
		}
		
		/*if(document.frm_register.txtHomeph.value=="")
			{
			   alert("Enter the Home phone number");
			   document.frm_register.txtHomeph.focus();
			   return false;
			}
			if(document.frm_register.txtFax.value=="")
			{
			   alert("Enter the Fax number");
			   document.frm_register.txtFax.focus();
			   return false;
			}*/
}
function emailcheck(emailvalue)
{
	var flagcheck;

	if ((emailvalue.length > 0 && (emailvalue.indexOf("@",0) == - 1 || emailvalue.indexOf(".",0) == - 1)))  
	{
		flagcheck=true;
	}
	emailval=emailvalue
	apos=emailval.indexOf("@");
	dotpos=emailval.lastIndexOf(".");
	lastpos=emailval.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{
		flagcheck=true;
	}
	return flagcheck;
	
}


function feedback_validate(){
	 if (document.feedback.txtName.value == "")
	 {
		alert("Enter the name");
		document.feedback.txtName.focus();
		return false;
	 }
	 if (document.feedback.txtcompany.value == "")
	 {
		alert("Enter the Company");
		document.feedback.txtcompany.focus();
		return false;
	 }
	 if(!validateEmail(document.feedback.txtEmail.value,1,1))
	{
	   document.feedback.txtEmail.focus();
	   return false;
	}
	 if (document.feedback.txtAddress1.value == "")
	 {
		alert("Enter the Address");
		document.feedback.txtAddress1.focus();
		return false;
	 }
	 if (document.feedback.txtCity.value == "")
	 {
		alert("Enter the City");
		document.feedback.txtCity.focus();
		return false;
	 }
	 if (document.feedback.txtState.value == "")
	 {
		alert("Enter the State");
		document.feedback.txtState.focus();
		return false;
	 }
	 if (document.feedback.txtZip.value == "")
	 {
		alert("Enter the Zipcode");
		document.feedback.txtZip.focus();
		return false;
	 }
	 if (document.feedback.txtcountry.value == "")
	 {
		alert("Enter the Country");
		document.feedback.txtcountry.focus();
		return false;
	 }
	 if (document.feedback.txtfeedback.value == "")
	 {
		alert("Choose the any one category Comment ot Question ");
		document.feedback.txtfeedback.focus();
		return false;
	 }
	 if (document.feedback.txtabout.value == "")
	 {
		alert("Choose the About");
		document.feedback.txtabout.focus();
		return false;
	 }

}
function cartqty_validate(){
	/* if (document.viewcart.getElementById(ONE).value == 0)
	 {
		alert("Enter the quantity");
		document.viewcart.getElementById(ONE).focus();
		return false;
	 }*/
	 if (document.viewcart.getElementById(ONE).value == 0)
	 {
		alert("Enter the quantity");
		document.viewcart.getElementById(ONE).focus();
		return false;
	 }
	 	var len=document.viewcart.ONE.length;
		   var flag=0;
		  	for(var index=0;index<len;index++)
			{
			quantity = document.viewcart.ONE[index].value;
			stockvalue = document.viewcart.STOCK[index].value;
				if( (quantity == "")  || isNaN(quantity) || (quantity == 0) || (quantity.indexOf("-") >= 0) || (quantity.indexOf(".") >= 0) || (quantity > 65535) )
				{
							alert("Type the valid quantity");
							document.viewcart.ONE[index].focus();
							return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.viewcart.ONE[index].focus();
						return false;
				}
						
			}
			return true;
	/*document.viewcart.action="modifycart.php";
	document.viewcart.submit();	 */
	 
}

function checkout_validation(){
	 if (document.checkout.txtFirst.value == "")
	 {
		alert("Enter the name");
		document.checkout.txtFirst.focus();
		return false;
	 }
	 if(!validateEmail(document.checkout.txtEmail.value,1,1))
	{
	   document.checkout.txtEmail.focus();
	   return false;
	}
	  if (document.checkout.txtPostcode1.value == "")
	 {
		alert("Enter the address line1");
		document.checkout.txtPostcode1.focus();
		return false;
	 }
	 if (document.checkout.txtPostCity.value == "")
	 {
		alert("Enter the city");
		document.checkout.txtPostCity.focus();
		return false;
	 }
	 if (document.checkout.txtPostState.value == "")
	 {
		alert("Enter the State");
		document.checkout.txtPostState.focus();
		return false;
	 }
	 if (document.checkout.txtPostZip.value == "")
	 {
		alert("Enter the zipcode");
		document.checkout.txtPostZip.focus();
		return false;
	 }
	 if(document.checkout.txtPostCountry.value == "Choose")
		{
		   alert("Select the country");
		   document.checkout.txtPostCountry.focus();
		   return false;
		}
	if(!(document.checkout.chkDelivery.checked))
		{
		    if(document.checkout.txtDelicode1.value=="")
			{
			   alert("Enter the delivery address line1");
			   document.checkout.txtDelicode1.focus();
			   return false;
			} 
			if(document.checkout.txtDeliCity.value=="")
			{
			   alert("Enter the city");
			   document.checkout.txtDeliCity.focus();
			   return false;
			}
			if(document.checkout.txtDeliState.value=="")
			{
			   alert("Enter the state");
			   document.checkout.txtDeliState.focus();
			   return false;
			}
			if(document.checkout.txtDeliZip.value=="")
			{
			   alert("Enter the zipcode");
			   document.checkout.txtDeliZip.focus();
			   return false;
			}
			if(document.checkout.txtDeliCountry.value == "Choose")
			{
			   alert("Select the country");
			   document.checkout.txtDeliCountry.focus();
			   return false;
			}
		}
		
}

//contact us validations

function contact_validations()
{
   if(document.contact.Comment.value=="")
	{
	  alert("Please Enter the Comments");
	  document.contact.Comment.focus();
	  return false;s
	}
   if(document.contact.Email.value=="")
	{
	  alert("Please Enter the Email");
	  document.contact.Email.focus();
	  return false;s
	}
   var res=emailcheck(document.contact.Email.value);
		 if(res)
		 {
			 alert("Please enter valid Email Address with correct domain name (i.e).com,.org.in");
			 document.contact.Email.focus();
			 flagcheck=false;
			 return false;
		 }
   if(document.contact.Name.value=="")
	{
	  alert("Please Enter the Name");
	  document.contact.Name.focus();
	  return false;
	}
}

//customer validations 

function frontlog1()
{
	 var emailid = document.Frmlogin1.txtUsername.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the User Email Address");
	 document.Frmlogin1.txtUsername.focus();
	 return false;
	 }	
	 if (!validateEmail(document.Frmlogin1.txtUsername.value,1,1)) 
	 {
	 document.Frmlogin1.txtUsername.focus();
	 return false;
	 }
   if(document.Frmlogin1.txtPassword.value=="")
	{
	  alert("Please Enter the Password");
	  document.Frmlogin1.txtPassword.focus();
	  return false;
	}

}


//script for registration

function reg_validation()
{	
	 var cname = document.register.companyname.value;
	 if (cname == "")
	 { 
	 alert ("Please enter the Company Name:");
	 document.register.companyname.focus();
	 return false;
	 }
	 var title = document.register.title.value;
	 if (title == "")
	 { 
	 alert ("Please enter the Title:");
	 document.register.title.focus();
	 return false;
	 }
	 var firstname = document.register.firstname.value;
	 if (firstname == "" )
	 { 
	 alert ("Please enter the First Name");
	 document.register.firstname.focus();
	 return false;
	 }
	var lastname = document.register.lastname.value; 
	 if (lastname == "")
	 { 
	 alert ("Please enter the Last Name");
	 document.register.lastname.focus();
	 return false;
	 }
	var middlename = document.register.middlename.value; 
	 if (middlename == "")
	 { 
	 alert ("Please enter the Middle Name");
	 document.register.middlename.focus();
	 return false;
	 }

    var address1 = document.register.add1.value;
	 if (address1 == "" )
	 { 
	 alert ("Please enter the Address 1:");
	 document.register.add1.focus();
	 return false;
	 }
/*	 var state = document.register.add2.value;
	 if (state == "")
	 { 
	 alert ("Please enter the Address 2:");
	 document.register.add2.focus();
	 return false;
	 }
*/	 var city=document.register.city.value;
	 if (city=="" )
	 { 
	 alert ("Please enter the City Name");
	 document.register.city.focus();
	 return false;
	 }
	 var zipcode = document.register.postalcode.value;
	 if (zipcode == "" )
	 { 
	 alert ("Please enter the Postal Code");
	 document.register.postalcode.focus();
	 return false;
	 }	
	 if (isNaN(document.register.postalcode.value))
	 { 
	 alert ("Post Code must be numeric");
	 document.register.postalcode.focus();
	 return false;
	 }	
	 var country=document.register.country.value;
	 if (country == "Choose")
	 { 
	 alert ("Plese select Country");
	 document.register.country.focus();
	 return false;
	 }
	 var phoneno = document.register.phoneno.value;
	 if (phoneno == "")
	 { 
	 alert ("Please enter the Phone Number");
	 document.register.phoneno.focus();
	 return false;
	 }	
	 if (isNaN(document.register.phoneno.value))
	 { 
	 alert ("Phone Number must be numeric");
	 document.register.phoneno.focus();
	 return false;
	 }		
	 var emailid = document.register.email.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the Email Address");
	 document.register.email.focus();
	 return false;
	 }	
	 if (!validateEmail(document.register.email.value,1,1)) 
	 {
	 document.register.email.focus();
	 return false;
	 }
}
function showhide(){
		if (!(document.frm_register.chkDelivery.checked)){
		delistyle=document.getElementById("delivery");
		    if(delistyle){
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById("delivery");
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
	}
function emailcheck(emailvalue)
{
	var flagcheck;

	if ((emailvalue.length > 0 && (emailvalue.indexOf("@",0) == - 1 || emailvalue.indexOf(".",0) == - 1)))  
	{
		flagcheck=true;
	}
	emailval=emailvalue
	apos=emailval.indexOf("@");
	dotpos=emailval.lastIndexOf(".");
	lastpos=emailval.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{
		flagcheck=true;
	}
	return flagcheck;
	
}
function frontleftlogin()
{
	/*if(document.login.txtUsername.value=="")
	{
	   alert("Enter the Username");
	   document.login.txtUsername.focus();
	   return false;
	}*/
	 var emailid = document.login.txtUsername.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the  Email Address");
	 document.login.txtUsername.focus();
	 return false;
	 }	
	 if (!validateEmail(document.login.txtUsername.value,1,1)) 
	 {
	 document.login.txtUsername.focus();
	 return false;
	 }
	if(document.login.txtPassword.value=="")
	{
	   alert("Enter the Password");
	   document.login.txtPassword.focus();
	   return false;
	}	
document.login.action="login.php";
document.login.submit();
}
//product validations
function productsfrm()
{
	if(document.frm_products.itemqty.value=="")
	{
	   alert("Enter Quantity value");
	   document.frm_products.itemqty.focus();
	   return false;
	}	
		if(document.frm_products.itemqty.value == 0)
	{
	   alert("Pelase Enter valid Quantity value");
	   document.frm_products.itemqty.focus();
	   return false;
	}	

	return true;
}
function wholecart_validation(formname)
{
	var quantity = parseInt(document.forms[formname].itemqty.value);
	var stock = parseInt(document.forms[formname].txtStock.value);
		if(quantity == "")
		{
			alert("Type the quantity");
			document.forms[formname].itemqty.focus();
			return false;
		}
		
		if(stock > 0){ 
			if(quantity > stock){
					alert("Quantity is out of stock.");
					document.forms[formname].itemqty.focus();
					return false;
				}
		}
		if(isNaN(quantity) || (quantity == 0) || (quantity.indexOf("-") >= 0) || (quantity.indexOf(".") >= 0) || (quantity > 65535))
		{
			alert("Type the valid quantity");
			document.forms[formname].itemqty.focus();
			return false;
		}
		return true;
}

function state_display(box) {
var us_state_value_list = new Array();
var us_state_text_list = new Array();
var in_state_value_list = new Array();
var in_state_text_list = new Array();
var check_state = document.frm_coupon.bstate;
var check_length = document.frm_coupon.bstate.length;
	if(box.options[box.selectedIndex].value != "" && box.options[box.selectedIndex].value != "")
	{
		emptyList(box.form.bstate);
	}

if (document.frm_coupon.country.value == "Canada"){
	 	 in_state_value_list.push('ON','QC','NS','NB','MB','BC','PE','SK','AB','NL');
		 
		 in_state_text_list.push('Ontario (ON)','Quebec (QC)','Nova Scotia (NS)','New Brunswick (NB)','Manitoba (MB)','British Columbia (BC)','Prince Edward Island (PE)','Saskatchewan (SK)','Alberta (AB)','Newfoundland (NL)');		 
		   
		   var i;

		   for (i=0; i<in_state_value_list.length; i++)
		   {
			  var opt = document.createElement('OPTION');
			  opt.value = in_state_value_list[i];
				   opt.text = in_state_text_list[i];
			  var instateList = document.frm_coupon.bstate;
			  if(opt.value != "" && opt.text != "")
			  {
			  	instateList[i+1] = opt;
			  }
		   }		 	 
		}
		 else{
		  // us_state_value_list.push('AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','DC','WV','WI','WY');
		   us_state_value_list.push('Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin','Wyoming');
			us_state_text_list.push('Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin','Wyoming');
       var j;
       for (j=0; j<us_state_value_list.length; j++)
       {
          var opt = document.createElement('OPTION');
          opt.value = us_state_value_list[j];
          opt.text = us_state_text_list[j];
          var usstateList = document.frm_coupon.bstate;
          usstateList[j+1] = opt;
       }		 	 			 
	} 
}

//-->
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;
	}
	box.selectedIndex=0;
}

function changeList(box) 
{
	//alert(lists[box.options[box.selectedIndex].value]);
	list = lists[box.options[box.selectedIndex].value];
	if(box.options[box.selectedIndex].value != "select" && box.options[box.selectedIndex].value != "choose")
	{
		emptyList(box.form.cityname);
		fillList( box.form.cityname, list );
	}
}

function change_state(countryobj)
{
	alert(countryobj.options[countryobj.selectedIndex].value);
}
function whole_validations()
{
		if(document.whole.firstname.value=="")
	{
	   alert("Enter the firstname");
	   document.whole.firstname.focus();
	   return false;
	}	
		if(document.whole.lastname.value == "")
	{
	   alert("Pelase Enter valid Quantity value");
	   document.whole.lastname.focus();
	   return false;
	}
			if(document.whole.companyname.value=="")
	{
	   alert("Enter the companyname");
	   document.whole.companyname.focus();
	   return false;
	}	
		if(document.whole.companyaddress.value == "")
	{
	   alert("Enter  the companyaddress");
	   document.whole.companyaddress.focus();
	   return false;
	}	

		if(document.whole.positioncompany.value=="")
	{
	   alert("Enter the positioncompany");
	   document.whole.positioncompany.focus();
	   return false;
	}	
		if(document.whole.businessphone.value == "")
	{
	   alert("Enter the businessphone");
	   document.whole.businessphone.focus();
	   return false;
	}	

		if(document.whole.cellphone.value=="")
	{
	   alert("Enter the cellphone");
	   document.whole.cellphone.focus();
	   return false;
	}	
		if(document.whole.email.value == "")
	{
	   alert("Enter the email");
	   document.whole.email.focus();
	   return false;
	}	

		if(document.whole.addinfo.value=="")
	{
	   alert("Enter the addinfo");
	   document.whole.addinfo.focus();
	   return false;
	}	
		if(document.whole.attachment.value == "")
	{
	   alert("Enter the attachment");
	   document.whole.attachment.focus();
	   return false;
	}	
}
