
function gopopit (url, name, props)
{
	newwindow=window.open (url, name, props);
	if (window.focus) {newwindow.focus()};
	return false;
}


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes,,toolbar=no,menubar=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}




	///////////////////////////////////////
	// Auto-Select Field
	///////////////////////////////////////
	// Requires "onLoad=ready()" in the BODY tag
	// Example: <body onLoad=ready()>
	// Requires form name to match where it reads "form" in script
	// Example: <form name="form">
	// Requires form field name to match where it reads "field" in script
	// Example: <input name="field">

function ready(){document.form.field.focus();}



	///////////////////////////////////////
	// Form Validation
	///////////////////////////////////////

function validateGiftCertificate ( form ) {
	return (
				 checkSelect(form.elements["amount"],"V","","Please enter an amount.",false) &&
				 checkSelect(form.elements["recipient_name"],"V","Please enter recipient's name",false) &&
				 checkSelect(form.elements["recipient_email"],"V","","Please enter your recipient's E-mail Address.",false) &&
				 checkEmail(form.elements["recipient_email"],false) &&
				 checkSelect(form.elements["recipient_email"],"V","joe@example.com","Please supply valid E-mail Address.",false));	
}

function validateTell(form) {
	return (
				 checkSelect(form.elements["to_email"],"V","","Please enter your Friend's E-mail Address.",false) &&
				 checkEmail(form.elements["to_email"],false) &&
				 checkSelect(form.elements["to_email"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&
				 checkSelect(form.elements["from_email"],"V","","Please enter Your E-mail Address.",false) &&
				 checkEmail(form.elements["from_email"],false) &&
				 checkSelect(form.elements["from_email"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&
				 checkSelect(form.elements["from_name"],"V","","Please enter Your Name.",false));
}

function validateContact(form) {
	return (
				 checkSelect(form.elements["firstname"],"V","","Please enter your First Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","","Please enter your Last Name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["message"],"V","","Please provide us with your Message.",false));
}

function validateEmailSignup(form) {
	return (
				 checkSelect(form.elements["firstname"],"V","","Please enter your First Name.",false) &&
				 checkSelect(form.elements["firstname"],"V","First Name","Please enter your real First Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","","Please enter your Last Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","First Name","Please enter your real Last Name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false));
}

function validateUnsub(form) {
	return (
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false));
}

function validateLogin(form) {
	return (
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["password"],"V","","Please enter your Password.",false));
}

function validateNewLogin(form) {
	return (
				
				 checkSelect(form.elements["fullname"],"V","","Please enter your full name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["password1"],"V","","Please create a Password.",false) &&
				 checkSelect(form.elements["password2"],"V","","Please confirm your Password.",false));
}

function validatePay(form) {
	return (
				validateBillingAddress(form) &&
				 checkSelect(form.elements["cc_num"],"V","","You have chosen to pay by Credit Card. Please enter your Credit Card Number before continuing.",false) &&
				 checkSelect(form.elements["cc_expires_month"],"V","00","Please select the Month this credit card expires.",false) &&
				 checkSelect(form.elements["cc_expires_year"],"V","00","Please select the Year this credit card expires.",false) &&
				 checkSelect(form.elements["cc_sid"],"V","","Please enter your credit card's 3-digit Identification Number.",false));
}

function validateSignin(form) {
	return (
				 checkSelect(form.elements["loginemail"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["loginemail"],false) &&
				 checkSelect(form.elements["loginemail"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&				 
				 checkSelect(form.elements["password"],"V","","Please enter your Password.",false));
}

function validatePO(form)
{
	return checkSelect(form.elements["po_number"],"V","","Please enter the PO Number.",false);
	
}//end validatePO

function validateBillingAddress(form)
{
	return ( checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		 checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		 checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		 checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		 checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		 checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false));


}//end validateBillingAddress

function checkPasswords(form) {
	
	if ( form.elements["password1"].value != form.elements["password1"].value ) {
		alert("Your passwords does not match.  Please enter re-enter your passwords");
		return false;
	} else {
		return true;
	}
	
}

function validateExpressPurchase(form)
{
	if ( 
		
		checkSelect(form.elements["email_address"],"V","","Please enter your E-mail.",false) &&
		checkEmail(form.elements["email_address"],false) &&
		checkSelect(form.elements["email_address"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&		
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false)) 
	
	{
		//All billing was ok - check shipping and return it
		return validateShippingAddress(form);
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateBillingAddress1(form)
{
	if (
		//checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing First Name.",false) &&
		//checkSelect(form.elements["billing_lastname"],"V","","Please enter the billing Last Name.",false) &&
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false) 
		//checkSelect(form.elements["billing_country"],"V","","Please enter the billing Country.",false)
	) {
		//All billing was ok - check shipping and return it
		return validateShippingAddress(form);
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateBillingAddress2(form)
{
	if (
		//checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing First Name.",false) &&
		//checkSelect(form.elements["billing_lastname"],"V","","Please enter the billing Last Name.",false) &&
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false) 
		//checkSelect(form.elements["billing_country"],"V","","Please enter the billing Country.",false)
	) {
		//All billing was ok - check shipping and return it
		return true;
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateShippingAddress(form)
{
	return (
		checkSelect(form.elements["ship_fullname"],"V","","Please enter the shipping full name.",false) &&
		checkSelect(form.elements["ship_phone"],"V","","Please enter the shipping Phone.",false) &&
		checkSelect(form.elements["ship_address"],"V","","Please enter the shipping Address.",false) &&
		checkSelect(form.elements["ship_city"],"V","","Please enter the shipping City.",false) && 
		checkSelect(form.elements["ship_state"],"V","","Please enter the shipping State/Prov.",false) && 
		checkSelect(form.elements["ship_zip"],"V","","Please enter the shipping ZIP.",false) 
	);
}//end validateShippingAddress

function validateExpressPurchase(form)
{
	return (
		checkSelect(form.elements["email_address"],"V","","Please enter your email address.",false) &&
		checkSelect(form.elements["ship_fullname"],"V","","Please enter the shipping full name.",false) &&
		checkSelect(form.elements["ship_phone"],"V","","Please enter the shipping Phone.",false) &&
		checkSelect(form.elements["ship_address"],"V","","Please enter the shipping Address.",false) &&
		checkSelect(form.elements["ship_city"],"V","","Please enter the shipping City.",false) && 
		checkSelect(form.elements["ship_state"],"V","","Please enter the shipping State/Prov.",false) && 
		checkSelect(form.elements["ship_zip"],"V","","Please enter the shipping ZIP.",false) 
	);
}//end validateShippingAddress

function validatePaypalForm()
{	
	if (document.getElementById('billing_state').value.length == 0) {
		alert ("Please enter the billing state.");
		return false;
	} else {
		return true;
	}
}//end validateShippingAddress

function checkProfile(form)
{
	var arrElements = new Array("fullname","address", "city", "state", "zip");
	var len = arrElements.length;
	var i = 0;
	
	for ( i=0; i<len; i++ ) {
		if ( form.elements['billing_'+arrElements[i]].value != form.elements['hidden_billing_'+arrElements[i]].value ) {
			form.elements['profilecontrol'].value = 'change';	
		}
		
	}//for
	
	//alert(form.elements['profilecontrol'].value);
	
	//and one by hand
	if ( form.elements['cc_type'].value != form.elements['hidden_cc_type'].value ) {
		form.elements['profilecontrol'].value = 'change';
	}
	
	return validateBillingAddress(form);
	
}//end checkProfile

////////////////////////////////////////////////
// disabling and enabling shipping info fields
////////////////////////////////////////////////

function toggleFields(form)
{
	var toggle = form.elements['same_as_billing'];
	
	var arrShipFields = new Array('ship_fullname', 'ship_address', 'ship_city', 'ship_state', 'ship_zip', 'ship_phone');
	var fieldShipCount = arrShipFields.length;
	
	var arrBillFields = new Array('billing_fullname', 'billing_address', 'billing_city', 'billing_state', 'billing_zip', 'billing_phone');
	var fieldBillCount = arrBillFields.length;
	
	var i = 0;
	
	if (toggle.checked == false) {
		//Already checked, unset everything
		for ( i=0; i<fieldShipCount; i++) {
			form.elements[arrShipFields[i]].value = "";
		}//for	
	
	} else {
		//Not yet checked, copy the values from billing
		for ( i=0; i<fieldShipCount; i++) {
			form.elements[arrShipFields[i]].value = form.elements[arrBillFields[i]].value;
		}//for	
	}
	
}//end toggleFields

function toggleSaveProfile(elem) {
	var form = elem.form;
	
	//valid values are insert, donotupdate, and update
	if (elem.checked == true) {
		form.elements['profilecontrol'].value = 'insert';
				
	} else {
		form.elements['profilecontrol'].value = 'donotupdate';
		
	}
	
	//alert(form.elements['profilecontrol'].value);
	
}//end toggleSaveProfile

function checkField() {
	var frm = document.search_store;
	
	if ( (frm.p_keyword.value == "" ) || (frm.p_keyword.value == " " ) ) {
		
		alert("A Keyword is required to search");
		return false;			
	}
	
}


function checkEmailSignup() {

	var frm = document.emailSignup;
	
	if ( (frm.firstname.value == "" ) || (frm.firstname.value == " " ) ) {
		
		alert("First name is required");
		return false;			
	}
	
	if ( (frm.lastname.value == "" ) || (frm.lastname.value == " " ) ) {
		alert("Last name is required");
		return false;	
	}	
	
	if ( (frm.email.value == "") || (frm.email.value == " ") ) {
		
		alert("E-mail is required");
		return false;	
	}
	
	return true;
	
}
function LoginOptionCheck(myself) {

	frm = document.forms['new_login'];
	// if the new Customer item is checked
	var elem_pass_new = document.getElementById('newcustomerpassword');
	var elem_pass_old = document.getElementById('returningcustomerpassword');
	
	if ( myself.value == "new" ) {
		elem_pass_old.disabled = true;
		elem_pass_old.style.display = "none";
		elem_pass_new.disabled = true;
		elem_pass_new.style.display = "";
		frm.elements['action'].value = "account_new";
		
	} else {
	
		elem_pass_old.disabled = false;
		elem_pass_old.style.display = "";
		elem_pass_new.disabled = true;
		elem_pass_new.style.display = "none";
        frm.elements['loginemail'].focus();
		frm.elements['action'].value = "account";
		
	}
	
	frm.elements['loginemail'].focus();
}


function focusLoginField() {
	if ( typeof(document.new_login) != "undefined" ) {
		document.new_login.loginemail.focus();
	}
}

function loadPreview() {

	var caption_value = window.opener.document.getElementById("caption").value;
	var headline_obj = window.opener.document.getElementById("headline");
	var body_obj = window.opener.document.getElementById("body");
	var child_head = document.getElementById("headline");
	var child_body = document.getElementById("body");
	var child_caption = document.getElementById("img_caption");
	
	if ( caption_value != '' && child_caption != null ) {
		
		child_caption.innerHTML = caption_value;
	}
	child_head.innerHTML = headline_obj.value;
	child_body.innerHTML = body_obj.value;
	
}

function doProfileChange() {
	document.getElementById('update_profile').style.display = "inline";
}

function fadeout() {
	for (var iterator = 0; iterator < arguments.length; iterator++) {
		arguments[iterator].value = '';
		arguments[iterator].disabled = true;
	}
}

function fadein() {
	for (var iterator = 0; iterator < arguments.length; iterator++) {
		arguments[iterator].disabled = false;
	}
	arguments[1].focus();
	arguments[1].select();
}

function add_to_cart(id)
{
	var frm = document.getElementById('frmAddCart');
	frm.elements['product_id'].value = id;
	frm.submit();
}//end add_to_cart

function customize_setting(id, form_name)
{
	form_name = form_name ? form_name : 'frmCustomize';
	var frm = document.getElementById(form_name);
	frm.elements['product_id'].value = id;
	frm.submit();
}//end customize

function add_diamond(id)
{
	var frm = document.getElementById('frmCustomize');
	frm.elements['product_id'].value = id;
	frm.submit();
}//end customize

function submit_customize_form()
{
	if ( $('i_size') ) {
		if ( !$F('i_size')) {
			alert("You must select a ring size");
			return;
		}
	}
	var frm = document.getElementById('detailForm');
	frm.action = "dyo_list.php";
	if ( is_stud_dyo ) {
		frm.elements['go'].value = "customize_stud";
	} else {
		frm.elements['go'].value = "customize";
	}
	frm.submit();
}

function check_ring_sizer()
{
	if ( $('i_size') ) {
		if ( !$F('i_size')) {
			alert("You must select a ring size");
			return false;
		}
	}
	return true;
}

function new_check_ring_size ()
{
	if (go_check_ring_size)
	{
		var i_size = document.getElementById ('i_size').value;
		if (i_size)
		{
			i_size = parseInt (i_size);
			if (i_size > 0) return true;
		}
		
		alert ("Please select a ring size first.");
		return false;
	}
	
	return true;
}

function quantity_check(frm)
{
	if ( frm.elements['qty'].value < 1 || !validateInteger(frm.elements['qty'].value) ) {
		alert("Quantity must be an integer greater than 0");
		return false;
	}
}

function multiple_quantity_check(frm)
{
	for ( var i=0; i<arr_content_index.length; i++ ) {
		if ( !validateInteger(frm.elements['update[' + arr_content_index[i] + ']'].value) ) {
 			alert("Quantity must be an integer greater than 0");
			return false;
		}
	}
}

function validateInteger( strValue ) {
	
  var objRegExp  = /(^-?\d\d*$)/;

  return objRegExp.test(strValue);
}

function addOption()
{
	var uri = "LiveUpdater.php";
	
	var data = "";
	
	var name = document.getElementById('optionname').value;
	var sku = document.getElementById('optionsku').value;
	var price = document.getElementById('optionprice').value;
	var ring_metal = document.getElementById('optionmetal').value;
	var qtyinstock = document.getElementById('optionqtyinstock').value;
	var engraveable = document.getElementById('optionengraveable').checked;
	
	if ( name != "" && sku != "" && price != "" ) {
		
		document.getElementById('optionname').value = "";
		document.getElementById('optionsku').value = "";
		document.getElementById('optionprice').value = "";
		document.getElementById('optionmetal').options[0].selected = true;
		document.getElementById('optionqtyinstock').value = "";
		document.getElementById('optionengraveable').value = "";
		
		document.getElementById('option_list').innerHTML = "Loading...";
		
		data += nh.compressData( 'action', "addOption" );
		data += nh.compressData( 'target', "option_list" );
		data += nh.compressData( 'name', name );
		data += nh.compressData( 'sku', sku );
		data += nh.compressData( 'price', price );
		data += nh.compressData( 'ring_metal', ring_metal );
		data += nh.compressData( 'qty_in_stock', qtyinstock );
		data += nh.compressData( 'engraveable', engraveable );
		
		//alert( data );
		
		LiveUpdater( uri, data );
	}
}

function editOption( id, update )
{
	if ( !update ) {
		
		var uri = "LiveUpdater.php";
	
		var data = "";
		
		button = document.getElementById("optionbutton");
		button.value = "Save Part/Option";
		button.onclick = function onclick(event) {editOption(id, true);};
		
		data += nh.compressData( 'action', "editOption");
		data += nh.compressData( 'target', "option_list");
		data += nh.compressData( 'id', id);
		data['action'] 	= "editOption";		
		data['target'] 	= "option_list";
		data['id'] = id;		
		
		LiveUpdater( uri, data );
		
	} else {
		
		var uri = "LiveUpdater.php";
		
		var data = "";
		
		var name = document.getElementById('optionname').value;
		var sku = document.getElementById('optionsku').value;
		var price = document.getElementById('optionprice').value;
		var ring_metal = document.getElementById('optionmetal').value;
		if ( document.getElementById('optionqtyinstock').value == '' ) {
			var qtyinstock = -1;
		} else {
			var qtyinstock = document.getElementById('optionqtyinstock').value;
		}
		var engraveable = document.getElementById('optionengraveable').checked;
		
		if ( name != "" && sku != "" && price != "" ) {
		
			document.getElementById('optionname').value = "";
			document.getElementById('optionsku').value = "";
			document.getElementById('optionprice').value = "";
			document.getElementById('optionmetal').options[0].selected = true;
			document.getElementById('optionqtyinstock').value = '';
			document.getElementById('optionengraveable').checked = false;
			
			button = document.getElementById("optionbutton");
			button.value = "Add Part/Option";
			button.onclick = function onclick(event) {addOption();};
			
			document.getElementById('option_list').innerHTML = "Loading...";
		
			data += nh.compressData( 'action', "updateOption");
			data += nh.compressData( 'target', "option_list");
			data += nh.compressData( 'id', id);
			data += nh.compressData( 'name', name);
			data += nh.compressData( 'sku', sku);
			data += nh.compressData( 'price', price);
			data += nh.compressData( 'ring_metal', ring_metal);
			data += nh.compressData( 'qty_in_stock', qtyinstock);
			data += nh.compressData( 'engraveable', engraveable);
		
			LiveUpdater( uri, data );
		}
	}
}

function moveOption( id, direction )
{
	var uri = "LiveUpdater.php";
	
	var data = "";
	
	document.getElementById('optionname').value = "";
	document.getElementById('optionsku').value = "";
	document.getElementById('optionprice').value = "";
	document.getElementById('optionqtyinstock').value = "";
	
	button = document.getElementById("optionbutton");
	if ( button.value == "Save Part/Option" ) {
		button.value = "Add Part/Option";
		button.onclick = function onclick(event) {addOption();};
	}
	
	data += nh.compressData( 'action', "moveOption" );
	data += nh.compressData( 'target', "option_list" );
	data += nh.compressData( 'id', id );
	data += nh.compressData( 'direction', direction );
	
	LiveUpdater( uri, data );
}

function removeOption( id )
{
	var uri = "LiveUpdater.php";
	
	var data = "";
	
	document.getElementById('optionname').value = "";
	document.getElementById('optionsku').value = "";
	document.getElementById('optionprice').value = "";
	document.getElementById('optionqtyinstock').value = "";
	
	button = document.getElementById("optionbutton");
	if ( button.value == "Save Part/Option" ) {
		button.value = "Add Part/Option";
		button.onclick = function onclick(event) {addOption();};
	}
	
	document.getElementById('option_list').innerHTML = "Loading...";
	
	data += nh.compressData( 'action', "removeOption");
	data += nh.compressData( 'target', "option_list");
	data += nh.compressData( 'id', id);
	
	LiveUpdater( uri, data );
}

function clearOption()
{
	document.getElementById('optionname').value = "";
	document.getElementById('optionsku').value = "";
	document.getElementById('optionprice').value = "";
	document.getElementById('optionqtyinstock').value = "";
	document.getElementById('optionengraveable').checked = 0;
	
	button = document.getElementById("optionbutton");
	if ( button.value == "Save Part/Option" ) {
		button.value = "Add Part/Option";
		button.onclick = function onclick(event) {addOption();};
	}
}

function displayNewOptions()
{
	var uri = "LiveUpdater.php";
	
	var data = "";
	
		
	data += nh.compressData( 'action', "displayNewOptions");
	data += nh.compressData( 'target', "option_list");
	
	LiveUpdater( uri, data );
}

function displayNewSettings()
{
	var uri = "LiveUpdater.php";
	
	var data = "";
	
	data += nh.compressData( 'action', "displayNewSettings");
	data += nh.compressData( 'target', "setting_list");
	
	LiveUpdater( uri, data );
}

function loadSearch(type)
{
	if ( type == "product" ) {
		document.getElementById('product').style.display = '';
		document.getElementById('ring').style.display = 'none';
		document.getElementById('diamond').style.display = 'none';
	} else if ( type == "ring" ) {
		document.getElementById('product').style.display = 'none';
		document.getElementById('ring').style.display = '';
		document.getElementById('diamond').style.display = 'none';
	} else if ( type == "diamond" ) {
		document.getElementById('product').style.display = 'none';
		document.getElementById('ring').style.display = 'none';
		document.getElementById('diamond').style.display = '';
	}
}

function loadVeriSign() {
	/*var div = document.getElementById('verisign');
	var e = document.createElement('script');
	e.src = 'https://seal.verisign.com/getseal?host_name=www.arseniadiamonds.com&size=M&use_flash=YES&use_transparent=YES&lang=en';
	e.type = "text/javascript";
	div.appendChild(e);*/
}

var arrCut = new Array();
arrCut[0] = 'Fair';
arrCut[1] = 'Good';
arrCut[2] = 'Very Good';
arrCut[3] = 'Ideal';

var arrColor = new Array();
for ( var i=68; i<=90; i++ ) {
	arrColor[arrColor.length] = String.fromCharCode(i);
}

var arrClarity = new Array();
arrClarity[0] = 'I3';
arrClarity[1] = 'I2';
arrClarity[2] = 'I1';
arrClarity[3] = 'SI3';
arrClarity[4] = 'SI2';
arrClarity[5] = 'SI2';
arrClarity[6] = 'VS2';
arrClarity[7] = 'VS1';
arrClarity[8] = 'VVS2';
arrClarity[9] = 'VVS1';
arrClarity[10] = 'IF';
arrClarity[11] = 'FL';


var arrClarityReq = new Array();
arrClarityReq[0] = 'A';
arrClarityReq[1] = 'B';
arrClarityReq[2] = 'C';
arrClarityReq[3] = 'D';
arrClarityReq[4] = 'E';
arrClarityReq[5] = 'F';
arrClarityReq[6] = 'G';
arrClarityReq[7] = 'H';
arrClarityReq[8] = 'I';
arrClarityReq[9] = 'J';
arrClarityReq[10] = 'K';
arrClarityReq[11] = 'L';

var arrCarat = new Array();
var pattern = /.0$/;
for ( var i=0; i<=5; i+=0.1 ) {
	var x = i.toFixed(1);

	if ( pattern.test(x) ) {
		x = i.toFixed(0);
	}
	arrCarat[x] = x;
}
arrCarat[5] = '5+';

var cut;
var price
var carat;
var color;
var clarity;

var shape = 0;

var cut_low = 0;
var cut_high = 3;

var price_low = 0;
var price_high = 50000;

var carat_low = 0;
var carat_high = 50;

var color_low = 0;
var color_high = 22;

var clarity_low = 0;
var clarity_high = 11;

var scroll_pos = 0;
var scrollbar;

var request;





// Firebug display function
function printfire()
{
    if (document.createEvent)
    {
        printfire.args = arguments;
        var ev = document.createEvent("Events");
        ev.initEvent("printfire", false, true);
        dispatchEvent(ev);
    }
}

function part_changed()
{
	var part = document.getElementById ('part_select').value;
	if (document.getElementById ('engrave_option'))
	{
		if (parts_array[part] == 1) document.getElementById ('engrave_option').style.display = '';
		else document.getElementById ('engrave_option').style.display = 'none';
	}
	
	var total_price = Number (option_prices['option_' + document.getElementById ('part_select').value]) + Number (get_size_price ());
	var nf = new NumberFormat(total_price);
	nf.setPlaces(2);
	total_price = nf.toFormatted();
	if ( document.getElementById('price_container') ) {
		document.getElementById('price_container').innerHTML = '$'+total_price;
	}
	if ( document.getElementById('total_price_container') ) {
		var total_price = diamond_price_subtotal + Number(option_prices['option_'+document.getElementById('part_select').value]);
		total_price += get_size_price();
		var nf = new NumberFormat(total_price);
		nf.setPlaces(2);
		total_price = nf.toFormatted();
		document.getElementById('total_price_container').innerHTML = '$'+total_price;
	}
}

function get_size_price()
{
	if ( !size_prices ) {
		return 0;
	}
	var size_price = size_prices[document.getElementById('i_size').value];
	if ( size_price != undefined ) {
		return size_price;
	}
	return 0;
}

function size_price_updated()
{
	part_changed();
}

function show_engrave()
{
	/*document.getElementById('i_quantity').style.display = 'none';
	var qty = document.createElement('input');
	qty.disabled = true;
	qty.className = "form35";
	qty.value = document.getElementById('i_quantity').value;
	document.getElementById('i_quantity').parentNode.appendChild(qty);
	document.getElementById('i_quantity')
	var td = document.getElementById('engrave_link').parentNode;
	td.removeChild(document.getElementById('engrave_link'));
	for ( var x=0;x<document.getElementById('i_quantity').value;x++) {
		var heading = document.createElement('h4');
		var text = "Engraving - "+engraving_cost;
		if ( document.getElementById('i_quantity').value != 1 ) {
			text += " #"+(x+1);
		}
		heading.appendChild(document.createTextNode(text));
		td.appendChild(heading);
		var input = document.createElement('input');
		input.type = 'text';
		input.maxLength = engraving_char_limit;
		input.name='engraving_box_actual_'+x;
		input.className = 'form210';
		input.id='engraving_id_'+x;
		input.setAttribute('onchange', 'update_hidden_engraving('+x+')');
		td.appendChild(input);
		var hidden = document.createElement('input');
		hidden.type = 'hidden';
		hidden.name='engraving_box['+x+']';
		hidden.id='engraving_hidden_'+x;
		document.getElementById('detailForm').appendChild(hidden);
	}*/
	document.getElementById('engrave_link').style.display = 'none';
	document.getElementById('s_engraving').style.display = '';
}

function update_hidden_engraving(id)
{
	document.getElementById('engraving_hidden_'+id).value = document.getElementById('engraving_id_'+id).value;
}

function setting_select(setting)
{
	document.getElementById('setting_'+document.getElementById('i_setting_type').value).className = '';
	document.getElementById('i_setting_type').value = setting;
	document.getElementById('setting_'+setting).className = 'selected';
}

function engrave_update()
{
	if ( document.getElementById('i_laser').checked) {
		diamond_price_subtotal = diamond_price_fixed + diamond_etch_price;
	} else {
		diamond_price_subtotal = diamond_price_fixed;
	}
	var nf = new NumberFormat(diamond_price_subtotal);
	nf.setPlaces(2);
	diamond_price_subtotal = nf.toFormatted();
	document.getElementById('s_diamond_price').innerHTML = diamond_price_subtotal;
	part_changed();
}

function switchImage(imgName, imgSrc, shape) {
	if (imgSrc != "none") {
			document.getElementById(imgName).src = imgSrc;
		}
}

function etch_update()
{
	var new_etch_price = 0;
	if ( document.getElementById('i_laser').checked ) {
		new_etch_price = diamond_etch_price;
	}
	var nf = new NumberFormat(diamond_price_fixed + new_etch_price);
	nf.setPlaces(2);
	document.getElementById('s_diamond_price').innerHTML = nf.toFormatted();
	
	nf = new NumberFormat(diamond_price_fixed + new_etch_price + setting_price_fixed);
	nf.setPlaces(2);
	document.getElementById('total_price_container').innerHTML = nf.toFormatted();
}

function dc_over(id)
{
	document.getElementById('dc_'+id).style.backgroundColor = "#96AEC7";
	document.getElementById('dc_'+id).style.color = "#354761";
}

function dc_out(id)
{
	document.getElementById('dc_'+id).style.backgroundColor = "";
	document.getElementById('dc_'+id).style.color = "";
}