// JavaScript Document

// JavaScript Document

/******************************************* General **************************************/

function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function GetXmlHttpObject() 
{ 
  	var xmlhttp; 
  	if(window.XMLHttpRequest)
  	{ 
    	xmlhttp = new XMLHttpRequest(); 
  	} 
  	else if (window.ActiveXObject)
  	{ 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		if (!xmlhttp)
		{ 
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		}
	} 
  	return xmlhttp; 
} 
var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;

/******************************************* Zone Manager **************************************/

function zone_edit(zone_id,page,limit)
{		
	document.frm_zone_mgmt.action = "zone_add.php?zone_id="+zone_id+"&page="+page+"&limit="+limit;
	document.frm_zone_mgmt.submit();
}
function zone_save(page,limit)
{	
	if(document.frm_zone_add.zone.value==''){
		alert("Please Enter Zone Name");
		document.frm_zone_add.zone.focus();
		return false;
	}else{
		
		var elm = document.getElementsByTagName("input");	
		var j=0, chkcount=0, chkname='', chkId='';
	
		for(var i=0; i< elm.length; i++)
		{
			if(elm[i].type.toLowerCase()=="checkbox")
			{
				j++;	//	alert("j="+j);
				if(j==1)
				{
					chkname = elm[i].name;	 // alert(chkname);
					chkId = elm[i].id;	 // alert(chkId);
				}
				if(elm[i].checked)
				{
					chkcount++;		//  alert(chkcount);
				}
			}
		}
	
		if(chkcount==0)
		{
			alert("Please select minimum any one Country");
			document.getElementById(chkId).focus();
			//	document.frm_zone_add.chkCountry[].focus();
			return false;
		}
		document.frm_zone_add.action = "zone_save.php?page="+page+"&limit="+limit;
		document.frm_zone_add.submit();
	}
}
function zone_delete(zone_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_zone_mgmt.action = "zone_delete.php?zone_id="+zone_id+"&page="+page+"&limit="+limit;
		document.frm_zone_mgmt.submit();
	}
}

/******************************************* FedEx Additional Weight Manager **************************************/

function additional_weight_save(page,limit)
{	
	document.frm_additional_weight.action = "additional_weight_save.php?page="+page+"&limit="+limit;
	document.frm_additional_weight.submit();
}
/******************************************* FedEx Weight Manager **************************************/

function fedex_weight_edit(weight_id,page,limit)
{		
	document.frm_fedex_weight_mgmt.action = "fedex_weight_add.php?weight_id="+weight_id+"&page="+page+"&limit="+limit;
	document.frm_fedex_weight_mgmt.submit();
}
function fedex_weight_save(page,limit)
{	
	if(document.frm_fedex_weight_add.weight_range.value==''){
		alert("Please Enter Weight");
		document.frm_fedex_weight_add.weight_range.focus();
		return false;
	}else if(!(float.test(document.frm_fedex_weight_add.weight_range.value))){
		alert("Please enter Weight in Number");
		document.frm_fedex_weight_add.weight_range.focus();
		return false;
	}else{
		document.frm_fedex_weight_add.action = "fedex_weight_save.php?page="+page+"&limit="+limit;
		document.frm_fedex_weight_add.submit();
	}
}
function fedex_weight_delete(weight_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_fedex_weight_mgmt.action = "fedex_weight_delete.php?weight_id="+weight_id+"&page="+page+"&limit="+limit;
		document.frm_fedex_weight_mgmt.submit();
	}
}

/******************************************* FedEx Ship Manager **************************************/

function getZone()
{
	var len = document.getElementById("weight_id").length; 
	var attribute_value = new Array();
	j=0;
	for(i=0; i<len; i++)
	{ 
		if(document.frm_fedex_ship_add.weight_id[i].selected)
		{			
			attribute_value[j++]=document.frm_fedex_ship_add.weight_id[i].value;
		//	j++;
		//	alert(attribute_value[j]);
		}
	}
	var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divZone").innerHTML=req.responseText;
               } 
          }
	};
	req.open("GET", "get_zone.php?weight_id="+attribute_value); //	alert(val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
	req.send(null); //send value
};

function getShip(val)
{	//alert(val); alert("val"); 
	var len = document.getElementById("zone_id").length; 
	var attribute_value2 = new Array();
	j=0;
	for(i=0; i<len; i++)
	{ 
		if(document.frm_fedex_ship_add.zone_id[i].selected)
		{			
			attribute_value2[j]=document.frm_fedex_ship_add.zone_id[i].value;
		//	alert(attribute_value2[j]);
			j++;
		}
	}
	var req = Inint_AJAX();
	req.onreadystatechange = function () { 
	  if (req.readyState==4) {
		   if (req.status==200) {
				document.getElementById("divShip").innerHTML=req.responseText;
		   } 
	  }
	};
	req.open("GET", "get_ship.php?zone_id="+attribute_value2+"&weight_id="+val); 	//alert(val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
	req.send(null); //send value
};

function fedex_ship_edit(fedex_ship_id,page,limit)
{		
	document.frm_fedex_ship_mgmt.action = "fedex_ship_add.php?fedex_ship_id="+fedex_ship_id+"&page="+page+"&limit="+limit;
	document.frm_fedex_ship_mgmt.submit();
}
function fedex_ship_edit_save(id,page,limit)
{
	document.frm_fedex_ship_add.action = "fedex_ship_save.php?page="+page+"&limit="+limit+"&fedex_ship_id="+id;
	document.frm_fedex_ship_add.submit();
}
function fedex_ship_save(page,limit)
{
	document.frm_fedex_ship_add.action = "fedex_ship_save.php?page="+page+"&limit="+limit;
	document.frm_fedex_ship_add.submit();
}
function fedex_ship_delete(fedex_ship_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_fedex_ship_mgmt.action = "fedex_ship_delete.php?fedex_ship_id="+fedex_ship_id+"&page="+page+"&limit="+limit;
		document.frm_fedex_ship_mgmt.submit();
	}
}

/*********************************************** Quotation Manager *************************************/

function quotation_view(quatation_id,page,limit)
{
	document.frm_quotation_mgmt.action="quotation_view.php?quatation_id="+quatation_id+"&page="+page+"&limit="+limit;
	document.frm_quotation_mgmt.submit();
}

function quotation_delete(quatation_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?"); 
	if(ans==true)
	{
		document.frm_quotation_mgmt.action="quotation_delete.php?quatation_id="+quatation_id+"&page="+page+"&limit="+limit;
		document.frm_quotation_mgmt.submit();	
	}
}

/*********************************************** User Newsletter Manager ****************************************/

function selectAll(field)
{	
	var chkAll = document.getElementById('chkAll');
 	var checks = document.getElementsByName('chksend[]');
	var boxLength = checks.length;
	
	if(chkAll.checked == true)
	{
		for(i=0;i<boxLength;i++) 
		{
			if(checks[i].disabled)
			{
			}else{
				checks[i].checked = true;
			}
	  	}
	}else{
		for(i=0;i<boxLength;i++)
		{
			checks[i].checked = false;
	  	}
	}
}

function user_newsletter_edit(user_newsletter_id,page,limit)
{	
	document.frm_news_user_mgmt.action="user_news_add.php?user_newsletter_id="+user_newsletter_id+"&page="+page+"&limit="+limit;
	document.frm_news_user_mgmt.submit();
}
function user_newsletter_delete(user_newsletter_id,page,limit)
{
	//alert(user_newsletter_id);
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_news_user_mgmt.action="user_news_delete.php?user_newsletter_id="+user_newsletter_id+"&page="+page+"&limit="+limit;
		document.frm_news_user_mgmt.submit();	
	}
}

function user_newsletter_save(page,limit)
{
	if(document.frm_news_user_add.user_name.value==0){
		alert("Enter User Name");
		document.frm_news_user_add.user_name.focus();
		return false;
	}else if(document.frm_news_user_add.user_email.value == ""){
		alert("Please Enter EmailID");
		document.frm_news_user_add.user_email.focus();
		return false;
	}else if(document.frm_news_user_add.user_email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_news_user_add.user_email.focus();
		return false;
	}else if(document.frm_news_user_add.user_email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_news_user_add.user_email.focus();
		return false;
	}else{
		document.frm_news_user_add.action="user_news_save.php?page="+page+"&limit="+limit;
		document.frm_news_user_add.submit();
	}
}

function select_news(){
	document.frm_news_user_mgmt.action="select_news.php";
	document.frm_news_user_mgmt.submit();
}

/*function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};
*/
function existing_editor(){
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("news1").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_news.php"); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function get_editor(){
	//alert("hi");
	document.user_news.action="add_news.php";
	document.user_news.submit();
};

function send_save(val,news_id){
	if(val=='send_save'){
		document.frmaddnews.action="send_news.php?val="+val+"&news_id="+news_id;
		document.frmaddnews.submit();
	}else if(val=='save'){
		document.frmaddnews.action="send_news.php?val="+val+"&news_id="+news_id;
		document.frmaddnews.submit();
	}
	
}

/************************************ Diamond Manager ***********************************/

function selAllDiamond()
{	
	var chkAll = document.getElementById('chkAll');
 	var checks = document.getElementsByName('chkDiamond[]');
	var boxLength = checks.length;
	
	if(chkAll.checked == true)
	{
		for(i=0;i<boxLength;i++) 
		{
			if(checks[i].disabled)
			{
			}else{
				checks[i].checked = true;
			}
	  	}
	}
	else{
		for(i=0;i<boxLength;i++)
		{
			checks[i].checked = false;
	  	}
	}
}

