function goURL(s) {       
	var d = s.options[s.selectedIndex].value
    window.top.location.href = d
    s.selectedIndex=0
}

function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	destination.focus()
}


//-----------------------------
 //dropout tree menu script //
//---------------------------- 

function logout ( selectedtype )
{
  document.authenticate.submit();
}

function updateMarkup ( diamondID )
{
	
	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
	
	var compareForm = document.getElementById('compare');
	var priceInput = 'base' + diamondID;
	var mkptInput = 'markup_percent_' + diamondID;
	var mkprInput = 'markup_price_' + diamondID;
	var totalInput = 'total' + diamondID;
	var totalField = document.getElementById(totalInput);
	var hiddenTotal = document.getElementById('hiddenTotal'+diamondID);
	var markupPercent = document.getElementById(mkptInput).value;
	var markupPrice = document.getElementById(mkprInput).value * 1;
	var baseprice = compareForm[priceInput].value * 1;
	var totalprice = addCommas( ( ( (markupPercent/100) * baseprice) + baseprice + markupPrice).toFixed(2) );
	totalField.innerHTML = '<b>$' + totalprice + '</b>';
	hiddenTotal.value = totalprice;
	//alert(totalprice);
}

function showHide(obj) { //onclick either shows or hides the current dropout
	
	var showEl = document.getElementById(obj);
	var showAr = document.getElementById("navMenu").getElementsByTagName("span");
	if(showEl.style.display != "block"){ 
		showEl.style.display = "block";
	} else {
		showEl.style.display = "none";
	}
}

function openWin(theURL,winName,w,h,scroll) { 
	
		
	  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	  settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no';
		openWin.popup = window.open(theURL,winName,settings);
	
}

function swapImageViewed(image){
	//var newImage = selectedView + currentImage;
	window.document.imageViewed.src = '/images/catalog/'+image;
}

function userFormCheck(formobj){
	// name of mandatory fields
	var fieldRequired = Array("name", "username", "password", "password2", "permission", "email");
	// field description to appear in the dialog box
	var fieldDescription = Array("Name", "Username", "Password", "Verify Password", "permission", "Email");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/

// Anti-Spam Email Displayer- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com) for this script and more.
// This notice must stay intact for use

var contacts=new Array()
//Specify text and corresponding email address.
//Use [at] and [dot] in place of "@" and "." for anti spam purpose:
contacts[0]=["Email Us", "intainfo[at]intagems[dot]com"]
contacts[1]=["&#105;&#110;&#116;&#097;&#114;&#101;&#103;&#105;&#115;&#116;&#114;&#097;&#116;&#105;&#111;&#110;&#064;&#105;&#110;&#116;&#097;&#103;&#101;&#109;&#115;&#046;&#099;&#111;&#109;", "i/n/t/a/r/e/g/i/s/t/r/a/t/i/o/n[at]intagems[dot]com"]
contacts[2]=["&#105;&#110;&#116;&#097;&#111;&#114;&#100;&#101;&#114;&#064;&#105;&#110;&#116;&#097;&#103;&#101;&#109;&#115;&#046;&#099;&#111;&#109;", "i/n/t/a/o/r/d/e/r[at]intagems[dot]com"]
contacts[3]=["&#105;&#110;&#116;&#097;&#114;&#101;&#113;&#117;&#101;&#115;&#116;&#064;&#105;&#110;&#116;&#097;&#103;&#101;&#109;&#115;&#046;&#099;&#111;&#109;", "i/n/t/a/r/e/q/u/e/s/t[at]intagems[dot]com"]

//Specify caption text to display within SELECT menu. Only applicable if you're using the form option:
var dropmenucaption="CONTACT US FORM "

function displaycontact(emailarray, cssclass, displaymethod, extrainfo){
	if (displaymethod=="text"){
		document.write('<span class="' + cssclass + '">\n')
		
		if (typeof emailarray[0]=="object"){ //if array passed consists of multiple elements
		for (i=0; i<emailarray.length; i++){
		var seperator=(i<emailarray.length-1)? extrainfo : ""
document.write('<a href="mailto:' + modifyemail(emailarray[i][1])+ '">'+ emailarray[i][0] + '</a>' + seperator)
}
}
else //else if it is a single array element
document.write('<a href="mailto:' + modifyemail(emailarray[1])+ '">'+ emailarray[0] + '</a>')
document.write('</span>')
}
else if (displaymethod=="form"){
document.write('<form>\n')
document.write('<select size="' + extrainfo + '" onChange="jumptooption(this)" class="' + cssclass + '">\n')
document.write('<option value="caption">' + dropmenucaption + '</option>\n')
for (i=0; i<emailarray.length; i++)
document.write('<option value="mailto:' + modifyemail(emailarray[i][1]) +'">' + emailarray[i][0] + ' </option>\n')
document.write('</select></form>\n')
}
}

function modifyemail(emailitem){
var modified=emailitem.replace(/\[at]/gi, "@")
modified=modified.replace(/\[dot]/gi, ".")
return modified
}

function jumptooption(themenu){
if (themenu.options[themenu.selectedIndex].value !="caption")
location=themenu.options[themenu.selectedIndex].value
}

//USAGE INSTRUCTION. displaycontact(1st paramter, "2nd paramter", "3rd paramter", "4th paramter")
//1st parameter: Input the name of the array containing the list of email addresses. To display one single email, input the corresponding array element. 
//2nd parameter: Input the CSS Classname that is to be applied. Enter arbitrary name for none.
//3rd parameter: Input either "form" or "text." Former will display email in drop down menu. Later in plain text. Only "text" mode supports displaying of single email address!
//4th parameter: If in "form" mode, enter an integer to control the height of the <SELECT> tag. If "text" mode, enter any string to act as a divider between each email text. For example "|", "<br>" etc.

//SAMPLE USAGES (uncomment below to see)
//displaycontact(contacts, "textstyle", "text", " | ")

//displaycontact(contacts, "formstyle", "form", "1")

//displaycontact(contacts[2], "textstyle", "text", "")

