function mo(o) {o.className=='stateoff'?o.className='stateon': o.className=o.className; return false}
function mx(o) {o.className=='stateon'?o.className='stateoff': o.className=o.className; return false}
function SetBusy(t){GetElementById('oBody').style.cursor="wait";setTimeout("GetElementById('oBody').style.cursor='default';",t)}
function ShowImg(o){ar=o.src.split('Resize=Y&Width=98&Height=98&');GetElementById('MainImg').src=ar[0]+ar[1];/*SetBusy(2000)*/}
 
function GetElementById(s)
{
	o=(document.getElementById?document.getElementById(s):document.all[s])
	return o==null?false:o
}

function AskQuestion(sURL,sItemTag,sPrice)
{
    document.write('<iframe src="/Include/AskQuestion.aspx?ItemURL='+escape(sURL)+'&amp;ItemTag='+sItemTag+'&amp;Price='+sPrice+'" height=226 width="100%" frameborder=no scrolling=no marginwidth=0 marginheight=0><\/iframe>')
}

function ErrorHandler(sMsg,sUrl,sLine)
{
	 //sMsg=sMsg||"Unknown JS Error";sUrl=sUrl||location.href;sLine=sLine||0
	 //new Image().src='/Include/AsLog.ashx?Err=1&Url='+escape(sUrl)+'&Line='+sLine+'&Msg='+escape(sMsg)
	 return true
}
window.onerror=ErrorHandler

function MapFrame()
{
	document.write('<iframe src="/SiteMap.aspx?R='+escape(window.parent.location.href)+'" width=452 height=332 frameborder=no scrolling=no marginwidth=0 marginheight=0><\/ifr'+'ame>')
}

function TestimonialsFrame()
{
	document.write('<iframe src="/Helpdesk/Testimonials.aspx?R='+escape(window.parent.location.href)+'" width=340 height=304 frameborder=no scrolling=no marginwidth=0 marginheight=0><\/iframe>')
} 

function ShowcaseFrame(sItemList, sTitle, nHeight)
{
    document.write('<iframe src="http://www.natalia-diamonds.com/Include/Diamond-Jewelry.aspx?ItemTags='+sItemList+'&amp;Width=190&amp;Title='+escape(sTitle)+'&amp;BG=F7FBFD" height='+nHeight+' width=190 frameborder=no scrolling=no marginwidth=0 marginheight=0><\/iframe>')
} 

function ShowFramedAd(nLocation, nAdTypeToUse, nWidth, nHeight, sAdKeyword, sAdContext, nFrameHeight)
{
    document.write('<iframe src="/1/1_1_'+sAdKeyword+'.aspx?L='+nLocation+'&amp;T='+nAdTypeToUse+'&amp;W='+nWidth+'&amp;H='+nHeight+'&amp;C='+sAdContext+'" width='+nWidth+' height='+nFrameHeight+' frameborder=no scrolling=no marginwidth=0 marginheight=0><\/iframe>')
}

function NavTo(sURL)
{	
	window.location.href=(sURL=="" || sURL==null ? "/" : sURL+".aspx");return false
}

function NavToGC(sURL)
{	
	window.location.href='http://www.gold-custom.com/'+sURL;return false
}

function NavToND(sURL)
{	
	window.location.href='http://www.natalia-diamonds.com/'+sURL;return false
}

function OpenTo(sURL)
{
	OpenWin(sURL, 900, 700, "yes", "yes", true, true);return false
}

function mailto(domain,user)
{
	 document.write("<a href='mailto:"+user+"@"+domain+"'>"+user+"@"+domain+"<\/a>")
}

function OpenWin(sURL, wdh, hgt, scroll, resize, center, toolbar)
{
	if(hgt>=screen.availHeight-26)hgt=screen.availHeight-26
	y=0;x=(screen.width-wdh-10)	
	if(center){x/=2;y=(screen.availHeight-26-hgt)/2}	
	o=window.open(sURL.replace('/\s/g', "+"), "_blank", "width="+wdh+",height="+hgt+",top="+y+",left="+x+","+(toolbar?"toolbar=yes,menubar=yes,status=yes,location=yes":"toolbar=no,menubar=no,status=no,location=no")+",scrollbars="+scroll+",resizable="+resize)
	if(o!=null && typeof(o)!="undefined") o.focus()
	return o
}

function OpenYehuda()
{
	return OpenTo('http://www.yehuda'+'.com/process.asp')
}

function SetCookie(sName, vValue)
{
	argv=SetCookie.arguments,argc=SetCookie.arguments.length
	sExpDate=(argc>2)?";expires="+argv[2].toGMTString():""
	sPath=(argc>3)?";path="+argv[3]:""
	sDomain=(argc>4)?";domain="+argv[4]:""
	sSecure=(argc>5)&&argv[5]?";secure":""
	document.cookie=sName+"="+escape(vValue,0)+sExpDate+sPath+sDomain+sSecure+";"
}

function DeleteCookie(sName)
{
	document.cookie=sName+"="+GetCookie(sName)+";expires="+(newDate()).toGMTString()+";"
}

