/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1

NAME: 

AUTHOR: Stephane , SP inc
DATE  : 4/26/2005

COMMENT: 

============================================================================ */

   img_rings = new Image();
   img_earrings = new Image();
   img_bracelets = new Image();
   img_pendants = new Image();
   img_necklaces = new Image();
   img_rings.src = "images/header/top_rings.jpg";
   img_earrings.src = "images/header/top_earrings.jpg"
   img_bracelets.src = "images/header/top_bracelets.jpg";
   img_pendants.src = "images/header/top_pendants.jpg";
   img_necklaces.src = "images/header/top_necklaces.jpg";

function append_ring_size(product_id, unit_price, ring_size) {
 var myString1 = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><META HTTP-EQUIV="REFRESH" CONTENT="0;URL=http://localhost/zaav/site/cart.php?action=add_cart&product_id='+product_id+'&quantity=1&unit_price='+unit_price+'&ring_size='+ring_size+'"> </head><body></body></html>';
   //'shopbag.php?action=AddCart&ProductID=".$productrow->ProductID."&Qty=1&UnitPrice=".$productrow->Price."'

  document.open();
  document.write(myString1);
  document.close();
}
function validate_edit_passowrd() {	
	
    if(document.frm_edit_passsword.old_password.value==""){
         alert("Please enter your old password!");         
		 document.getElementById("old_password").style.background="#FFFF00";
		 document.getElementById("old_password").style.fontweight="bold";
         //return false;
		 }
	else if (document.frm_edit_passsword.new_password.value==""){
		alert("Please enter your new password!");         
		 document.getElementById("new_password").style.background="#FFFF00";
		 document.getElementById("new_password").style.fontweight="bold";
	}
	else if (document.frm_edit_passsword.new_password_confirm.value==""){
		alert("Please confirm your new password!");         
		 document.getElementById("new_password_confirm").style.background="#FFFF00";
		 document.getElementById("new_password_confirm").style.fontweight="bold";
	}
	else{
		 		
		document.forms[2].submit();
		return true;
	}
}
function validate_ring_size(ver) {
	//alert (ver)
	if (ver==1)
	{
		var objFormField = document.forms[4].ring_size;
		var strValue = objFormField.value;
		
		var objFormField2 = document.forms[4].inside_engrav_style;
		var strValue2 = objFormField2.selectedIndex;
		
		var objFormField3 = document.forms[4].inside_engrav_text;
		var strValue3 = objFormField3.value;
	
		var objFormField4 = document.forms[4].ring_finish;
		var strValue4 = objFormField4.options[objFormField4.options.selectedIndex].value
		
		if(!strValue)
		{
			 alert("Please select a ring size!");
			 objFormField.focus();
			 document.getElementById("ring_size").style.background="#FFFF00";
			 document.getElementById("ring_size").style.fontweight="bold";
			 return false;
		 }
		 else
		 {
			 var tmprs= document.forms[4].ring_size.options[document.forms[4].ring_size.options.selectedIndex].value.split("_");
			 document.forms[2].ring_size.value = tmprs[0];
			 
			 	
				if( strValue2!=0 || strValue3!="" )
				{
					
					//alert("pass")
					
					if(strValue2 ==0)
					{
						 alert("Please select an engraving font style!");
						 objFormField2.focus();
					}
					else
					{
						
						var tmpre= document.forms[4].inside_engrav_style.options[document.forms[4].inside_engrav_style.options.selectedIndex].value.split("_");
						document.forms[2].ring_engrav_style.value = tmpre[0];
						//alert(document.forms[2].ring_engrav_style.value)
						//return
						if(strValue3=="")
						{
							 alert("Please write an text for your engraving!");
							 objFormField3.focus();
						}
						else
						{
							setRingColor()
							document.forms[2].ring_engrav_text.value = strValue3;
							document.forms[2].ring_finish.value = strValue4
							document.forms[2].set_or_isAring.value = 1
							document.forms[2].submit();
							return true;
		
						}//fin else
						
					}//fin else
				}//fin if
				else
				{
					setRingColor()
					document.forms[2].ring_finish.value = strValue4
					document.forms[2].set_or_isAring.value = 1
					document.forms[2].submit();
					return true;
				}
		 }
		
	}
	
	if (ver==2)
	{
		
		//Ring 1 **********************************************************************
		var objFormField7 = document.forms[4].ring_set_size1;
		var strValue7 = objFormField7.value;
		
		var objFormField8 = document.forms[4].set_inside_engrav_style1;
		var strValue8 = objFormField8.selectedIndex;
		
		var objFormField9 = document.forms[4].set_inside_engrav_text1;
		var strValue9 = objFormField9.value;
	
		var objFormField10 = document.forms[4].ring_set_finish1;
		var strValue10 = objFormField10.options[objFormField10.options.selectedIndex].value
		
		if(!strValue7)
		{
			 alert("Please select a ring size!");
			 objFormField7.focus();
			 document.getElementById("ring_set_size1").style.background="#FFFF00";
			 document.getElementById("ring_set_size1").style.fontweight="bold";
			 return ;
		 }
		 else
		 {
			 var tmprs= document.forms[4].ring_set_size1.options[document.forms[4].ring_set_size1.options.selectedIndex].value.split("_");
			 document.forms[2].ring_set_size1.value = tmprs[0];
			 
			 
			 	if( strValue8!=0 || strValue9!="" )
				{
					
					//alert("pass")
					if(strValue8 ==0)
					{
						 alert("Please select an engraving font style!");
						 objFormField8.focus();
						 return ;
					}
					else
					{
						var tmpre= document.forms[4].set_inside_engrav_style1.options[document.forms[4].set_inside_engrav_style1.options.selectedIndex].value.split("_");
						document.forms[2].ring_set_engrav_style1.value = tmpre[0];
						
						document.forms[2].material_id_set1.value = document.forms[4].material_id_set1.value;
						
						if(strValue9=="")
						{
							 alert("Please write an text for your engraving!");
							 objFormField9.focus();
							 return ;
							 
						}
						else
						{
							document.forms[2].ring_set_engrav_text1.value = strValue9;
							document.forms[2].ring_set_finish1.value = strValue10
							//document.forms[2].submit();
							//return true;
		
						}//fin else
						
					}//fin else
				}//fin if
				//else
				//{
					//document.forms[2].ring_set_finish1.value = strValue10
					//document.forms[2].submit();
					//return true;
				//}
		 }
		 
		//Ring 2 **********************************************************************
		var objFormField11 = document.forms[4].ring_set_size2;
		var strValue11 = objFormField11.value;
		
		var objFormField12 = document.forms[4].set_inside_engrav_style2;
		var strValue12 = objFormField12.selectedIndex;
		
		var objFormField13 = document.forms[4].set_inside_engrav_text2;
		var strValue13 = objFormField13.value;
	
		var objFormField14 = document.forms[4].ring_set_finish2;
		var strValue14 = objFormField14.options[objFormField14.options.selectedIndex].value
		
		if(!strValue11)
		{
			 alert("Please select a ring size!");
			 objFormField11.focus();
			 document.getElementById("ring_set_size2").style.background="#FFFF00";
			 document.getElementById("ring_set_size2").style.fontweight="bold";
			 return ;
		 }
		 else
		 {
			
			var tmprs= document.forms[4].ring_set_size2.options[document.forms[4].ring_set_size2.options.selectedIndex].value.split("_");
			document.forms[2].ring_set_size2.value = tmprs[0];
			
			document.forms[2].material_id_set2.value = document.forms[4].material_id_set2.value;
			
			 	if( strValue12!=0 || strValue13!="" )
				{
					
					//alert("pass")
					if(strValue12 ==0)
					{
						 alert("Please select an engraving font style!");
						 objFormField12.focus();
					}
					else
					{
						var tmpre= document.forms[4].set_inside_engrav_style2.options[document.forms[4].set_inside_engrav_style2.options.selectedIndex].value.split("_");
						document.forms[2].ring_set_engrav_style2.value = tmpre[0];
						
						if(strValue13=="")
						{
							 alert("Please write an text for your engraving!");
							 objFormField13.focus();
						}
						else
						{
							document.forms[2].ring_set_engrav_text2.value = strValue13;
							document.forms[2].ring_set_finish2.value = strValue14
							document.forms[2].set_or_isAring.value = 1
							document.forms[2].submit();
							
		
						}//fin else
						
					}//fin else
				}//fin if
				else
				{
					document.forms[2].ring_set_finish2.value = strValue14
					document.forms[2].set_or_isAring.value = 1
					document.forms[2].submit();
					
				}
		 }
	}
	
	if (ver==3)
	{
		var objFormField5 = document.forms[4].set_finish1;
		var strValue5 = objFormField5.options[objFormField5.options.selectedIndex].value
		
		var objFormField6 = document.forms[4].set_finish2;
		var strValue6 = objFormField6.options[objFormField6.options.selectedIndex].value
		
		document.forms[2].set_finish1.value = strValue5
		document.forms[2].set_finish2.value = strValue6
		
		document.forms[2].set_or_isAring.value = 1
		document.forms[2].submit();
		
	}
	


  
		
		
		
		
		//return true;

}

