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

function ChangeURL(	URL, QueryStrValue){
	window.location.href = URL + QueryStrValue;
}

function group_validate(){
	if(document.frm_group.catname.value == "")
	{
		alert("Choose the Group Category.");
		document.frm_group.catname.focus();
		return false;
	}
	if(document.frm_group.groupname.value == "")
	{
		alert("Enter the Group Name.");
		document.frm_group.groupname.focus();
		return false;
	}
	if(document.frm_group.headline.value == "")
	{
		alert("Choose the Group Headline.");
		document.frm_group.headline.focus();
		return false;
	}
}

function ChangeURL1(	URL, QueryStrValue,mid){
	if(mid > 0)
		metid = mid;
	else
		metid = QueryStrValue;
	window.location.href = URL + metid;
}

function forget_validate()
{
	if(document.form1_reg.txtEmail.value == "")
	{
	   alert("Please enter the email address");
	   document.form1_reg.txtEmail.focus();
	   return false;
	}
	if(!validateEmail(document.form1_reg.txtEmail.value,1,1))
	{
	   document.form1_reg.txtEmail.focus();
	   return false;
	}
}

function showVideo(){
	if (document.frm_video.videotype[0].checked ){
		onetimest = document.getElementById("browse");
		
		if(onetimest){
			onetimest.style.display="block";
			onetimest.style.visibility="visible";
		}
		multitimest = document.getElementById("embed");
		if(multitimest){
			multitimest.style.display="none";
			multitimest.style.visibility="hidden";
		}
	}
	if (document.frm_video.videotype[1].checked){
		onetimest = document.getElementById("browse");
		if(onetimest){
			onetimest.style.display="none";
			onetimest.style.visibility="hidden";
		}
		multitimest = document.getElementById("embed");
		if(multitimest){
			multitimest.style.display="block";
			multitimest.style.visibility="visible";
		}
	}
}

function invite_frnd()
{
	if(document.frm_invite.yourname.value == "")
	{
	   alert("Please enter the your name");
	   document.frm_invite.yourname.focus();
	   return false;
	}
	if(document.frm_invite.youremail.value == "")
	{
	   alert("Please enter the your email");
	   document.frm_invite.youremail.focus();
	   return false;
	}
	if(!validateEmail(document.frm_invite.youremail.value,1,1))
	{
	   document.frm_invite.youremail.focus();
	   return false;
	}
	if(document.frm_invite.frname.value == "")
	{
	   alert("Please enter the friend name");
	   document.frm_invite.frname.focus();
	   return false;
	}
	if(document.frm_invite.fremail.value == "")
	{
	   alert("Please enter the friend email");
	   document.frm_invite.fremail.focus();
	   return false;
	}
	if(!validateEmail(document.frm_invite.fremail.value,1,1))
	{
	   document.frm_invite.fremail.focus();
	   return false;
	}
	if(document.frm_invite.description.value == "")
	{
	   alert("Please enter the message");
	   document.frm_invite.description.focus();
	   return false;
	}
	return true;
}

