function MM_openBrWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
}

//Start AutoForm ClearTXT
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

function readCookie(name) {
    var cookieCrumbs = document.cookie.split(';');
	var nameToFind = name + '=';
	for (var i = 0; i < cookieCrumbs.length; i++) {
	    var crumb = cookieCrumbs[i];
	    while (crumb.charAt(0) == ' ') {
	        crumb = crumb.substring(1, crumb.length); /* delete spaces */
	    }
	    if (crumb.indexOf(nameToFind) == 0) {
	        return crumb.substring(nameToFind.length, crumb.length);
	    }
	}
	return null;
}

function eraseCookie(name) {
    createCookie(name, '', -1);
}

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target)
        return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target)
        return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}
//End AutoForm ClearTXT

//Start Old PriceChecker
function old_pcsearch(id) {
    var text = document.pcform.ID.value;
    if((text == "Enter Part # Here")||(text == "")||(text == " ")) {
        alert("Please Enter a Part Number");
        document.pcform.ID.focus();
        return false;
    } else {
        whatever = "/pc3.html?id=" + text;
        if(id == "pcform") {
            window.open(window.location.href.replace(window.location.pathname, whatever) , "popup", "width=627,height=535,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"); pcform.submit();
        }
        if(id == "pcsubmit") {
            window.open(window.location.href.replace(window.location.pathname, whatever) , "popup", "width=627,height=535,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"); pcform.submit();
        }
    }
}
//End Old PriceChecker

//Start PriceChecker
function pcsearch(id, fullUrl) {
    var text = document.pcform.ID.value;
    //Modification. plunnebe 2/3/2010. Trim the value before operating on it
    text = unescape(text).replace(/^\s+|\s+$/g, "");
    if((text == "Enter Part # Here")||(text == "")||(text == " ")) {
        alert("Please Enter a Part Number");
        document.pcform.keyword.focus();
        return false;
    } else {
        if(id == "pcform") {
            window.open((fullUrl ? fullUrl : "http://appliancezone.com/") + "pc3.html?id=" + text, "popup", "width=627,height=535,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"); pcform.submit();
        }
        
        if(id == "pcsubmit") {
            window.open((fullUrl ? fullUrl : "http://appliancezone.com/") + "pc3.html?id=" + text, "popup", "width=627,height=535,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"); pcform.submit();
        }
    }
}
//End PriceChecker

window.onload = function OnLoadAdjust() {
    // get a reference to the three DIVS that make up the columns
    var Body = window.document.getElementById('body');
    var Mcol = window.document.getElementById('middlecol');
    var Lcol = window.document.getElementById('leftcol');
    var Rcol = window.document.getElementById('rightcol');
    // calculate the max height
    var hBody = Body.offsetHeight;
    var hMcol = Mcol.offsetHeight;
    var hLcol = Lcol.offsetHeight;
    if (Rcol != null) {
        var hRcol = Rcol.offsetHeight;
    }
    if (Rcol != null) {
        var maxHeight = Math.max(hBody, Math.max(hMcol, hLcol, hRcol));
    } else {
        var maxHeight = Math.max(hBody, Math.max(hMcol, hLcol));
    }
    // set the height of all 3 DIVS to the max height
    Body.style.height = maxHeight + 'px';
    Mcol.style.height = maxHeight + 'px';
    Lcol.style.height = maxHeight + 'px';
    if (Rcol != null) {
        Rcol.style.height = maxHeight + 'px';
    }
    var BTN = document.getElementById("middlecol").getElementsByTagName("input");
    for (var i = 0; i < BTN.length; i++) {
        if (BTN[i].type == "button" || BTN[i].type == "submit" || BTN[i].type == "reset") {
            if (BTN[i].className.length > 0)
                BTN[i].className += " inputBTN";
            else
                BTN[i].className = "inputBTN";
        }
    }
}
  
  function PartZone() {
	var product = document.getElementById('product');
	if (product.value != "Product Search" && product.value != "" && product.value != " ")
	   {
	    var url = window.location.href;
	    var pathArray = url.split("/");

	    //var hurl = pathArray[0] + pathArray[1] + "//" + pathArray[2] + "/" + pathArray[3]; 
		var hurl = location.protocol + "//" + location.hostname;
		
  		hurl1 = hurl + "/SearchProducts.aspx?id=" + product.value;
	    location.href = hurl1;
	   }
	else {
	  alert("Please enter a product number");
	  return;
	}
  }
  
  function PriceChecker() {
	var product = document.getElementById('pctxt');
	if (product.value != "Enter Part # Here" && product.value != "" && product.value != " ")
	   {
	    var url = window.location.href;
	    var pathArray = url.split("/");

		//var hurl = location.protocol + "//" + location.hostname;
		var hurl = "https://appliancezone.com";
	       
  		hurl1 = hurl + "/SearchProducts.aspx?id=" + product.value;
  		hurl2 = hurl + "/pc3.html?id=" + product.value;
	  	window.open(hurl2, "popup", "width=627,height=535,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
	    location.href = hurl1;
	   }
	else
	  {
	  alert("Please enter a product number");
	  return;
	  }
  }
  
  function PartSearch(){
	var url = "SearchProducts.aspx";
	var product = document.getElementById('SearchText');
	if (product.value != "" && product.value != " "){
	  url = url + "?id=" + product.value;
	  location.href = url;
	}
	else {
	  alert("Please enter a product number");
	  return;
	}
  }