<!-- Begin
	/* This script and many more are available free online at
	The JavaScript Source!! http://javascript.internet.com
	Created by: Ultimater :: http://ultimiacian.tripod.com/
	Add this snippet to the very beginning of your script. */

	if(!document.getElementById){
	if(document.all)
	document.getElementById=function(){
		if(typeof document.all[arguments[0]]!="undefined")
		return document.all[arguments[0]]
		else
		return null
	}
	else if(document.layers)
	document.getElementById=function(){
		if(typeof document[arguments[0]]!="undefined")
		return document[arguments[0]]
		else
		return null
	}
	}
	// End -->

	browserName=navigator.appName;
	browserVer=parseInt(navigator.appVersion);
	
	if (browserVer > 2) {
	
	Home_R = new Image(95, 55);
	Home_R.src="images/Home_R.gif";
	Home_O = new Image(95, 55);
	Home_O.src="images/Home_O.gif";	
	Home_A = new Image(95, 55);
	Home_A.src="images/Home_A.gif";		
	
	DashImg = new Image(5, 9);
	DashImg.src="images/SideNavDash.gif";
	ClearImg = new Image(5, 9);
	ClearImg.src="images/Clear.gif";
	
	}
	
	function Dash_Roll(imgName) {
		var el = document.getElementById(imgName);
		if (el != null) {
				el.src = DashImg.src;
		}
	}
		
	function Dash_UnRoll(imgName) {
		var el = document.getElementById(imgName);
		if (el != null) {
				el.src = ClearImg.src;
		}

	}		
	
	function RollIt(imgName) {
		var el = document.getElementById(imgName);
		el.src = eval(imgName + "_O.src");
	}
	
	function UnRollIt(imgName, RorA) {
		var el = document.getElementById(imgName);
		if (RorA == 'A')
		    { el.src = eval(imgName + "_A.src"); }
		else
		    { el.src = eval(imgName + "_R.src"); }
	}
      
function FindMyControl(MyID) {

	var frmElements,i,t,ctl;
	
	// Since the use of master pages mangles the names of child controls, we need a method 
	// of searching through the form elements and returning a reference to the control we are 
	// looking for that control by the name we know it as instead of the dumb-ass name ASP.Net creates.
	// First scan through all of the input elements and look for our control
    frmElements=document.getElementsByTagName('input');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }
   // Still not found, scan through all of the select elements
    frmElements=document.getElementsByTagName('select');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    } 
   
   // Still not found, scan through all of the textarea elements
    frmElements=document.getElementsByTagName('textarea');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }
   
   // Still not found, scan through all of the textarea elements
    frmElements=document.getElementsByTagName('td');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }      
   
   // Still not found, scan through all of the textarea elements
    frmElements=document.getElementsByTagName('img');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }     

   // Still not found, scan through all of the iframe elements
    frmElements=document.getElementsByTagName('div');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }        
    
   // Still not found, scan through all of the iframe elements
    frmElements=document.getElementsByTagName('a');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }      
   
    return false;         

}       

function PositionLayer(LayerName, OffSetX, OffSetY) {

	var imgX;
	var imgY;
	var el;
		
	if (OffSetX == 450 ) { OffSetX = 325 }		// correction
	if (navigator.appVersion.indexOf('MSIE 7') > -1) { OffSetY = OffSetY + 20 } // correct for IE 7
	
	imgX = (document.body.clientWidth / 2);	// find the center of the window
	imgX = imgX - OffSetX
	imgY = OffSetY;
	// adjust for scroll position
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
    var dsoctop=document.all? iebody.scrollTop : pageYOffset
    imgY = imgY + dsoctop;
    
    el = document.getElementById(LayerName);
	el.style.left = imgX + 'px';
	el.style.top = imgY + 'px';
}

function ShowLayer(LayerName) {		

	var BrowserType = "";
	if(document.layers) { BrowserType="NN4" }
	if(document.all) { BrowserType="IE"  }
	if(!document.all && document.getElementById) { BrowserType="NN6" } 
	if (BrowserType=="") { BrowserType="IE"  }	// default to IE, just because....

	if (BrowserType=="IE") { document.all[LayerName].style.visibility = 'visible' }
	if (BrowserType=="NN4") { document.layers[LayerName].visibility = 'visible' }
	if (BrowserType=="NN6") { document.getElementById(LayerName).style.visibility='visible' }
	
}

function CancelLayer(LayerName) {

	// determine our browser type for layer usage
	var BrowserType = "";
	if(document.layers) { BrowserType="NN4" }
	if(document.all) { BrowserType="IE"  }
	if(!document.all && document.getElementById) { BrowserType="NN6" } 
	if (BrowserType=="") { BrowserType="IE"  }	// default to IE, just because....

	if (BrowserType=="IE") { parent.document.all[LayerName].style.visibility = 'hidden' }
	if (BrowserType=="NN4") { parent.document.layers[LayerName].visibility = 'hidden' }
	if (BrowserType=="NN6") { parent.document.getElementById(LayerName).style.visibility='hidden' }
}	

// QUICK SEARCH Scripts ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var PreviousKeyword = '';
var Tmr1;
var BusySearching = false;
var CancelClear = false;
var lnkCnt  = -1;

function DoSearch() {

    var el;
    var CurrentKeyword = '';
    var SiteFlag = '';
    var Action = '';
    var Param = '';
    var CustNo = '';
    
    clearTimeout(Tmr1);
       
    el = FindMyControl('hdCustNoForSearching');
    CustNo = el.value;
    el = FindMyControl('hdSiteFlag');
    SiteFlag = el.value;
    el = FindMyControl('txtQuickSearch');
    CurrentKeyword = el.value;
        
    if (PreviousKeyword != CurrentKeyword && CurrentKeyword.length >= 2 ) {
        Catalog.QuickSearchCatalog(SiteFlag, CurrentKeyword, Action, Param, CustNo, DrawQuickSearchResults, ErrorHandler, TimeOutHandler);
    }

    PreviousKeyword = CurrentKeyword;
    BusySearching = true;
    lnkCnt  = -1;
    Tmr1 = setTimeout('DoSearch()', 300);

}