function validate_white_diamond_stud() {
	
	var objFormField = document.forms[2].white_product_id;
    var strValue = objFormField.value;
	
    if(strValue==""){
         alert("Please select a diamond weight.");
         objFormField.focus();
		 document.getElementById("white_product_id").style.background="#FFFF00";
		 document.getElementById("white_product_id").style.fontweight="bold";
         //return false;
		 }
	else{		 
		document.forms[2].submit();
		return true;
	}
}

function validate_diamond_stud() {
	
	var objFormField = document.forms[3].product_id;
    var strValue = objFormField.value;
	
    if(strValue==""){
         alert("Please select a diamond weight.");
         objFormField.focus();
		 document.getElementById("product_id").style.background="#FFFF00";
		 document.getElementById("product_id").style.fontweight="bold";
         //return false;
		 }
	else{		 
		document.forms[3].submit();
		return true;
	}
}



function validate_set_ring_size() {
	 
	 var engagment_ring_size = document.forms[3].ring_size_engagement;
     var strEngagement = engagment_ring_size.value;
     
     var band_ring_size = document.forms[5].ring_size_band;
     var strBand = band_ring_size.value;
	 
	 if(strEngagement == ""){
         alert("Please select a ring size for your engagement ring!");
         engagment_ring_size.focus();
		 document.getElementById("ring_size_engagement").style.background="#FEFF98";
		 document.getElementById("ring_size_engagement").style.fontweight="bold";
         //return false;
	}
	else if (strBand == "") {
		 alert("Please select a ring size for your wedding band");
         band_ring_size.focus();
		 document.getElementById("ring_size_band").style.background="#FEFF98";
		 document.getElementById("ring_size_band").style.fontweight="bold";
         //return false;
	}
	else{
		 
		document.forms[2].engagement_ring_size.value = strEngagement;
		document.forms[2].band_ring_size.value = strBand;
		document.forms[2].submit();
		return true;
	}

}