function diamond_upload(page,limit)
{
	if(document.frm_diamond_add.diamond_sheet.value==''){
		alert("Please Upload Diamond Excel Sheet")
		document.frm_diamond_add.diamond_sheet.focus();
		return false;
	}
	if(document.frm_diamond_add.diamond_sheet.value != '')
	{		
		var extensions = new Array("xls","csv"); 
		var image_file = document.frm_diamond_add.diamond_sheet.value;
		var image_length = document.frm_diamond_add.diamond_sheet.value.length;
		var pos = image_file.lastIndexOf('.') + 1; 
		var ext = image_file.substring(pos, image_length);
		var final_ext = ext.toLowerCase(); 
		var flag = false;
		for (i = 0; i < extensions.length; i++)   
		{   
			if(extensions[i] == final_ext)   
			{   
				flag = true;   
			}   
		} 
		if(flag == false){ 
			alert("Please upload Dimond Excel Sheet with one of the following extensions: "+ extensions.join(', ') +".");   		
			document.frm_diamond_add.diamond_sheet.focus();
			return false;   
		}
	}
	document.frm_diamond_add.action="diamond_save.php?page="+page+"&limit="+limit;
	document.frm_diamond_add.submit();
}
function diamond_save(page,limit)
{
	if(document.frm_diamond_add.ref_no.value==''){
		alert("Please Enter Diamond Reference No.");
		document.frm_diamond_add.ref_no.focus();
		return false;
	}else if(document.frm_diamond_add.shape.value==''){
		alert("Please Enter Diamond Shape");
		document.frm_diamond_add.shape.focus();
		return false;
	}else if(document.frm_diamond_add.carat.value == ''){
		alert("Please Enter Diamond Carat");
		document.frm_diamond_add.carat.focus();
		return false;
	}else if(document.getElementById('colour').value == ''){
		alert("Please Enter Diamond Colour");
		document.getElementById('colour').focus();
		return false;
	}else if(document.frm_diamond_add.clarity.value == ''){
		alert("Please Enter Diamond Clarity");
		document.frm_diamond_add.clarity.focus();
		return false;
	}else if(document.frm_diamond_add.cut_proportion.value == ''){
		alert("Please Enter Diamond Cut Proportion");
		document.frm_diamond_add.cut_proportion.focus();
		return false;
	}else if(document.frm_diamond_add.cut_symmetry.value == ''){
		alert("Please Enter Diamond Cut Symmetry");
		document.frm_diamond_add.cut_symmetry.focus();
		return false;
	}else if(document.frm_diamond_add.cut_polish.value == ''){
		alert("Please Enter Diamond Cut Polish");
		document.frm_diamond_add.cut_polish.focus();
		return false;
	}else if(document.frm_diamond_add.flourescence.value == ''){
		alert("Please Enter Diamond Flourescence");
		document.frm_diamond_add.flourescence.focus();
		return false;
	}else if(document.frm_diamond_add.certification.value == ''){
		alert("Please Enter Diamond Certification");
		document.frm_diamond_add.certification.focus();
		return false;
	}else if(document.frm_diamond_add.mrp.value == ''){
		alert("Please Enter Diamond Price");
		document.frm_diamond_add.mrp.focus();
		return false;
	}else{	alert(limit);
		document.frm_diamond_add.action="diamond_save.php?page="+page+"&limit="+limit;
		document.frm_diamond_add.submit();
	}
}
function diamond_edit(diamond_id,page,limit)
{
	document.frm_diamond_mgmt.action="diamond_add.php?diamond_id="+diamond_id+"&page="+page+"&limit="+limit;
	document.frm_diamond_mgmt.submit();
}
function diamond_delete(diamond_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?"); 
	if(ans==true)
	{
		document.frm_diamond_mgmt.action="diamond_delete.php?diamond_id="+diamond_id+"&page="+page+"&limit="+limit;
		document.frm_diamond_mgmt.submit();	
	}
}

/************************************ Address Manager ***********************************/

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function address_save(user_id,page,limit){
	if(document.frm_address_add.user_fname.value==''){
		alert("Please Enter First Name")
		document.frm_address_add.user_fname.focus();
		return false;
	}else if(document.frm_address_add.user_lname.value==''){
		alert("Please Enter Last Name")
		document.frm_address_add.user_lname.focus();
		return false;
	}else if(document.frm_address_add.address1.value==''){
		alert("Please Enter Address1")
		document.frm_address_add.address1.focus();
		return false;
	}else if(document.frm_address_add.address2.value==''){
		alert("Please Enter Address2")
		document.frm_address_add.address2.focus();
		return false;
	}else if(document.frm_address_add.city.value==''){
		alert("Please Enter City")
		document.frm_address_add.city.focus();
		return false;
	}else if(document.frm_address_add.state.value==''){
		alert("Please Enter State")
		document.frm_address_add.state.focus();
		return false;
	}else if(document.frm_address_add.selCountry.value==''){
		alert("Please Select Country")
		document.frm_address_add.selCountry.focus();
		return false;
	}else if(document.frm_address_add.txtzip.value==''){
		alert("Please Enter Zipcode")
		document.frm_address_add.txtzip.focus();
		return false;	
	}else{
		document.frm_address_add.action="address_save.php?page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_address_add.submit();
	}
}

function address_edit(user_address_id,page,limit,user_id)
{
	document.frm_address_mgmt.action="address_add.php?user_address_id="+user_address_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
	document.frm_address_mgmt.submit();
}

function address_delete(user_address_id,page,limit,user_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_address_mgmt.action="address_delete.php?user_address_id="+user_address_id+"&page="+page+"&limit="+limit+"&user_id="+user_id;
		document.frm_address_mgmt.submit();	
	}
}

function default_bill_address_change(user_address_id,status,user_id,page,limit){
	document.frm_address_mgmt.action="default_bill_address_change.php?user_address_id="+user_address_id+"&status="+status+"&user_id="+user_id+"&page="+page+"&limit="+limit;	
	document.frm_address_mgmt.submit();	
}

function default_ship_address_change(user_address_id,status,user_id,page,limit){
	document.frm_address_mgmt.action="default_ship_address_change.php?user_address_id="+user_address_id+"&status="+status+"&user_id="+user_id+"&page="+page+"&limit="+limit;	
	document.frm_address_mgmt.submit();	
}

function getCity(val) {
     var req = Inint_AJAX();
		req.onreadystatechange = function () { 
	       if (req.readyState==4) {
	          if (req.status==200) {
	             document.getElementById("city").innerHTML=req.responseText; //retuen value
              } 
           }
        };
	 req.open("GET", "get_city.php?val="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

/******************************************* Country Manager **************************************/

function country_edit(country_id,page,limit)
{		
	document.frm_country_mgmt.action = "country_add.php?country_id="+country_id+"&page="+page+"&limit="+limit;
	document.frm_country_mgmt.submit();
}
function country_save(page,limit)
{	
	if(document.frm_country_add.country_name.value==''){
		alert("Please Enter Country Name");
		document.frm_country_add.country_name.focus();
		return false;
	}else{
		document.frm_country_add.action = "country_save.php?page="+page+"&limit="+limit;
		document.frm_country_add.submit();
	}
}
function country_delete(country_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_country_mgmt.action = "country_delete.php?country_id="+country_id+"&page="+page+"&limit="+limit;
		document.frm_country_mgmt.submit();
	}
}

/******************************************* Category Manager ***********************************/

function cat_edit(category_id,page,limit)
{
	document.frm_cat_mgmt.action="cat_add.php?category_id="+category_id+"&page="+page+"&limit="+limit;
	document.frm_cat_mgmt.submit();
}

function cat_delete(category_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_cat_mgmt.action="cat_delete.php?category_id="+category_id+"&page="+page+"&limit="+limit;
		document.frm_cat_mgmt.submit();	
	}
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function cat_save(id1,img1,page,limit)
{	
	if(document.frm_cat_add.product_type.value==''){
		alert("Please select Item Type");
		document.frm_cat_add.product_type.focus();
		return false;
	}else if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter Category Name");
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.disp_cat_name.value==''){
		alert("Please Enter Category Name to Display");
		document.frm_cat_add.disp_cat_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==""){
		alert("Please Select Parent Category");
		document.frm_cat_add.parent_id.focus();
		return false;
	}else{//alert(id);
		if(id1 == ''){
			if(document.frm_cat_add.txt_image.value == ''){
				alert("Please upload category image");
				document.frm_cat_add.txt_image.focus();
				return false;
			}
		}else{
			if(img1 == ''){
				if(document.frm_cat_add.txt_image.value == ''){
					alert("Please upload category image");
					document.frm_cat_add.txt_image.focus();
					return false;
				}
			}
		}
		if(document.frm_cat_add.txt_image.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");   
  
			var image_file = document.frm_cat_add.txt_image.value;   
			  
			var image_length = document.frm_cat_add.txt_image.value.length;   
			  
			var pos = image_file.lastIndexOf('.') + 1;   
			  
			var ext = image_file.substring(pos, image_length);   
			  
			var final_ext = ext.toLowerCase();   
			  
			var flag = false;
			
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			} 
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_cat_add.txt_image.focus();
				return false;   
			}
		}
	}
	if(document.frm_cat_add.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_cat_add.display_order.focus();
		return false;
	}
	document.frm_cat_add.action="category_save.php?page="+page+"&limit="+limit+"&image="+img1+"&id="+id1;
	document.frm_cat_add.submit();
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function cat_save1(page,limit)
{
	if(document.frm_cat_add.product_type.value==''){
		alert("Please select Item Type");
		document.frm_cat_add.product_type.focus();
		return false;
	}else if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter Category Name");
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.disp_cat_name.value==''){
		alert("Please Enter Display Category Name");
		document.frm_cat_add.disp_cat_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==''){
		alert("Please Select Parent Category")
		document.frm_cat_add.parent_id.focus();
		return false;
	}else if(document.frm_cat_add.txt_image.value == ''){
		alert("Please upload category image");
		document.frm_cat_add.txt_image.focus();
		return false;
	}else{//alert(id);
		if(document.frm_cat_add.txt_image.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif"); 
			var image_file = document.frm_cat_add.txt_image.value;
			var image_length = document.frm_cat_add.txt_image.value.length;
			var pos = image_file.lastIndexOf('.') + 1;
			var ext = image_file.substring(pos, image_length);
			var final_ext = ext.toLowerCase();
			var flag = false;
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_cat_add.txt_image.focus();
				return false;   
			}
		}
		if(document.frm_cat_add.display_order.value==""){
			alert("Please enter Display Order");
			document.frm_cat_add.display_order.focus();
			return false;
		}
		document.frm_cat_add.action="category_save.php?page="+page+"&limit="+limit;
		document.frm_cat_add.submit();
	}
}