function StopSearch() {

    clearTimeout(Tmr1);
    Tmr1 = setTimeout('ClearSearchResults()', 600);
    
}

function ClearSearchResults() {
    
    var el;
    clearTimeout(Tmr1);
    if ( CancelClear == false ) {
        el = document.getElementById('divSearchResults');
        el.style.visibility = 'hidden';
        el.innerHTML = '';
        BusySearching = false;
    }
    else
    {
        CancelClear = false;
        Tmr1 = setTimeout('ClearSearchResults()', 2000);
    }

}

function fnTrapKD(ev) {

	var kc = 0;
	var BrowserType = '';
	var el;
	
	if ( BusySearching == false ) { return };
	
	// determine our browser type 
	if(document.layers) { BrowserType='NN4' }
	if(document.all) { BrowserType='IE'  }
	if(!document.all && document.getElementById) { BrowserType='NN6' } 
	
	if ( BrowserType == 'IE' ) { kc = event.keyCode }
		else { kc =((ev.which)||(ev.keyCode)) }
		
	if ( kc == 40 ) { // Down Arrow
        // increment link cnt
        lnkCnt += 1;	
	    el = document.getElementById('lnkQS' + lnkCnt);
	    if ( el != null ) { 
	        el.focus(); 
	        CancelClear = true;
	        // highlight  current cell
	        el = document.getElementById('tdQS' + lnkCnt);
	        if ( el != null ) { el.className = 'tdQS_Title_Selected'; }
	        // un-highlight previous
	        el = document.getElementById('tdQS' + (lnkCnt - 1));
	        if ( el != null ) { el.className = 'tdQS_Title'; }
	        }	    
	}
	
	if ( kc == 38 ) { // Up Arrow
        // decrement link cnt
        lnkCnt -= 1;
        if ( lnkCnt < 0 ) { el = FindMyControl('txtQuickSearch'); el.focus(); BusySearching = false; PreviousKeyword = ''; return; }
	    el = document.getElementById('lnkQS' + lnkCnt);
	    if ( el != null ) { 
	        el.focus(); 
	        CancelClear = true;
	        // highlight  current cell
	        el = document.getElementById('tdQS' + lnkCnt);
	        if ( el != null ) { el.className = 'tdQS_Title_Selected'; }
	        // un-highlight previous
	        el = document.getElementById('tdQS' + (lnkCnt + 1));
	        if ( el != null ) { el.className = 'tdQS_Title'; }
	        }	    
	}	
	
}

function DrawQuickSearchResults(results) {

    var el;
    var HTML;
    var T;
    var KeywordHold;
    var classname;
    var link;
        
    el = document.getElementById('divSearchResults');
    el.style.visibility = 'visible';
    
    // run the rows
    HTML = '<table>';
    for (var i = 0; i < results.length; i++) {
        HTML += '<tr>';
        T = results[i].FAMILY_NAME;
        KeywordHold = PreviousKeyword;
        T = HighlightSearchTerm(T, KeywordHold);
        // set class name
        if ( (i % 2) == 0 ) { classname = 'tdQS_Title' }
            else { classname = 'tdQS_Title_gray' }
        // build up link
        link = 'ItemPage.aspx?Selected_Category=' + results[i].CATEGORY_ID + '&FAMILY_ID=' + results[i].FAMILY_ID + '&ST=' + escape(KeywordHold);
        if ( results[i].ItemNo.length > 0 ) { link = link + '&PreSelectedItemNo=' + results[i].ItemNo }
                    
        HTML += '<td class="' + classname + '" id="tdQS' + i + '"><a href="' + link + '" id="lnkQS' + i + '">' + T + '</a>';
        // History icon
        if ( results[i].History != '' ) { HTML += '&nbsp;<img src="images/History-Icon.png" width="19" height="17" align="absmiddle" title="History" />'; }
        // Restrictions icon
        if ( results[i].Restrictions != '' ) { HTML += '&nbsp;<img src="images/Restriction-Icon.png" width="19" height="17" align="absmiddle" title="Restricted" />'; }        
        // Promotion icon
        if ( results[i].Promotion != '' ) { HTML += '&nbsp;<img src="images/Promo-Icon.png" width="19" height="17" align="absmiddle" title="Promotion" />'; }                
        // Quote only icon
        if ( results[i].Quote_Only = 0 ) { HTML += '&nbsp;<img src="images/Quote-Icon.png" width="19" height="17" align="absmiddle" title="Quote only" />'; }                        
        HTML += '</td>';
        HTML += '</tr>';
    }

    HTML += '<tr>';
    HTML += '<td class="tdQS_Title" id="tdQS' + i + '">&nbsp;<br /><a href="javascript: GatherNGo();" id="lnkQS' + results.length + 1 + '"><span class=spReplaceText><b>... click here for a complete list of results</b></span></a></td>';
    HTML += '</tr>';
    
    HTML += '</table>';
        
    el.innerHTML = HTML;

}

function HighlightSearchTerm(TextIn, SearchTerm) {

    var TextOut = '';
    var Pos;
    var Len
    var frag;
    var safetyCnt = 0;
    
    Pos = 0;
    Len = TextIn.length;
    
    while (Pos < Len) {
        frag = TextIn.substring(Pos, Pos + SearchTerm.length)
        if (frag.toUpperCase() == SearchTerm.toUpperCase() ) {
            TextOut = TextOut + '<span class=spReplaceText>' + frag + '</span>';
            Pos = Pos + SearchTerm.length;
        }
        else {
            TextOut = TextOut + TextIn.substring(Pos, Pos + 1);
            Pos = Pos + 1;
        }
        
        safetyCnt += 1;
        if ( safetyCnt > 200 ) { Pos = 9999 };
    
    }
    
    return TextOut;

}

function ErrorHandler(result) {
    var msg = result.get_exceptionType() + "\r\n";
    msg += result.get_message() + "\r\n";
    msg += result.get_stackTrace();
    alert(msg);
}

function TimeOutHandler(result) {
    alert("Timeout :" + result);
}

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;
   
   }

var _MessageBoxType;

