function openthaigem()
{
 var width  = 400;
 var height = 300;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=yes';
 params += ', location=yes';
 params += ', menubar=yes';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=yes';
 params += ', toolbar=yes';
 newwin=window.open('http://www.thaigem.com/','Thaigem', params);
}

var url="";

//This function is called upon selection of left directory items
function selectCat(jvalue,jcode,shandle) {
	// REMOVE JEL 10242009
	//shandle="ST1QcmljZX5LPTR_TD0xfk09MTEzOH4";//selection of directory items,reset all the previous selection
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+jcode+"&productTypeSel="+jcode+"&pathToken="+jvalue;
	window.location.href=url;
}

//This function is called upon selection of price filter
function assignPriceRange(range,shandle) {
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	{
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+range+"&priceRangeSel="+range;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;	
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;	
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
	}
}

//This function is called upon selection of gem filter
function assignGems(gem,shandle) {
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	{
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+gem+"&stoneTypeSel="+gem;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;	
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
	}
}
//This function is called upon selection of metal filter
function assignMetalType(metal,shandle) {

	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	{
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+metal+"&metalTypeSel="+metal;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;	
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
	}
}
//This function is called upon selection of metal filter
function assignKaratType(karat,shandle) {

	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	{
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+karat+"&karatTypeSel="+karat;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;	
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
	}
}
//This function is called upon selection of birthstone filter
function assignBirthStoneType(birthStone,shandle) {

	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	{
	url="searchGems.htm?SearchHandle="+shandle+"&Action=2&AnswerID="+birthStone+"&birthStoneTypeSel="+birthStone;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;	
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
	}
}
//This function is called upon page navigation
function goToPage(page,shandle) {
	url="searchGems.htm?SearchHandle="+shandle+"&Action=1&Page="+page+"&PageSize="+document.getElementById("itemCountForDisplayPerPage").value;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;	
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
}
//This function is called upon page size change
function itemSize(size,shandle) {
	url="searchGems.htm?SearchHandle="+shandle+"&Action=5&PageSize="+size;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;	
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   	url=url+"&sortByPriceType="+document.getElementById("sortByPriceType1").value;
	window.location.href=url;
}
//This function is called upon sorting
function sortPrice(price,shandle) {
   if((document.getElementById("sortByPriceType1").value !="")&&(document.getElementById("sortByPriceType1").value !="b"))
   {
	url="searchGems.htm?SearchHandle="+shandle+"&Action=6";
	url=url+"&sortByPriceType="+price;
	url=url+"&PageSize="+document.getElementById("itemCountForDisplayPerPage").value;
	if((document.getElementById("metalTypeSel").value !="")&&(document.getElementById("metalTypeSel").value !="b"))
	url=url+"&metalTypeSel="+document.getElementById("metalTypeSel").value;
	if((document.getElementById("stoneTypeSel").value !="")&&(document.getElementById("stoneTypeSel").value !="b"))
	url=url+"&stoneTypeSel="+document.getElementById("stoneTypeSel").value;
	if((document.getElementById("birthStoneTypeSel").value !="")&&(document.getElementById("birthStoneTypeSel").value !="b"))
	url=url+"&birthStoneTypeSel="+document.getElementById("birthStoneTypeSel").value;
	if((document.getElementById("karatTypeSel").value !="")&&(document.getElementById("karatTypeSel").value !="b"))
	url=url+"&karatTypeSel="+document.getElementById("karatTypeSel").value;
	if((document.getElementById("priceRangeSel").value !="")&&(document.getElementById("priceRangeSel").value !="b"))
	url=url+"&priceRangeSel="+document.getElementById("priceRangeSel").value;
	if(document.getElementById("productType").value !="")
	url=url+"&productTypeSel="+document.getElementById("productType").value;
	window.location.href=url;
	}
}


