
			
			var ns6 = document.getElementById && !document.all;
			var ie4 = document.all;						
			var ns4 = document.layers;
			var ct=0;
			
			function getObjectByID(Objid){	
				if(ns4)
				{
					return eval('document.' + Objid)
				}
				if(ns6)
				{
					return document.getElementById(Objid);
				}
				if(ie4)
				{
					return document.all(Objid);      
				}  
				return null
			}


			function SetText(objid,msg, fg, bg){
				if(!fg) fg = "#ff0000";
				if(!bg) bg = "#FFFFFF";
				var content = msg ;
				if(ns4)
				{
					objItm = eval('document.' + objid)
					objItm.document.write(content);
					objItm.document.close();
					objItm.visibility = "visible";
				}
				if(ns6)
				{
					document.getElementById(objid).innerHTML = content;
				}
				if(ie4)
				{
					document.all(objid).innerHTML=content;
				}  
			}
		
//Global XMLHTTP Request object
var XmlHttp;
var currentCntrl = 0


//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{	firstgo = 0
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
	
}


//Called when response comes back from server
function HandleResponse()
{	
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{	
		   	
			ClearAndSetDdlItems(XmlHttp.responseXML.documentElement);				
			ddlweighdimondOnChange ();	
			
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetDdlItems(RowNode)
{
 	
	var textValue; 
	var optionItem;
	var val;
var ddlList;
   if(currentCntrl < 1)
		ddlList = document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal"); 
		
   else
		ddlList = document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond");
		
	//Clears the state combo box contents.			
	//alert(ddlList);	
		
	if (ddlList!=null)
	{
		if(ddlList.options.length)
		{	
			ddlList.options.length = 0;
		}
	}
	
		var RowNodes = RowNode.getElementsByTagName('item');
		//[document.getElementById("ddlweighdimond").selectedIndex].text	
		//Add new states list to the state combo box.
		for (var count = 0; count < RowNodes.length; count++)
		{
   			textValue = GetInnerText(RowNodes[count]);
   			var value1 = RowNodes[count].getAttribute('value');
   			optionItem = new Option(textValue ,value1 ,  false, false);
			ddlList.options[ddlList.length] = optionItem;
		}
	
	
	
	if(currentCntrl = 1) 
	{
	//ddlmetalOnChange();	
	//alert(currentCntrl );
	//var RowNodes = RowNode.getElementsByTagName('item');	
	ddlweighdimondOnChange();
	}
	
	if (ddlList == document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal")) 
	{
		if (document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal"))
		{
			ddlmetalOnChange();	
		}
		
		if (document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond"))
			{
			ddlweighdimondOnChange();
			}
	}

}

//Returns the node text value 
function GetInnerText (node)
{	
	 return (node.textContent || node.innerText || node.text) ;
}


//Gets called when country combo box selection changes
function ddlwidthOnChange() 
{	
	
	currentCntrl = 0
	if (document.getElementById("ctl00_ContentPlaceHolder1_ddlwidth"))
		{
			var ddlwidth = document.getElementById("ctl00_ContentPlaceHolder1_ddlwidth");
			//Getting the selected country from country combo box.
			var Widthid = ddlwidth.options[ddlwidth.selectedIndex].value;
		}
		
	
	
	
	// URL to get states for a given country
	var requestUrl = AjaxServerPageName + "?Widthid=" + encodeURIComponent(Widthid) ;
	
	CreateXmlHttp();
	
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response		
		XmlHttp.onreadystatechange = HandleResponse;
				
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

//code adde dby devang

/*function followmouse1(e){

	//gettrailobj().left=xcoord+"px"
	//gettrailobj().top=ycoord+"px"
	
		
	gettrailobj().left="400px"
	gettrailobj().top="300px"

}
function show1(width,height)
{
    
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		document.onmousemove=followmouse1;
		
		newHTML = '<div id="loader_container"><div id="loader"><div align="center">Loading Data...</div><div id="loader_bg"><div id="progress"> </div></div></div>';
		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
		
	}
}*/

//Gets called when state combo box selection changes
function ddlmetalOnChange(id) 
{
	//************************code added by devang
	//ctl00_ContentPlaceHolder1_metal
	//var str=document.Form1.metal.value;
	var str=document.getElementById("ctl00_ContentPlaceHolder1_metal").value; 
	var arr=str.split(',');
	
	var i;
	for (i=0;i<arr.length-1;i++)
	{
	    if (arr[i]==0)
	    {
	        var defImg=arr[i+1];
	        
	    }
	}
	i=0;
	for (i=0;i<arr.length-1;i++)
	{
	    
	    if (arr[i]==id)
	    {
	        document.getElementById("ctl00_ContentPlaceHolder1_imgMainImage").src="ExtraThumbimages/" + arr[i+1];
	        
	    }
	    else if(arr[i]==0 && arr[i]!=id)
	    {
	        document.getElementById("ctl00_ContentPlaceHolder1_imgMainImage").src="ExtraThumbimages/" + defImg;
	        
	    }
	    
	}
	//document.Form1.metalid.value=id;
	document.getElementById("ctl00_ContentPlaceHolder1_metalid").value;
	
	//************************************************
	
	
	
	currentCntrl = 1
	//Getting the selected country from country combo box.
	if (document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal"))
	{
	var ddlmetal = document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal");	
	var Metalid=  ddlmetal.options[ddlmetal.selectedIndex].value;
	}
	
	if (document.getElementById("ctl00_ContentPlaceHolder1_ddlwidth"))
	{
	var ddlwidth = document.getElementById("ctl00_ContentPlaceHolder1_ddlwidth");
	var Widthid = ddlwidth.options[ddlwidth.selectedIndex].value;
	}
	
	//alert(Widthid);	
	// URL to get states for a given country 
	var requestUrl = AjaxServerPageName + "?Widthid=" + encodeURIComponent(Widthid) + "&Metalid=" + encodeURIComponent(Metalid);
	
	CreateXmlHttp();	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

function ddlweighdimondOnChange()
{	
	
	//show1(100,100); 
	if (document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal"))
	{
	document.getElementById("ctl00_ContentPlaceHolder1_selmetal").value =document.getElementById("ctl00_ContentPlaceHolder1_ddlmetal").value; 	
	//alert(document.getElementById("selmetal").value);
	}
	
	//alert(document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond").options.length);
	document.getElementById("ctl00_ContentPlaceHolder1_selweight").value = document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond").options[document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond").selectedIndex].text;
	document.getElementById("ctl00_ContentPlaceHolder1_lblprate").value = document.getElementById("ctl00_ContentPlaceHolder1_ddlweighdimond").value ;
	
	//alert(document.getElementById("imgAddtocart"));
	if (document.getElementById("ctl00_ContentPlaceHolder1_lblprate").value==0)
	{
	//alert('in');
		SetText("ctl00_ContentPlaceHolder1_ContentRate","POA");
		if (document.getElementById("imgAddtocart"))
		{
		//alert('without price');
			document.getElementById("imgAddtocart").style.visibility="hidden";
			document.getElementById("imgbtnWatch").style.visibility="hidden";
		}
	}
	else
	{
	//traction.Style.Add("visibility", "visible")
	    //alert(document.getElementById("traction"));
		SetText("ctl00_ContentPlaceHolder1_ContentRate", document.getElementById("ctl00_ContentPlaceHolder1_lblprate").value);	
		if (document.getElementById("imgAddtocart"))
		{
		    //alert('price');
			document.getElementById("imgAddtocart").style.visibility="visible";
			document.getElementById("imgbtnWatch").style.visibility="visible";
		}
	}
	
    //alert('d');
    //remove_loading();
    
}