function AddToCart(MessageBoxType) {

    var el;
    var t;
    var OkToGo = false;
    var QuoteOnly;
    var tDbl;
    var elConversion;
    var Conversion;
    var validateConversion;
    
    var SiteFlag, CustNo, Q_ID, OrderID, LineNum, strLItemNo, Qty, UnitPrice, LItemNo, ItemName, Family_ID, Selected_Category;
    var SizeRequired,ColorRequired;
    
    _MessageBoxType = MessageBoxType;
    
    // get our size and color requirement flags
    el = document.getElementById('hdSizeRequired');
    if ( el.value == 'True' ) { SizeRequired = true }
        else { SizeRequired = false }
    el = document.getElementById('hdColorRequired');
    if ( el.value == 'True' ) { ColorRequired = true }
        else { ColorRequired = false }         
    // validate that correct size and colors are selected
    if ( SizeRequired == true && ColorRequired == true ) {
        el = FindMyControl('selSize');
        t = el[el.selectedIndex].value;
        t = t.split('|');
        if ( t.length != 6 ) { alert('Please select a product size option.\n\nThe product size selection is located above the \"Add to Cart\" button.'); return; }
        el = FindMyControl('selColor');
        t = el[el.selectedIndex].value;
        t = t.split('|');
        if ( t.length != 6 ) { alert('Please select a color option.\n\nThe product color selection is located above the \"Add to Cart\" button.'); return; }
    }
    if ( SizeRequired == true && ColorRequired == false ) {
        el = FindMyControl('selSize');
        t = el[el.selectedIndex].value;
        t = t.split('|');
        if ( t.length != 6 ) { alert('Please select a product size option.\n\nThe product size selection is located above the \"Add to Cart\" button.'); return; }
    }    
    if ( SizeRequired == false && ColorRequired == true ) {
        el = FindMyControl('selColor');
        t = el[el.selectedIndex].value;
        t = t.split('|');
        if ( t.length != 6 ) { alert('Please select a color option.\n\nThe product color selection is located above the \"Add to Cart\" button.'); return; }
    }  
    if ( SizeRequired == false && ColorRequired == false ) {
        el = FindMyControl('selSize');
        t = el[el.selectedIndex].value;
        t = t.split('|');
        if ( t.length != 6 ) { alert('Please select a product size option.\n\nThe product size selection is located above the \"Add to Cart\" button.'); return; }
    }       
    // validate that something was selected
    if ( t.length != 6 ) { alert('Please select a product size option.\n\nThe product size selection is located above the \"Add to Cart\" button.'); return; }
    LItemNo = t[1];
    UnitPrice = t[2];
    UnitPrice = UnitPrice.replace('$', '');
    
    // validate qty
    validateConversion = false;
    el = FindMyControl('txtQty');  // for qty
    elConversion = FindMyControl('hdQty_Conversion'); // for conversion attribute
    if ( elConversion != false ) {
        validateConversion = true;
    }
    if ( IsNumeric(el.value) == false ) {
        alert('The quantity you have provided does not appear to be a valid number.\n\nPlease review your quantity value and make sure that is a valid number.');
        return;
    }
    Qty = el.value;
    if ( validateConversion ) {
        t = elConversion.value;
        if ( IsNumeric(t) == false ) { t = 10 }
        Conversion = parseInt(t);
        Qty = parseInt(Qty);
        if ( (Qty % Conversion) > 0 ) {
            alert('This item must be ordered in multiples of ' + String(Conversion) + '.  Please adjust the quantity you have entered to be a multiple of ' + String(Conversion) + '.');
            return;
        }
        
    }

    // grab our required values
    el = FindMyControl('hdSiteFlag');
    SiteFlag = el.value;
    el = FindMyControl('hdCustNo');
    CustNo = el.value;    
    el = FindMyControl('hdQ_ID');
    Q_ID = el.value;
    el = FindMyControl('hdOrderID');
    OrderID = el.value;
    LineNum = 1;
    el = document.getElementById('divMfr');
    strLItemNo = el.innerHTML;
    el = FindMyControl('hdItemName');
    ItemName = el.value;
    el = FindMyControl('hdFamily_ID');
    Family_ID = el.value;
    el = FindMyControl('hdSelected_Category');
    Selected_Category = el.value;
    el = FindMyControl('hdQuoteOnly');
    QuoteOnly = el.value;
    
    // we have a new method for determining if it is quote only or not - 5/14/2009
    // if there's not price, then it's quote, if there is a price then it's to cart
    tDbl = parseFloat(UnitPrice);
    if (tDbl <= 0 ) { QuoteOnly = 'True' }
        else { QuoteOnly = 'False' }
    
    // add via an ajax call
   Catalog.AddLineItem(SiteFlag, CustNo, Q_ID, OrderID, LineNum, strLItemNo, Qty, UnitPrice, LItemNo, ItemName, Family_ID, Selected_Category, QuoteOnly, AddToCartResults, ErrorHandler, TimeOutHandler);
     
}

function AddToCartResults(results) {

    var el;
    var HTML;
    var CartLink;
    var t;
    
    if ( results.substring(0, 5) != 'ERROR' ) {
        // show success message
        el = FindMyControl('hdItemName');
        HTML = '<b>' + el.value + '</b> was successfully added to your cart.';
        // results will contain a line count and quote/order id since it may be knew
        results = results.split('|');
        if ( results.length == 3 ) {
            // set quote count
            el = FindMyControl('divQuoteCnt');
            el.innerHTML = '(' + results[0] + ')';
            // set new id in cookie
            if ( results[1] == 'Q_ID' ) {
                document.cookie = 'Q_ID=' + results[2];
            }
            else {
                document.cookie = 'OrderID=' + results[2];
            }                
        }
        
    }
    else {
        HTML = results;
    }

    if ( _MessageBoxType == 'Regular' ) {
        if ( document.cookie.indexOf('DoNotShow=Yes') == -1 ) {
            grayOut(true);
            el = document.getElementById('divItemPageMsg');
            el.innerHTML = HTML;
            el = document.getElementById('divItemPageMsgLayer');
            el.style.visibility = 'visible';
            el = FindMyControl('hdCartLink');
            CartLink = el.value;
            el = FindMyControl('lnkCart');
            if (el != false) {
                el.href = CartLink;
            }
        }
    }        
    else {
        // only show this pop-up if they have not told you not to
        if ( document.cookie.indexOf('DoNotShow=Yes') == -1 ) {
            grayOut(true);
            el = FindMyControl('hdItemName');
            t = el.value;
            el = document.getElementById('spProductName');
            el.innerHTML = t;
            el = document.getElementById('divAddToQuoteMsgLayer');
            el.style.visibility = 'visible';
            el = FindMyControl('hdCartLink');
            CartLink = el.value;
            el = FindMyControl('lnkViewCart_Quote');
            if (el != false) {
                el.href = CartLink;
            }  
            el = FindMyControl('lnkCart');
            if (el != false) {
                el.href = CartLink;
            }                  
        }
        
        
    }
    
}