/******************************************* Color Manager **************************************/

function color_edit(color_id,page,limit)
{		
	document.frm_color_mgmt.action = "color_add.php?color_id="+color_id+"&page="+page+"&limit="+limit;
	document.frm_color_mgmt.submit();
}
function color_save(page,limit)
{	
	if(document.frm_color_add.color_name.value==''){
		alert("Please Enter Color Name");
		document.frm_color_add.color_name.focus();
		return false;
	}else{
		document.frm_color_add.action = "color_save.php?page="+page+"&limit="+limit;
		document.frm_color_add.submit();
	}
}
function color_delete(color_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
	document.frm_color_mgmt.action = "color_delete.php?color_id="+color_id+"&page="+page+"&limit="+limit;
	document.frm_color_mgmt.submit();
	}
}

/******************************************** Page Manager **************************************/

function page_edit(page_id,page,limit)
{
	document.frm_page_mgmt.action="page_add.php?page_id="+page_id+"&page="+page+"&limit="+limit;
	document.frm_page_mgmt.submit();
}

function page_delete(page_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_page_mgmt.action="page_delete.php?page_id="+page_id+"&page="+page+"&limit="+limit;
		document.frm_page_mgmt.submit();	
	}
}

function page_save(page,limit,page_id,image)
{
	//var textarea = tinyMCE.get('page_desc').getContent(); 
	//alert(textarea);
	if(document.frm_page_add.page_name.value==''){
		alert("Please Enter Page Name");
		document.frm_page_add.page_name.focus();
		return false;
		//tinyMCE.getContent()
	}else if(document.frm_page_add.page_link.value==''){
		alert("Please Enter Page Link");
		document.frm_page_add.page_link.focus();
		return false;
	}else if(document.frm_page_add.display_order.value==''){
		alert("Please Enter Display Order");
		document.frm_page_add.display_order.focus();
		return false;
	}else{
		document.frm_page_add.action="page_save.php?page="+page+"&limit="+limit;
		document.frm_page_add.submit();
	}
	
}

/********************************************* Size Manager *************************************/

function size_edit(size_id,page,limit)
{
	document.frm_size_mgmt.action="size_add.php?size_id="+size_id+"&page="+page+"&limit="+limit;
	document.frm_size_mgmt.submit();
}

function size_delete(size_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_size_mgmt.action="size_delete.php?size_id="+size_id+"&page="+page+"&limit="+limit;
		document.frm_size_mgmt.submit();	
	}
}

function size_save(size_id,page,limit)
{
	if(document.frm_size_add.size_desc.value==''){
		alert("Please Enter Size Description");
		document.frm_size_add.size_desc.focus();
		return false;
	}else{
		document.frm_size_add.action="size_save.php?page="+page+"&limit="+limit+"&size_id="+size_id;
		document.frm_size_add.submit();
	}
}

/*******************************************  Product Type Manager  **************************************/

function product_type_edit(product_type_id,page,limit)
{
	document.frm_product_type_mgmt.action="product_type_add.php?product_type_id="+product_type_id+"&page="+page+"&limit="+limit;
	document.frm_product_type_mgmt.submit();
}

function product_type_delete(product_type_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_product_type_mgmt.action="product_type_delete.php?product_type_id="+product_type_id+"&page="+page+"&limit="+limit;
		document.frm_product_type_mgmt.submit();	
	}
}

function product_type_save(id,page,limit)
{
	
	if(document.frm_product_type_add.product_type_name.value==''){
		alert("Please Enter Product Type Name");
		document.frm_product_type_add.product_type_name.focus();
		return false;
	}else if(document.frm_product_type_add.product_type_price.value==''){
		alert("Please Enter Product Type Price");
		document.frm_product_type_add.product_type_price.focus();
		return false;
	}else{
		document.frm_product_type_add.action="product_type_save.php?page="+page+"&limit="+limit;
		document.frm_product_type_add.submit();
	}
}

/*********************************************** User Manager *************************************/
function user_edit(user_id,page,limit)
{
	document.frm_user_mgmt.action="user_add.php?user_id="+user_id+"&page="+page+"&limit="+limit;
	document.frm_user_mgmt.submit();
}
function user_delete(user_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_user_mgmt.action="user_delete.php?user_id="+user_id+"&page="+page+"&limit="+limit;
		document.frm_user_mgmt.submit();	
	}
}

var int =/^\d+$/;
var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function user_save(page,limit)
{
	if(document.frm_user_add.user_type_id.value==0){
		alert("Select User Type");
		document.frm_user_add.user_type_id.focus();
		return false;
	}else if(document.frm_user_add.user_fname.value==''){
		alert("Please Enter First Name");
		document.frm_user_add.user_fname.focus();
		return false;
	}else if(document.frm_user_add.user_lname.value==''){
		alert("Please Enter Last Name");
		document.frm_user_add.user_lname.focus();
		return false;
	}else if(document.frm_user_add.day.value==''){
		alert("Please Enter your birth Day");
		document.frm_user_add.day.focus();
		return false;
	}else if(!(float.test(document.frm_user_add.day.value))){
		alert("Please enter Integer");
		document.frm_user_add.day.focus();
		return false;
	}else if(document.frm_user_add.month.value==''){
		alert("Please Enter your birth Month");
		document.frm_user_add.month.focus();
		return false;
	}else if(document.frm_user_add.year.value==''){
		alert("Please Enter your birth Year");
		document.frm_user_add.year.focus();
		return false;
	}else if(!(float.test(document.frm_user_add.year.value))){
		alert("Please enter Integer");
		document.frm_user_add.year.focus();
		return false;
	}else if(document.frm_user_add.year.value.length != 4){
		alert("Please enter 4 digit birth year");
		document.frm_user_add.year.focus();
		return false;
	}else if(document.frm_user_add.user_email.value == ""){
		alert("Please Enter EmailID");
		document.frm_user_add.user_email.focus();
		return false;
	}else if(document.frm_user_add.user_email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_user_add.user_email.focus();
		return false;
	}else if(document.frm_user_add.user_email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_user_add.user_email.focus();
		return false;
	}else{
		var password=document.frm_user_add.user_pass;
		
		if(password.value==""){
			alert("Please enter your password");
			password.focus();
			return false;
		}else if(password.value.length < 6){
			alert("Your password should contain minimum 6 characters");
			password.focus();
			return false;
		}
		
		var pass_string = password.value;		
		var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for (var i=0; i<pass_string.length; i++) {
        	if (valid.indexOf(pass_string.charAt(i)) < 0) {
            	alert('Your password contains invalid characters');
				password.focus();
            	return false;
        	}
    	}
		
		var alphaCount=0
 		var numCount=0

		var num_valid="123456789";
		
		for (var i=0; i<pass_string.length; i++) {
			if (num_valid.indexOf(pass_string.charAt(i)) < 0) {
			 numCount++;
			}
		}
		if(numCount==pass_string.length){
			alert('Your password contains only characters. Please enter an alphanumeric	value like -alpha1-');
			password.focus();
			return false;
		}
		
		var	alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for (var i=0; i<pass_string.length; i++) {
			if (alph_valid.indexOf(pass_string.charAt(i)) < 0) {
				alphaCount++;
			}
		}
		if(alphaCount==pass_string.length){
			alert('Your password contains only numbers. Please enter an alphanumeric value like -alpha1-');
			password.focus();
			return false;
		}
		
		if((document.frm_user_add.day.value <= 0) || (document.frm_user_add.day.value > 31)){ 
			alert("Please Enter your birth Day between 1-31");
			document.frm_user_add.day.focus();
			return false;
		}
		
		document.frm_user_add.action="user_save.php?page="+page+"&limit="+limit;
		document.frm_user_add.submit();
	}
}

/******************************************* Product Manager **************************************/