function validate_engagement_ring_size() {
	
	var objFormField = document.forms[3].ring_size_engagement;
    var strValue = objFormField.value;
	
    if(strValue==""){
         alert("Please select a ring size for your engagement ring!");
         objFormField.focus();
		 document.getElementById("ring_size_engagement").style.background="#FEFF98";
		 document.getElementById("ring_size_engagement").style.fontweight="bold";
         //return false;
		 }
	else{
		 
		document.forms[4].ring_size.value = strValue;
		document.forms[4].submit();
		return true;
	}
}

function validate_band_ring_size() {
	
	var objFormField = document.forms[5].ring_size_band;
    var strValue = objFormField.value;
	
    if(strValue==""){
         alert("Please select a ring size for your wedding band!");
         objFormField.focus();
		 document.getElementById("ring_size_band").style.background="#FEFF98";
		 document.getElementById("ring_size_band").style.fontweight="bold";
         //return false;
		 }
	else{
		 
		document.forms[6].ring_size.value = strValue;
		document.forms[6].submit();
		return true;
	}
}

function validate_promotion_email(){

var stremail=document.frm_promotion.promotion_email.value
var filteremail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

if (!(filteremail.test(stremail))) {
        alert("Please enter a valid email address.");
        document.getElementById("promotion_email").style.background="#FFFF00";
        //return false;
}
else {
        document.forms[1].submit();
		return true;
    } 
  

}