function HideItemPageMsg() {
    el = document.getElementById('divItemPageMsgLayer');
    el.style.visibility = 'hidden';
    grayOut(false);
}

function HideAddToQuoteMsgLayer() {
    el = document.getElementById('divAddToQuoteMsgLayer');
    el.style.visibility = 'hidden';
    grayOut(false);
}

function ToggleDoNotShow() {

    if ( document.cookie.indexOf('DoNotShow=Yes') > -1 ) {
        document.cookie = 'DoNotShow=No';
    }
    else {
        document.cookie = 'DoNotShow=Yes';
    }

}

function ToggleDoNotShowQuote() {

    if ( document.cookie.indexOf('DoNotShowQuote=Yes') > -1 ) {
        document.cookie = 'DoNotShowQuote=No';
    }
    else {
        document.cookie = 'DoNotShowQuote=Yes';
    }
    
}

function RemoveCartItem(Action, ID) {
    
    var el;
    
    el = FindMyControl('hdCartAction');
    el.value = Action
    
    el = FindMyControl('hdCartParam');
    el.value = ID
    
    el.form.submit();
    
}

function UpdateCart() {

    var el;
    
    el = FindMyControl('hdCartAction');
    el.value = "Update"
    
    el.form.submit();

}

function EmptyQuoteCart() {

    var el;
    
    if ( confirm('Are you sure you want to remove all items from your cart.\n\nClick Ok to continue or Cancel.') ) {
        el = FindMyControl('hdCartAction');
        el.value = "EmptyQuoteCart"
        el.form.submit();    
    }   
    
}


function SetItemDetails () {

    var el;
    var t;
    var SizeRequired;
    var ColorRequired;
    var img;
    var imgTag;
    var el2;
    var w;
    var h;
      
    // get our size and color requirement flags
    el = document.getElementById('hdSizeRequired');
    if ( el.value == 'True' ) { SizeRequired = true }
        else { SizeRequired = false }
    el = document.getElementById('hdColorRequired');
    if ( el.value == 'True' ) { ColorRequired = true }
        else { ColorRequired = false }         
    // validate that correct size and colors are selected
    if ( SizeRequired == true && ColorRequired == true ) {
        el = FindMyControl('selColor');
        t = el[el.selectedIndex].value;
        t = t.split('|');
    }
    if ( SizeRequired == true && ColorRequired == false ) {
        el = FindMyControl('selSize');
        t = el[el.selectedIndex].value;
        t = t.split('|');
    }    
    if ( SizeRequired == false && ColorRequired == true ) {
        el = FindMyControl('selColor');
        t = el[el.selectedIndex].value;
        t = t.split('|');
    }  
    if ( SizeRequired == false && ColorRequired == false ) {
        el = FindMyControl('selSize');
        t = el[el.selectedIndex].value;
        t = t.split('|');
    }        
    
    if ( t.length == 6 ) { 
            el = document.getElementById('divMfr');
            el.innerHTML = t[0];
            el = document.getElementById('divAHI');
            el.innerHTML = t[1];
            el = document.getElementById('divPrice');
            if ( el != null ) { el.innerHTML = t[2]; }
            // hide price if it is zero
            
            if ( t[2] == '$0.00' ) {
                el = document.getElementById('divPrice');
                if ( el != null ) { el.style.display   = 'none'; }
                el = document.getElementById('divWhyNoPrice');
                if ( el != null ) { el.style.display   = 'block'; }
                // set Add to cart or add to quote button
                el = FindMyControl('imgAddBtn');
                var QuoteBtn = new Image(115, 20);
	            QuoteBtn.src="images/AddToQuote.gif";
	            el.src = QuoteBtn.src;                
	            el = FindMyControl('lnkAddToCart');
	            el.href = "javascript: AddToCart('QuoteThing');"
            }
            else {
                el = document.getElementById('divPrice');
                if ( el != null ) { el.style.display   = 'block'; }
                el = document.getElementById('divWhyNoPrice');
                if ( el != null ) { el.style.display   = 'none'; }
                // set Add to cart or add to quote button
                el = FindMyControl('imgAddBtn');
                var CartBtn = new Image(115, 20);
	            CartBtn.src="images/AddToCart.gif";
	            el.src = CartBtn.src;
	            el = FindMyControl('lnkAddToCart');
	            el.href = "javascript: AddToCart('Regular');"
            }
            // set image
            img = t[3];
            img = img.replace('}', '\\');
            img = img.replace('}', '\\');
            img = img.replace('}', '\\');
            w = parseInt(t[4]);
            h = parseInt(t[5]);
            if (img.indexOf('.') > 0 && w > 0 ) {
            
                imgTag = '<img src="GetItemImage.aspx?i=' + escape(img) + '" width="' + w + '" height="' + h + '" alt="" />';
                el2 = document.getElementById('divItemImage');
                if ( el2 != null ) { el2.innerHTML = imgTag; }
                
            }
            
            
    }

}

var CurrentlySelectedText;

function RemoveAllItems(el_name) {
    var i;
    var el;
    
    el = FindMyControl(el_name);
    // grab the currently selected text
    CurrentlySelectedText = el[el.selectedIndex].text;
    for(i=el.options.length-1;i>=0;i--)
    {
        el.remove(i);
    }
}

function AddItem(el_name, txt, val) {

    var el;
    var optn;
    
    el = FindMyControl(el_name);
    optn = document.createElement('OPTION');
    optn.text = txt;
    optn.value = val;
    el.options.add(optn);
    
}