function get_size(){
	var temp=0;
	//alert("Hi");
	var len = document.getElementById("product_color").length;	//alert(len);
	var attribute_value = new Array();
	for (i = 0; i < len; i++)
	{
	 	if (document.frm_product_add.product_color[i].selected) 
		{
			temp++; 
			attribute_value[i]=document.frm_product_add.product_color[i].value;	//alert(attribute_value[i]);
		}
	}
		//alert(temp+" number of options");
	var req = Inint_AJAX();
	   //alert(src);alert(val);
	req.onreadystatechange = function () { 
    if (req.readyState==4) {
        if (req.status==200) {
			//alert(req.responseText);
            document.getElementById("divSize").innerHTML=req.responseText; //retuen value
        } 
      }
    };
	req.open("GET","get_size.php?p="+temp+"&arr="+attribute_value); //make connection
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
    req.send(null);
}

function product_edit(product_id,page,limit)
{
	document.frm_product_mgmt.action="product_add.php?product_id="+product_id+"&page="+page+"&limit="+limit;
	document.frm_product_mgmt.submit();
}

function product_delete(product_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_product_mgmt.action="product_delete.php?product_id="+product_id+"&page="+page+"&limit="+limit;
		document.frm_product_mgmt.submit();	
	}
}

function product_save(id,img1,img2,page,limit)
{	//alert(color_id);
	if(document.frm_product_add.product_type.value==''){
		alert("Please Select Product Type");
		document.frm_product_add.product_type.focus();
		return false;
	}else if(document.frm_product_add.category_id.value==''){
		alert("Please Select Category");
		document.frm_product_add.category_id.focus();
		return false;
	}else if(document.frm_product_add.product_name.value==''){
		alert("Please Enter Product Name");
		document.frm_product_add.product_name.focus();
		return false;
	}else {
		if(id == ''){		
			if(document.frm_product_add.product_image_small1.value == ''){
				alert("Please upload your small image");
				document.frm_product_add.product_image_small1.focus();
				return false;
			}
			if(document.frm_product_add.product_image_big1.value == ''){
				alert("Please upload your big image");
				document.frm_product_add.product_image_big1.focus();
				return false;
			}	
		}else{
			if(img1 == ''){
				if(document.frm_product_add.product_image_small1.value == ''){
					alert("Please upload your small image");
					document.frm_product_add.product_image_small1.focus();
					return false;
				}
			}
			if(img2 == ''){
				if(document.frm_product_add.product_image_big1.value == ''){
					alert("Please upload your big image");
					document.frm_product_add.product_image_big1.focus();
					return false;
				}
			}
		}
		if(document.frm_product_add.product_image_small1.value != '')
		{
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");
			var image_file = document.frm_product_add.product_image_small1.value; 
			var image_length = document.frm_product_add.product_image_small1.value.length; 
			var pos = image_file.lastIndexOf('.') + 1;   
			var ext = image_file.substring(pos, image_length); 
			var final_ext = ext.toLowerCase();  
			var flag = false;
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}  
			if(flag == false){
				alert("Please upload product small image with one of the following extensions: "+ extensions.join(', ') +".");
				document.frm_product_add.product_image_small1.focus();
				return false;   
			}
		}
		if(document.frm_product_add.product_image_big1.value != '')
		{
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif"); 
			var image_file = document.frm_product_add.product_image_big1.value; 
			var image_length = document.frm_product_add.product_image_big1.value.length; 
			var pos = image_file.lastIndexOf('.') + 1;   
			var ext = image_file.substring(pos, image_length); 
			var final_ext = ext.toLowerCase(); 
			var flag = false;
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			} 
			if(flag == false){ 
				alert("Please upload product big image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_product_add.product_image_big1.focus();
				return false;   
			}
		}
		
		/*var b,color,sel_color_arr='';
		for(i = 0; i < document.getElementById('product_color').options.length; i++) 
		{
			if (document.getElementById('product_color').options[i].selected) 
			{ 
				var b = 1; 
				color = document.getElementById('product_color').options[i].value;
			//	sel_color_arr = sel_color_arr + color + ',';
			}
		}
		if(!b)
		{
			alert("Please select a Color!");
			frm_product_add.product_color.focus();
			return false;
		}else{
			
			var elm = document.getElementsByTagName("input");	
			var j=0, chkcount=0, chkname='';
		
			for(var i=0; i< elm.length; i++)
			{
				if(elm[i].type.toLowerCase()=="checkbox")
				{
					j++;	//	alert("j="+j);
					if(j==1)
					{
						chkname = elm[i].name;	  //alert(chkname);
					}
					if(elm[i].checked)
					{
						chkcount++;		//  alert(chkcount);
					}
				}
			}
		
			if(chkcount==0)
			{
				alert("Please select minimum any one Product Size");
				document.getElementById(chkname).focus();
				return false;
			}
			
			var j=0, txtcount=0,selChk=1,txtname='',txtname_part_1='',txtname_part_2='';
			for(var i=0; i< elm.length; i++)
			{	j=0;
				if(elm[i].type.toLowerCase()=="text")
				{
					txtname = elm[i].name;
					txtname_len = txtname.length;	//	alert(len);
					txtname_part_1 = txtname.substr(0,7);
					
					if(txtname_part_1 == 'txtQty_')
					{
						txtname_part_2 = txtname.substr(7,txtname_len);		//alert(txtname_part_2);
						if(document.getElementById('chksize_'+txtname_part_2).checked)
						{													//	alert("hi---"+elm[i].value);		
							if(elm[i].value != '')
							{	j++;
								txtcount++;		//  alert("---"+txtcount);								
							}
						//	if(j==0)
							if(txtcount==0)	
							{
								selChk = txtname_part_2;	//	alert("sss--"+selChk);
							}
						}
					}
					
				}
			}
			if(txtcount==0)
			{
				alert("Please enter Product's Quantity");
				document.getElementById('txtQty_'+selChk).focus();
				return false;
			}
		}*/
		if(document.frm_product_add.product_qty.value == ''){
			alert("Please enter Product Quantity");
			document.frm_product_add.product_qty.focus();
			return false;
		}else if(!(float.test(document.frm_product_add.product_qty.value))){
			alert("Please enter Product Quantity in Numeric Values");
			document.frm_product_add.product_qty.focus();
			return false;
		}else if(document.frm_product_add.product_weight.value == ''){
			alert("Please enter Product Weight");
			document.frm_product_add.product_weight.focus();
			return false;
		}else if(!(float.test(document.frm_product_add.product_weight.value))){
			alert("Please enter Weight in Numeric Values");
			document.frm_product_add.product_weight.focus();
			return false;
		}else if(document.frm_product_add.gold_weight.value == ''){
			alert("Please enter Gold Weight");
			document.frm_product_add.gold_weight.focus();
			return false;
		}else if(!(float.test(document.frm_product_add.gold_weight.value))){
			alert("Please enter Gold Weight in Numeric Values");
			document.frm_product_add.gold_weight.focus();
			return false;
		}else if(document.frm_product_add.other_charges.value == ''){
			alert("Please enter Product Other Charges");
			document.frm_product_add.other_charges.focus();
			return false;
		}else if(!(float.test(document.frm_product_add.other_charges.value))){
			alert("Please enter Product Other Charges in Numeric Values");
			document.frm_product_add.other_charges.focus();
			return false;
		}
		document.frm_product_add.action="product_save.php?page="+page+"&limit="+limit+"&img1="+img1+"&img2="+img2;
		document.frm_product_add.submit();
	}
}

var intTextBox=1;
var i = 0;
function add_more_images(val){
	
	if(val != 0){
		i++;
		if(i==1){
			intTextBox = val;	
		}
	}
	intTextBox++;
	
	var contentID = document.getElementById('divImages');
	var newTBDiv = document.createElement('div');
	newTBDiv.setAttribute('id','strText'+intTextBox);
	newTBDiv.innerHTML = "<input type='file' id=product_image_small" + intTextBox + " name=product_image_small" + intTextBox + " /><br/><input type='file' id='product_image_big" + intTextBox + "' name=product_image_big" + intTextBox + "  />";
	contentID.appendChild(newTBDiv);
}

function getCat(val){
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCat").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_cat.php?pro_type="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};



