// JavaScript Document
function popupload(url)
{
	newwindow=window.open(url,'ImageDisplay','height=450,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function EditFiles(url)
{
	newwindow=window.open(url,'ImageDisplay','height=550,width=500,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function open_prodwin(proid,categid,deptid,quty){
	window.location.href = "productdetails.php?ProdId="+proid+"&categid="+categid+"&departid="+deptid+"&qty="+quty+"";
}


function openwindow(){
	document.viewcart.action="deletecart.php";
	document.viewcart.submit();
}
function openw(){
	//window.location.href = "companies.php";
	window.location.href = "myproducts.php";
}
function openwi(val){
	
	window.location.href = "checkout.php?from="+val+"";
}

function opencart(){
document.viewcart.action="modifycart.php";
document.viewcart.submit();
}

function calc(price) 
{
	var price;
	document.cartproducts.total.value = price;
	
}

function showdeli(){
		if(document.checkout.daddressfrom[2].checked){
		//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 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 login_validate(){
	if (document.Frmlogin.txtUsername.value == "") 
	{
		 alert("Email is empty");
		document.Frmlogin.txtUsername.focus();
		return false;
	}
	if (!validateEmail(document.Frmlogin.txtUsername.value,1,1)) 
	{
		document.Frmlogin.txtUsername.focus();
		return false;
	}
	if(document.Frmlogin.txtPassword.value == ""){
		 alert("Password is empty");
		 document.Frmlogin.txtPassword.focus();
		 return false;
	}
}

function frmlogin_validate(){
	if (document.Login.txtUsername.value == "") 
	{
		 alert("Email is empty");
		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("Password is empty");
		 document.Login.txtPassword.focus();
		 return false;
	}
}

function cust_validate(){
	if (document.frm_register.txtfirst.value == "") 
	{
		alert ("Please Enter the first name.");
		document.frm_register.txtfirst.focus();
		return false;
	}
	if (document.frm_register.txtlast.value == "") 
	{
		alert ("Please Enter the last name.");
		document.frm_register.txtlast.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 ("Please Enter the password.");
		document.frm_register.txtpassword.focus();
		return false;
	}
	if (document.frm_register.txtaddress.value == "") 
	{
		alert ("Please Enter the address.");
		document.frm_register.txtaddress.focus();
		return false;
	}
	if (document.frm_register.txtcity.value == "") 
	{
		alert ("Please Enter the city.");
		document.frm_register.txtcity.focus();
		return false;
	}
	if (document.frm_register.txtPostState.value == "") 
	{
		alert ("Please choose the state.");
		document.frm_register.txtPostState.focus();
		return false;
	}
	if (document.frm_register.txtPostCountry.value == "Choose") 
	{
		alert ("Please choose the country.");
		document.frm_register.txtPostCountry.focus();
		return false;
	}
	zipvale = document.frm_register.txtPostZip.value;
	if( (zipvale == "")  || (zipvale == 0) || isNaN(zipvale) ||  (zipvale.indexOf("-") >= 0) || (zipvale.indexOf(".") >= 0) )
	{
		alert ("Please enter the valid zipcode.");
		document.frm_register.txtPostZip.focus();
		return false;
	}

	if (document.frm_register.txtphone.value == "") 
	{
		alert ("Please Enter the phone number.");
		document.frm_register.txtphone.focus();
		return false;
	}
	phone = document.frm_register.txtphone;
	if (checkInternationalPhone(phone.value)==false){
		alert("Please Enter a Valid Phone Number");
		phone.value="";
		phone.focus();
		return false;
	}
}

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=635,width=600,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();
}

function wholecart_validation(formname){
	
		var quantity = document.forms[formname].txtQty.value;
		var stock = document.forms[formname].txtStock.value;
		var outstock = document.forms[formname].pro_Outstock.value;
		if (document.forms[formname].txtQty.value == ""){ 
				alert("Type the quantity");
				document.forms[formname].txtQty.focus();
				return false;
			}
			if(isNaN(quantity) || (quantity == 0) || (quantity.indexOf("-") >= 0) || (quantity.indexOf(".") >= 0) || (quantity > 65535) )
			{
				alert("Type the valid quantity");
				document.forms[formname].txtQty.focus();
				return false;
			}
			
			if(stock > 0){ 
				if(quantity > stock){
						alert("Quantity is out of stock.");
						document.forms[formname].txtQty.focus();
						return false;
					}
			}
			return true;
	}

//validation for register
function register_validate(){
	 if (document.frm_register.txtUser.value == "")
	 {
		alert("Enter the user name");
		document.frm_register.txtUser.focus();
		return false;
	 }
	 if(!validateEmail(document.frm_register.txtUser.value,1,1))
	{
	   document.frm_register.txtUser.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.membertype.value == "")
	 {
		alert("Please Select the Member Type");
		document.frm_register.membertype.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 address line1");
		document.frm_register.txtPostcode1.focus();
		return false;
	 }
	 if (document.frm_register.txtPostCity.value == "")
	 {
		alert("Enter the city");
		document.frm_register.txtPostCity.focus();
		return false;
	 }
	 if (document.frm_register.txtPostState.value == "")
	 {
		alert("Enter the State");
		document.frm_register.txtPostState.focus();
		return false;
	 }
	 if (document.frm_register.txtPostZip.value == "")
	 {
		alert("Enter the zipcode");
		document.frm_register.txtPostZip.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.txtBusinessph.value=="")
			{
			   alert("Enter the phone number");
			   document.frm_register.txtBusinessph.focus();
			   return false;
			}
		phone = document.frm_register.txtBusinessph;
		if (checkInternationalPhone(phone.value)==false)
		{
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
		}
}
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;
	 }
}

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;
			}
		}
		
}

