
function init()
{
//    window.setTimeout('rolloversInit();', 500);
    alert('Test');
//    rolloversInit(1);
}
/*
submitDealerLocatorHeader
*/
//Start
function trimAll(sString) 
	{
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
			sString = sString.substring(0,sString.length-1);
		}
		return sString;
	}
function IsNumeric(sText)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	
		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
		Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}
	return IsNumber;
}
		// End trim function
function submitDealerLocatorHeader()
	{	
	    var bool= true;
	    var objZip = document.frmLocator.txtZipCode;
		if ((trimAll(objZip.value)).length == 0 || objZip.value == "Find a Dealer (Enter Zip)"
		        || objZip.value == "Please enter a Postal code.") 
		{
		 	//alert('Please enter a Postal code.');
			//objZip.focus();
			objZip.style.color = '#e03d27';
			if (objZip.value.indexOf('Please enter')< 0)
              {
                objZip.value = "Please enter a Postal code.";
              }
			bool = false;
		} 
        else
        {
        //document.frmLocator.submit();
        //alert('submit');
        window.name="this";
	    window.open("/Residential/Dealer-Info/Dealer-Locator?txtZipCode=" + document.frmLocator.txtZipCode.value,"this");
	    bool = true;
         }                             
		return bool;
	}

//End
		
	
/*-------------------------------------------------------------------------------
Function:   openGlossaryWindow
Documented: 27 June 2002 By Brian Payne
Purpose:    Opens the glossary page in small pop-up window. If a word is 
            specifed the page jumps to that word.
Parameters: strWord - the selected word
Returns:    none
-------------------------------------------------------------------------------*/
function openGlossaryWindow(strWord)
{
	openWindow("/Residential/NewSystem/Glossary/GlossaryPopup.asp#" + strWord, "winGlossary", "scrollbars=yes,resizable=yes,width=200,height=300");
}

function openWindow(location, windowName, windowParams)
{
    window.open(location, windowName, windowParams);
}

function custMoreInfo(topic) {
	var whatsthis
	var url = '/Residential/whatsthis.aspx?topic=' + topic
	if(!whatsthis || whatsthis.closed) {	
	whatsthis = window.open(url,'whatsthis', 'width=310,height=300,resizable=yes,scrollbars=1');
	}
	whatsthis.focus();
}

function SwapImage(objectID, task)
{
    //alert('SwapImage Called');
    var object = document.getElementById(objectID);
    if (task == 'on')
    {
        object.src = object.src.replace('.','_on.');
    }
    else
    {
        object.src = object.src.replace('_on.','.');
    }
}

function SetValue(obj)
{
    var p_1 = document.getElementById('p1');
    var p_2 = document.getElementById('p2');
    var p_3 = document.getElementById('p3');
    if (obj.checked)
    {
        if (p_1.value == '')
        {    p_1.value = obj.value;}
        else if (p_2.value == '')
        {    p_2.value = obj.value;}
        else if (p_3.value == '')
        {    p_3.value = obj.value;}
        else
        {
            alert('Only two or three products can be compared at one time');
            obj.checked = false;
        }  
    }
    else
    {
        if (p_1.value == obj.value)
        {
            p_1.value = '';
            if (p_2.value != '') {p_1.value = p_2.value; p_2.value = '';}
            if (p_3.value != '') {p_2.value = p_3.value; p_3.value = '';}
        }
        else if (p_2.value == obj.value)
        {
            p_2.value = '';
            if (p_3.value != '') {p_2.value = p_3.value; p_3.value = '';}
        }
        else if (p_3.value == obj.value)
        {
            p_3.value = '';
        }
    }   
}

function SubmitResults()
{
    var p_1 = document.getElementById('p1');
    var p_2 = document.getElementById('p2');
    var p_3 = document.getElementById('p3');
    if (p_1.value != '' && p_2.value != '')
    {
        var sPage = 'ComparisonResults.aspx?p1=' + p_1.value + '&p2=' + p_2.value + '&p3=' + p_3.value;
        window.location = sPage;
    }
    else
    {
        alert('Must select two to three products');
    }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
var isIE6 = false;
if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6')
{
    isIE6 = true;
}

//function rolloversInit(numCalls) {
//	alert('rolloverInit called');
//	if (!document.getElementById) return;
//	
//	var arrPreload = new Array();
//	var strSrcTmp;
//	var arrImages = document.getElementsByTagName('img');
//	alert(arrImages.length);
//    if (arrImages.length == 0 && numCalls < 4)
//    {   
//        numCalls += 1;
//        window.setTimeout('rolloversInit(' + numCalls + ');', 500);
//        return;
//    }
//	for (var i=0; i<arrImages.length; i++) {
//		if (arrImages[i].className.indexOf("imgOver") == 0) {
//			alert(arrImages[i].id);
//			var src = arrImages[i].src;
//			var imgtype = src.substring(src.lastIndexOf("."), src.length);
//			if ( src.match("_on" + imgtype)==null )
//			    var altsrc = src.replace(imgtype, "_on" + imgtype);
//			else
//			    var altsrc = src;

//			arrImages[i].setAttribute('altsrc', altsrc);
//			arrPreload[i] = new Image();
//			arrPreload[i].src = altsrc;
//			
//			arrImages[i].onmouseover = function() {
//				strSrcTmp = this.getAttribute('src');
//				this.setAttribute('src', this.getAttribute('altsrc'));
//			}

//			arrImages[i].onmouseout = function() {
//				if (!strSrcTmp) 
//				   strSrcTmp = this.getAttribute('src').replace("_on" + imgtype, imgtype);
//				this.setAttribute('src', strSrcTmp);
//			}

//		}
//	}
//}
//window.onload = init;
