/*
Version 1.8
*/

var to_swap = 0;
var isIndex = false;
// ==============================================================================================
function i_swap(iname){
	// only run on index page
	clearTimeout(to_swap);
	if(isIndex){
		if (iname == "") {
			to_swap=setTimeout("MM_swapImage('index_img','','" + defaultImg + "')",2500);
		}else{
			iname= 'images/i_'+iname+'.jpg';
			MM_swapImage('index_img','',iname);
		}
	}
}
// -------------------------------------------------------------
function costsWin(){
	mywindow = window.open ("setup.php","costs","location=0,status=0,scrollbars=0,width=570,height=358");
	
}
// -------------------------------------------------------------

function noEnterKey() {
	//alert(window.event.keyCode)
	if (window.event.keyCode == 13){
		alert("Enter key has been disabled.")
		window.event.keyCode =0;
	}
} 

// -------------------------------------------------------------
function requestQuote(mode) {
	//showHideDiv("prod_request");
	if(mode == "hide"){
		showHide("product_request","none");
		showHide("product_specs","block");
	}else{
		showHide("product_specs","none");
		showHide("product_request","block");
	}
}
// -------------------------------------------------------------

function showHide(divID, mode) {
	document.getElementById(divID).style.display = mode;
}
// -------------------------------------------------------------
function moveToTop(){
	document.getElementById("container").scrollTop = 0; //It scrolls to top;
}
// -------------------------------------------------------------
function writeEmail(emName,emHost,emSubject, emClass, emText){
	/*  outputs email link : emClass and emText are optional
		emClass is the name of the class for the <a> tag
		emText is the text shown - defaults to email address
	*/
	var emClass = (emClass == null) ? "" : 'class="'+ emClass +'"';
	var emText = (emText == null) ? emName + "@" +emHost : emText;
	document.write ('<a href="mailto:' + emName + '@' + emHost + emSubject +'"' + emClass + ' onClick="doTracking()">');
	document.write (emText + '</a>');
}
// -------------------------------------------------------------

function findPos(obj) {
	this.X = obj.offsetLeft;
	this.Y = obj.offsetTop;
	while(obj.offsetParent){
		this.X=this.X+obj.offsetParent.offsetLeft;
		this.Y=this.Y+obj.offsetParent.offsetTop;
		if(obj==document.getElementsByTagName('body')[0]){break}
		else{obj=obj.offsetParent;}
	}
	return this
}
// -------------------------------------------------------------

function browserType() {
    t = "Other";
    if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4)) 
		t = "NS";
    if ((navigator.appName == "Microsoft Internet Explorer") &&	(parseInt(navigator.appVersion) >= 4)) 
		t = "IE";
    return t;
}
var thisBrowser = browserType();
// -------------------------------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// -------------------------------------------------------------

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
// number formatting function
// copyright Stephen Chapman 24th March 2006, 10th February 2007
// permission to use this function is granted provided
// that this copyright notice is retained intact
// -------------------------------------------------------------

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0');y.splice(z, 0, pnt); if(y[0] == pnt) y.unshift('0'); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}
// -------------------------------------------------------------
function doSearchForm(){
	var frm  =document.frm_search;
	var t_or_f = true;
	if(frm.search_phrase.value == ""){
		t_or_f = false;
		alert("Please enter a word or phrase to search for.");
	}
	if(t_or_f){
		showHide("div_search_fields","none");
		showHide("div_searching","block");
		frm.submit();	
	}
}

// -------------------------------------------------------------
function doTracking(){
	info_popup('mailer.php', 1);
}

