if(window.event +"" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;
/*****************popUp()*************** */
function popUp(url)
{
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}

function popUpWindow(url)
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}

/*****************checkselect()****************/
function checkselect(form)
{
var i = document.getElementById("select2").selectedIndex;
if (document.getElementById("select2").options[i].value=='Bracelets')
{
	hide_item("crt");
	hide_item("trs");
}
else
{
	show_item("crt");
	show_item("trs");
}

ShowWeightOptions();
}
		
/****************CheckNumber()****************/ 
function CheckNumber(num,str)
{
var i=0;
    
if (num.length==0)  {
   alert(str);
   return false;
}
while (i<num.length) {
   if (num.substring(i,i+1)>"9" || num.substring(i,i+1)<"0" )
   {
      alert(str); 
      return false;
   }
   i++ ;
}
 
return true ;
}

/***************** checkEmail()****************/
function checkEmail(strEmail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail)){
  return (true);
}
alert("Invalid E-mail Address! Please re-enter.");
return (false);
}

/*     **************** checkAffiliateForm()***************       */
function checkAffiliateForm(form)
{
if (form.Name.value==""){
	alert ("Please insert Site Name!");
	form.Name.focus();
	return(false);
}else if (form.Password.value==""){
	alert ("Please choose a Password");
	form.Password.focus();
	return(false);
}else if (form.Password.value.length<6){
	alert ("Password should be at least 6 characters.");
	form.Password.focus();
	return(false);
}else if (form.Site.value==""){
	alert ("Please insert Site URL!");
	form.Site.focus();
	return(false);
}else if (form.Address1.value==""){
	alert ("Please insert Mailing Address!");
	form.Address1.focus();
	return(false);
}else if (form.Contact_Name.value==""){
	alert ("Please insert Contact Name!");
	form.Contact_Name.focus();
	return(false);
}else if (form.Tel_No2.value==""){
	alert ("Please insert Contact Phone Number!");
	form.Tel_No2.focus();
	return(false);
}else if (form.Email.value==""){
	alert ("Please insert Email!");
	form.Email.focus();
	return(false);
}else if (!checkEmail(form.Email.value)){
	form.Email.focus();
	return(false);

}else {return true;}
}

/****************checkBasketform()***************/
function checkBasketform()
{
for (i=0;i<f1.elements.length;i++)
{
	if (f1.elements[i].type=='radio' && (f1.elements[i].value=='UK' || f1.elements[i].value=='USA') && f1.elements[i].checked==true) 
	{
	//alert('SS'+f1.elements[i].name.substring(8,20)+f1.elements[i].value);
	//alert(document.getElementById('SS'+f1.elements[i].name.substring(8,20)+f1.elements[i].value).selectedIndex);
	if (document.getElementById('SS'+f1.elements[i].name.substring(8,20)+f1.elements[i].value).selectedIndex==0)
	//if (f1.elements[i].selectedIndex==0&&f1.elements[i].name!='rates')
	{
		alert("Please Select a Finger Size for this Ring");
		document.getElementById('SS'+f1.elements[i].name.substring(8,20)+f1.elements[i].value).focus();
		//f1.elements[i].focus();
		return false;
	}
	}
}
return true;
}

/*****************popUp2()****************************/
function popUp2(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}

/*************************OpenPopUp()***************/
function OpenShowDiamondWin(id,itype)
{
	window.open('ShowDiamond.asp?itype='+itype+'&id='+id,"Diamonds","height=600,width=800,scrollbars=1,toolbar=0,status=0,resizable=0,menubar=0")
}