function showdeli(){
		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 showship(){
		if (document.checkout.addressfrom[1].checked){
		ap1=document.getElementById("showattrib");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
			}				
		}
		else
		{
			ap1=document.getElementById("showattrib");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
			}
		}
		if (document.checkout.addressfrom[0].checked){
		ap1=document.getElementById("showcheck");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
			}				
		}
		else
		{
			ap1=document.getElementById("showcheck");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
			}
		}
}

function showdeliv(){
		if (document.checkout.daddressfrom[1].checked){
		ap1=document.getElementById("showprim");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
			}				
		}
		else
		{
			ap1=document.getElementById("showprim");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
			}
		}
		if (document.checkout.daddressfrom[0].checked){
		ap1=document.getElementById("showreg");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
			}				
		}
		else
		{
			ap1=document.getElementById("showreg");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
			}
		}
		if (document.checkout.daddressfrom[2].checked){
		 delistyle=document.getElementById("delivery");
		    if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}				
		}
		
}

/*function cartcheck_validate()
{
	<!-- Brochure Form-->
	if(document.cartproducts.txtcompany.value == "")
	{
		alert("Please Enter the Company Name of the Brouchure Form");
		document.cartproducts.txtcompany.focus();
		return false;
	}
	if(document.cartproducts.txtname.value == "")
	{
		alert("Please Enter the Name of the Brouchure Form");
		document.cartproducts.txtname.focus();
		return false;
	}
	if(document.cartproducts.txtcity.value == "")
	{
		alert("Please Enter the City of the Brouchure Form");
		document.cartproducts.txtcity.focus();
		return false;
	}
	if(document.cartproducts.txtstate.value == "")
	{
		alert("Please Enter the State of the Brouchure Form");
		document.cartproducts.txtstate.focus();
		return false;
	}
	if(document.cartproducts.txtzip.value == "")
	{
		alert("Please Enter the Zipcode of the Brouchure Form");
		document.cartproducts.txtzip.focus();
		return false;
	}
	<!-- Business Form-->
	if(document.cartproducts.busname.value == ""){
		alert("Please Enter the Name of the Business Form");
		document.cartproducts.busname.focus();
		return false;
	}
	if(document.cartproducts.bustitle.value == ""){
		alert("Please Enter the Title of the Business Form");
		document.cartproducts.bustitle.focus();
		return false;
	}
	if(document.cartproducts.busaddress.value == ""){
		alert("Please Enter the Address of the Business Form");
		document.cartproducts.busaddress.focus();
		return false;
	}
	if(document.cartproducts.buscity.value == ""){
		alert("Please Enter the City of the Business Form");
		document.cartproducts.buscity.focus();
		return false;
	}
	if(document.cartproducts.busstate.value == ""){
		alert("Please Enter the State of the Business Form");
		document.cartproducts.busstate.focus();
		return false;
	}
	if(document.cartproducts.buszip.value == ""){
		alert("Please Enter the Zipcode of the Business Form");
		document.cartproducts.buszip.focus();
		return false;
	}
	if(document.cartproducts.busbphone.value == ""){
		alert("Please Enter the Phone Number of the Business Form");
		document.cartproducts.busbphone.focus();
		return false;
	}
	if(document.cartproducts.busemail.value == ""){
		alert("Please Enter the Email of the Business Form");
		document.cartproducts.busemail.focus();
		return false;
	}
	if(document.cartproducts.buswebaddr.value == ""){
		alert("Please Enter the Web Address of the Business Form");
		document.cartproducts.buswebaddr.focus();
		return false;
	}
	<!-- Mailing Form-->
	if(document.cartproducts.txtcompaign.value == ""){
		alert("Please Enter the Compaign Name of the Mailing Form");
		document.cartproducts.txtcompaign.focus();
		return false;
	}
	
}*/