function ResetCurrentlySelectedText(el_name) {

    var i;
    var el;

    el = FindMyControl(el_name);
    for(i=0;i<=el.options.length-1;i++)
    {
        if (el.options[i].text == CurrentlySelectedText) {
            el.selectedIndex = i;
        }
    }

}


function ChangeShippingAddress() {

    var el;
    var SelectedShippingAddress;
    
    el = FindMyControl('selAltShipping');
    SelectedShippingAddress = el[el.selectedIndex].value;
    
    location.href = 'Checkout.aspx?SelectedShippingAddress=' + SelectedShippingAddress;
    
}

function ShowAddNewShippingAddress() {

    var el;
    el = document.getElementById('divAddNewShipping');
    el.style.visibility = 'visible';

}

function AddNewShippingAddress() {

    var el;
    
    el = FindMyControl('txtShipToName');
    if ( el.value.length <= 1 ) { alert('A valid ship to name is required.'); return; }
    el = FindMyControl('txtshipToAddress');
    if ( el.value.length <= 1 ) { alert('A valid address is required.'); return; }
    el = FindMyControl('txtShipToCity');
    if ( el.value.length <= 1 ) { alert('A valid city is required.'); return; }   
    el = FindMyControl('selShipToState');
    if ( el.selectedIndex <= 0 ) { alert('A valid state selection is required.'); return; }       
    el = FindMyControl('txtShipToZip');
    if ( el.value.length <= 1 ) { alert('A valid zip code is required.'); return; }   
    el = FindMyControl('hdCheckoutAction');
    el.value = 'AddAddress';
    el.form.submit()
             
}

function CompleteOrder() {

}

