var page = '';
var site = '';
function init()
{
	page = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1);
	site = document.domain.replace(/^(local|www)./,'');
	if(typeof(onload_updates) == 'function') onload_updates(site);
	if(typeof(load_product_list) == 'function') load_product_list();
}

/* http://www.netlobo.com/url_query_string_javascript.html */
function gup(name, href)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( href );
  return (results == null) ? "" : results[1];
}

/* http://www.dreamincode.net/code/snippet70.htm */
function isZipValid(s)
{
	reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

	return reZip.test(s);
}

function inputOnlyNumbers(evt)
{
	var e = window.event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;
	if ((charCode > 47 && charCode < 58) || charCode == 8 || charCode == 9 || charCode == 46)
	{
		return true;
	}
	return false;
}

function isValidNumber(val)
{
	if(val==null){return false;}
	if (val.length==0){return false;}
	var DecimalFound = false;
	for(var i = 0; i < val.length; i++)
	{
		var ch = val.charAt(i);
//		if(i == 0 && ch == "-")
//		{
//			continue;
//		}
		if(ch == "." && !DecimalFound)
		{
			DecimalFound = true;
			continue;
		}
		if(ch < "0" || ch > "9")
		{
			return false;
		}
	}
	return true;
}

function inputOnlyPhoneNumbers(evt)
{
	var e = window.event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;
	if ((charCode > 47 && charCode < 58) || charCode == 8 || charCode == 9 || charCode == 43 || charCode == 32 || charCode == 45)
	{
		return true;
	}
	return false;
}

/* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */
function echeck(str)
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
 	return true;
}

/* http://www.trap17.com/index.php/Image-Highlight-Mouseovered_t38231.html */
function makevisible(cur, which)
{
	strength = (which == 0) ? 1 : 0.6;
	if (cur.style.MozOpacity) cur.style.MozOpacity=strength;
	else if (cur.filters) cur.filters.alpha.opacity=strength*100;
}

window.onload = init;