function brouchure_validate(){
	<!-- Brochure Form-->
	if(document.brouchure.txtcompany.value == "")
	{
		alert("Please Enter the Company Name of the Brouchure Form");
		document.brouchure.txtcompany.focus();
		return false;
	}
	if(document.brouchure.txtname.value == "")
	{
		alert("Please Enter the Name of the Brouchure Form");
		document.brouchure.txtname.focus();
		return false;
	}
	if(document.brouchure.txtcity.value == "")
	{
		alert("Please Enter the City of the Brouchure Form");
		document.brouchure.txtcity.focus();
		return false;
	}
	if(document.brouchure.txtstate.value == "")
	{
		alert("Please Enter the State of the Brouchure Form");
		document.brouchure.txtstate.focus();
		return false;
	}
	if(document.brouchure.txtzip.value == "")
	{
		alert("Please Enter the Zipcode of the Brouchure Form");
		document.brouchure.txtzip.focus();
		return false;
	}
}

function business_validate(){
	<!-- Business Form-->
	if(document.business.busname.value == ""){
		alert("Please Enter the Name of the Business Form");
		document.business.busname.focus();
		return false;
	}
	if(document.business.bustitle.value == ""){
		alert("Please Enter the Title of the Business Form");
		document.business.bustitle.focus();
		return false;
	}
	if(document.business.busaddress.value == ""){
		alert("Please Enter the Address of the Business Form");
		document.business.busaddress.focus();
		return false;
	}
	if(document.business.buscity.value == ""){
		alert("Please Enter the City of the Business Form");
		document.business.buscity.focus();
		return false;
	}
	if(document.business.busstate.value == ""){
		alert("Please Enter the State of the Business Form");
		document.business.busstate.focus();
		return false;
	}
	if(document.business.buszip.value == ""){
		alert("Please Enter the Zipcode of the Business Form");
		document.business.buszip.focus();
		return false;
	}
	if(document.business.busbphone.value == ""){
		alert("Please Enter the Phone Number of the Business Form");
		document.business.busbphone.focus();
		return false;
	}
	if(document.business.busemail.value == ""){
		alert("Please Enter the Email of the Business Form");
		document.business.busemail.focus();
		return false;
	}
	if(document.business.buswebaddr.value == ""){
		alert("Please Enter the Web Address of the Business Form");
		document.business.buswebaddr.focus();
		return false;
	}
}

function mailing_validate(){
	<!-- Mailing Form-->
	if(document.mailing.txtcompaign.value == ""){
		alert("Please Enter the Compaign Name of the Mailing Form");
		document.cartproducts.txtcompaign.focus();
		return false;
	}
}
function password_validate(){
	if(!validateEmail(document.Frmgetpass.txtEmail.value,1,1))
	{
	   document.Frmgetpass.txtEmail.focus();
	   return false;
	}

}

//Checkout Validation