/**************************************************** Order Manager **************************************************/

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function order_add_save(bill_id,ship_id,page,limit){
	if(document.frm_order_add.bill_fname.value==''){
		alert("Please Enter Billing First Name");
		document.frm_order_add.bill_fname.focus();
		return false;
	}else if(document.frm_order_add.bill_lname.value==''){
		alert("Please Enter Billing Last Name");
		document.frm_order_add.bill_lname.focus();
		return false;
	}else if(document.frm_order_add.bill_address1.value==''){
		alert("Please Enter Billing Address1");
		document.frm_order_add.bill_address1.focus();
		return false;
	}else if(document.frm_order_add.bill_address2.value==''){
		alert("Please Enter Billing Address2");
		document.frm_order_add.bill_address2.focus();
		return false;
	}else if(document.frm_order_add.bill_city.value==''){
		alert("Please Enter Billing City");
		document.frm_order_add.bill_city.focus();
		return false;
	}else if(document.frm_order_add.bill_state.value==''){
		alert("Please Select Billing State");
		document.frm_order_add.bill_state.focus();
		return false;
	}else if(document.frm_order_add.bill_country.value==''){
		alert("Please Select Billing Country");
		document.frm_order_add.bill_country.focus();
		return false;
	}else if(document.frm_order_add.bill_zip.value==''){
		alert("Please Enter Billing Zipcode");
		document.frm_order_add.bill_zip.focus();
		return false;		
	}else if(document.frm_order_add.ship_fname.value==''){
		alert("Please Enter Shipping First Name");
		document.frm_order_add.ship_fname.focus();
		return false;
	}else if(document.frm_order_add.ship_lname.value==''){
		alert("Please Enter Shipping Last Name");
		document.frm_order_add.ship_lname.focus();
		return false;
	}else if(document.frm_order_add.ship_address1.value==''){
		alert("Please Enter Shippig Address1");
		document.frm_order_add.ship_address1.focus();
		return false;
	}else if(document.frm_order_add.ship_address2.value==''){
		alert("Please Enter Shipping Address2");
		document.frm_order_add.ship_address2.focus();
		return false;
	}else if(document.frm_order_add.ship_city.value==''){
		alert("Please Enter Shipping City");
		document.frm_order_add.ship_city.focus();
		return false;
	}else if(document.frm_order_add.ship_state.value==''){
		alert("Please Select Shipping State");
		document.frm_order_add.ship_state.focus();
		return false;
	}else if(document.frm_order_add.ship_country.value==''){
		alert("Please Select Shipping Country");
		document.frm_order_add.ship_country.focus();
		return false;
	}else if(document.frm_order_add.ship_zip.value==''){
		alert("Please Enter Shipping Zipcode");
		document.frm_order_add.ship_zip.focus();
		return false;	
	}else{
		document.frm_order_add.action="order_add_save.php?bill_id="+bill_id+"&ship_id="+ship_id+"&page="+page+"&limit="+limit;
		document.frm_order_add.submit();	
	}
}

/******************************************** Front Side ************************************************/

function contact(){
	if(document.frm_contact.title.value==''){
		alert("Please enter title");
		document.frm_contact.title.focus();
		return false;
	}else if(document.frm_contact.first_name.value==''){
		alert("Please enter first name");
		document.frm_contact.first_name.focus();
		return false;
	}else if(document.frm_contact.last_name.value==''){
		alert("Please enter last name");
		document.frm_contact.last_name.focus();
		return false;
	}else if(document.frm_contact.email.value==''){
		alert("Please enter email");
		document.frm_contact.email.focus();
		return false;
	}
	document.frm_contact.action = "mail.php";
	document.frm_contact.submit();
}

function delete_prod(val,frmpara){
	document.frm_cart.action="delete_prod.php?cart_item_id="+val+"&frmpara="+frmpara;
	document.frm_cart.submit(); 
}

function update_cart(frmpara){
	document.frm_cart.action="delete_prod.php?frmpara="+frmpara;
	document.frm_cart.submit();
}

function continue_shopping(){
	document.frm_cart.action="index.php";
	document.frm_cart.submit();
}

function empty_cart(frmpara){
	document.frm_cart.action="delete_prod.php?frmpara="+frmpara;
	document.frm_cart.submit();
}

function checkout(){
	document.frm_cart.action="chk_user.php?frmpara=cart";
	document.frm_cart.submit();
}

function get_size1(val){
	var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
				   document.getElementById("size10").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_size.php?pro_size_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value	
}

function wire_transfer()
{
	document.frm_checkout.action = "wire_transfer.php";
	document.frm_checkout.submit();
}

function paypal()
{
	/*if(val == 1)
	{*/
		document.frm_checkout.action = "paypal.php";
		document.frm_checkout.submit();
		
	/*}else{
		alert("Can't proceed until you fulfill above condition");	
	}*/
}
function paypal_not()
{
	/*if(val == 1)
	{*/
		document.frm_checkout.action = "online_disable.php";
		document.frm_checkout.submit();
		
	/*}else{
		alert("Can't proceed until you fulfill above condition");	
	}*/
}

/*function paypal1(val){
	if(val == 1){
		document.frm_checkout.action = "credit_info.php";
		document.frm_checkout.submit();
	}else{
		alert("Can't proceed until you fulfill above condition");	
	}
}*/

function addtocart()
{	
	document.frm_product.action = "addtocart.php";
	document.frm_product.submit();
}
function view_cart()
{
	document.frm_cart.action = "viewcart.php";
	document.frm_cart.submit();
}

/****************************************** Register *****************************************/