function register_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(document.frm_register.txtNick.value == "")
	{
	   alert("Please enter the User name");
	   document.frm_register.txtNick.focus();
	   return false;
	}
		
	if(document.frm_register.city.value == "")
	{
	   alert("Please choose the city");
	   document.frm_register.city.focus();
	   return false;
	}
	if(document.frm_register.state.value == "")
		{
		   alert("Please choose the state");
		   document.frm_register.state.focus();
		   return false;
		}
	if(document.frm_register.zipcode.value == "")
	{
	   alert("Please enter the zip code");
	   document.frm_register.zipcode.focus();
	   return false;
	}
	
	
	if(document.frm_register.txtemail.value == "")
	{
	   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.txtemail.value != document.frm_register.txtemail2.value)
	{
	   alert("Please enter the same email address");
	   document.frm_register.txtemail2.value="";
	   document.frm_register.txtemail2.focus();
	   return false;
	}
	if(document.frm_register.txtPassword.value == "")
	{
	   alert("Please enter the password");
	   document.frm_register.txtPassword.focus();
	   return false;
	}
	var passwordlen = document.frm_register.txtPassword.value;
	if(passwordlen.length < 6 || passwordlen.length > 12)
	{
	   alert("Password must be unique and from 6 to 12 characters long");
	   document.frm_register.txtPassword.focus();
	   return false;
	}
	if(document.frm_register.txtConfirmPassword.value == "")
	{
	   alert("Please enter the confirm password");
	   document.frm_register.txtConfirmPassword.focus();
	   return false;
	}
	if(document.frm_register.txtPassword.value != document.frm_register.txtConfirmPassword.value)
	{
	   alert("Please enter the same password");
	   document.frm_register.txtConfirmPassword.value="";
	   document.frm_register.txtConfirmPassword.focus();
	   return false;
	}
	if(document.frm_register.security_code.value == "")
	{
	   alert("Please enter the security code");
	   document.frm_register.security_code.focus();
	   return false;
	}
}

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()}
}
function popupscr(url)
{
	newwindow=window.open(url,'ImageDisplay','height=500,width=400,left=250,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

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 openwindow(){
	document.viewcart.action="deletecart.php";
	document.viewcart.submit();
}

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 popinfo(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=350,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function searchad(){
	if(document.frm_search.subcategoryname.value == "")
	{
		alert("Enter the keyword");
		document.frm_search.subcategoryname.focus();
		return false;
	}
	if(document.frm_search.subcategoryid.value == "")
	{
		alert("Choose the subcategory");
		document.frm_search.subcategoryid.focus();
		return false;
	}
}
function event_validate(){
	
	if(document.frm_event.txt_category.value == "")
	{
		alert("Please choose the event category");
		document.frm_event.txt_category.focus();
		return false;
	}
	if(document.frm_event.heading.value == "")
	{
		alert("Please enter the heading");
		document.frm_event.heading.focus();
		return false;
	}
	if(document.frm_event.eventfromdate.value == "")
	{
		alert("Please enter the event From Date");
		document.frm_event.eventfromdate.focus();
		return false;
	}
	if(document.frm_event.eventtodate.value == "")
	{
		alert("Please enter the event To Date");
		document.frm_event.eventtodate.focus();
		return false;
	}
	
	if(document.frm_event.txt_location.value == "")
	{
		alert("Please enter the location");
		document.frm_event.txt_location.focus();
		return false;
	}
	
	/*if(document.frm_event.txt_contactperson.value == "")
	{
		alert("Please enter the contact person name");
		document.frm_event.txt_contactperson.focus();
		return false;
	}
	if(document.frm_event.txt_contactphone.value == "")
	{
		alert("Please enter the contact phone");
		document.frm_event.txt_contactphone.focus();
		return false;
	}
	if(document.frm_event.txt_contactemail.value == "")
	{
		alert("Please enter the contact email");
		document.frm_event.txt_contactemail.focus();
		return false;
	}
	if (!validateEmail(document.frm_event.txt_contactemail.value,1,1)) 
	{
		document.frm_event.txt_contactemail.focus();
		return false;
	}*/
}
function reply_validate(){
	if (!validateEmail(document.frm_reply.youremail.value,1,1)) 
	{
		document.frm_reply.youremail.focus();
		return false;
	}
	if(document.frm_reply.confemail.value == "")
	{
		alert("Enter the Confirm email address");
		document.frm_reply.confemail.focus();
		return false;
	}
	if (document.frm_reply.confemail.value != document.frm_reply.youremail.value) 
	{
		alert("Confirm email address must be same as Email address");
		document.frm_reply.confemail.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 showad(){
		if (document.frm_postad.rdofeaturedad[0].checked){
		ap1=document.getElementById("showadcost");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
				}				
		}
		else
		{
			ap1=document.getElementById("showadcost");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
				}
		}
}
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()}
}

function adform_validate(){
	EnableFeature = 0;
	if(document.frm_postad.title.value == "")
	{
		alert("Enter the title");
		document.frm_postad.title.focus();
		return false;
	}
	if (!validateEmail(document.frm_postad.email.value,1,1)) 
	{
		document.frm_postad.email.focus();
		return false;
	}
	if(document.frm_postad.confemail.value == "")
	{
		alert("Enter the Confirm email address");
		document.frm_postad.confemail.focus();
		return false;
	}
	if (document.frm_postad.confemail.value != document.frm_postad.email.value) 
	{
		alert("Confirm email address must be same as Email address");
		document.frm_postad.confemail.focus();
		return false;
    }
	
	FeaturedCount =  document.frm_postad.Feature.length;
	if(FeaturedCount > 1){
		for(rdoIndex = 0; rdoIndex < FeaturedCount; rdoIndex++ ){
			
			if(document.frm_postad.Feature[rdoIndex].checked == true){
				EnableFeature = 1;
				FeaturedAdValue = document.frm_postad.Feature[rdoIndex].value;
				break;
			}
			
		}
	}else{
		FeaturedAdValue = document.frm_postad.rdofeaturedad.value;
	}
	
	if(EnableFeature == 1 && document.frm_postad.chkrepost.checked == true){
		if(FeaturedAdValue != "No"){
		alert("You can choose featured ad or repost ad.");
		return false;
		}
	}
	
	/*if(document.frm_postad.rdofeaturedad.checked == true){
		if(document.frm_postad.chkrepost.checked == true && (document.frm_postad.rdofeaturedad[0].checked == true || document.frm_postad.rdofeaturedad[1].checked == true)){
			alert("You can choose featured ad or repost ad.");
			return false;
		}
	}*/
}

function popservices(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	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 changeList(box) 
{
	list = lists[box.options[box.selectedIndex].value];
	
	if(box.options[box.selectedIndex].value != "select" && box.options[box.selectedIndex].value != "choose")
	{
		emptyList(box.form.txt_category);
		fillList(box.form.txt_category,list );
	}
}

//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 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 showstate(passcountry){
	if (document.getElementById(passcountry).value == "US")
	{
		shipname=document.getElementById("secondapplicant");
		if(shipname){
		shipname.style.display="block";
		shipname.style.visibility="visible";
		}
	}
	else
	{
	   shipname1=document.getElementById("secondapplicant");
		if(shipname1){
		shipname1.style.display="none";
		shipname1.style.visibility="hidden";
		}
	}
}