/***************** checkMemberForm()***************       */
function checkMemberForm(form)
{
if (form.Email.value==""){
	alert ("Please insert Email Address !");
	form.Email.focus();
	return(false);
}else if (!(checkEmail(form.Email.value))){
		form.Email.focus();
		return(false);
}else if (form.First_Name.value==""){
	alert ("Please insert First Name!");
	form.First_Name.focus();
	return(false);
}else if (form.Last_Name.value==""){
	alert ("Please insert Last Name!");
	form.Last_Name.focus();
	return(false);
}else if (form.Password.value==""){
	alert ("Please choose a Password");
	form.Password.focus();
	return(false);
}else if (form.Password.value.length<6){
	alert ("Password should be at least 6 characters.");
	form.Password.focus();
	return(false);
}else if (form.Country_ID.value==""){
	alert ("Please choose a Country");
	form.Country_ID.focus();
	return(false);

}else {return true;}
}

/*****************gosubmit()****************/
 function gosubmit(jtype)
 {
  f1.JewelrySubTypeId.value=jtype;
  
  if(jtype==20) //band type ring - no main diamond
	f1.CS.value = "";
  
  f1.submit();
 }
  
/*****************OpenPopUp()***************/

function OpenPopUp(id)
{
window.open('ShowBigjewelries.asp?id='+id,"jewelries","height=450,width=700,scrollbar=0,toolbar=0,status=0,resizable=0,menubar=0")
}

/*****************OpenPopUp2()****************/

function OpenPopUp2(id)
{
window.open('ShowBigjewelries2.asp?id='+id,"jewelries","height=450,width=700,scrollbar=0,toolbar=0,status=0,resizable=0,menubar=0")
}

/*****************MakeWin()****************/