function valid_regi()
{
	if(document.frm_register.user_fname.value==''){
		alert("Please Enter First Name");
		document.frm_register.user_fname.focus();
		//var fname = 'user_fname';
		//return fname;
		return false;
	}else if(!(alpha(document.frm_register.user_fname.value)))
	{
		alert("Only Alphabatic allowed in First Name");
		document.frm_register.user_fname.focus();
		return false;
	}else if(document.frm_register.user_lname.value==''){
		alert("Please Enter Last Name");
		document.frm_register.user_lname.focus();
		return false;
	}else if(!(alpha(document.frm_register.user_lname.value)))
	{
		alert("Only Alphabatic allowed in First Name");
		document.frm_register.user_lname.focus();
		return false;
	}else if(document.frm_register.user_birth_date.value == ""){
		alert("Please Enter Birth Date");
		document.frm_register.user_birth_date.focus();
		return false;
	}else{
		selDate = document.frm_register.user_birth_date.value;
		var selDatePart = selDate.split("/");
		
		var day = selDatePart[0];
		var month = selDatePart[1];
		var year = selDatePart[2];
		//alert(day);alert(month);alert(year);
		var date1 = new Date(); 
		date1.setYear(year);
		date1.setMonth(month-1);
		date1.setDate(day);
		var current_date = new Date();
		//alert(date1);
		if(date1 >= current_date){
			alert("Please enter Birth Date which is less than Current Date!");
			document.frm_register.user_birth_date.focus();
			return false;
		}
	}
	if(document.frm_register.email.value == ""){
		alert("Please Enter EmailID");
		document.frm_register.email.focus();
		return false;
	}else if(document.frm_register.email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_register.email.focus();
		return false;
	}else if(document.frm_register.email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_register.email.focus();
		return false;
	}else{
		
		var password=document.frm_register.password;
		
		if(password.value==""){
			alert("Please enter your password");
			password.focus();
			return false;
		}else if(password.value.length < 6){
			alert("Your password should contain minimum 6 characters");
			password.focus();
			return false;
		}
		
		var pass_string = password.value;		
		var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for (var i=0; i<pass_string.length; i++) {
        	if (valid.indexOf(pass_string.charAt(i)) < 0) {
            	alert('Your password contains invalid characters');
				password.focus();
            	return false;
        	}
    	}
		
		var alphaCount=0
 		var numCount=0

		var num_valid="123456789";
		
		for (var i=0; i<pass_string.length; i++) {
			if (num_valid.indexOf(pass_string.charAt(i)) < 0) {
			 numCount++;
			}
		}
		if(numCount==pass_string.length){
			alert('Your password contains only characters. Please enter an alphanumeric	value like -alpha1-');
			password.focus();
			return false;
		}
		
		var	alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for (var i=0; i<pass_string.length; i++) {
			if (alph_valid.indexOf(pass_string.charAt(i)) < 0) {
				alphaCount++;
			}
		}
		if(alphaCount==pass_string.length){
			alert('Your password contains only numbers. Please enter an alphanumeric value like -alpha1-');
			password.focus();
			return false;
		}
		
		if(document.frm_register.security_code.value == ""){
			alert("Please Enter Security Code");
			document.frm_register.security_code.focus();
			return false;
		}
	}
		
	document.frm_register.action = 'register.php';
	document.frm_register.submit();
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function billing_address(){
	if(document.frm_billing_address.bill_first_name.value==''){
		alert("Please enter first name");
		document.frm_billing_address.bill_first_name.focus();
		return false;	
	}else if(!(alpha(document.frm_billing_address.bill_first_name.value)))
	{
		alert("Only Alphabatic allowed in First Name");
		document.frm_billing_address.bill_first_name.focus();
		return false;
	}else if(document.frm_billing_address.bill_last_name.value==''){
		alert("Please enter last name");
		document.frm_billing_address.bill_last_name.focus();
		return false;	
	}else if(!(alpha(document.frm_billing_address.bill_last_name.value)))
	{
		alert("Only Alphabatic allowed in last Name");
		document.frm_billing_address.bill_last_name.focus();
		return false;
	}else if(document.frm_billing_address.bill_tele_day1.value==''){
		alert("Please Enter Country Code");
		document.frm_billing_address.bill_tele_day1.focus();
		return false;
	}else if(!(numeric(document.frm_billing_address.bill_tele_day1.value)))
	{
		alert("Only Number allowed in Country Code");
		document.frm_billing_address.bill_tele_day1.focus();
		return false;
	}else if(document.frm_billing_address.bill_tele_day2.value==''){
		alert("Please Enter Area Code");
		document.frm_billing_address.bill_tele_day2.focus();
		return false;
	}else if(!(numeric(document.frm_billing_address.bill_tele_day2.value)))
	{
		alert("Only Number allowed in Area Number");
		document.frm_billing_address.bill_tele_day2.focus();
		return false;
	}else if(document.frm_billing_address.bill_tele_day.value==''){
		alert("Please Enter Telephone Daytime");
		document.frm_billing_address.bill_tele_day.focus();
		return false;
	}else if(!(numeric(document.frm_billing_address.bill_tele_day.value)))
	{
		alert("Only Number allowed in Phone Number");
		document.frm_billing_address.bill_tele_day.focus();
		return false;
	}else if(document.frm_billing_address.bill_address1.value==''){
		alert("Please Enter Address 1");
		document.frm_billing_address.bill_address1.focus();
		return false;	
	}else if(document.frm_billing_address.bill_city.value==''){
		alert("Please Enter City");
		document.frm_billing_address.bill_city.focus();
		return false;	
	}else if(!(alpha(document.frm_billing_address.bill_city.value)))
	{
		alert("Only Alphabatic allowed in City");
		document.frm_billing_address.bill_city.focus();
		return false;
	}else if(document.frm_billing_address.bill_state.value==''){
		alert("Please Enter State");
		document.frm_billing_address.bill_state.focus();
		return false;	
	}else if(!(alpha(document.frm_billing_address.bill_state.value)))
	{
		alert("Only Alphabatic allowed in State");
		document.frm_billing_address.bill_state.focus();
		return false;
	}else if(document.frm_billing_address.bill_postcode.value==''){
		alert("Please Enter Zipcode");
		document.frm_billing_address.bill_postcode.focus();
		return false;
	}else if(!(alphanumeric(document.frm_billing_address.bill_postcode.value)))
	{
		alert("Only Alphabatic & number allowed in Post Code");
		document.frm_billing_address.bill_postcode.focus();
		return false;
	}else if(document.frm_billing_address.bill_country.value==''){
		alert("Please select Country");
		document.frm_billing_address.bill_country.focus();
		return false;
	}else if(document.frm_billing_address.bill_mobile.value==''){
		alert("Please enter mobile number");
		document.frm_billing_address.bill_mobile.focus();
		return false;
	}else if(!(numeric(document.frm_billing_address.bill_mobile.value)))
	{
		alert("Only Number allowed in Mobile Number");
		document.frm_billing_address.bill_mobile.focus();
		return false;
	}
	if(document.frm_billing_address.chkshipping.checked == true){
		document.frm_billing_address.action="user_save.php";
		document.frm_billing_address.submit();
	}else{
		document.frm_billing_address.action="shipping_address.php";
		document.frm_billing_address.submit();
	}
	
}
function bill_addr_reset()
{
	document.frm_billing_address.bill_tele_day.value='';
	document.frm_billing_address.bill_address1.value='';
	document.frm_billing_address.bill_city.value='';
	document.frm_billing_address.bill_state.value='';
	document.frm_billing_address.bill_postcode.value='';
	document.frm_billing_address.bill_country.selectedIndex=0;
}
function back_register()
{
	document.frm_billing_address.action="register.php?type=back";
	document.frm_billing_address.submit();	
}

function back_billing()
{
	document.frm_shipping_address.action="billing_address.php";
	document.frm_shipping_address.submit();	
}
function ship_addr_reset()
{ 
	document.frm_shipping_address.ship_tele_day.value='';
	document.frm_shipping_address.ship_address1.value='';
	document.frm_shipping_address.ship_city.value='';
	document.frm_shipping_address.ship_state.value='';
	document.frm_shipping_address.ship_postcode.value='';
	document.frm_shipping_address.ship_country.selectedIndex=0;
}
function shipping_address(){
	if(document.frm_shipping_address.ship_first_name.value==''){
		alert("Please enter first name");
		document.frm_shipping_address.ship_first_name.focus();
		return false;	
	}else if(document.frm_shipping_address.ship_last_name.value==''){
		alert("Please enter last name");
		document.frm_shipping_address.ship_last_name.focus();
		return false;	
	}else if(document.frm_shipping_address.ship_tele_day.value==''){
		alert("Please Enter Telephone Daytime");
		document.frm_shipping_address.ship_tele_day.focus();
		return false;
	}else if(document.frm_shipping_address.ship_address1.value==''){
		alert("Please Enter Address 1");
		document.frm_shipping_address.ship_address1.focus();
		return false;	
	}else if(document.frm_shipping_address.ship_city.value==''){
		alert("Please Enter City");
		document.frm_shipping_address.ship_city.focus();
		return false;	
	}else if(document.frm_shipping_address.ship_state.value==''){
		alert("Please Enter State");
		document.frm_shipping_address.ship_state.focus();
		return false;
	}else if(document.frm_shipping_address.ship_postcode.value==''){
		alert("Please Enter Zipcode");
		document.frm_shipping_address.ship_postcode.focus();
		return false;
	}else if(document.frm_shipping_address.ship_country.value==''){
		alert("Please Select Country");
		document.frm_shipping_address.ship_country.focus();
		return false;
	}
	document.frm_shipping_address.action="user_save.php";
	document.frm_shipping_address.submit();
	
}

/****************************************** Login *****************************************/

/*function ret2tab(index) {
	var indexNo = index;
	var keyCode = event.keyCode;
	var ele = document.getElementById("frmlogin").elements[indexNo];
	if (keyCode == 13) {
		event.keyCode = 0;
		ele.focus();
		ele.select();
		}
}*/

function login_validate(frmpara)
{	//alert("Hi");
	if(document.frmlogin.txtEmail.value == ""){
		alert("Please Enter EmailID");
		document.frmlogin.txtEmail.focus();
		return false;
	}else if(document.frmlogin.txtEmail.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frmlogin.txtEmail.focus();
		return false;
	}else if(document.frmlogin.txtEmail.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frmlogin.txtEmail.focus();
		return false;
	}else{
		
		var password=document.frmlogin.txtPass;
		
		if(password.value==""){
			alert("Please enter your password");
			password.focus();
			return false;
		}else if(password.value.length < 6){
			alert("Your password should contain minimum 6 characters");
			password.focus();
			return false;
		}
		
		var pass_string = password.value;		
		var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for (var i=0; i<pass_string.length; i++) {
        	if (valid.indexOf(pass_string.charAt(i)) < 0) {
            	alert('Your password contains invalid characters');
				password.focus();
            	return false;
        	}
    	}
		
		var alphaCount=0
 		var numCount=0

		var num_valid="123456789";
		
		for (var i=0; i<pass_string.length; i++) {
			if (num_valid.indexOf(pass_string.charAt(i)) < 0) {
			 numCount++;
			}
		}
		if(numCount==pass_string.length){
			alert('Your password contains only characters. Please enter an alphanumeric	value like -alpha1-');
			password.focus();
			return false;
		}
		
		var	alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for (var i=0; i<pass_string.length; i++) {
			if (alph_valid.indexOf(pass_string.charAt(i)) < 0) {
				alphaCount++;
			}
		}
		if(alphaCount==pass_string.length){
			alert('Your password contains only numbers. Please enter an alphanumeric value like -alpha1-');
			password.focus();
			return false;
		}
	}
		
	document.frmlogin.action="login_validate.php?frmpara="+frmpara;
	document.frmlogin.submit();	
	
}

function forgot_validate()
{
	if(document.frmlogin1.txtEmail.value == ""){
		alert("Please Enter Your EmailID");
		document.frmlogin1.txtEmail.focus();
		return false;
	}else if(document.frmlogin1.txtEmail.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frmlogin1.txtEmail.focus();
		return false;
	}else if(document.frmlogin1.txtEmail.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frmlogin1.txtEmail.focus();
		return false;
	}else{
		document.frmlogin1.action ="check_pass.php";
		document.frmlogin1.submit();	
	}
}
/***************************** My Account (Edit_personal_detail && Edit_login_detail) *******************************/

function edit_personal_detail()
{
	document.frm_edit_personal.action="myaccount_save.php?type=personal";
	document.frm_edit_personal.submit();		
}
function login_detail()
{
	var password=document.frm_edit_login.user_pass;
		if(password.value==""){
			alert("Please enter your password");
			password.focus();
			return false;
		}else if(password.value.length < 6){
			alert("Your password should contain minimum 6 characters");
			password.focus();
			return false;
		}
		var pass_string = password.value;		
		var valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for (var i=0; i<pass_string.length; i++) {
        	if (valid.indexOf(pass_string.charAt(i)) < 0) {
            	alert('Your password should contain both letters and numbers');
				password.focus();
            	return false;
        	}
    	}
		
		var alphaCount=0
 		var numCount=0

		var num_valid="1234567890";
		
		for (var i=0; i<pass_string.length; i++) {
			if (num_valid.indexOf(pass_string.charAt(i)) < 0) {
			 numCount++;
			}
		}
		if(numCount==pass_string.length){
			alert('Your password should contain both letters and numbers');
			password.focus();
			return false;
		}
		
		var	alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for (var i=0; i<pass_string.length; i++) {
			if (alph_valid.indexOf(pass_string.charAt(i)) < 0) {
				alphaCount++;
			}
		}
		if(alphaCount==pass_string.length){
			alert('Your password should contain both letters and numbers');
			password.focus();
			return false;
		}
		var re_pass=document.frm_edit_login.re_pass.value;
		if(re_pass==''){
			alert("Please retype your password");
			document.frm_edit_login.re_pass.focus();
			return false;
		}
		if(password.value!=re_pass){
			alert("Passwords do not match, please try again");
			document.frm_edit_login.re_pass.focus();
			return false;
		}
	document.frm_edit_login.action="myaccount_save.php?type=login";
	document.frm_edit_login.submit();		
}

/****************************************** Edit Address Details *****************************************/

function default_bill_address_change1(user_address_id,status,user_id){
	document.frm_edit_address.action="default_bill_address_change.php?user_address_id="+user_address_id+"&status="+status+"&user_id="+user_id;	
	document.frm_edit_address.submit();	
}

function default_ship_address_change1(user_address_id,status,user_id){
	document.frm_edit_address.action="default_ship_address_change.php?user_address_id="+user_address_id+"&status="+status+"&user_id="+user_id;	
	document.frm_edit_address.submit();	
}

function address_edit1(user_address_id)
{
	document.frm_edit_address.action="address_add.php?user_address_id="+user_address_id+"&type=edit";
	document.frm_edit_address.submit();
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function add_address1(type)
{
	if(document.frm_add_address.user_fname.value==''){
		alert("Please enter first name");
		document.frm_add_address.user_fname.focus();
		return false;
	}else if(document.frm_add_address.user_fname.value.length > 20){
		alert("Your first name shuold contain maximum 20 characters");
		document.frm_add_address.user_fname.focus();
		return false;
	}else if(document.frm_add_address.user_lname.value==''){
		alert("Please enter last name");
		document.frm_add_address.user_lname.focus();
		return false;
	}else if(document.frm_add_address.user_lname.value.length > 20){
		alert("Your last name shuold contain maximum 20 characters");
		document.frm_add_address.user_lname.focus();
		return false;	
	}else if(document.frm_add_address.address1.value==''){
		alert("Please Enter Address 1");
		document.frm_add_address.address1.focus();
		return false;
	}else if(document.frm_add_address.address1.value.length > 100){
		alert("Address line one should contain a maximum of 100 characters");
		document.frm_add_address.address1.focus();
		return false;
	}else if(document.frm_add_address.txtcity.value==''){
		alert("Please Enter City");
		document.frm_add_address.txtcity.focus();
		return false;
	}else if(document.frm_add_address.txtcity.value.length > 40){
		alert("Your city name shuold contain maximum 40 characters");
		document.frm_add_address.txtcity.focus();
		return false;
	}else if(document.frm_add_address.txtstate.value==''){
		alert("Please Enter State");
		document.frm_add_address.txtstate.focus();
		return false;
	}else if(document.frm_add_address.selCountry.value==''){
		alert("Please Select Country");
		document.frm_add_address.selCountry.focus();
		return false;
	}else if(document.frm_add_address.txtzip.value==''){
		alert("Please Enter Postcode");
		document.frm_add_address.txtzip.focus();
		return false;
	}
	document.frm_add_address.action="myaccount_save.php?type="+type;
	document.frm_add_address.submit();
}

function address_delete1(user_address_id)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_edit_address.action="address_delete.php?user_address_id="+user_address_id;
		document.frm_edit_address.submit();	
	}
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function add_address(type,user_address_id,redirect)
{
	if(document.frm_add_address.user_fname.value==''){
		alert("Please enter first name");
		document.frm_add_address.user_fname.focus();
		return false;
	}else if(document.frm_add_address.user_fname.value.length > 20){
		alert("Your first name shuold contain maximum 20 characters");
		document.frm_add_address.user_fname.focus();
		return false;
	}else if(document.frm_add_address.user_lname.value==''){
		alert("Please enter last name");
		document.frm_add_address.user_lname.focus();
		return false;
	}else if(document.frm_add_address.user_lname.value.length > 20){
		alert("Your last name shuold contain maximum 20 characters");
		document.frm_add_address.user_lname.focus();
		return false;	
	}else if(document.frm_add_address.address1.value==''){
		alert("Please Enter Address 1");
		document.frm_add_address.address1.focus();
		return false;
	}else if(document.frm_add_address.address1.value.length > 100){
		alert("Address line one should contain a maximum of 100 characters");
		document.frm_add_address.address1.focus();
		return false;
	}else if(document.frm_add_address.txtcity.value==''){
		alert("Please Enter City");
		document.frm_add_address.txtcity.focus();
		return false;
	}else if(document.frm_add_address.txtcity.value.length > 40){
		alert("Your city name shuold contain maximum 40 characters");
		document.frm_add_address.txtcity.focus();
		return false;
	}else if(document.frm_add_address.txtstate.value==''){
		alert("Please Enter State");
		document.frm_add_address.txtstate.focus();
		return false;
	}else if(document.frm_add_address.selCountry.value==''){
		alert("Please Select Country");
		document.frm_add_address.selCountry.focus();
		return false;
	}else if(document.frm_add_address.txtzip.value==''){
		alert("Please Enter Postcode");
		document.frm_add_address.txtzip.focus();
		return false;	
	}
	document.frm_add_address.action="myaccount_save.php?user_address_id="+user_address_id+"&type="+type+"&redirect="+redirect;
	document.frm_add_address.submit();
}

/****************************************************** Gift Finder in left menu & also on home **************************************/

function getCat2(val){ // alert("Hi");
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCat").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "get_cat2.php?pro_type="+val); 	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); //send value
};

function gift_finder()
{
	if(document.frmGiftFinder.selMetal.value==''){
		alert("Please select any Metal");
		document.frmGiftFinder.selMetal.focus();
		return false;
	}else if(document.frmGiftFinder.selCat.value==''){
		alert("Please select any Category");
		document.frmGiftFinder.selCat.focus();
		return false;
	}
	document.frmGiftFinder.action="product.php";
	document.frmGiftFinder.submit();
}

/****************************************************** Search in header **************************************/

function search_jwellery()
{
	if(document.frmSearch.txtSearch.value==''){
		alert("Please enter anything you want to search");
		document.frmSearch.txtSearch.focus();
		return false;
	}
	document.frmSearch.action="search_results.php";
	document.frmSearch.submit();
}

/****************************************************** Product Detail (Get Image) **************************************/

function get_stock(pro_id)
{	
	var color = document.getElementById("selProColor").value;	//alert(color);
	var size = document.getElementById("selProSize").value;		//alert(size);
	var req = Inint_AJAX();
	req.onreadystatechange = function () { 
    if (req.readyState==4) {
        if (req.status==200) {
            document.getElementById("divStock").innerHTML=req.responseText; 
        } 
      }
    };
	req.open("GET","get_stock.php?color_id="+color+"&size_id="+size+"&product_id="+pro_id); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
    req.send(null);
}

function getSize(pro_id,color)
{	
//	var color = document.getElementById("selProColor").value;	
	//alert("pro_id - "+pro_id);	alert(color);
	var req = Inint_AJAX();
	req.onreadystatechange = function () { 
    if (req.readyState==4) {
        if (req.status==200) {
            document.getElementById("divSelSize").innerHTML=req.responseText; 
        } 
      }
    };
	req.open("GET","get_pro_size.php?color_id="+color+"&product_id="+pro_id); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
    req.send(null);
}

function getImage(image)
{ 
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divImage").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "get_image.php?image="+image); 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
};

/****************************************************** Diamond **************************************/

function setColor(color)
{
	var str=color;
	var newcolor = str.replace("+", "plus")
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divColor").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "set_color.php?color="+newcolor); 
	
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
}
function setClarity(clarity)
{
	var str=clarity;
	var newclarity = str.replace("+", "plus")
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divClarity").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "set_clarity.php?clarity="+newclarity); 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
}
function setCutProportion(cut_proportion)
{
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCut").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "set_cut_proportion.php?cut_proportion="+cut_proportion); 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
}
function setCutPolish(cut_polish)
{
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divPolish").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "set_cut_polish.php?cut_polish="+cut_polish); 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
}
function setCutSymmetry(cut_symmetry)
{
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divSymmetry").innerHTML=req.responseText; 
               } 
          }
     };
	 req.open("GET", "set_cut_symmetry.php?cut_symmetry="+cut_symmetry); 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     req.send(null); 
}
function selAllLabs()
{	
	var chkAll = document.getElementById('chkAllLabs');
 	var checks = document.getElementsByName('chkLabs');
	var boxLength = checks.length;
	
	if(chkAll.checked == true)
	{
		for(i=0;i<boxLength;i++) 
		{
			if(checks[i].disabled)
			{
			}else{
				checks[i].checked = true;
			}
	  	}
	}
	else{
		for(i=0;i<boxLength;i++)
		{
			checks[i].checked = false;
	  	}
	}
}
function selectWeight(val)
{	
	if(val == 1)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.10";
		document.frmSrchForDiamond.txtToWeight.value = "0.20";
		return true;
		
	}else if(val == 2)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.21";
		document.frmSrchForDiamond.txtToWeight.value = "0.29";
		return true;			
	}else if(val == 3)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.30";
		document.frmSrchForDiamond.txtToWeight.value = "0.39";
		return true;
	}else if(val == 4)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.40";
		document.frmSrchForDiamond.txtToWeight.value = "0.49";
		return true;
	}else if(val == 5)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.50";
		document.frmSrchForDiamond.txtToWeight.value = "0.59";
		return true;
	}else if(val == 6)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.60";
		document.frmSrchForDiamond.txtToWeight.value = "0.69";
		return true;
	}else if(val == 7)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.70";
		document.frmSrchForDiamond.txtToWeight.value = "0.79";
		return true;
	}else if(val == 8)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.80";
		document.frmSrchForDiamond.txtToWeight.value = "0.89";
		return true;
	}else if(val == 9)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "0.90";
		document.frmSrchForDiamond.txtToWeight.value = "0.99";
		return true;
	}else if(val == 10)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "1.00";
		document.frmSrchForDiamond.txtToWeight.value = "1.19";
		return true;
	}else if(val == 11)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "1.20";
		document.frmSrchForDiamond.txtToWeight.value = "1.49";
		return true;
	}else if(val == 12)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "1.50";
		document.frmSrchForDiamond.txtToWeight.value = "1.69";
		return true;
	}else if(val == 13)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "1.70";
		document.frmSrchForDiamond.txtToWeight.value = "1.99";
		return true;
	}else if(val == 14)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "2.00";
		document.frmSrchForDiamond.txtToWeight.value = "2.99";
		return true;
	}else if(val == 15)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "3.00";
		document.frmSrchForDiamond.txtToWeight.value = "3.99";
		return true;
	}else if(val == 16)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "4.00";
		document.frmSrchForDiamond.txtToWeight.value = "4.99";
		return true;
	}else if(val == 17)
	{
		document.frmSrchForDiamond.txtFromWeight.value = "5.00";
		document.frmSrchForDiamond.txtToWeight.value = "100.00";
		return true;
	}else{
		return false;
	}
}
/*function search_diamond(low_price,high_price)
{	//alert(low_price);alert(high_price);
	var elm = document.getElementsByTagName("input");	
	var j=0, str='';
	for(var i=0; i< elm.length; i++)
	{
		if(elm[i].type.toLowerCase()=="radio")
		{
			j++;	//	alert("j="+j);
			if(elm[i].checked)
			{
				str = elm[i].value;
			}
		}
	} //alert(str);
	
	document.frmDiamond.action="searched_diamond.php?shape_str="+str+"&lowestp="+low_price+"&highestp="+high_price;
	document.frmDiamond.submit();
}*/
function search_diamond()
{
	document.frmDiamond.action = "search_for_diamond.php";
	document.frmDiamond.submit();
}
var float2 =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function search_for_diamond()
{
	var elm = document.getElementsByTagName("input");	
	var j=0,m=0, low_price=0, high_price=0, chkcount=0, chkcount_labs=0, str_shape='', str_labs='', chkname='', chkname_part='';
	for(var i=0; i< elm.length; i++)
	{
		if(elm[i].type.toLowerCase()=="checkbox")
		{
			chkname = elm[i].name;
			chkname_part = chkname.substr(0,8);
			//alert("chkname_part = "+chkname_part);
			if(chkname_part == 'chkShape')
			{
				j++;	//	alert("j="+j);
				if(elm[i].checked)
				{
					if(str_shape != '')
					{
						str_shape = str_shape + ',' + elm[i].value;
					}else{
						str_shape = elm[i].value;
					}
					chkcount++;		  // alert(chkcount);
				}
			}else{
				m++;	//	alert("j="+j);
				if(elm[i].checked)
				{
					if(str_labs != '')
					{
						str_labs = str_labs + ',' + elm[i].value;
					}else{
						str_labs = elm[i].value;
					}
					chkcount_labs++;		  // alert(chkcount_labs);
				}
			}
		}
	} //alert(str_shape);
	if(chkcount==0)
	{
		alert("Please select minimum any one Shape for Diamond");
		document.frmSrchForDiamond.chkShape_round.focus();
		return false;
	}	
	if(document.frmSrchForDiamond.txtFromWeight.value != '' || document.frmSrchForDiamond.txtToWeight.value != '')
	{	
		if(!(float2.test(document.frmSrchForDiamond.txtFromWeight.value)))
		{
			alert("Please enter only numeric value for weight range");
			document.frmSrchForDiamond.txtFromWeight.focus();
			return false;
		}
	}
	if(document.frmSrchForDiamond.txtLowPrice.value=='')
	{
		alert("Please enter any lowest amount you want to search");
		document.frmSrchForDiamond.txtLowPrice.focus();
		return false;
	}else{
		low_price = document.frmSrchForDiamond.txtLowPrice.value;
	}
	if(document.frmSrchForDiamond.txtHighPrice.value=='')
	{
		alert("Please enter any highest amount you want to search");
		document.frmSrchForDiamond.txtHighPrice.focus();
		return false;
	}else{
		high_price = document.frmSrchForDiamond.txtHighPrice.value;
	}
	document.frmSrchForDiamond.action="searched_diamond.php?shape_str="+str_shape+"&str_labs="+str_labs+"&lowestp="+low_price+"&highestp="+high_price;
	document.frmSrchForDiamond.submit();
}