function validate_create_form(){

var stremail=document.frm_checkout_create_account.email.value
var filteremail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

if (document.frm_checkout_create_account.first_name.value=='' ) {
        alert("Please enter your first name.");
        document.getElementById("first_name").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.last_name.value=='' ) {
        alert("Please enter your last name.");
        document.getElementById("last_name").style.background="#FFFF00";
        //return false;
    }    
else if (document.frm_checkout_create_account.phone_home.value=='' ) {
        alert("Please enter your home phone number.");
        document.getElementById("phone_home").style.background="#FFFF00";
        //return false;
    }
else if (!(filteremail.test(stremail))) {
        alert("Please enter your email address.");
        document.getElementById("email").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.password.value=='' ) {
    alert("Please enter your account password.");
        document.getElementById("password").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.billing_address.value=='' ) {
    alert("Please enter biling address.");
        document.getElementById("billing_address").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.billing_city.value=='' ) {
    alert("Please enter billing city.");
        document.getElementById("billing_city").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.billing_country.value=='' ) {
    alert("Please enter billing country.");
        document.getElementById("billing_country").style.background="#FFFF00";
        //return false;
    }  
else if ((document.frm_checkout_create_account.billing_country.value=='US' || document.frm_checkout_create_account.billing_country.value=='CA')&&(document.frm_checkout_create_account.billing_state.value=='' && document.frm_checkout_create_account.billing_other_state.value=="")){
    		alert("Please enter biling state.");
        	document.getElementById("billing_state").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.billing_zip.value=='' ) {
    alert("Please enter billing zip.");
        document.getElementById("billing_zip").style.background="#FFFF00";
        //return false;
    }                                       

else if (document.frm_checkout_create_account.shipping_address.value=='' ) {
    alert("Please enter shipping address.");
        document.getElementById("shipping_address").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.shipping_city.value=='' ) {
    alert("Please enter shipping city.");
        document.getElementById("shipping_city").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.shipping_country.value==''){
    		alert("Please enter shipping country.");
       		document.getElementById("shipping_country").style.background="#FFFF00";
        //return false;
    } 
else if ((document.frm_checkout_create_account.shipping_country.value=='US' || document.frm_checkout_create_account.shipping_country.value=='CA')&&(document.frm_checkout_create_account.shipping_state.value=='' && document.frm_checkout_create_account.shipping_other_state.value=="")){
    alert("Please enter shipping state.");
        document.getElementById("shipping_state").style.background="#FFFF00";
        //return false;
    }
else if (document.frm_checkout_create_account.shipping_zip.value=='' ) {
    alert("Please enter shipping zip.");
        document.getElementById("shipping_zip").style.background="#FFFF00";
        //return false;
    }
    
else {
        document.forms[1].submit();
			return true;
    }    

}