function CompleteQuote() {

    var el;
    
    // validate required fields
    el = FindMyControl('txtFirst_Name');
    if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid first name is required.'); return; }
    el.style.backgroundColor = '#ffffff';
    el = FindMyControl('txtLast_Name');
    if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid last name is required.'); return; }
    el.style.backgroundColor = '#ffffff';
    el = FindMyControl('txtPhone');
    if ( el.value.length < 10 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid phone number is required.'); return; }
    el.style.backgroundColor = '#ffffff';
    // Customer Number 
    el = FindMyControl('chkCustomer');
    if (el.checked == true ) {
        el = FindMyControl('txtCustomerNumber');
        if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A customer number is required when you select that you are a customer.  You may enter zeros if you do not know your customer number.'); return; }
        el.style.backgroundColor = '#ffffff';
    }
    el = FindMyControl('txtAddress1');
    if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid address is required.'); return; }
    el.style.backgroundColor = '#ffffff';
    el = FindMyControl('txtCity');
    if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid city is required.'); return; }
    el.style.backgroundColor = '#ffffff';
    el = FindMyControl('selState');
    if ( el.selectedIndex <= 0 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid state selection is required.'); return; }  
    el.style.backgroundColor = '#ffffff';
    el = FindMyControl('txtZip');
    if ( el.value.length <= 1 ) { el.style.backgroundColor = '#fbcdcf'; alert('A valid zip code is required.'); return; }
    el.style.backgroundColor = '#ffffff';

    
    el.form.submit();   
    
    
}

function SwapBGStyle(el, SiteFlag, BGStyle) {

    if ( BGStyle == 'Clear' ) {
        el.style.backgroundImage = 'url(images/' + SiteFlag + '/Username_BG.gif)';
    }
    else
    {
        if ( el.value.length <= 0 ) { el.style.backgroundImage = 'url(images/' + SiteFlag + '/Password_BG.gif)'; }
    }

}

function ToggleCustomerNumberTextBoxThatAppearsJustBelowThisCheckbox() {
    
    var el;
    
    el = FindMyControl('chkCustomer');
    if (el.checked == true ) {
        el = document.getElementById('trCustomerNumber');
        el.style.visibility = 'visible';
    }
    else {
        el = document.getElementById('trCustomerNumber');
        el.style.visibility = 'hidden';    
    }
    
}

function GatherNGo() {

    var CurrentKeyword;
    
    el = FindMyControl('txtQuickSearch');
    CurrentKeyword = el.value;
    
    if ( CurrentKeyword == 'QUICK SEARCH' ) { CurrentKeyword = PreviousKeyword; }
    
    if ( PreviousKeyword.length < 2 ) { alert('You must provide a valid search term to conduct a search.  Please enter a search term that is at least 2 characters in length to continue.'); return; }
    
    location.href = 'SearchResults.aspx?Keyword=' + PreviousKeyword;

}

function ToggleSort(NewSortColumn) {

    var el;
    var Keyword;
    var SortAorD;
    
    el = FindMyControl('hdSortAorD');
    if ( el.value == 'ASC' ) { SortAorD = 'DESC' }
        else { SortAorD = 'ASC' }
    el = FindMyControl('hdKeyword');
    Keyword = el.value;
    location.href = 'SearchResults.aspx?Keyword=' + escape(Keyword) + '&SortColumn=' + NewSortColumn + '&SortAorD=' + SortAorD;
        
}

function ShowContactForm() {

 PositionLayer('divContactForm', 250, 150);
 ShowLayer('divContactForm');
 grayOut(true);
 
}

function SubmitContactUs() {

    var el;
    var el2;
        
    el = FindMyControl('txtName');
    if ( el.value.length <= 3 ) {
        alert('A valid name is required to use the Contact Us Form.\n\nPlease enter a valid name to continue.'); return;
    }
    el = FindMyControl('txtEmail');
    el2 = FindMyControl('txtPhone');
    if ( el.value.length <= 4  && el2.value.length <= 5 ) {
        alert('Either a valid email or phone number is required to use the Contact Us Form.\n\nPlease enter either a valid email or phone number to continue.'); return;
    }
    el = FindMyControl('txtMessage');
    if ( el.value.length <= 3 ) {
        alert('A valid message is required to use the Contact Us Form.\n\nPlease enter a valid message to continue.'); return;
    }    
    el = FindMyControl('hdAction');
    el.value = 'ContactForm';
    el.form.submit();
       

}

function PresetItemNo(ItemNo) {

    var el;
    var selIdx = -1;
    var t;
    var GotOne = false;
    
    // preselect sizes    
    selIdx = -1;
    el = FindMyControl('selSize');
    if ( el != false ) {
       
        for (var i=0; i < el.length; i++) {
            t = el.options[i].value;
            t = t.split('|');
            if ( ItemNo == t[1] ) { selIdx = i; }
        }
       
       if ( selIdx > -1 ) {
            el.selectedIndex = selIdx;
            SetItemDetails();
            GotOne = true;
       }
       
    }
  
    // preselect color    
    selIdx = -1;
    el = FindMyControl('selColor');
    if ( el != false ) {
        
        for (var i=0; i < el.length; i++) {
            t = el.options[i].value;
            t = t.split('|');
            if ( ItemNo == t[1] ) { selIdx = i; }
        }
        
       if ( selIdx > -1 ) {
            el.selectedIndex = selIdx;
            SetItemDetails();
            GotOne = true;
       }
    }    
    
    // in order to prevent all the sizes showing, Toggle the sizes using the current color
    if (GotOne == true ) {
        el = FindMyControl('selColor');
        ToggleSizes(el);
    }
    
    el = document.getElementById('divPrice');
    if ( el != null ) {
        if ( el.innerHTML == '0' ) {
            // hide price 
            el = document.getElementById('divPrice');
            if ( el != null ) { el.style.display   = 'none'; }
            el = document.getElementById('divWhyNoPrice');
            if ( el != null ) { el.style.display   = 'block'; }
        }

    }

    
}

var _WorkingTemplateID; 

function AddToTemplate() {

    var el;
    var t;
    var tDbl;
    var PricingError = false;
        
    var SiteFlag, CustNo, Qty, ID, strLItemNo, ItemNo;
    
    // see if this item has a price
    el = document.getElementById('divPrice');
    if ( el == null ) { PricingError = true };
    if ( el != null ) {
        if ( el.style.display == 'none' || el.style.display == '' ) { PricingError = true };
    }
    if ( PricingError == true ) {
        alert('Only priced items may be added to a template.  Please double check your size and/or color options to ensure you have a priced item.');
        return;
    }    
    
    el = FindMyControl('selTemplates');
    if ( el.value == 'New' ) {
        PositionLayer('divCreateNewTemplate', 250, 150);
        ShowLayer('divCreateNewTemplate');
        return;
    }
    if ( el.value == '0' ) {
        alert('Please select a template to add the current item to \nor select <<Create New Template>> to create a new template.');
        return;
    }
    ID = el.value;
    _WorkingTemplateID = ID;
    // validate qty
    el = FindMyControl('txtQty');
    if ( el == false ) {
        el = FindMyControl('selQty');
    }
    if ( IsNumeric(el.value) == false ) {
        alert('The quantity you have provided does not appear to be a valid number.\n\nPlease review your quantity value and make sure that is a valid number.');
        return;
    }
    Qty = el.value;
    // grab our required values
    el = FindMyControl('hdSiteFlag');
    SiteFlag = el.value;
    el = FindMyControl('hdCustNo');
    CustNo = el.value;    
    el = document.getElementById('divMfr');
    strLItemNo = el.innerHTML;
    el = document.getElementById('divAHI');
    ItemNo = el.innerHTML;
    // add via an ajax call
    Catalog.AddItemToTemplate(SiteFlag, CustNo, ID, strLItemNo, ItemNo, Qty, AddToTemplateResults, ErrorHandler, TimeOutHandler);
     
}

function AddToTemplateResults(results) {

    var el, ItemName, HTML, TemplateName;
    
    if ( results == '0' ) {
        el = FindMyControl('hdItemName');
        ItemName = el.value;
        el = FindMyControl('selTemplates');
        TemplateName = el.options[el.selectedIndex].text;
        HTML = '<b>' + ItemName + '</b> was successfully added to your cart <b>' + TemplateName + '</b> template.';
        el = document.getElementById('divTemplateMsg');
        el.innerHTML = HTML;
        el = document.getElementById('divTemplateMsgLayer');
        el.style.visibility = 'visible';
        el = FindMyControl('lnkTemplateMsg');
        if (el != false) {
            el.innerHTML = 'View Template';
            el.href = 'ViewTemplate.aspx?ID=' + _WorkingTemplateID;
        }
        el = FindMyControl('lnkTemplateOk');
        if (el != false) {
            el.href = 'javascript: HideTemplateMsg();';
        }        
        
        
    }
    else {
        alert(results);
    }

}

var _TemplateName;

function CreateNewTemplate() {

    var el;
    var t;
    var OkToGo = false;
    var QuoteOnly;
    var tDbl;
    
    var SiteFlag, CustNo, Name, Description;
    
    // grab our values
    el = FindMyControl('txtTemplate_Name');
    if ( el.value.length <= 1 ) {
        alert('A valid template name is required.  Please enter a valid template name to continue.');
        return;
    }
    Name = el.value;
    el = FindMyControl('txtTemplate_Description');
    Description = el.value;
    // grab our required values
    el = FindMyControl('hdSiteFlag');
    SiteFlag = el.value;
    el = FindMyControl('hdCustNo');
    CustNo = el.value;    
    // just store this value
    _TemplateName = Name;
    
    // add via an ajax call
    Catalog.CreateNewTemplate(SiteFlag, CustNo, Name, Description, CreateNewTemplateResults, ErrorHandler, TimeOutHandler);
        
    CancelLayer('divCreateNewTemplate');   

}

function CreateNewTemplateResults(results) {

    var el;
    var HTML;
    var TemplateLink;
    var Name;
    
    if ( results.substring(0, 5) != 'ERROR' ) {
        // show success message
        HTML = 'Your template named <b>' + _TemplateName + '</b> was successfully created.';
        // add the newly added item as an element of the selTemplates
        el = FindMyControl('selTemplates');
        if ( el != false ) {
            var opt = document.createElement("option");        
            opt.text = _TemplateName;
            opt.value = results;
            el.options.add(opt);
            // pre select it
            for (var i = 0; i < el.length; i++) {
                if ( el.options[i].value == results ) {
                    el.selectedIndex = i;
                }
            }            
        }
        
    }
    else {
        HTML = results;
    }
    el = document.getElementById('divTemplateMsg');
    el.innerHTML = HTML;
    el = document.getElementById('divTemplateMsgLayer');
    el.style.visibility = 'visible';
    el = FindMyControl('lnkTemplateMsg');
    if (el != false) {
        el.href = 'javascript: AddToTemplate();';
        el.innerHTML  = 'Add Item to Template';
        //el.href = 'http://order4.animalhealthpros.com/Templates/TempMain.asp';
    }
    el = FindMyControl('lnkTemplateOk');
    if (el != false) {
        el.href = 'javascript: ConfirmTemplateAdd();';
    }    
    
}

function ConfirmTemplateAdd() {

    if ( confirm('If you wish to add the current item to your newly created template, be sure to click \"Add Item to Template\" on this screen.\n\nClick \"Cancel\" to continue and not add the current item to your template.') ) {
        return;
    }
    HideTemplateMsg();
    return;
    

}

function HideTemplateMsg() {
    el = document.getElementById('divTemplateMsgLayer');
    el.style.visibility = 'hidden';
}

function CheckAll() {

      var inputs = document.getElementsByTagName ('input');
      if (inputs) {
        for (var i = 0; i < inputs.length; ++i) {
          if (inputs[i].type == 'checkbox')
                {
                    inputs[i].checked = true;
                } 
          }        
      }    

}

function UnCheckAll() {

      var inputs = document.getElementsByTagName ('input');
      if (inputs) {
        for (var i = 0; i < inputs.length; ++i) {
          if (inputs[i].type == 'checkbox')
                {
                    inputs[i].checked = false;
                } 
          }        
      }

  }
  
function DeleteSelectedTemplateItems() {

      var ToBeDeleteds = '';
      var el;
      var GotOne = false;
                  
      var inputs = document.getElementsByTagName ('input');
      if (inputs) {
        for (var i = 0; i < inputs.length; ++i) {
          if (inputs[i].type == 'checkbox')
                {
                    if ( inputs[i].checked == true ) { ToBeDeleteds = ToBeDeleteds + inputs[i].value + ','; GotOne = true; }
                } 
          }        
      }
      
    if ( GotOne == false ) { alert('You must select at least one item in order to delete.'); return; }
    
    if ( confirm('Are you sure you want to delete the selected items.\n\nClick \"Ok\" to continue or cancel.') ) {
        el = FindMyControl('hdAction');
        el.value = 'DeleteSelectedItems';
        el = FindMyControl('hdParam');
        el.value = ToBeDeleteds;
        el.form.submit();
    }    
}

function DeleteTemplate() {

    if ( confirm('Are you sure you want to delete this template.\n\nClick \"Ok\" to continue or cancel.') ) {
        el = FindMyControl('hdAction');
        el.value = 'DeleteTemplate';
        el.form.submit();
    }    
    
}

function AddSelectedTemplateItemsToCart() {

    var el;
    var elConversion;
    var CustNo;
    var Q_ID;
    var OrderID;
    var ItemsList = '';
    var Qty;
    var T;
    var GotOne = false;

    el = FindMyControl('hdCustNo');
    CustNo = el.value;    
    el = FindMyControl('hdQ_ID');
    Q_ID = el.value;
    el = FindMyControl('hdOrderID');
    OrderID = el.value;
          
      var inputs = document.getElementsByTagName ('input');
      if (inputs) {
        for (var i = 0; i < inputs.length; ++i) {
            if ( inputs[i].id.indexOf('_Qty') > 0 ) {
                Qty = inputs[i].value;
                if ( IsNumeric(Qty) == true && Qty != '' ) {
                        GotOne = true
                        // before we continue adding, we need to validate that this item does not have a QTY restriction
                        elConversion = FindMyControl(inputs[i].id.replace('_Qty', '_Conversion'));
                        if (elConversion != false) {
                        
                        
                            T = elConversion.value;
                            if (IsNumeric(T) == false) { T = 10 }
                            Conversion = parseInt(T);
                            Qty = parseInt(Qty);
                            if ((Qty % Conversion) > 0) {
                                inputs[i].style.backgroundColor = "IndianRed";
                                alert('This highlighted item must be ordered in multiples of ' + String(Conversion) + '.  Please adjust the quantity you have entered to be a multiple of ' + String(Conversion) + '.');
                                return;
                            }
                            else {
                                inputs[i].style.backgroundColor = "White";
                            }
                        
                        
                        }
                        el = FindMyControl(inputs[i].id.replace('_Qty', '_SelectedParams'));
                        T = el.value
                        T = T.replace('{Qty}', Qty)
                        ItemsList = ItemsList + T + '|*|';
                
                }
            }

          }        
      }

      
    if ( GotOne == false ) {
        alert('Make sure you have entered a quantity on at least one item that you would like to add to your cart.');
        return;
    }
    
    // add via an ajax call
   Catalog.AddMultipleLineItem(CustNo, Q_ID, OrderID, ItemsList, AddSelectedTemplateItemsToCartResults, ErrorHandler, TimeOutHandler);
}

function AddSelectedTemplateItemsToCartResults(results) {

    var el;
    var HTML;
    var CartLink;
    var T;
    
    if ( results.substring(0, 5) != 'ERROR' ) {
        results = results.split('|*|');
        if ( results.length == 7 ) {
            // set quote count
            el = FindMyControl('divQuoteCnt');
            el.innerHTML = '(' + results[5] + ')';
            // set new ids in cookie
            if ( results[1] != '0' ) {
                document.cookie = 'Q_ID=' + results[1];
            }
            if ( results[3] != '0' ) {
                document.cookie = 'OrderID=' + results[3];
            }
            HTML = "<p>The following items were successfully added to your cart:</p>";
            HTML = HTML + "<p><b>";
            T = results[6];
            T = T.split('|');
            for (var i = 0; i < T.length; i++) {
                HTML = HTML + T[i] + '<br />';
            }
            HTML = HTML + "</b></p>";
            
            
        }
        
    }
    else {
        HTML = results;
    }
    el = document.getElementById('divTemplateMsg');
    el.innerHTML = HTML;
    el = document.getElementById('divTemplateMsgLayer');
    el.style.visibility = 'visible';
    
    el = FindMyControl('hdCartLink');
    CartLink = el.value;
    el = FindMyControl('lnkTemplateMsg');
    if (el != false) {
        el.href = CartLink;
    }
    el = FindMyControl('lnkTemplateOk');
    if (el != false) {
        el.href = 'javascript: HideTemplateMsg();';
    }        
    
    
    el = FindMyControl('lnkCart');
    if (el != false) {
        el.href = CartLink;
    }    
 

}

var _HavePrice = false;

function AddSelectedItemsToCart() {

    var el;
    var CustNo;
    var Q_ID;
    var OrderID;
    var ItemsList = '';
    var Qty;
    var T;
    var GotOne = false;
    var elConversion;

    el = FindMyControl('hdCustNo');
    CustNo = el.value;    
    el = FindMyControl('hdQ_ID');
    Q_ID = el.value;
    el = FindMyControl('hdOrderID');
    OrderID = el.value;
    _HavePrice = false;
          
      var inputs = document.getElementsByTagName ('input');
      if (inputs) {
        for (var i = 0; i < inputs.length; ++i) {
            if ( inputs[i].id.indexOf('_Qty') > 0 ) {
                Qty = inputs[i].value;
                inputs[i].value = 0;  //clear it for the next pass/use
                if ( Qty == '0' ) { Qty = ''; }
                if ( IsNumeric(Qty) == true && Qty != '' ) {
                        GotOne = true
                        
                        // before we continue adding, we need to validate that this item does not have a QTY restriction
                        elConversion = FindMyControl(inputs[i].id.replace('_Qty', '_Conversion'));
                        if (elConversion != false) {
                        
                        
                            T = elConversion.value;
                            if (IsNumeric(T) == false) { T = 10 }
                            Conversion = parseInt(T);
                            Qty = parseInt(Qty);
                            if ((Qty % Conversion) > 0) {
                                inputs[i].style.backgroundColor = "IndianRed";
                                alert('This highlighted item must be ordered in multiples of ' + String(Conversion) + '.  Please adjust the quantity you have entered to be a multiple of ' + String(Conversion) + '.');
                                return;
                            }
                            else {
                                inputs[i].style.backgroundColor = "White";
                            }
                        
                        
                        }                        
                        
                        // check for price, we now have to show 1 of 30 different pop ups based on the presence of a price
                        el = document.getElementById(inputs[i].id.replace('_Qty', '_Price'));
                        if ( el != null ) {
                            T = el.innerHTML;
                            if ( T.indexOf('$') > -1 ) { _HavePrice = true }
                        }
                        
                        el = FindMyControl(inputs[i].id.replace('_Qty', '_SelectedParams'));
                        T = el.value
                        T = T.replace('{Qty}', Qty)
                        ItemsList = ItemsList + T + '|*|';
                }
            }

          }        
      }
      
    if ( GotOne == false ) {
        alert('Make sure you have entered a quantity on at least one item that you would like to add to your cart.');
        return;
    }

    // add via an ajax call
   Catalog.AddMultipleLineItem(CustNo, Q_ID, OrderID, ItemsList, AddSelectedItemsToCartResults, ErrorHandler, TimeOutHandler);
}

function AddSelectedItemsToCartResults(results) {

    var el;
    var HTML;
    var CartLink;
    var cartName;
    var T;
    
    if ( _HavePrice == true ) { cartName = 'cart' } else { cartName = 'quote' }
    
    if ( results.substring(0, 5) != 'ERROR' ) {
        results = results.split('|*|');
        if ( results.length == 7 ) {
            // set quote count
            el = FindMyControl('divQuoteCnt');
            el.innerHTML = '(' + results[5] + ')';
            // set new ids in cookie
            if ( results[1] != '0' ) {
                document.cookie = 'Q_ID=' + results[1];
            }
            if ( results[3] != '0' ) {
                document.cookie = 'OrderID=' + results[3];
            }
            HTML = "<p>The following items were successfully added to your " + cartName + ":</p>";
            HTML = HTML + "<p><b>";
            T = results[6];
            T = T.split('|');
            for (var i = 0; i < T.length; i++) {
                HTML = HTML + T[i] + '<br />';
            }
            HTML = HTML + "</b></p>";
            
        }
        
    }
    else {
        HTML = results;
    }    
 
    if ( _HavePrice == true ) {
        if ( document.cookie.indexOf('DoNotShow=Yes') == -1 ) {   
        
            el = document.getElementById('divSearchCartMsg');
            el.innerHTML = HTML;
            PositionLayer('divSearchCartMsgLayer', 300, 300);
            el = document.getElementById('divSearchCartMsgLayer');
            el.style.visibility = 'visible';
            grayOut(true);
            
            el = FindMyControl('hdCartLink');
            CartLink = el.value;
            el = FindMyControl('lnkTemplateMsg');
            if (el != false) {
                el.href = CartLink;
            }
               
            el = FindMyControl('lnkCart');
            if (el != false) {
                el.href = CartLink;
            }    
            
        }
    } else {
        if ( document.cookie.indexOf('DoNotShowQuote=Yes') == -1 ) {       
        
            grayOut(true);
            el = document.getElementById('spProductName');
            el.innerHTML = HTML;
            el = document.getElementById('divAddToQuoteMsgLayer');
            el.style.visibility = 'visible';
            el = FindMyControl('hdCartLink');
            CartLink = el.value;
            el = FindMyControl('lnkViewCart_Quote');
            if (el != false) {
                el.href = CartLink;
            } 
        }       
}
 
}

function HideSearchCartMsg() {
    el = document.getElementById('divSearchCartMsgLayer');
    el.style.visibility = 'hidden';
    grayOut(false);
}

function GetSearchingFor() {

    var el;

    document.forms[0].submit();    

}

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    var pageWidth = getW() + 'px'; 
    var pageHeight = getH() + 'px';
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';				 
  } 
  else {
     dark.style.display='none';
    }
}

function getW(){
    var w;
    if(document.innerWidth){ w=document.innerWidth;
    } else if(document.documentElement.clientWidth){ w=document.documentElement.clientWidth;
    } else if(document.body){ w=document.body.clientWidth; }
    return w;
}

function getH(){
    var h;
    if(document.innerHeight){ h=document.innerHeight;
    } else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight;
    } else if(document.body){ h=document.body.clientHeight; }
    return h;
}