function addtocart_diamond()
{
	document.frm_diamond.action = "addtocart.php";
	document.frm_diamond.submit();
}

function selectDiamond(diamond_id)
{
	document.frmDiamondList.action = "diamond_detail.php?diamond_id="+diamond_id;
	document.frmDiamondList.submit();
}
function change_css()
{ 
	document.getElementById('txtLowPrice').style.color = "black";
}
function change_css2()
{
	document.getElementById('txtHighPrice').style.color = "black";
}
var str;
function select_shape()
{
	var elm = document.getElementsByTagName("input");	
	var j=0,low_price=0,high_price=0, chkcount=0; 
	str='';
	for(var i=0; i< elm.length; i++)
	{
		if(elm[i].type.toLowerCase()=="checkbox")
		{
			j++;	//	alert("j="+j);
			if(elm[i].checked)
			{
				if(str != '')
				{
					str = str + ',' + elm[i].value;
				}else{
					str = elm[i].value;
				}
				chkcount++;		  // alert(chkcount);
			}
		}
	} //alert(str);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
  
  	var url="get_shape_total.php";
	url=url+"?str="+str;
//	alert(url);
	
	xmlHttp.onreadystatechange=optionstatechanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
 
}
function optionstatechanged1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		xmlDoc = xmlHttp.responseXML;
		if(str != ""){ 
			document.getElementById("sp_diamonds").innerHTML = xmlDoc.getElementsByTagName("TOTAL")[0].childNodes[0].nodeValue;
		}
	}
}

