
function getThumbs(strName,intPageIndex,intId, strShopBy,Gem,Metal,Type,LowPrice,Highprice, keyword )
{
    try
    {
         
    }
    catch(err)
    {  
    }
    finally
    {
    }

     dianavincent.populateThumbnails(strName,intPageIndex, intId, strShopBy,Gem,Metal,Type,LowPrice,Highprice, keyword, _populateThumbnailsCallback);

    //var response = dianavincent.prod_template.populateThumbnails(intStart, strCategory, _populateThumbnailsCallback);
    
     //var response = html.populateThumbnails(intStart, intId, strShopBy);
      //alert(response);
     //var strHTML = new String(response.value);
     //alert(strHTML);
}

function _populateThumbnailsCallback(res) 
{

    try
    {
	    var strHTML = new String(res.value);
	    var strHTMLArr = strHTML.split("^");
		document.getElementById("thumbs").innerHTML  = strHTMLArr[0];
		document.getElementById("pagination").innerHTML  = strHTMLArr[1];
    }
    catch(err)
    {
    }
    finally
    {
   
    }
  }  
    
    function getSKU(intSKU,intId, strName, strShopBy, strImage)
{
    try
    {
          dianavincent.populateRightColumn(intSKU,intId, strName, strShopBy,_populateSKUCallback);
          dianavincent.populateImage(strImage, _populateImageCallback);
    }
    catch(err)
    {  
    }
    finally
    {
    }
    //var response = dianavincent.prod_template.populateThumbnails(intStart, strCategory, _populateThumbnailsCallback);
    
     //var response = html.populateThumbnails(intStart, intId, strShopBy);
      //alert(response);
     //var strHTML = new String(response.value);
     //alert(strHTML);
}


 function getImage(strImage)
{
    try
    {
          dianavincent.populateImage(strImage, _populateImageCallback);

    }
    catch(err)
    {  
    }
    finally
    {
    }
    //var response = dianavincent.prod_template.populateThumbnails(intStart, strCategory, _populateThumbnailsCallback);
    
     //var response = html.populateThumbnails(intStart, intId, strShopBy);
      //alert(response);
     //var strHTML = new String(response.value);
     //alert(strHTML);
}


function _populateSKUCallback(res) 
{
     //alert(document.title);
    try
    {
	    var strHTML = new String(res.value);
		document.getElementById("rightShop").innerHTML  = strHTML;
    }
    catch(err)
    {
        
    }
    finally
    {
   
    }

}


function _populateImageCallback(res) 
{
     //alert(document.title);
    try
    {
	    var strHTML = new String(res.value);
		document.getElementById("mainImage").innerHTML  = strHTML;
    }
    catch(err)
    {
        
    }
    finally
    {
   
    }

}


function __doPostBack(eventTarget, eventArgument,theform) {
		 	    theform.__EVENTTARGET.value = eventTarget;
		 	    theform.__EVENTARGUMENT.value = eventArgument;
		 	    theform.submit();
		 	}
		 	
	