function GetCookie(sCookieName)
{
	sName=sCookieName+"=",ichSt,ichEnd
	sCookie=document.cookie
	if (sCookie.length&&(-1!=(ichSt=sCookie.indexOf(sName))))
	{
		if (-1==(ichEnd=sCookie.indexOf(";",ichSt+sName.length)))ichEnd=sCookie.length
		return unescape(sCookie.substring(ichSt+sName.length,ichEnd))
	}
	return null
}

function ChangeQuery()
{
	GetElementById("txtAbsPageNum").value="1"
	GetElementById("txtItemTag").value=""
	RefreshPage()
	return true
}

function RenderSearch()
{
    e=GetElementById("tdSearch")
    e.innerHTML=GetElementById("divSearch").innerHTML
    e.className="clsSearch2"
}

function Loose_Diamonds_Search()
{
	return RefreshPage("/Loose-Diamonds/Loose-Diamonds")
}

function RefreshPage(sURL)
{
	cmdLine="?"
	NameArr=new Array("cmbShape","cmbWeight","cmbPrice","cmbEnh","cmbColor","cmbClarity","cmbSortBy","cmbSortOrder","cmbDesignType","cmbSideStonesWeight","cmbSideStonesColor","cmbSideStonesShape","cmbSideStonesType","txtItemTag","chkInStock")
	for (i=0; i<NameArr.length; i++)
	{
		oElmt = GetElementById(NameArr[i])
		if (!oElmt) continue
		if (NameArr[i].indexOf("chk")>=0)
		{
			cmdLine += NameArr[i].toString().replace("chk","") + (oElmt.checked ? "=Y&" : "=N&")
			continue
		}
		if (!oElmt.value.length) continue
		cmdLine += NameArr[i].toString().replace("cmb","").replace("txt","")+"="+oElmt.value+"&"
	}

	if (sURL)
	{
		cmdLine = sURL+".aspx"+cmdLine.substr(0, cmdLine.length-1)
	}
	else
	{
		sURL = window.location.pathname
		i = sURL.indexOf("_"); j = sURL.indexOf(".")
		if (i>0 || j>0) { if (i>j || i<0) i=j; sURL=sURL.substr(0, i)}
		cmdLine = sURL+".aspx"+cmdLine.substr(0, cmdLine.length-1)
	}

	oElmt = GetElementById("txtAbsPageNum")
	if (oElmt && !isNaN(parseInt(oElmt.value)) && parseInt(oElmt.value)>1)
	{
		cmdLine=cmdLine.replace(".aspx", "_AbsPageNum_"+parseInt(oElmt.value)+".aspx")
	}
	window.location.href = cmdLine
	return false
}


function NextPage()
{
	oElmt=GetElementById("txtAbsPageNum")
	if(!oElmt) return false
	pageNum=parseInt(oElmt.value)
	if(isNaN(pageNum))pageNum=0
	oElmt.value=pageNum+1
	RefreshPage()
	return false
}

function PrevPage()
{
	oElmt=GetElementById("txtAbsPageNum")
	if(!oElmt) return false
	pageNum=parseInt(oElmt.value)
	if(isNaN(pageNum))pageNum=1
	if(pageNum>1)oElmt.value=pageNum-1
	RefreshPage()
	return false
}

function ThisPage(pageNum)
{
	oElmt=GetElementById("txtAbsPageNum")
	if(!oElmt) return false
	oElmt.value=pageNum
	RefreshPage()
	return false
}

function OnChkBoxClick()
{
	var sTemp=""
	var oTbl = GetElementById("tblItemList")
	for (j=0,i=1; i<oTbl.rows.length; i++)
	{
		var chkBox = oTbl.rows[i].cells[0].firstChild
		if (chkBox==null || typeof(chkBox)=="undefined") continue
		if (chkBox.type=="checkbox")
		{
			if (chkBox.checked && j < 5)
			{
				sTemp += chkBox.id.substr(3, chkBox.id.length-3) + ","
				j++
			}
			//chkBox.disabled = true
		}
	}
	sTemp = sTemp.substr(0, sTemp.length-1)
	var expdate = new Date()
	expdate.setMonth(expdate.getMonth() + 1)
	SetCookie("PinnedStones", sTemp, expdate)
	RefreshPage()
}


function ShowCEdescr()
{
	oPopup = window.createPopup()
	oPopBody = oPopup.document.body
	oPopBody.style.backgroundColor="lightyellow"
	oPopBody.style.border="solid black 1px"
	oPopBody.innerHTML=divCEpopup.innerHTML
	oPopup.show(0, -188, 240, 180, GetElementById("imgCE"))
}

function SetRowBG(Id)
{
	e=GetElementById(Id)
	if (e!=null && typeof(e)!="undefined") e.style.backgroundColor='#FFFFD9'
}

function ClrRowBG(Id)
{
	e=GetElementById(Id)
	if (e!=null && typeof(e)!="undefined") e.style.backgroundColor='#'+Id.substr(Id.indexOf("_")+1,10)
}