/****************************************************** Quatation **************************************/

function valid_quat()
{
	if(document.frm_quatation.user_name.value==''){
		alert("Please Enter your Name");
		document.frm_quatation.user_name.focus();
		return false;
	}else if(document.frm_quatation.email.value == ""){
		alert("Please Enter EmailID");
		document.frm_quatation.email.focus();
		return false;
	}else if(document.frm_quatation.email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_quatation.email.focus();
		return false;
	}else if(document.frm_quatation.email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_quatation.email.focus();
		return false;
	}
	if(document.frm_quatation.fl_img_doc.value == ''){
		alert("Please upload any image or doc");
		document.frm_quatation.fl_img_doc.focus();
		return false;
	}
	if(document.frm_quatation.fl_img_doc.value != '')
	{
		var extensions = new Array("jpg","jpeg","gif","png","bmp","tif","doc");  
		var image_file = document.frm_quatation.fl_img_doc.value;
		var image_length = document.frm_quatation.fl_img_doc.value.length;
		var pos = image_file.lastIndexOf('.') + 1; 
		var ext = image_file.substring(pos, image_length); 
		var final_ext = ext.toLowerCase(); 
		var flag = false;
		for (i = 0; i < extensions.length; i++)   
		{   
			if(extensions[i] == final_ext)   
			{   
				flag = true;   
			}   
		}
		if(flag == false)
		{ 
			alert("Please upload any file with one of the following extensions: "+ extensions.join(', ') +".");   		
			document.frm_quatation.fl_img_doc.focus();
			return false;   
		}
	}
	if(document.frm_quatation.product_description.value==''){
		alert("Please Enter Product Description");
		document.frm_quatation.product_description.focus();
		return false;
	}else if(document.frm_quatation.selMetal.value == ""){
		alert("Please Select any Metal");
		document.frm_quatation.selMetal.focus();
		return false;
	}else if(document.frm_quatation.selMetalColor.value == ""){
		alert("Please Select any Metal Color");
		document.frm_quatation.selMetalColor.focus();
		return false;
	}
	document.frm_quatation.action = 'quatation_save.php';
	document.frm_quatation.submit();
}


/****************************************************** NewsLetter **************************************/

function news_save(val){
	if(document.frm_news_signup.txtName.value==''){
		alert("Please enter your name");
		document.frm_news_signup.txtName.focus();
		return false;
	}else if(document.frm_news_signup.txtEmail.value==''){
		alert("Please enter your email id");
		document.frm_news_signup.txtEmail.focus();
		return false;
	}else if(document.frm_news_signup.txtEmail.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_news_signup.txtEmail.focus();
		return false;
	}else if(document.frm_news_signup.txtEmail.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_news_signup.txtEmail.focus();
		return false;
	}else{
		document.frm_news_signup.action ="news_save.php?val="+val;
		document.frm_news_signup.submit();
	}
}

function news_save1(val)
{
	if(document.frmUnSubscribe.email_unsub.value==''){
		alert("Please enter your email id");
		document.frmUnSubscribe.email_unsub.focus();
		return false;
	}else if(document.frmUnSubscribe.email_unsub.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frmUnSubscribe.email_unsub.focus();
		return false;
	}else if(document.frmUnSubscribe.email_unsub.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frmUnSubscribe.email_unsub.focus();
		return false;
	}else{
		document.frmUnSubscribe.action ="news_save.php?val="+val;
		document.frmUnSubscribe.submit();
	}
}

/****************************************************** wire_transfer **************************************/

function print_details()
{	
	var progress;
	progress = window.open("popup_wiretransfer.php","WireTransfer","height=500,width=600");
	
	window.print();
	if (progress && !progress.closed) {
		progress.close();
	}	
}
function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
			  
		  }else{
			return false;
		  }
 		}
	return true;
}
function alpha(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
			  
		  }else{
			return false;
		  }
 		}
	return true;
}

function numeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58)) 
		  {
			  
		  }else{
			return false;
		  }
 		}
	return true;
}
/****************************************************** wire_transfer **************************************/