var Gem = -99999
var Metal = -99999
var Type = null
var LowPrice = -99999
var Highprice = -99999
function chgTxt(zObject, z,strShopBy, intId,  strName, strSearch)
{

	strSearchArr = strSearch.split("~");
	var sGem = strSearchArr[0];
	var sMetal = strSearchArr[1];
	var sType = strSearchArr[2];
	var sLowPrice = strSearchArr[3];
	var sHighprice = strSearchArr[4];
	var sKeyWord = strSearchArr[5];
	
	if (z != "" && z != "~")
	{
		 

		zArr = z.split("~");
		cName = zArr[0];
		cId =  zArr[1];
		zContents = cName;
		itemdiv=document.getElementById(zObject);

		// reset "ad-on" link
		// each menu can be reset separately, resetVal = whatever link you want
		if (zObject == "theTxt") { resetVal = "javascript:chgTxt('theTxt','Type','"+strShopBy+"',"+intId+",'"+strName.replace("'","\\'")+"', '"+strSearch+"')"; }
		if (zObject == "theTxt2") { resetVal = "javascript:chgTxt('theTxt2','Gemstone','"+strShopBy+"',"+intId+",'"+strName.replace("'","\\'")+"', '"+strSearch+"')"; }
		if (zObject == "theTxt3") { resetVal = "javascript:chgTxt('theTxt3','Metal','"+strShopBy+"',"+intId+",'"+strName.replace("'","\\'")+"', '"+strSearch+"')"; }
		if (zObject == "theTxt4") { resetVal = "javascript:chgTxt('theTxt4','Price','"+strShopBy+"',"+intId+",'"+strName.replace("'","\\'")+"', '"+strSearch+"')"; }


		// reset add-on conditions (based on zContents, not zObject)
		if ((zContents == "Type") || (zContents == "Gemstone") || (zContents == "Metal") || (zContents == "Price"))
			{ addReset = 0; }
		else
			{ 
			addReset = 1; 
			}


		
		if(zObject == "theTxt4" && zContents != "Price")
		{
			if(cId == "499")zContents="under 500";
			else if(cId  == "9999999")zContents="over $5,000";
			else zContents= CurrencyFormatted(cName).replace('.00','')+" - "+CurrencyFormatted(cId).replace('.00','');
		}
		
		
		// add href to txt here instead of in initial call (avoid too many alternating " and ' characters)
		//form HREF from first link on line

		if (addReset == 1)
			{ zContents = '<a href="' + resetVal + '" id="style2">' + zContents + '<\/a>'; }
		else
			{ zContents = '<a href="' + resetVal + '" id="style1">' + zContents + '<\/a>'; }


		// only add if not activating a reset menu link
		if (addReset == 1) { zContents = zContents + ''; }


		//empty out zContents just in case
		//zContents = "";

		if(zObject =="theTxt")
		{
			if(cName == "Type")Type = null
			else Type = cId;
		}
		if(zObject =="theTxt2")
		{
			if(cName== "Gemstone")Gem = -99999
			else Gem = cId;
		}
		
		if(zObject =="theTxt3")
		{
			if(cName == "Metal")Metal = -99999
			else Metal = cId;
		}
		
		if(zObject =="theTxt4")
		{
			if(cName == "Price")
			{
				LowPrice = -99999
				Highprice = -99999
			}
			else
			{
				LowPrice = cName;
				Highprice = cId;
			}
		}
	if(sGem != -99999)
		Gem = sGem;
	if(sMetal != -99999)
		Metal = sMetal;
	if(sType != "" && sType != null)
		Type = sType;
	if(sLowPrice != -99999)
		LowPrice = sLowPrice ;
	if(sHighprice != -99999)
		Highprice = sHighprice;

	//var sKeyWord = strSearchArr[0];


		if(Gem == -99999)
		{

			var res = dianavincent.populateNarrowSearchGemstones(strShopBy, intId,  strName,Gem,Metal,Type,LowPrice,Highprice,sKeyWord);
			var strHTML = new String(res.value);
			document.getElementById("gemstone").innerHTML  = strHTML;
		}
		else
		{
		   document.getElementById("ugem").style.display = 'none';
		}
		if(Metal == -99999)
		{
			var res = dianavincent.populateNarrowSearchPreciousMetals(strShopBy, intId,  strName,Gem,Metal,Type,LowPrice,Highprice,sKeyWord);
			var strHTML = new String(res.value);
			document.getElementById("metal").innerHTML  = strHTML;
		}
		else
		{
		   document.getElementById("umetal").style.display = 'none';
		}
		if(Type == null)
		{
			var res = dianavincent.populateNarrowSearchType(strShopBy, intId,  strName,Gem,Metal,Type,LowPrice,Highprice,sKeyWord);
			var strHTML = new String(res.value);
			document.getElementById("type").innerHTML  = strHTML;
		}
		else
		{
		   document.getElementById("utype").style.display = 'none';
		}
			
		if(Highprice == -99999)
		{
			var res = dianavincent.populateNarrowSearchPrice(strShopBy, intId,  strName,Gem,Metal,Type,LowPrice,Highprice,sKeyWord);
			var strHTML = new String(res.value);
			document.getElementById("tprice").innerHTML  = strHTML;
		}
		else
		{
		   document.getElementById("uprice").style.display = 'none';
		}

		
		// finally, swap zContents into ID zObject
		itemdiv=document.getElementById(zObject);
		itemdiv.innerHTML = zContents;
		
		if(addReset == 0 && vGlobal != "")
			showHide(vGlobal, false);
		
		getThumbs(strName,1,intId, strShopBy,Gem,Metal,Type,LowPrice,Highprice,sKeyWord)
		//type.InnerHtml = dianavincent.populateNarrowSearchType(strShopBy, intId,  strName);
		
		//gemstone.InnerHtml = dianavincent.populateNarrowSearchGemstones(strShopBy, intId,  strName);
		
		//metal.InnerHtml = dianavincent.populateNarrowSearchPreciousMetals(strShopBy, intId,  strName);
		
		//price.InnerHtml = dianavincent.populateNarrowSearchPrice(strShopBy, intId,  strName);
	}
	
	

	



function CurrencyFormatted(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

	
}


var vBlHide = false;

var vGlobal 
function showHide(v)
{		
	vGlobal = v
	var ele = document.getElementById(v);
	

	
	if(vBlHide == false)
	{
		if(ele.style.display == '' || ele.style.display == 'none')
			{	
				ele.style.display = 'block';
				
			}
			else
			{
				ele.style.display = 'none';
				vGlobal = ""
				
			}
	}

	if(ele.parentNode.firstChild.firstChild.id == "style2" && vBlHide == false)
		vBlHide = true;
	else if(ele.parentNode.firstChild.firstChild.id == "style1")
		vBlHide = false;

		
		if(vBlHide)
		{
			ele.style.display = 'none';
		}
				//vBlMetalHidden = false;
		
		//if(vBlMetalHidden)ele.style.display = 'none';
}
		 	
		 	