function validate_chk_load_account_form()
{
	var err = false;
	
	var first_name = document.frm_checkout_load_account.first_name.value;
	var last_name  = document.frm_checkout_load_account.last_name.value;
	var phone_home = document.frm_checkout_load_account.phone_home.value;	
	var billing_address = document.frm_checkout_load_account.billing_address.value;
	var billing_city = document.frm_checkout_load_account.billing_city.value;
	var billing_state = document.frm_checkout_load_account.billing_state.value;
	var billing_other_state = document.frm_checkout_load_account.billing_other_state.value;
	var billing_zip = document.frm_checkout_load_account.billing_zip.value;
	var billing_country = document.frm_checkout_load_account.billing_country.value;
	var shipping_address = document.frm_checkout_load_account.shipping_address.value;
	var shipping_city = document.frm_checkout_load_account.shipping_city.value;
	var shipping_state = document.frm_checkout_load_account.shipping_state.value;
	var shipping_other_state = document.frm_checkout_load_account.shipping_other_state.value;
	var shipping_zip = document.frm_checkout_load_account.shipping_zip.value;
	var shipping_country = document.frm_checkout_load_account.shipping_country.value;
	
	if (first_name == ''){
		alert("Please enter your first name.");
   		document.getElementById("first_name").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (last_name == ''){
		alert("Please enter your last name.");
   		document.getElementById("last_name").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (phone_home == ''){
		alert("Please enter your home phone number.");
   		document.getElementById("phone_home").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (billing_address == ''){
		alert("Please enter a billing address.");
   		document.getElementById("billing_address").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (billing_city == ''){
		alert("Please enter a billing city.");
   		document.getElementById("billing_city").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (billing_country == ''){
		alert("Please enter a billing country.");
   		document.getElementById("billing_country").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (billing_country=="US" || billing_country=="CA")
	if (billing_state == '' && billing_other_state == ''){
		alert("Please enter a billing state.");
   		document.getElementById("billing_state").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (billing_zip == ''){
		alert("Please enter a billing zip.");
   		document.getElementById("billing_zip").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	
	if (shipping_address == ''){
		alert("Please enter a shipping address.");
   		document.getElementById("shipping_address").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (shipping_city == ''){
		alert("Please enter a shipping city.");
   		document.getElementById("shipping_city").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (shipping_country == ''){
		alert("Please enter a shipping country.");
   		document.getElementById("shipping_country").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (shipping_country=="US" || shipping_country=="CA")
	if (shipping_state == '' && shipping_other_state == ''){
		alert("Please enter a shipping state.");
   		document.getElementById("shipping_state").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	if (shipping_zip == ''){
		alert("Please enter a shipping zip.");
   		document.getElementById("shipping_zip").style.background="#FFFF00";   		
   		err = true;
   		return false;
	}
	 if (err == false) {
  		document.forms[2].submit();  	
 	 	return true;
 }
	
}


function ship_billing_address_onclick() {
	document.frm_checkout_create_account.shipping_address.value=document.frm_checkout_create_account.billing_address.value;
	document.frm_checkout_create_account.shipping_city.value=document.frm_checkout_create_account.billing_city.value;
	document.frm_checkout_create_account.shipping_state.value=document.frm_checkout_create_account.billing_state.value;
	document.frm_checkout_create_account.shipping_other_state.value=document.frm_checkout_create_account.billing_other_state.value;
	document.frm_checkout_create_account.shipping_zip.value=document.frm_checkout_create_account.billing_zip.value;
	document.frm_checkout_create_account.shipping_country.value=document.frm_checkout_create_account.billing_country.value;
}

function remove_shipping_address_onclick() {
	document.frm_checkout_create_account.shipping_address.value='';
	document.frm_checkout_create_account.shipping_city.value='';
	document.frm_checkout_create_account.shipping_state.value='';
	document.frm_checkout_create_account.shipping_other_state.value='';
	document.frm_checkout_create_account.shipping_zip.value='';
	document.frm_checkout_create_account.shipping_country.value='';
}

function ship_billing_address_load_onclick() {
	document.frm_checkout_load_account.shipping_address.value=document.frm_checkout_load_account.billing_address.value;
	document.frm_checkout_load_account.shipping_city.value=document.frm_checkout_load_account.billing_city.value;
	document.frm_checkout_load_account.shipping_state.value=document.frm_checkout_load_account.billing_state.value;
	document.frm_checkout_load_account.shipping_other_state.value=document.frm_checkout_load_account.billing_other_state.value;
	document.frm_checkout_load_account.shipping_zip.value=document.frm_checkout_load_account.billing_zip.value;
	document.frm_checkout_load_account.shipping_country.value=document.frm_checkout_load_account.billing_country.value;
}

function remove_shipping_address_load_onclick() {
	document.frm_checkout_load_account.shipping_address.value='';
	document.frm_checkout_load_account.shipping_city.value='';
	document.frm_checkout_load_account.shipping_state.value='';
	document.frm_checkout_load_account.shipping_other_state.value='';
	document.frm_checkout_load_account.shipping_zip.value='';
	document.frm_checkout_load_account.shipping_country.value='';
}


function submit_add_cart(){
	document.frm_add_cart.submit();
}

function submit_wishlist(){
	document.frm_wishlist.submit();
}

function search_image_over(i)
{
cellId = 'search_image_'+i;
document.getElementById(cellId).style.border="solid 1px #cccccc";

}

function search_image_out(i)
{
cellId = 'search_image_'+i;
document.getElementById(cellId).style.border="";
}

function Hilite_wedding( name, over)
{
	if(window.document.images) 
	{
		var top_name = 'top';
		if (over)
			window.document.images[name].src = "images/" + name + "_on.jpg";
		else
			window.document.images[name].src =  "images/" + name + ".jpg";
	}
}

function Hilite_left( name, over)
{
	if(window.document.images) 
	{		
		var mime="jpg";
		//if(name=="gemstones")
			//mime="jpg"
			
		if (over)
			window.document.images[name].src = "images/leftnav/" + name + "_on."+mime;
		else
			window.document.images[name].src =  "images/leftnav/" + name + "."+mime;
	}
}

function Top_Hilite( name, image_name, over)
{
		if (over)
			window.document.images[name].src = image_name.src ;						
		else
			window.document.images[name].src = "images/header/" +image_name;
}