function MakeWin(passedURL,pWidth,pHeight){
	window.open(passedURL,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,left=200,top=100,resizable=1,width=" + pWidth + ",height=" + pHeight)
}

/*****************MakeWin2()***************unresizable*/

function MakeWin2(passedURL,pWidth,pHeight){
	window.open(passedURL,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,left=200,top=10,resizable=0,width=" + pWidth + ",height=" + pHeight)
}

/*****************checkAddPaymentForm()****************/

function checkAddPaymentForm(form,balance,layAway){

var result = true;

if (document.getElementById("CCNum").value=="")
{
	alert ("Please insert Credit Card Number!");
	form.CCNum.focus();
	result = false;
}
if (document.getElementById("paySum").value=="")
{
	alert ("Please insert amount of payment in US$!");
	form.paySum.focus();
	result = false;
}
if (document.getElementById("slcCCType").value==-1)
{
	alert ("Please insert Type of Card!");
	form.slcCCType.focus();
	result = false;
}
if (document.getElementById("CSCNumber").value=="")
{
	alert ("Please insert your CSC Number!");
	form.CSCNumber.focus();
	result = false;
}
if (eval(document.getElementById("paySum").value)>balance)
{
	alert ("The amount is more than the balance due (US$ " + balance +")!");
	form.paySum.focus();
	result = false;
}
if (balance>=150)
{
	if (eval(document.getElementById("paySum").value)<150)
		{
		alert ("The amount is less than the minimum (US$150)!");
		form.paySum.focus();
		result = false;
		}
}
if(layAway)
{
	var ok=confirm("Are you sure you want to charge your credit card now ? \n This is not authorization!");
	if(ok==false)
		result = false;
}
if (submitted)
{
  alert("Your transaction is being submitted but the connection to the Manager Service is taking longer than usual  - please be patient. Click OK to continue the submission.")
  return (false);
}

if(result)
{
	document.getElementById("f1").submit();
	submitted = true;
	return (true);
}
else
	return false;
}
/*****************openWinCSC()****************/

function openWinCSC()
{
win=open("http://www.diamonds-usa.com/pages/csc.htm","csc","width=300,height=400,status=yes,scrollbars=yes,left=50,top=50")
}
/*****************openWinCSC_sp()****************/

function openWinCSC_sp()
{
win=open("http://www.diamonds-usa.com/pages/csc_sp.htm","csc","width=300,height=400,status=yes,scrollbars=yes,left=50,top=50")
}
/*****************openWinAmex()****************/
function openWinAmex()
{
win=open("http://www.diamonds-usa.com/pages/amx.htm","amx","width=300,height=400,status=yes,scrollbars=yes,left=50,top=50")
}
/*****************openWinAmex_sp()****************/
function openWinAmex_sp()
{
win=open("http://www.diamonds-usa.com/pages/amx_sp.htm","amx","width=300,height=400,status=yes,scrollbars=yes,left=50,top=50")
}
/********************OpenPopUp()***************/
function OpenPopUp(id,itype)
{
window.open('ShowDiamond.asp?itype='+itype+'&id='+id,"Diamonds","height=450,width=700,scrollbars=1,toolbar=0,status=0,resizable=0,menubar=0")
}
/********************variables***************/
var isNav, isIE, tempChar1, tempChar,tempWidth,tempalignLeft;
tempalignLeft = 0;
 
if (parseInt(navigator.appVersion) >=4 )
{
    if (navigator.appName =="Netscape")
		{isNav = true;}
	else
		{isIE = true;}
} 
/***************** checkWinSize()****************/
function checkWinSize()
{
if(isNav)
{
	tempChar1 = window.innerWidth
}
else{
	document.write ("<body>");
	tempChar1 = document.body.clientWidth;
	document.write ("</body>");
}
tempChar1 =(tempChar1 - 710)/2;
return tempChar1;
}
/*****************document.write() - code canceled****************/
/*tempalignLeft = checkWinSize();
document.write ("<style>");
document.write ("#Explanation{position:absolute;visibility:hidden;top:105;left:"+(tempalignLeft+0)+"}");
document.write ("#AvailabelDiamond{position:absolute;visibility:hidden;top:135;left:"+(tempalignLeft+10)+"}");
document.write ("#UnAvailabelDiamond{position:absolute;visibility:hidden;top:135;left:"+(tempalignLeft+110)+"}");
document.write ("</style>");*/

/*****************OpenWin()****************/
function OpenWin(PageSource)
{
window.open (PageSource,'','width=770 height=400 scrollbars=yes');
}
/*****************tempGifon****************/
var colorVar,tempImage,ShapeNum;
colorVar="";
tempImage="nothing";
ShapeNum =0;

if(navigator.appVersion.substring(0,1)>=3)
{
var tempGifon = new Image();
tempGifon.src = "../images/nothing.gif";

var S1on = new Image();
S1on.src = "../images/images-search/S1on.gif";
var S2on = new Image();
S2on.src = "../images/images-search/S2on.gif";
}
/***************** OffImage2()****************/
function OffImage2(Shape,Place)
{
  OffImg="../images/images-search/S"+ Shape+".gif";
	document["S" + Shape].src=OffImg;
	if (parseInt(ShapeNum) == 1)
		document.f1.CS.checked=false;
	else
		document.f1.CS[parseInt(Place)].checked=false;
}

/*****************OnImage2()****************/
function OnImage2(Shape,Place)
{	
	ShapeOn=Shape+"on";	
	OnImg="../images/images-search/S"+ShapeOn+".gif";
	document["S" + Shape].src=OnImg;
	tempImage=Shape;
	if (parseInt(ShapeNum) == 1)
		document.f1.CS.checked=true;	
	else
		document.f1.CS[parseInt(Place)].checked=true;
}

/*****************check()****************/
function check(Shape,Place)
{
if (parseInt(ShapeNum) == 1)
{
	if (document.f1.CS.checked)
	{
		OnImage2(Shape,Place);
	}else{
		OffImage2(Shape,Place);
		}
}else{
	if (document.f1.CS[parseInt(Place)].checked)
	{
		OnImage2(Shape,Place);
	}else{
		OffImage2(Shape,Place);
	}
}
}

/*****************checkOff()****************/
function checkOff(Shape,Place)
{	
if (document.f1.CS[parseInt(Place)].checked)
{
	document.f1.CS[parseInt(Place)].checked = false;
}
}

/*****************ChangeImage2()****************/
function ChangeImage2(Shape,Place,on){			

if (on){
	if (tempImage!=Shape){
       tempImg="../images/images-search/S"+Shape+"on.gif";
       document["S" + Shape].src = tempImg;
	}
}else{
		if (parseInt(ShapeNum) == 1)
			temp=document.f1.CS.checked;
		else
			temp=document.f1.CS[parseInt(Place)].checked;
	if (!temp){
	   tempImg="../images/images-search/S"+Shape+".gif";
	   document["S" + Shape].src = tempImg;
	}
}
}
/*****************checkanniv()****************/
function checkanniv(type,metalID)
{
if(eval(type==20))
	{
	document.location.href = "../anniversary_jewelry/Match_Jewelry_Action.asp?wizard=Locked&OccasionType2=2&JewelryTypeId=4&JewelrySubTypeId=20&Fprice=-1&tPrice=&JewelryMetalId="+metalID+"&IS_FOR_ANNIVERSIRY=1"
	}
}

/*****************priceConverte()****************/
function priceConverte(price)
{
var newPrice = 0;
var rates_list=document.getElementById("rates");
var str = rates_list.options[rates_list.selectedIndex].value;
var rate = eval(str.substring(0,str.indexOf(',')));
var update = str.substring(str.indexOf(',')+1,str.indexOf('#'));
var code = str.substring(str.indexOf('#')+1);
newPrice = Math.round(rate * price);
	
newStr=newPrice.toString();
	
if(newStr.length>=4) // add "," before three last digits
{
	temp=newStr.substring((newStr.length)-3);
	newPrice=newStr.substring(0,(newStr.length)-3)+","+temp;
}

document.getElementById("price").value = code + " " + newPrice ;
document.getElementById("update_date").value = update ;
if(document.getElementById("convertedPrice"))
	document.getElementById("convertedPrice").style.visibility="visible" ;
if(document.getElementById("rateUpdate"))
	document.getElementById("rateUpdate").style.visibility="visible" ;
		
session_rate=rate;
}

/*****************checkPayment()****************/
function checkPayment(item,amount)
{
minAmount = Math.round(amount*0.05);
if(minAmount < 150)
	minAmount=150;

if (eval(item.value)<minAmount) // less than minimum 5%/150$  payment
	{
		alert ("The minimum amount for the payment is: US$ " + minAmount);
		item.focus();
		return false;
	}
else  // payment ok 
	item.form.submit();
}

/* ******************checkCbox()*************************/
function checkCbox(form,num)
{
var flagC=0;	
for (i=0;i<form.elements.length;i++)
{
	if(form.elements(i).type=="checkbox")
		if(form.elements(i).checked)
			flagC = 1;										
}
if (flagC==1)
{
	return true;
}
else
{	
	if (num == 1)		
		alert("please select a setting!");
	else
		alert("please select a diamond!");
	return false;
}

}
/* ******************set_shapes for quick search************/
function set_shapes(form)
{
var shapelen = form.Shape.length;
if (form.Shape.selectedIndex==0)
	{
	for (var i=1;i<shapelen;i++)
		{
		form.Shape.options(i).selected=false;
		}
	}
}

/* ******************SelectAll*****************************/
function SelectAll(form)
{
for (var i=0;i<form.length;i++)
{
	if (form.elements(i).checked)
		form.elements(i).checked = false;
	else
		form.elements(i).checked = true;
}
}
/* ******************get_select_value**********************/
function get_select_value(obj)
{
var sel_opt=obj.options.selectedIndex;
return obj.options[sel_opt].value;
}
/*******************openModalImage*************************/

function openModalImage(settingID,strSettingName)
{
window.open("../include/showBigImagesInc.asp?id=" + settingID + "&amp;settingName=" + strSettingName ,null, "height=630,width=450,top=50, left=50, status=no,toolbar=no,menubar=no,location=no")
}
/*******************openModalImage for Firefox*************/

function openModalImage_ff(settingID,strSettingName)
{
window.open("../include/showBigImages_ff.asp?id=" + settingID + "&settingName=" + strSettingName ,null, "height=630,width=450,top=50, left=50, status=no,toolbar=no,menubar=no,location=no")
}

/*******************PUWindow*************************/
function PUWindow(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}
/*******************PUWindow*************************/
function SWindow(url) {
var params,screenHeigth, screenWidth, winTop, winLeft;
screenHeigth=screen.height;
screenWidth=screen.width;
winLeft=screenWidth-50;
params='toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=5,height=5,left=' + winLeft;
sealWin=window.open(url,"win",params);
self.name = "mainWin";
}
/*******************CreateControl*************************/
function CreateFlashControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL, bgcolor)
{
var d = document.getElementById(DivID);
var html='<object classid=' + CLSID + ' id=' + ObjectID +
' width="' + WIDTH + '" height="' + HEIGHT +'"><param name="movie" value="' + URL + '"/><param name="quality" value="high"/>';
html+='<param name="wmode" value="opaque" />';
html+='</object>';
d.innerHTML =html;
}
/*******************check_QS_form*************************/
function check_QS_form()
{
var sel=document.getElementById("sel_product");
var s_index=sel.options.selectedIndex;
if(sel.options[s_index].value=="")
	{
		alert("Please Select a Product");
		return false;
	}
	
sel=document.getElementById("sel_budget");	
s_index=sel.options.selectedIndex;
if(sel.options[s_index].value=="0")
	{
		alert("Please Select Budget");
		return false;
	}
return true;
}
/*******************************************************/
function get_list_chose(list_name)
{
var opt=document.getElementById(list_name).selectedIndex;
var val=document.getElementById(list_name).options[opt].value;
return val;
}
/*******************************************************/
function set_list_chose(list_name,val)
{
var list_o=document.getElementById(list_name).options;
for(var i=0;i<list_o.length-1;i++)
	{
		if(list_o[i].value==val)
			list_o[i].selected=true;
	}
 }
/*******************************************************/
function clear_reg_email()
{
document.getElementById("reg_email").value="";
}
/*******************************************************/
function clear_tb(tb_name)
{
document.getElementById(tb_name).value="";
}
/*******************************************************/
function send_reg()
{
var sealWin, params,screenHeigth, screenWidth, winTop, winLeft;
screenHeigth=screen.height;
screenWidth=screen.width;
winLeft=screenWidth-50;
params='toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=5,height=5,left=' + winLeft;

div_name=document.getElementById("div_name").value;
if(div_name=='email_reg')
	tb_name='reg_email';
else
	tb_name='reg_email_bottom';
email=document.getElementById(tb_name).value;
if(checkEmail(email))
	{
	sealWin=window.open('',"reg_win",params);
	document.getElementById("reg_form").target="reg_win";
	document.getElementById("reg_form").submit();
	}
}
/*******************************************************/
function reg(reg_page,div_name)
{
var url, tb_name, email;
if(div_name=='email_reg')
	tb_name='reg_email';
else
	tb_name='reg_email_bottom';
email=document.getElementById(tb_name).value;
if(checkEmail(email))
	{
		url="http://www.diamonds-usa.com/pages/quickregaction.asp?email=" + email + "&page=" + reg_page + "&div=" + div_name;
		SWindow(url);
	}
}
/*******************************************************/
function get_reg_results(msg,div_name)
{ 
document.getElementById(div_name).innerHTML=msg;
}
/*******************************************************/
function match_diamond_to_settings(set_id, metal_id)
{
	var url="../diamonds/loose_diamonds.asp?wizard=Jewelries&amp;Jid=" + set_id + "&amp;MetalId=" + metal_id + "&amp;JMask=10000";
	document.location.replace(url);
}
/*******************************************************/
function set_focus(element_id)
{
	document.getElementById(element_id).focus();
}
/*******************************************************/
function CheckCaptcha()
{
if (document.getElementById("fig1").value=="" || document.getElementById("fig2").value=="" || document.getElementById("fig3").value=="")
	{
		alert ("Please type the security characters into the boxes!");
		document.getElementById("fig1").focus();
		return(false);
	}
else
	return(true);
}
/*******************************************************/
function hide_item(item_id)
{
	document.getElementById(item_id).style.display="none";
}
/*******************************************************/
function show_item(item_id)
{
	document.getElementById(item_id).style.display="";
}
/*******************************************************/
function validate_sweapstakes_form()
{
valid = true;
if (document.getElementById("UserName").value == "" || document.getElementById("UserName").value == "Name" )
{
        alert ( "Please fill in your full name." );
        valid = false;
}
if(! checkEmail(document.getElementById("UserEmail").value))
{
        valid = false;
}
if ( document.getElementById("terms").checked == false )
{
        alert ( "Please check the Terms & Conditions box." );
        valid = false;
}
return valid;
}
/*******************************************************/
function show_price_in_local_currency(price,session_rate)
{
   var rates_list=document.getElementById("rates");
   
   for (i=0;i<rates_list.options.length;i++)
   { 
   // get rate form  from select box values and compare to the session value
   str = rates_list.options[i].value;
   rate = eval(str.substring(0,str.indexOf(',')));
  
   if (parseFloat(rate) == session_rate)
        { 
       // if rate match then select the current select box option 
       rates_list.options[i].selected=true;
       // call converted price display function
       priceConverte(price);
       }
    }
}
/*******************************************************/
function fill_list(list_obj,list_items,list_vals)
{
//remove existing options
for (var i = list_obj.length - 1; i>=0; i--)
      list_obj.remove(i);
//add new options
var arr_items=list_items.split(",");
var arr_vals=list_vals.split(",");
var OptNew;
for (i =0 ; i<=arr_items.length - 1; i++)
	{
		var OptNew = document.createElement('option');
		OptNew.text = arr_items[i];
		OptNew.value = arr_vals[i];

		try {
		  list_obj.add(OptNew); // IE only
		}
		catch(ex) {
		  list_obj.add(OptNew, null); // standards compliant; doesn't work in IE
		}
	}
}
/*******************************************************/
function createXmlDomObject()
{
var ro;
if (window.XMLHttpRequest)
	{      
	try 
		{ 
	        ro = new XMLHttpRequest();      
		} 
	catch(e) 
		{          
		//some kind of a weird mistake...you choose what you want to do          
		ro = false;      
		}   
	} 
else if(window.ActiveXObject)
	{  
	try
		{         
			ro = new ActiveXObject("Microsoft.XMLDOM");
		} 
	catch(e) 
		{         
		try
				{            
					ro=new ActiveXObject("Microsoft.XMLHTTP");         
				} 
			catch(e) 
				{            
					//don't know what to do...you choose            
					ro = false;         
				}      
		}  
	}  
return ro;
}
/*******************************************************/
function loadXmlToObj(xml)
{
if (window.XMLHttpRequest)
  var xmlDoc = new DOMParser().parseFromString(xml, "application/xml"); 
else if(window.ActiveXObject)
	{xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

xmlDoc.loadXML(xml);}
  
return xmlDoc;
}

/*******************************************************/
//for AJAX work
function createXmlRequestObject()
{
var ro;
if (window.XMLHttpRequest)
	{      
	try 
		{ 
	        ro = new XMLHttpRequest();      
		} 
	catch(e) 
		{          
		//some kind of a weird mistake...you choose what you want to do          
		ro = false;      
		}   
	} 
else if(window.ActiveXObject)
	{  
	try
		{         
			ro = new ActiveXObject("Msxml.HTMLHTTP");      
		} 
	catch(e) 
		{         
		try
				{            
					ro=new ActiveXObject("Microsoft.XMLHTTP");         
				} 
			catch(e) 
				{            
					//don't know what to do...you choose            
					ro = false;         
				}      
		}  
	}
return ro;
}