function selectCat(jcode) {
	document.searchCatalog.productType.value = jcode;
	document.searchCatalog.metalType.value = "";
	document.searchCatalog.priceRange.value = "";
	document.searchCatalog.stoneType.value = "";
	document.searchCatalog.primaryDropdown.value = "";
	var url="";
	url="hotpicksGems.htm?&productType="+document.searchCatalog.productType.value;
	window.location.href=url;
}
function Getresult() {
	document.searchCatalog.metalType.value = document.getElementById("metalTypeSel").value;
	document.searchCatalog.stoneType.value = document.getElementById("stoneTypeSel").value;
	document.searchCatalog.priceRange.value = document.getElementById("priceRangeSel").value;
	if (document.getElementById("sortByPriceType1") != null) {
		document.searchCatalog.sortByPriceType.value = document.getElementById("sortByPriceType1").value;
	}
	document.searchCatalog.primaryDropdown.value = document.getElementById("primaryDropdown").value;
	var url="";
	url="hotpicksGems.htm?&metalTypeSel="+document.searchCatalog.metalType.value;
	url=url+"&stoneTypeSel="+document.searchCatalog.stoneTypeSel.value;
	url=url+"&priceRange="+document.searchCatalog.priceRange.value;
	url=url+"&sortByPriceType1="+document.searchCatalog.sortByPriceType.value;
	url=url+"&primaryDropdown="+document.searchCatalog.primaryDropdown.value;
	url=url+"&productType="+document.searchCatalog.productType.value;
	window.location.href=url;

}
function goToPage(page) {	
	document.searchCatalog.page.value = page;
	document.searchCatalog.primaryDropdown.value = document.getElementById("primaryDropdown").value;
	var url="hotpicksGems.htm?&primaryDropdown="+document.searchCatalog.primaryDropdown.value;
	url=url+"&page="+document.searchCatalog.page.value;
	url=url+"&itemCountForDisplayPerPage="+document.searchCatalog.itemCountForDisplayPerPage.value;
	url = url +"&stoneTypeSel="+document.searchCatalog.stoneTypeSel.value;
	url=url+"&priceRange="+document.searchCatalog.priceRange.value;
	url=url+"&metalTypeSel="+document.searchCatalog.metalType.value;
	url=url+"&sortByPriceType1="+document.searchCatalog.sortByPriceType.value;
	url=url+"&productType="+document.searchCatalog.productType.value;
	window.location.href=url;
}
function itemSize(size) {
	document.searchCatalog.itemCountForDisplayPerPage.value = size;
	document.searchCatalog.primaryDropdown.value = document.getElementById("primaryDropdown").value;
	var url="hotpicksGems.htm?&primaryDropdown="+document.searchCatalog.primaryDropdown.value;
	url=url+"&itemCountForDisplayPerPage="+document.searchCatalog.itemCountForDisplayPerPage.value;
	url=url+"&page="+document.searchCatalog.page.value;
	url = url +"&stoneTypeSel="+document.searchCatalog.stoneTypeSel.value;
	url=url+"&priceRange="+document.searchCatalog.priceRange.value;
	url=url+"&metalTypeSel="+document.searchCatalog.metalType.value;
	url=url+"&sortByPriceType1="+document.searchCatalog.sortByPriceType.value;
	url=url+"&productType="+document.searchCatalog.productType.value;
	window.location.href=url;
}
function sortPrice(price) {
	document.searchCatalog.sortByPriceType.value = price;
	document.searchCatalog.primaryDropdown.value = document.getElementById("primaryDropdown").value;
	var url="hotpicksGems.htm?&primaryDropdown="+document.searchCatalog.primaryDropdown.value;
	url=url+"&sortByPriceType1="+document.searchCatalog.sortByPriceType.value;
	url = url +"&itemCountForDisplayPerPage="+document.searchCatalog.itemCountForDisplayPerPage.value;
	url=url+"&page="+document.searchCatalog.page.value;
	url = url +"&stoneTypeSel="+document.searchCatalog.stoneTypeSel.value;
	url=url+"&priceRange="+document.searchCatalog.priceRange.value;
	url=url+"&metalTypeSel="+document.searchCatalog.metalType.value;
	url=url+"&productType="+document.searchCatalog.productType.value;
	window.location.href=url;
}