function checkout_validate(){
	 if ((document.checkout.payby[0].checked != true) && (document.checkout.payby[1].checked!= true)&& (document.checkout.payby[2].checked != true) && (document.checkout.payby[3].checked != true))
	 { 
		 alert ("Please click any one payment choice");
		 return false;
	 }
	 
	//Billing Address
	
	 if ((document.checkout.addressfrom[0].checked != true ) && (document.checkout.addressfrom[1].checked != true ))
	 { 
		 alert ("Please click any one Billing Addressfrom");
		 return false;
	 }
	 
	 //New  Billing Address
	 if(document.checkout.addressfrom[1].checked != false ){
	if(document.checkout.name.value == ""){
		alert("Please Enter the Name ");
		document.checkout.name.focus();
		return false;
	}
	if(document.checkout.email.value == ""){
		alert("Please Enter the Email ");
		document.checkout.email.focus();
		return false;
	}
	 if(!validateEmail(document.checkout.email.value,1,1))
	{
	   document.checkout.email.focus();
	   return false;
	}
	if(document.checkout.addr1.value == ""){
		alert("Please Enter the Addressline");
		document.checkout.addr1.focus();
		return false;
	}
	if(document.checkout.city.value == ""){
		alert("Please Enter the City ");
		document.checkout.city.focus();
		return false;
	}
	if(document.checkout.county.value == ""){
		alert("Please Enter the County");
		document.checkout.county.focus();
		return false;
	}
		if(document.checkout.country.value == "Choose"){
		alert("Please Enter the Country");
		document.checkout.country.focus();
		return false;
	}
	if(document.checkout.zipcode.value == ""){
		alert("Please Enter the Zipcode");
		document.checkout.zipcode.focus();
		return false;
	}
	if(document.checkout.phone.value == ""){
		alert("Please Enter the Phone");
		document.checkout.phone.focus();
		return false;
	}
	 var phoneno = document.checkout.phone;
		if (checkInternationalPhone(phoneno.value)==false){
			alert("Please Enter a Valid Phone Number");
			phoneno.value="";
			phoneno.focus();
			return false;
			} 
	 }
	 
	//Delivery Address 
	 if ((document.checkout.daddressfrom[0].checked != true ) && (document.checkout.daddressfrom[1].checked != true ) && (document.checkout.daddressfrom[2].checked != true ))
	 { 
		 alert ("Please click any one Delivery Addressfrom");
		 return false;
	 }
	 
	 //New  Delivery Address
	 if(document.checkout.daddressfrom[1].checked != false ){
	if(document.checkout.dname.value == ""){
		alert("Please Enter the Name ");
		document.checkout.dname.focus();
		return false;
	}
	/*if(document.checkout.demail.value == ""){
		alert("Please Enter the Email ");
		document.checkout.demail.focus();
		return false;
	}
	 if(!validateEmail(document.checkout.demail.value,1,1))
	{
	   document.checkout.demail.focus();
	   return false;
	}*/
	if(document.checkout.daddr1.value == ""){
		alert("Please Enter the Addressline");
		document.checkout.daddr1.focus();
		return false;
	}
	if(document.checkout.dcity.value == ""){
		alert("Please Enter the City ");
		document.checkout.dcity.focus();
		return false;
	}
	if(document.checkout.dcounty.value == ""){
		alert("Please Enter the County");
		document.checkout.dcounty.focus();
		return false;
	}
		if(document.checkout.dcountry.value == "Choose"){
		alert("Please Enter the Country");
		document.checkout.dcountry.focus();
		return false;
	}
	if(document.checkout.dzipcode.value == ""){
		alert("Please Enter the Zipcode");
		document.checkout.dzipcode.focus();
		return false;
	}
	if(document.checkout.dphone.value == ""){
		alert("Please Enter the Phone");
		document.checkout.dphone.focus();
		return false;
	}
	 var phoneno = document.checkout.dphone;
		if (checkInternationalPhone(phoneno.value)==false){
			alert("Please Enter a Valid Phone Number");
			phoneno.value="";
			phoneno.focus();
			return false;
			} 
	 }
		 return true;
}

function showpay(){
		if ((document.checkout.payby[0].checked == true) || (document.checkout.payby[1].checked == true) || (document.checkout.payby[3].checked == true)){
		delistyle=document.getElementById("showpay");
		    if(delistyle){
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById("showpay");
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
	}

function prodsearch_validate(){
	if(document.prodsearch.keyword.value == ""){
		alert("Please Enter the Product Keyword to Search");
		document.prodsearch.keyword.focus();
		return false;
	}
	return true;
}

function browsefile(){
	if(document.frm_browse.filename1.value == "" && document.frm_browse.filename2.value == "" && document.frm_browse.filename2.value == ""){
		alert("Please Upload atleast one file");
		document.frm_browse.filename1.focus();
		return false;
	}
	if(document.frm_browse.comments.value == ""){
		alert("Please enter your comments");
		document.frm_browse.comments.focus();
		return false;
	}
	return true;
}