function getdetails(prodid,catid)
{
document.frmpopular.prodid.value=prodid;
document.frmpopular.catid.value=catid;
document.frmpopular.action="details.php";
document.frmpopular.submit();
}
function category(catid,selfid)
{
document.frmcategory.catid.value=catid;
document.frmcategory.selfid.value=selfid;
document.frmcategory.action="category.php";
document.frmcategory.submit();
}
function validatezone()
{
	if(document.frmzone.lstzone.value="")
	{
		alert("Please select the zone");
		document.frmzone.lstzone.focus();
		return false;
	}
}

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}

function zoompic(img_name,width,height)
{
window.open("zoomimg.php?img="+img_name,"","height="+height+",width="+width+",status=yes,toolbar=no,menubar=no,location=no,top=150px,left=300px");
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function onlynum(){
	
if(!((event.keyCode>=48) && (event.keyCode <=57)))
event.keyCode=0;
}


function validate_forgotemail()
{
	
	if(check_fields("email_address","txtemail_address_div"))
		{	
			if(checkmail('email_address',"txtemail_address2_div"))
			  var te = true;
			else
			  var te = false;
		}
		else
			var te = false;
			
	 if(te == true)
   		return true;
   else
		return false;
		
			
}

function enrollment_validate()
{
	
	if(check_fields("txtInvoiceDate","txtInvoiceDate_div"))
		  var c = true;
		else
		  var c = false;
		  
	if(check_fields("txtStoreName","txtStoreName_div"))
		  var d = true;
		else
		  var d = false;
		  
	if(check_fields("txtconfirm","txtCustName_div"))
		  var e = true;
		else
		  var e = false;
		  
	 if(check_fields("txtDOB","txtDOB_div"))
		  var f = true;
		else
		  var f = false;
		  
	if(check_fields("txtAnnivDate","txtAnnivDate_div"))
		  var g = true;
		else
		  var g = false;
		  
	if(check_fields("txtAddress","txtAddress_div"))
		  var h = true;
		else
		  var h = false;
		  
	 if(check_fields("txtTelephone","txtTelephone_div"))
		  var i = true;
		else
		  var i = false;
		  
	if(check_fields("txtMobile","txtMobile_div"))
		  var j = true;
		else
		  var j = false;
		  
	 if(check_fields("txtEmail","txtEmail_div"))
	 {
		 if(checkmail('txtEmail',"txtEmail_div"))
			  var k = true;
			else
			  var k = false;
	 }
		else
		  var k = false;
		  
	if(check_fields("txtSignatureGift","txtSignatureGift_div"))
		  var l = true;
		else
		  var l = false;
		  
	if(check_fields("txtTelephone","txtTelephone_div"))
		  var m = true;
		  else
		  var m = false;
		

	
	 if((c == true) && (d == true) && (e == true) && (f == true) && (g == true) && (h == true) && (i == true) && (j == true) && (k == true) && (l == true) && (m == true))
   		return true;
   else
		return false;


}

function isBlank(s) {
	var k;
	if (s !="") {
		for (k=0;k<s.length;k++) {
			if(s.charAt(k) != " ") {
				return false;
			}
		}
	}
	return true;
}

function enquiry_validate()
{
if(document.frmenquiry.txtname.value=="") 
   {
	 alert('Enter Your Name');
	 document.frmenquiry.txtname.focus();
	 return false;
   }

if(document.frmenquiry.txtemail.value=="") 
  {
	 alert('Enter Email-ID');
	 document.frmenquiry.txtemail.focus();
	 return false;
   }
var eID=document.frmenquiry.txtemail;
	
	if ((eID.value!=""))
	{
	if (echeck(eID.value)==false)
	{
		eID.value=""
		eID.focus()
		return false
	}
	}
if(document.frmenquiry.txtcontactno.value=="") 
   {
	 alert("Enter Contact Number");
	 document.frmenquiry.txtcontactno.focus();
	 return false;
  }

}

function pupdate_val()
{
	if(check_fields("txtname","txtname_div"))
		  var tn = true;
		else
		  var tn = false;
	
	if(check_fields("txtemail","txtemail_div"))
	{	
		if(checkmail('txtemail',"txtemail2_div"))
		  var te = true;
		else
		  var te = false;
	}
	else
		var te = false;
	
	
	if(check_fields("txtcontactno","txtcontactno_div"))
		  var tc = true;
		else
		  var tc = false;
	

	if(check_fields("txtaddress","txtaddress_div"))
		  var ad = true;
		else
		  var ad = false;
		  
	if(document.getElementById('day').value == "" || document.getElementById('month').value == "" || document.getElementById('year').value == "")
	{
		document.getElementById("txtdob_div").style.visibility = 'visible';
		document.getElementById("txtdob_div").style.position = 'static';
		var dob = false;
	}
	else
	{
		document.getElementById("txtdob_div").style.visibility = 'hidden';
		document.getElementById("txtdob_div").style.position = 'absolute';
		var dob = true;
	}
	
	 if((tn == true) && (te == true) && (tc == true) && (ad == true) && (dob == true) )
   		return true;
   else
		return false;

}

function chgpass()
{
	if(check_fields("txtpass","txtpass_div"))
	{
		if(document.getElementById("txtpass").value.length >= 6)
		{
		 document.getElementById("length_div").style.visibility = 'hidden';
		 document.getElementById("length_div").style.position = 'absolute';	
		 var ps = true;
		}
		else
		{
		  document.getElementById("length_div").style.visibility = 'visible';
		  document.getElementById("length_div").style.position = 'static';	
		  var ps = false;
		}
	}
	else
	{
		var ps = false;
	}
		
 
	if((ps == true) )
 	{
	  if(document.getElementById("txtpass").value == document.getElementById("txtconfirm").value)
	  {
		document.getElementById("match_div").style.visibility = 'hidden';
		document.getElementById("match_div").style.position = 'absolute';
		var cmp = true;
	  }
	  else
	  {
		  document.getElementById("match_div").style.visibility = 'visible';
		  document.getElementById("match_div").style.position = 'static';
		  var cmp = false;
	   }
	}
	else
	{
	   var cmp = false;
	}
	
	if( (ps == true) && (cmp == true) )
		return true;
	else	
		return false;
}

function signup_validate()
{
	if(check_fields("txtname","txtname_div"))
		  var tn = true;
		else
		  var tn = false;
	
	if(check_fields("txtemail","txtemail_div"))
	{	
		if(checkmail('txtemail',"txtemail2_div"))
		  var te = true;
		else
		  var te = false;
	}
	else
		var te = false;
	
	
	if(check_fields("txtcontactno","txtcontactno_div"))
		  var tc = true;
		else
		  var tc = false;
	
	if(check_fields("txtpass","txtpass_div"))
	{
		if(document.getElementById("txtpass").value.length >= 6)
		{
		 document.getElementById("length_div").style.visibility = 'hidden';
		 document.getElementById("length_div").style.position = 'absolute';	
		 var ps = true;
		}
		else
		{
		  document.getElementById("length_div").style.visibility = 'visible';
		  document.getElementById("length_div").style.position = 'static';	
		  var ps = false;
		}
	}
	else
	{
		var ps = false;
	}
		
    if(check_fields("txtconfirm","txtconfirm_div"))
		   var cps = true;
		 else
		   var cps = false;	  
  
	if((ps == true) && (cps == true) )
 	{
	  if(document.getElementById("txtpass").value == document.getElementById("txtconfirm").value)
	  {
		document.getElementById("match_div").style.visibility = 'hidden';
		document.getElementById("match_div").style.position = 'absolute';
		var cmp = true;
	  }
	  else
	  {
		  document.getElementById("match_div").style.visibility = 'visible';
		  document.getElementById("match_div").style.position = 'static';
		  var cmp = false;
	   }
	}
	else
	{
	   var cmp = false;
	}
	
	
	if(check_fields("txtaddress","txtaddress_div"))
		  var ad = true;
		else
		  var ad = false;
		  
	//if(document.getElementById('day').value == "" || document.getElementById('month').value == "" || document.getElementById('year').value == "")
//	{
//		document.getElementById("txtdob_div").style.visibility = 'visible';
//		document.getElementById("txtdob_div").style.position = 'static';
//		var dob = false;
//	}
//	else
//	{
//		document.getElementById("txtdob_div").style.visibility = 'hidden';
//		document.getElementById("txtdob_div").style.position = 'absolute';
//		var dob = true;
//	}
	
	
	if(document.getElementById('continentList').value == "")
	{
		document.getElementById("txtcountry_div").style.visibility = 'visible';
		document.getElementById("txtcountry_div").style.position = 'static';
		var ctr = true;
	}
	else
	{
		document.getElementById("txtcountry_div").style.visibility = 'hidden';
		document.getElementById("txtcountry_div").style.position = 'absolute';
		var ctr = true;
	}
	
	 if((tn == true) && (te == true) && (tc == true) && (ps == true) && (cps == true) && (cmp == true) && (ad == true) && (ctr == true))
   		return true;
   else
		return false;

}

function update_validate()
{

	if(check_fields("txtname","txtname_div"))
		  var tn = true;
		else
		  var tn = false;
		  
	if(check_fields("txtcontactno","txtcontactno_div"))
		  var tc = true;
		else
		  var tc = false;
	
	if(check_fields("txtpass","txtpass_div"))
	{
		if(document.getElementById("txtpass").value.length >= 6)
		{
		 document.getElementById("length_div").style.visibility = 'hidden';
		 document.getElementById("length_div").style.position = 'absolute';	
		 var ps = true;
		}
		else
		{
		  document.getElementById("length_div").style.visibility = 'visible';
		  document.getElementById("length_div").style.position = 'static';	
		  var ps = false;
		}
	}
	else
	{
		var ps = false;
	}
		
    if(check_fields("txtconfirm","txtconfirm_div"))
		   var cps = true;
		 else
		   var cps = false;	  
  
	if((ps == true) && (cps == true) )
 	{
	  if(document.getElementById("txtpass").value == document.getElementById("txtconfirm").value)
	  {
		document.getElementById("match_div").style.visibility = 'hidden';
		document.getElementById("match_div").style.position = 'absolute';
		var cmp = true;
	  }
	  else
	  {
		  document.getElementById("match_div").style.visibility = 'visible';
		  document.getElementById("match_div").style.position = 'static';
		  var cmp = false;
	   }
	}
	else
	{
	   var cmp = false;
	}
	
	
	if(check_fields("txtaddress","txtaddress_div"))
		  var ad = true;
		else
		  var ad = false;
		  
//	if(document.getElementById('day').value == "" || document.getElementById('month').value == "" || document.getElementById('year').value == "")
//	{
//		document.getElementById("txtdob_div").style.visibility = 'visible';
//		document.getElementById("txtdob_div").style.position = 'static';
//		var dob = false;
//	}
//	else
//	{
//		document.getElementById("txtdob_div").style.visibility = 'hidden';
//		document.getElementById("txtdob_div").style.position = 'absolute';
//		var dob = true;
//	}
	
	 if((tn == true) && (tc == true) && (ps == true) && (cps == true) && (cmp == true) && (ad == true))
   		return true;
   else
		return false;

}


function login_validate()
{
	if(check_fields("txtemail","txtemail_div"))
	{	
		if(checkmail('txtemail',"txtemail2_div"))
		  var te = true;
		else
		  var te = false;
	}
	else
		var te = false;
		
	
	 if(check_fields("txtpass","txtpass_div"))
		   var cps = true;
		 else
		   var cps = false;	  
	
	 if( (te == true) && (cps == true) )
   		return true;
   else
		return false;
}

function check_agrrement()
{
	if( (document.getElementById('chkAgree').checked == true ) )
	{
		/*for (var i=0; i<document.updatecart.payType.length; i++)  { 
			if (document.updatecart.payType[i].checked == true)  {
				if(document.updatecart.payType[i].value == 'ebs')
				{
					alert(document.updatecart.payType[i].value);
					//return false;
					window.location = "orderprocessEbs.php";
				}
				else
				{
					alert(document.updatecart.payType[i].value);
					//return false;
					window.location = "orderprocess.php";
				}
			} */ 

		/*for (var i=0; i < document.updatecart.payType.length; i++)
		{
			if(document.updatecart.payType[i].checked == true)
			{
				alert(document.updatecart.payType[i].checked.value);
				return false;
				if(document.updatecart.payType[i].checked.value == 'ebs')
				{
					//alert("---ebs---");
					window.location = "http://www.nirvanajewellery.com/orderprocessEbs.php";
				}
				else if(document.updatecart.payType[i].checked.value == 'paypal')
				{
					//alert("---paypal---");
					window.location = "http://www.nirvanajewellery.com/orderprocess.php";
				}
			}
		}*/
		return true;
	}
	else{
		alert("You must accept terms and conditions before confirming the order");
		return false;
	}
}


function check_shipping()
{
	
	if(check_fields("txtname","txtname_div"))
	   var nm = true;
	 else
	   var nm = false;	
	   
	if(check_fields("txtaddress","txtaddress_div"))
	   var ad = true;
	 else
	   var ad = false;	 
	   
	 if(check_fields("txtcity","txtcity_div"))
	   var city = true;
	 else
	   var city = false;	 
	   
	 if(check_fields("shpaddress","shpaddress_div"))
		  var sad = true;
		else
		  var sad = false;
	
	if(check_fields("shpcity","shpcity_div"))
	   var scity = true;
	 else
	   var scity = false;	
		   
	if(check_fields("txtemail","txtemail_div"))
	{	
		if(checkmail('txtemail',"txtemail_div"))
		  var te = true;
		else
		  var te = false;
	}
	else
		var te = false;
		
	if(check_fields("txtcontact","txtcontact_div"))
	   var ct = true;
	 else
	   var ct = false;	
	   
	   
	if(check_fields("txtContectPerson","txtContectPerson_div"))
	   var cp = true;
	 else
	   var cp = false;	  
	   


	if (document.getElementById('shpcode').value.length <= 6)
	  {
		document.getElementById("shpcode_div1").style.visibility = 'hidden';
		document.getElementById("shpcode_div1").style.position = 'absolute';	
		var sc = true;
	  }
	  else
	  {
		document.getElementById("shpcode_div1").style.visibility = 'visible';
		document.getElementById("shpcode_div1").style.position = 'static';
		 var sc = false;
	  }
	  
	if(check_fields("txtcontactno","txtcontectNo_div"))
	   var ctn = true;
	 else
	   var ctn = false;
	

	if(document.getElementById('shpcode').value == "")
	{
		document.getElementById("shpcode_div").style.visibility = 'visible';
		document.getElementById("shpcode_div").style.position = 'static';
		var code = false;
	}
	else
	{
		document.getElementById("shpcode_div").style.visibility = 'hidden';
		document.getElementById("shpcode_div").style.position = 'absolute';
		var code = true;
	}


	if(document.getElementById('bshpcode').value == "")
	{
		document.getElementById("bshpcode_div").style.visibility = 'visible';
		document.getElementById("bshpcode_div").style.position = 'static';
		var bcode = false;
	}
	else
	{
		document.getElementById("bshpcode_div").style.visibility = 'hidden';
		document.getElementById("bshpcode_div").style.position = 'absolute';
		var bcode = true;
	}


	if(document.getElementById('continentList').value == "")
	{
		document.getElementById("txtcountry_div").style.visibility = 'visible';
		document.getElementById("txtcountry_div").style.position = 'static';
		var ctr = true;
	}
	else
	{
		document.getElementById("txtcountry_div").style.visibility = 'hidden';
		document.getElementById("txtcountry_div").style.position = 'absolute';
		var ctr = true;
	}
	
	if(document.getElementById('bcontinentList').value == "")
	{
		document.getElementById("btxtcountry_div").style.visibility = 'visible';
		document.getElementById("btxtcountry_div").style.position = 'static';
		var bctr = true;
	}
	else
	{
		document.getElementById("btxtcountry_div").style.visibility = 'hidden';
		document.getElementById("btxtcountry_div").style.position = 'absolute';
		var bctr = true;
	}
	
	
	
	 if( (nm == true) && (ad == true) && (sad == true) && (te == true) && (ct == true) && (code == true) && (bcode == true) && (sc==true ) && (ctn==true ) && (cp==true) && (ctr == true)&& (bctr == true))
   		return true;
   else
		return false;
}

function enquiry_india(country)
{ 
//alert("Please select xyz");
//country= document.frmenquiry.getElementById("country");
var cities = document.getElementById("city_india");
var citi=document.getElementById("city")
if(country.value=="india")
{
//alert("Please select xyz");
//document.getElementById("city_india").Enabled=true;

cities.style.display= "block";
}
else
{ //document.getElementById("city_india").disabled=true;
//alert("Please select abc");
//var cities = document.getElementById("city_india");
cities.style.display= "none";
}
if(country.value!=="india")
{
//alert("Please select xyz");
//document.getElementById("city_india").Enabled=true;

citi.style.display= "block";
}
else
{ //document.getElementById("city_india").disabled=true;
//alert("Please select abc");
//var cities = document.getElementById("city_india");
citi.style.display= "none";
}
}

function check_dropdownfields(field_id,span_name)
{
  if (document.getElementById(field_id).value != 0)
  {   
	document.getElementById(span_name).style.visibility = 'hidden';
	document.getElementById(span_name).style.position = 'absolute';
	return true;
  }
  else
  {
	alert("Please Select Ring Size first.");
	document.getElementById(span_name).style.visibility = 'visible';
	document.getElementById(span_name).style.position = 'static';
	return false;
  }
}

function check_fields(field_id,span_name)
{	
	  if (document.getElementById(field_id).value.length != 0)
	  {
		document.getElementById(span_name).style.visibility = 'hidden';
		document.getElementById(span_name).style.position = 'absolute';	
		return true;
	  }
	  else
	  {
		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';
		return false;
	  }
}

/* Added 2nd March 08 - samir */
function checkmail(email_field,email_div)  
{  
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i  
var returnval=emailfilter.test(document.getElementById(email_field).value)  
if (returnval==false)  
{  
document.getElementById(email_div).style.visibility = 'visible';  
document.getElementById(email_div).style.position = 'static';  
return false;  
}  
else  
return true;  
}  

function finalcheck(field_id,span_name)
{
	if(document.getElementById(field_id).value == 'other')
	{
		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';
		return false;
	}
	
	if (document.getElementById(field_id).value.length != 0)
 	 {   
 	 	document.getElementById(span_name).style.visibility = 'hidden';
		document.getElementById(span_name).style.position = 'absolute';
		return true;
	  }
 	 else
 	 {
		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';
		return false;
  	}
}
