var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

function update_combo_price(price){
	var combo_diamond = document.getElementById('combo_diamond');
	document.getElementById('combo_diamond').innerHTML = "$" + price ;
	document.getElementById('combo_combo').innerHTML = "$" + ( Number( combo_ring_price) + Number(price) );
	
}
function show_recommended(){
	document.getElementById('recommended').style.display = "";
}

function hide_recommended(){
	document.getElementById('recommended').style.display = "none";
}


var combo_ring_price = '' ;

function set_price(id){
	//alert(id);
	var select_list_field = document.getElementById('metal_type');
	var text = select_list_field.options[select_list_field.selectedIndex].text;
	//alert(text);
	
	var item_price = document.getElementById("item_price");
	var page_metal_type = document.getElementById("page_metal_type");
	var my_price1 = text.split('$');
	var my_price2 = my_price1[0].split(' -');
	//alert(my_price1[1]);
	line = '<span  class="price_title">Price: $'+my_price1[1]+'</span> ';
	item_price.innerHTML = line ; 
	page_metal_type.innerHTML = my_price2[0] ; 
	combo_ring_price = my_price1[1] ;
	document.getElementById('combo_ring').innerHTML = "$" + my_price1[1] ;
}
		
		
	function popupRingSizingWindow(id) {
		var newWindow = window.open("/grid_info.php?id="+id, "newWin", "toolbar=no, scrollbars=no, locationbar=no, width=570px, height=300px, left=470px, top=270px");
	}

	function email_friendWindow(id) {
		var metal_type = document.getElementById("metal_type").value;
		var product_type = document.getElementById("product_type").value;
		var product_id = document.getElementById("product_id").value;

var newWindow = window.open("/email_friend.php?product_id="+product_id+"&product_type="+product_type+"&metal_type="+metal_type, "newWin2", "toolbar=no, scrollbars=no, locationbar=no,dependent=yes, width=256px, height=360px, left=470px, top=270px");
	}
	
	function email_usWindow(id) {
		var metal_type = document.getElementById("metal_type").value;
		var product_type = document.getElementById("product_type").value;
		var product_id = document.getElementById("product_id").value;

var newWindow = window.open("/email_us.php?product_id="+product_id+"&product_type="+product_type+"&metal_type="+metal_type, "newWin2", "toolbar=no, scrollbars=no, locationbar=no,dependent=yes, width=256px, height=360px, left=470px, top=270px");
	}

	function addtocart(option,id) {
		var ring_size = document.getElementById("ring_size").value;
		var metal_type = document.getElementById("metal_type").value;
		var product_type = document.getElementById("product_type").value;
		var product_id = document.getElementById("product_id").value;
		var action = document.getElementById("action").value;
		
		
				
		if(option == "test_drive"){
		 window.location="/test_drive.php?id="+product_id;
		}else{
	
			if (ring_size == 0){
				alert('Please select a Ring Size.');
				var my_stop = "yes"; 
		
			}
			if (my_stop){}else{
				if (metal_type == 0){
					alert('Please select a Metal Type.');
					var my_stop = "yes"; 
			
				}
	
			}
			
			if (my_stop){}else{
				
			
				log_in_url = 'action=add&product_type='+product_type+'&product_id='+product_id+'&ring_size='+ring_size+'&metal_type='+metal_type;
				
				
				if(option == "wish_list"){
					
					log_in_url = log_in_url + '&set_item_status=wish_list&myreturn=wish_list';
				}
				
				if(option == "combo"){
					
					log_in_url = log_in_url + '&set_item_status=combo&myreturn=combo';
				}
				
				if(option == "per_combo"){
					if(id == ""){
					}else{
						log_in_url = log_in_url + '&retrnvalue=' + id;
					}
					log_in_url = log_in_url + '&set_item_status=combo&myreturn=pre_combo';
				}
				
				
				 window.location="/cartmanager.php?" + log_in_url;
				
	
			}
		
		
		}
		
	}
	
	
	

function get_engagement_rings(page,set_type,price_min,price_max)
{ 
xmlHttp=GetXmlHttpObject4()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="/get_engagement_rings_detail_page.php"
url=url+"?page="+page
url=url+"&set_type="+set_type;
url=url+"&price_min="+price_min;
url=url+"&price_max="+price_max;
//alert(url);
xmlHttp.onreadystatechange=stateChanged4
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged4() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	c = xmlHttp.responseText;
	d = c.split("rkr");
	//alert(d[0]);
	a = document.getElementById("main_engagemaent");
 	b = document.getElementById("my_page_index");
	
//	alert(xmlHttp.responseText);
//	alert(a.innerHTML);
	
	a.innerHTML = d[1];
	b.innerHTML = '<a  class="style7" href="/engagement_rings.php">&lt; Back to Viewing Engagement Rings</a> | Page : ' + d[0];
	//setTimeout("a.innerHTML = xmlHttp.responseText",2050);
	//setTimeout("main_engagemaent.innerHTML =  xmlHttp.responseText",2050);
} 
}
function GetXmlHttpObject4()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function mouse_click(id)
{
	//alert("mouse_click");
	document.getElementById(''+id).style.cursor="pointer";
}



function update_table_page(page_id)
{
page = page_id;
get_engagement_rings(page,set_type,price_min,price_max);

}

var item_id ;


function mouseOver(id,image,mylink)
{
//alert(image)
//document.form1.image4.src ="products/Engagment/thum.9346UP.jpg";
 // document.getElementById('mymy'+id).style.visibility="hidden";
 //alert( document.getElementById('mymy'+id).style.backgroundImage);
//	document.getElementById('mymy'+id).innerHTML = '<a style="text-decoration:none; color:#333333;"  href="'+mylink+'  " > </a>';
	myimage = "url(/products/Engagement/cart." + image + ")";
	//alert(myimage);
	document.getElementById('mymy'+id).style.cursor="pointer";
	document.getElementById('mymy'+id).style.backgroundImage = myimage;
	item_id = id ;
//alert(item_id);
}
function mouseOut(id,price,type,image,mylink)
{
	myimage = "url(/products/Engagement/cart." + image + ")";

	document.getElementById('mymy'+id).style.backgroundImage = myimage;
	document.getElementById('mymy'+id).innerHTML ='<a style="text-decoration:none; font-size:12px; color:#7c7c7c; font-family:Tahoma, Geneva, sans-serif;" href="'+mylink+'"> Price :<span style="color:#4a4a4a;" > $'+price +'</span> </a>';

}



