﻿// JScript File
<!--
    focusedFormControl = '';

    if (document.getElementsByTagName) onload = function () {
    var e, i = 0;
    while (e = document.getElementsByTagName ('INPUT')[i++]) {
        if (e.type == 'text') e.onfocus = function () {focusedFormControl = this}
        }
    }
   
   if (document.getElementsByTagName) onsubmit = function () {
        //alert('test');
    } 
   
function searchClick()
{
	//alert("test");
	//var tb = document.getElementById('ctl00_HeaderContainer_searchtext');
	var tb = document.getElementById('searchtext');
	if(tb)
	{ 
		if(tb = focusedFormControl)
		{ 
			//this.window.location.href = '?search=' + tb.value;
			this.window.location.href = '/search.aspx?search=' + tb.value;
		 } 
	}    
}    

function zipClick(oEvent)
{
	//alert("test");
	if(!oEvent && window.event) oEvent = window.event;

	if(oEvent)
	{
	//try {
		if( oEvent.keyCode == 13 ) {
			return false;
			if( document.getElementById('searchtext').value != "" )			
				searchClick(); 
			return false;
		}
	//} catch (err) { return true; }
	}
	
	var tb = document.getElementById('ctl00_HeaderContainer_zipcode');
	if(tb)
	{ 
       if(("" + tb.value).length >= 5) 
        {
			aux = "";
			url = document.location.href.toLowerCase();
			if( url.indexOf('raceway') > 0 || url.indexOf('availablestores') > 0 )
				aux = "&folder=22";
            this.window.location.href = '/search-results.aspx?zip=' + tb.value + "&id=1368" + aux;
			return false;
        } 
	}
}

// -->
