$(document).ready(
	function() {
	// hide everything on the same level as the .handler.  Case sensitive
	var DocName = returnDocument();
	$(".menu > .handler").siblings().toggle();
	if(DocName == "BestOverview.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "OnlineAcctAccess.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "AccountAccessReq.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "ProdCrossRef.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "EmailInv.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "EDI.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "AIM.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "BestSupport.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "HelpUs.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "EFT.asp") {
		$("#best").siblings().toggle();
	}
	else if (DocName == "ProductsServices.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "ProprietaryBrands.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "Brigade.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "Seasons.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "ProValue.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "Plumbing.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "HVAC.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "IPVF.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "PlumbingSuppliers.asp") {
		$("#products").siblings().toggle();
	}
	else if (DocName == "News.asp") {
		$("#pressroom").siblings().toggle();
	}
	else if (DocName == "CommunityService.asp") {
		$("#pressroom").siblings().toggle();
	}
	;
	
	$(".menu > .handler").click(function() {
		 //hideAll();
		$(this).siblings().slideToggle("fast");
	});
  }
);


function expandAll() {
	$(".menu > .handler").siblings().slideDown("fast");
}
function hideAll() {
	$(".menu > .handler").siblings().not(".show").slideUp("fast");
/* note that I've added a not(".show") here to make sure you can still
   show some paragraphs if you want that. simply give them a class="show" */
}
function addDestination(loc) {
	document.getElementById("daddr").value = loc;
	window.location.hash="maptop"; 
}
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function returnDocument() {
	var file_name = document.location.href;
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	return file_name.substring(file_name.lastIndexOf("/")+1, end);
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

//used for form validation
function NumOnly(field,msg)
{
	if (field.value == "")
	{
		return true
	}
	if (msg == "")
	{
		msg = "Invalid entry!  Only numbers are accepted!"
	}
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{
			ok = "no";
		}
	}
	if (ok == "no")
	{
		alert(msg);
		field.focus();
		field.select();
		return false;
	}
}

function ValidatePhone(field,msg)
{
	if (field.value == "")
	{
		return true
	}
	if (msg == "")
	{
		msg = "You've entered an invalid phone or fax number.  Please use one of the 999.999.9999 formats!"
	}
	
	var valid = "0123456789"
	var temp;
	var phonenum = ""
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) >= 0)
		{
			phonenum = phonenum + temp
		}
	}
	
	if (phonenum.length != 10)
	{
		alert(msg);
		field.focus();
		field.select();
		return false;
	}
	
	var pattern = /\d\d\d\d\d\d\d\d\d\d/
	if (pattern.test(phonenum) == false)
	{
		alert(msg);
		field.focus();
		field.select();
		return false;
	}
	var phonenumber = phonenum.substring(0,3) + "."+phonenum.substring(3,6)+"."+phonenum.substring(6,10) 
	field.value = phonenumber
}

function ValidateEmail(field,msg)
{
	if (field.value == "")
	{
		return true
	}
	var Email = field.value
	if (msg == "")
	{
		msg = "You've entered an invalid Email Address.  Please use the yourname@yourdomain.com format."
	}
//    re = /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/
      re = /^([-A-Za-z0-9_"."])*(\w+)@([-A-Za-z0-9_"."])+([a-zA-Z]{2,4})$/

    if (re.test(Email)== false)
	{
		alert(msg);
		field.focus();
		field.select();
		return false;
	}
}

//Hide and Show larger images on hover
function showImg(img)
	{
		document.getElementById('Imgholder').style.display='inline';
		document.getElementById('IMG').src=img;
	}

function hideImg()
	{
		document.getElementById('Imgholder').style.display='none';
	}

//function for login form
function browserType()

  {
    if (navigator.appName != "Microsoft Internet Explorer")
    {
      browser = '<input type="hidden" name="BROWSER" value="NS">';
    }
    else
    {
      browser = '<input type="hidden" name="BROWSER" value="IE">';
    }
    document.write(browser);
  }