var req;
function assignMetalType(metal){

	//Anu-September 05,On selection change,reset price filter
	if (document.getElementById("priceRangeSel").value != '')
	document.getElementById("priceRangeSel").value='';
	
	//Anu-September 05,if current selection value is null,then set this as primary dropdown
	if (document.getElementById("primaryDropdown").value == "") {
		document.getElementById("primaryDropdown").value = "Metal";
	}
	
	if(metal != 'b'){
		document.searchCatalog.metalType.value = metal;
	}
	else
	{
		document.searchCatalog.metalType.value ='';
	}
	if (document.getElementById("primaryDropdown").value == "Metal") {
	
	//Anu-September 05,Clear the primary dropdown selection and populate metal,gemstone dropdown with all items
		if (metal == "") {
			var url = "group_catalog_select2.htm?metalcode=" + document.searchCatalog.metalType.value;
			url = url + "&salefeature=" + document.searchCatalog.saleFeature.value;
			url = url + "&producttype=" + document.searchCatalog.productType.value;
			url = url + "&stonetype=" + metal;//stone type should be null
			url = url + "&price=" + document.getElementById("priceRangeSel").value;
			url = url + "&dropdown=PopulateBothHotpicks";
			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
			} else {
				if (window.ActiveXObject) {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
			req.onreadystatechange = GetMetalGem;
			req.open("GET", url, true);
			req.send(null);
			document.getElementById("primaryDropdown").value = '';
		} else {
	    //Anu-September 05..Make Ajax call to fill Gem dropdown on selection of Metal
			var url = "group_catalog_select2.htm?metalcode=" + document.searchCatalog.metalType.value;
			url = url + "&salefeature=" + document.searchCatalog.saleFeature.value;
			url = url + "&producttype=" + document.searchCatalog.productType.value;
			url = url + "&stonetype=" + document.searchCatalog.stoneType.value;
			url = url + "&price=" + document.getElementById("priceRangeSel").value;
		//Anu-August 13,identify the drodown
			url = url + "&dropdown=PopulateGemsHotpicks";
			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
			} else {
				if (window.ActiveXObject) {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
			req.onreadystatechange = GetGemsonMetalselection;
			req.open("GET", url, true);
			req.send(null);
		}//end of else
	}//end of if (document.getElementById("primarydropdown").value=="Metal")
	//Anu-September 05..Make Ajax call to fill Gem dropdown on selection of Metal
}

function GetMetalGem() {
	var metalstring;
	var gemstring;
	if (req.readyState == 4) {
		if (req.status == 200) {
			var l = req.responseText;
			var p = l.split(/\^\#\#\^/);
			var index = -1;
			for (i = 1; i <= p.length; i++) {
				if (i <= p.length) {
					if (p[0] != metalstring) {
						obj = document.getElementById("metalType2");
						obj.innerHTML = p[i + index];
						metalstring = p[i + index];
					} else {
						if (p[1] != gemstring) {
							obj = document.getElementById("stoneType2");
							obj.innerHTML = p[i + index];
							gemstring = p[i + index];
						}
					}
				}//end of if (i <= p.length)
			}//end of for (i = 1; i <= p.length; i+...
		}//end of if (req.status == 200) {
	}//end of if (req.readyState == 4) {
}//end of function GetMetalGem

function GetGemsonMetalselection() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var l = req.responseText;
			var p = l.split(/\^\#\#\^/);
			var index = -1;
			
			for (i = 1; i <= p.length; i++) {
				if (i <= p.length) {
					
							obj = document.getElementById("stoneType2");
							obj.innerHTML = p[i + index];						
						
					}
				}
			}
		}
	}
function assignPriceRange(range){
	if(range != 'b'){
		document.searchCatalog.priceRange.value = range;
	}
	else
	{
		document.searchCatalog.priceRange.value = '';
	}
}

function assignGems(gem){

	//Anu-September 05,On selection change,reset price filter
	if (document.getElementById("priceRangeSel").value != '')
	document.getElementById("priceRangeSel").value='';
	
	//Anu-September 05,if current selection value is null,then set this as primary dropdown
	if (document.getElementById("primaryDropdown").value == '') {
		document.getElementById("primaryDropdown").value = 'Gem';
	}
	
	if(gem != 'b'){
		document.searchCatalog.stoneType.value = gem;
	}
	else
	{
		document.searchCatalog.stoneType.value = '';
	}
	//Anu-September 05,if primary drodown is Gem,then only make Ajax call to populate Gem
	if (document.getElementById("primaryDropdown").value == 'Gem') {
	
	//Anu-September 05,Clear the primary dropdown selection and populate metal,gemstone dropdown with all items
		if (gem == "") {
			var url = "group_catalog_select2.htm?metalcode=" + gem;//metal should be null
			url = url + "&salefeature=" + document.searchCatalog.saleFeature.value;
			url = url + "&producttype=" + document.searchCatalog.productType.value;
			url = url + "&stonetype=" +document.searchCatalog.stoneType.value;
			url = url + "&price=" + document.getElementById("priceRangeSel").value;
			url = url + "&dropdown=PopulateBothHotpicks";
			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
			} else {
				if (window.ActiveXObject) {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
			req.onreadystatechange = GetMetalGem;
			req.open("GET", url, true);
			req.send(null);
			document.getElementById("primaryDropdown").value = '';
		} else {
		//Anu-September 05,Ajax call to populate Metal dropdown on Gems stone selection
		var url = "group_catalog_select2.htm?metalcode=" + document.searchCatalog.metalType.value;
		url = url + "&salefeature=" + document.searchCatalog.saleFeature.value;
		url = url + "&producttype=" + document.searchCatalog.productType.value;
		url = url + "&stonetype=" + document.searchCatalog.stoneType.value;
		url = url + "&price=" + document.getElementById("priceRangeSel").value;
		url = url + "&dropdown=PopulateMetalHotpicks";
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else {
			if (window.ActiveXObject) {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		req.onreadystatechange = GetMetalonGemselection;
		req.open("GET", url, true);
		req.send(null);
		}
	}//end of else if (document.getElementById("primaryDropdown").value=="Gem")
}
function GetMetalonGemselection() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var l = req.responseText;
			var p = l.split(/\^\#\#\^/);
			var index = -1;
			for (i = 1; i <= p.length; i++) {
				if (i <= p.length) {
					
						obj = document.getElementById("metalType2");
						obj.innerHTML = p[i + index];
					
				}
			}
		}//if (req.status == 200)
	}//if (req.readyState == 4)
}//end of GetMetalonGemselection
function getDetail(no){
	if(document.searchCatalog.productTypeSel.value != 'b'){
			document.searchCatalog.productType.value = document.searchCatalog.productTypeSel.value;
	}
	else
	{
			document.searchCatalog.productType.value ='';
	}
	
	if(document.searchCatalog.stoneTypeSel2.value != 'b'){
				document.searchCatalog.stoneType.value = document.searchCatalog.stoneTypeSel2.value;
	}
	else
	{
				document.searchCatalog.stoneType.value = '';
	}
	
	if (no==1 || (document.searchCatalog.productType.value != "" && no == 2)) {
		var url = "group_catalog_select2.htm?jCode="+document.searchCatalog.productType.value;
		if (no == 2){
			url = url + "&sCode="+document.searchCatalog.stoneType.value;
		}
		if (window.XMLHttpRequest){
			req = new XMLHttpRequest();
		}else if (window.ActiveXObject){
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.onreadystatechange = callbackTypes;
		req.open("GET", url, true);
		req.send(null);
	}
}	

var p0tmp;
var p1tmp;
var p2tmp;
var p3tmp;

function callbackTypes(){
	if (req.readyState == 4){
		if (req.status == 200){
			var l = req.responseText;
			var p = l.split(/\^\#\#\^/);
			var index = -1;
			var obj;
			var obj1;
			/*if (navigator.appName == 'Netscape')
				index = 0;*/
			for (i=1;i<=p.length;i++) {
					if (i==1) {
						if ((p[i+index] != 'no') && (p[0] != p0tmp)) {
							if (navigator.appName == 'Netscape')	{
								obj = document.getElementById("stoneType");
								obj.innerHTML = p[i+index];						
							}
							else	{
								obj = document.getElementById("stoneType");
								obj.innerHTML = p[i+index];
							}
							p0tmp = p[i+index];
						}
					} else if(i==2){
						if ((p[i+index] != 'no') && (p[1] != p1tmp)) {
							if (navigator.appName == 'Netscape')	{
								obj = document.getElementById("metalType");
								obj.innerHTML = p[i+index];
							}
							else	{
								obj = document.getElementById("metalType");
								obj.innerHTML = p[i+index];
							}
							p1tmp = p[i+index];
						}
					} else if(i==3){
						if ((p[i+index] != 'no') && (p[2] != p2tmp)) {
							if (navigator.appName == 'Netscape')	{
								obj = document.getElementById("stoneType2");
								obj.innerHTML = p[i+index];						
							}
							else	{
								obj = document.getElementById("stoneType2");
								obj.innerHTML = p[i+index];
							}
							p2tmp = p[i+index];
						}
					} else if(i==4){
						if ((p[i+index] != 'no') && (p[3] != p3tmp)) {
							if (navigator.appName == 'Netscape')	{
								obj = document.getElementById("metalType2");
								obj.innerHTML = p[i+index];
							}
							else	{
								obj = document.getElementById("metalType2");
								obj.innerHTML = p[i+index];
							}
							p3tmp = p[i+index];
						}
					}
				}
		}
	}
}