//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

top.status = 'Sherwin-Williams Online Wallpaper Store';

var message = "";

function clickIE()
{ 
    if( document.all )
    { 
        ( message ); 
        return false; 
    } 
}

function clickNS( e )
{ 
    if( document.layers || ( document.getElementById && !document.all ) ) 
    {
        if( e.which == 2 || e.which == 3 ) 
        {
            ( message );
            return false;
        }
    }
}

if( document.layers ) 
{
    document.captureEvents( Event.MOUSEDOWN );
    document.onmousedown = clickNS;
}
else
{
    document.onmouseup = clickNS;
    document.oncontextmenu = clickIE;
}

document.oncontextmenu = new Function( "return false" );

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function openWindow( url, h, w, features )
{
    if( screen.width )
    {
        var winl = ( screen.width - w ) / 2;
        var wint = ( screen.height - h ) / 2;
    }
    else
    {
        winl = 0;
        wint = 0;
    }
    
    if( winl < 0 ) winl = 0;
    if( wint < 0 ) wint = 0;
    
    var settings = 'height=' + h + ',';
        settings += 'width=' + w + ',';
        settings += 'top=' + wint + ',';
        settings += 'left=' + winl + ',';
        settings += features;
    
    var win = window.open( url,"", settings);
    win.window.focus();
}


function popPage(strURL, intWidth, intHeight, strParams)
{
	if(intWidth && intHeight)
	{		
		var window_left = 50;
		var window_top = 50;
		if(strParams)
		{
			var winParams = strParams;
		}
		else
		{
			var winParams = "'resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes'";
		}
			
		win = window.open(strURL,'popUp','width=' + intWidth + ',height=' + intHeight + ',top=' + window_top + ',left=' + window_left + ',' + strParams);	
	}
	else
	{
		win = window.open(strURL,'popUp','width=735,height=500,top=50,left=50,resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes');
    }
		
	win.opener.name = "opener";
    if (! is.aol)
    {
    	win.focus();      		
	}
}
	
//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function swValidRegistration()
{
    var frm      = document.forms[0];
    var flen     = frm.length;
    var isBlank  = "";
    var blankStr = "";
    
    // check to see if anything required is empty
    if( frm.firstname.value == "" )
    {
        isBlank = true;
        blankStr += " - First Name\n\t";
    }
    
    if( frm.lastname.value == "" )
    {
        isBlank = true;
        blankStr += " - Last Name\n\t";
    }
    
    if( frm.address1.value == "" )
    {
        isBlank = true;
        blankStr += " - Address\n\t";
    }
    
    if( frm.city.value == "" )
    {
        isBlank = true;
        blankStr += " - City\n\t";
    }
    
    if( frm.email1.value == "" )
    {
        isBlank = true;
        blankStr += " - Email\n\t";
    }
    
    if( frm.pw.value == "" )
    {
        isBlank = true;
        blankStr += " - Password\n\t";
    }
    
    if( frm.pw_conf.value == "" )
    {
        isBlank = true;
        blankStr += " - Password Confirmation\n\t";
    }
    
    if( isBlank )
    {
        alert( "Some required fields are empty.\n\n\t" + blankStr + "\nPlease correct the registration and re-submit." );
        return false;
    }
    else
    {
        // check to see if the email is valid 
        if( !IsValidEmail( frm.email1.value ) )
        {
            alert( "Your email address appears to be invalid.\nPlease correct it and re-submit." );
            frm.email1.focus();
            frm.email1.select();
            return false;
        }
        
        if( frm.pw.value != frm.pw_conf.value )
        {
            // password and confirmation are not the same.
            alert( "Your passwords do not match. Please retype your password and confirmation." );
            frm.pw.value      = "";
            frm.pw_conf.value = "";
            frm.pw.focus();
            return false;
        }
    }
    return true;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function IsValidEmail( str ) 
{
	var isValid = true;
	str += "";

	namestr   = str.substring( 0, str.indexOf( "@" ) );
	domainstr = str.substring( str.indexOf( "@" ) + 1, str.length );

   	if ( ( namestr.length == 0 ) || ( domainstr.indexOf(".") <= 0 ) ||
		 ( domainstr.indexOf("@") != -1 ) || !IsAlpha( str.charAt( str.length-1 ) ) )
    {
	    isValid = false;
	}
   
   	return isValid;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function IsAlpha( str ) 
{
	if( str+"" == "undefined" || str + "" == "null" || str + "" == "")	
	{
	    return false;
	}

	var isValid = true;
	str += "";	

  	for (i = 0; i < str.length; i++) 
  	{
	    if( !( ( ( str.charAt(i) >= "a" ) && ( str.charAt(i) <= "z" ) ) ||
      	  ( ( str.charAt(i) >= "A" ) && ( str.charAt(i) <= "Z" ) ) ) ) 
      	{
            isValid = false;
         	break;
        }
   }
	return isValid;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function MM_preloadImages() 
{ 
    var d = document; 
    if( d.images )
    { 
        if( !d.MM_p ) d.MM_p=new Array();
        var i, b, j = d.MM_p.length, a = MM_preloadImages.arguments; 
        for( i = 0; i < a.length; i++ )
        {
            if (a[i].indexOf("#")!=0)
            { 
                d.MM_p[j] = new Image; 
                d.MM_p[j++].src = a[i];
            }
        }
     }
        
}

function MM_swapImgRestore() 
{ 
    var i, x, a = document.MM_sr; 
    
    for( i = 0; a && i < a.length && ( x = a[i] ) && x.oSrc; i++ ) 
    {
        x.src = x.oSrc;
    }
}

function MM_findObj(n, d) 
{ 
    var p, i, x;  
    if( !d ) d = document; 
    if( ( p = n.indexOf( "?" ) ) > 0 && parent.frames.length ) 
    {
        d = parent.frames[n.substring(p+1)].document; 
        n = n.substring( 0, p );
    }
    
    if( !( x = d[n] ) && d.all ) x = d.all[n]; 
    
    for( i = 0; !x && i < d.forms.length; i++ ) 
        x = d.forms[i][n];
    
    for( i = 0; !x && d.layers && i < d.layers.length; i++ ) 
        x = MM_findObj( n, d.layers[i].document );
    
    if( !x && d.getElementById ) x = d.getElementById( n ); 
    return x;
}

function MM_swapImage() 
{ 
    var i, j = 0, x, a=MM_swapImage.arguments; 
    document.MM_sr=new Array; 
    
    for( i = 0; i < ( a.length - 2 ); i += 3 )
    {
        if ((x=MM_findObj(a[i]))!=null)
        {
            document.MM_sr[j++] = x; 
            if( !x.oSrc ) x.oSrc = x.src; 
            x.src = a[i+2];
        }
    }
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function doCheckOut()
{
	//var SERVER = "https://www.swdecorating.com"       // production
	//var SERVER = "https://www2.swdecorating.com"       // qa
	//var SERVER = "https://dev.swdecorating.com"       // develpment

    document.frmCart.action = AppRoot + "/checkout1.asp";
    document.frmCart.target = "_parent";
    document.frmCart.method = "POST";
    document.forms[0].submit();
}

function doCheckOut2()
{
    // this function has no use. the form is already setup with these values.
    // not sure why this was added? bg
    document.frmCheckout1.action = "checkout1process.asp";
    document.frmCheckout1.submit();
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function setDisabled()
{
    if( document.all )
    {
        if( document.frmCheckout1.ship_firstname.disabled == false )
        {
            document.frmCheckout1.ship_firstname.disabled = true;
            document.frmCheckout1.ship_lastname.disabled  = true;
            document.frmCheckout1.ship_address1.disabled  = true;
            document.frmCheckout1.ship_address2.disabled  = true;
            document.frmCheckout1.ship_city.disabled      = true;
            document.frmCheckout1.ship_state.disabled     = true;
            document.frmCheckout1.ship_zipcode.disabled   = true;
            document.frmCheckout1.ship_country.disabled   = true;
        }
        else
        {
            document.frmCheckout1.ship_firstname.disabled = false;
            document.frmCheckout1.ship_lastname.disabled  = false;
            document.frmCheckout1.ship_address1.disabled  = false;
            document.frmCheckout1.ship_address2.disabled  = false;
            document.frmCheckout1.ship_city.disabled      = false;
            document.frmCheckout1.ship_state.disabled     = false;
            document.frmCheckout1.ship_zipcode.disabled   = false;
            document.frmCheckout1.ship_country.disabled   = false;
        }
    }
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\
// filters input text to numeric entry only //

function validate( e ) 
{
    if ( document.all )
    {
        key = window.event.keyCode;
    }
    else
    {
        key = e.which;
    }

    if ( key < 48 || key > 57 )
    {
        return false;
    }
    return true;  
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function setState( st )
{
    var state = st.substring( st.indexOf( "|" ) + 1, st.length );
    document.frmCart.state.value = state;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function addSampleToCart()
{
    document.forms[0].Sample.value    = "yes";
    document.forms[0].quantity.value  = 1;
    document.forms[0].unitprice.value = 5;
    document.forms[0].submit();   
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function formatCCNumber( frm ) 
{
     var len = frm.txtCCAcctNum.value.length + 1;
     if ((len % 5) == 0) 
     {
          frm.txtCCAcctNum.value = frm.txtCCAcctNum.value + " ";
     }
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function swValidRegistration2()
{
    var frm      = document.forms[0];
    var flen     = frm.length;
    var isBlank  = "";
    var blankStr = "";
    
    // check to see if anything required is empty
    if( frm.firstname.value == "" )
    {
        isBlank = true;
        blankStr += " - First Name\n\t";
    }
    
    if( frm.lastname.value == "" )
    {
        isBlank = true;
        blankStr += " - Last Name\n\t";
    }
    
    if( frm.address1.value == "" )
    {
        isBlank = true;
        blankStr += " - Address\n\t";
    }
    
    if( frm.city.value == "" )
    {
        isBlank = true;
        blankStr += " - City\n\t";
    }
    
    if( frm.email1.value == "" )
    {
        isBlank = true;
        blankStr += " - Email\n\t";
    }
    
    if( frm.phone1.value == "" )
    {
        isBlank = true;
        blankStr += " - Day Phone\n\t";
    }
    
    if( isBlank )
    {
        alert( "Some required fields are empty.\n\n\t" + blankStr + "\nPlease correct the registration and re-submit." );
        return false;
    }
    else
    {
        // check to see if the email is valid 
        if( !IsValidEmail( frm.email1.value ) )
        {
            alert( "Your email address appears to be invalid.\nPlease correct it and re-submit." );
            frm.email1.focus();
            frm.email1.select();
            return false;
        }
    }
    return true;
}

function valCheck() {

	var frm=window.document.frmCheckout1;

    //Do a Right Trim on all Text fields and null the field if all spaces  (equivalent to == "" )
        
	for (var i=0; i<=15; i++) {  // there aren't any text fields after 15
	   if(frm[i].type == "text")  { 
	     // alert(frm[i].name + "  " + frm[i].value + " " + frm[i].value.length); 
	      for (var j=frm[i].value.length - 1; j>=0; j--) { //find 1st nonspace from right
	         if (frm[i].value.charAt(j) != " ") {
		    frm[i].value = frm[i].value.substring(0,j+1); break; //set new value
		 } //if (charAt)
	      } //for (length)
	      if(frm[i].value.charAt(frm[i].value.length - 1) == " ") {  //all spaces->Null
	         frm[i].value = ""; 
		 } //if (last char is blank)
	   } //if (type Text)			
	} //for (all fields)

	var fnamlen=frm.firstname.value.length;
	var lnamlen=frm.lastname.value.length;
	var addlen=frm.address1.value.length;
	var citylen=frm.city.value.length;
	var emaillen=frm.email1.value.length;
	var phonelen=frm.phone1.value.length;
	var dot=0;
	var atsign=0;


	if(fnamlen<2) { alert("Please enter First Name"); frm.firstname.focus(); return false; }
	if(lnamlen<2) { alert("Please enter Last Name"); frm.lastname.focus(); return false; }
	if(addlen<4) { alert("Please enter Street Address"); frm.address1.focus(); return false; }
	if(citylen<2) { alert("Please enter City"); frm.city.focus(); return false; }
if(phonelen<10) { alert("Please enter Phone number"); frm.phone1.focus(); return false; }
	for (var i=0; i<emaillen; i++) 
		{ 
		if (emaillen.charAt(i) == "." ) 
			{ dot = i } 
		else
			{ if (emaillen.charAt(i) == "@" ) { atsign = i } }
		}			
					
	if (! (dot>0 && (dot<emaillen - 2 && dot>emaillen - 5) && atsign>0 && atsign<emaillen - 2 && dot>atsign))
		{ 
		alert("Please correct email address (i.e. myname@aol.com)")
		frm.EMAIL1.focus();
		return false }

	
  return true; 
        }

function valCheck2() {

	var frm=window.document.registration;

//Do a Right Trim on all Text fields and null the field if all spaces
	for (var i=0; i<=15; i++) {  // there aren't any text fields after 15
	   if(frm[i].type == "text")  { 
	     // alert(frm[i].name + "  " + frm[i].value + " " + frm[i].value.length); 
	      for (var j=frm[i].value.length - 1; j>=0; j--) { //find 1st nonspace from right
	         if (frm[i].value.charAt(j) != " ") {
		    frm[i].value = frm[i].value.substring(0,j+1); break; //set new value
		 } //if (charAt)
	      } //for (length)
	      if(frm[i].value.charAt(frm[i].value.length - 1) == " ") {  //all spaces->Null
	         frm[i].value = ""; 
		 } //if (last char is blank)
	   } //if (type Text)			
	} //for (all fields)

	var fnamlen=frm.firstname.value.length;
	var lnamlen=frm.lastname.value.length;
	var addlen=frm.address1.value.length;
	var citylen=frm.city.value.length;
	var emaillen=frm.email1.value.length;
	var phonelen=frm.phone1.value.length;
	var dot=0;
	var atsign=0;


	if(fnamlen<2) { alert("Please enter First Name"); frm.firstname.focus(); return false; }
	if(lnamlen<2) { alert("Please enter Last Name"); frm.lastname.focus(); return false; }
	if(addlen<4) { alert("Please enter Street Address"); frm.address1.focus(); return false; }
	if(citylen<2) { alert("Please enter City"); frm.city.focus(); return false; }
if(phonelen<10) { alert("Please enter Phone number"); frm.phone1.focus(); return false; }
	for (var i=0; i<emaillen; i++) 
		{ 
		if (emaillen.charAt(i) == "." ) 
			{ dot = i } 
		else
			{ if (emaillen.charAt(i) == "@" ) { atsign = i } }
		}			
					
	if (! (dot>0 && (dot<emaillen - 2 && dot>emaillen - 5) && atsign>0 && atsign<emaillen - 2 && dot>atsign))
		{ 
		alert("Please correct email address (i.e. myname@aol.com)")
		frm.EMAIL1.focus();
		return false }

	
  return true; 
        }

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function FavoritesValidate()
{
    var frm = document.forms[0];
    
    return true;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function clearDefaultandCSS( el ) 
{
	if( el.defaultValue == el.value ) el.value = "";
	if( el.style ) el.style.cssText = "";
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function checkEvenQty( val, factor )
{
    if( ( val % factor ) > 0 )  
    {
        alert( "This wallpaper is packaged in "+factor+" rolls.\nPlease re-enter a number that is a multiple of "+factor+"." );
        if( location.href.indexOf( 'detail' ) != -1 )
        {
            document.forms[0].quantity.focus();
            document.forms[0].quantity.select();
        }
        else
        {
            window.focus();
        }
    }
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\

function SWBrowserDetect() 
{
	var ua = navigator.userAgent.toLowerCase(); 

	this.isGecko     = (ua.indexOf('gecko') != -1);
	this.isMozilla   = (this.isGecko && ua.indexOf("gecko/") + 14 == ua.length);
	this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.isIE        = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
	this.isOpera     = (ua.indexOf("opera") != -1); 
	this.isKonqueror = (ua.indexOf("konqueror") != -1); 
	this.isIcab      = (ua.indexOf("icab") != -1); 
	this.isAol       = (ua.indexOf("aol") != -1); 
	this.isWebtv     = (ua.indexOf("webtv") != -1); 
	
	this.isIECompatible = ( (ua.indexOf("msie") != -1) && !this.isIE);
	this.isNSCompatible = ( (ua.indexOf("mozilla") != -1) && !this.isNS && !this.isMozilla);
	
	this.versionMinor = parseFloat(navigator.appVersion); 
	
	if (this.isNS && this.isGecko) {
		this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
	}
	else if (this.isIE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	}
	else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isOpera) {
		if (ua.indexOf('opera/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
		}
		else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
		}
	}
	else if (this.isKonqueror) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
	}
	else if (this.isIcab) {
		if (ua.indexOf('icab/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
		}
		else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
		}
	}
	else if (this.isWebtv) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) );
	}
	
	this.versionMajor = parseInt(this.versionMinor); 
	this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
    
    this.isDOM1 = (document.getElementById);
	this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
    this.mode = document.compatMode ? document.compatMode : 'BackCompat';

	this.isWin   = (ua.indexOf('win') != -1);
	this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
	this.isMac   = (ua.indexOf('mac') != -1);
	this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
	
	this.isNS4x = (this.isNS && this.versionMajor == 4);
	this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
	this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
	this.isNS4up = (this.isNS && this.versionMinor >= 4);
	this.isNS6x = (this.isNS && this.versionMajor == 6);
	this.isNS6up = (this.isNS && this.versionMajor >= 6);
	this.isNS7x = (this.isNS && this.versionMajor == 7);
	this.isNS7up = (this.isNS && this.versionMajor >= 7);
	
	this.isIE4x = (this.isIE && this.versionMajor == 4);
	this.isIE4up = (this.isIE && this.versionMajor >= 4);
	this.isIE5x = (this.isIE && this.versionMajor == 5);
	this.isIE55 = (this.isIE && this.versionMinor == 5.5);
	this.isIE5up = (this.isIE && this.versionMajor >= 5);
	this.isIE6x = (this.isIE && this.versionMajor == 6);
	this.isIE6up = (this.isIE && this.versionMajor >= 6);
	
	this.isIE4xMac = (this.isIE4x && this.isMac);
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\
// Returns passed number as string in $xxx,xxx.xx format.

function currency( anynum ) 
{
    anynum = eval( anynum );
    workNum = Math.abs( ( Math.round( anynum * 100 ) / 100 ) );
    workStr = "" + workNum;
    
    if( workStr.indexOf( "." ) == -1 )
    {
        workStr += ".00"
    }
    
    dStr = workStr.substr( 0, workStr.indexOf( "." ) );
    dNum = dStr - 0;
    pStr = workStr.substr( workStr.indexOf( "." ) );
    
    while( pStr.length < 3 )
    {
        pStr += "0";
    }

    if( dNum >= 1000 ) 
    {
       dLen = dStr.length;
       dStr = parseInt( "" + ( dNum / 1000 ) ) + "," + dStr.substring( dLen - 3, dLen )
    }

    if( dNum >= 1000000 ) 
    {
       dLen = dStr.length;
       dStr = parseInt( "" + ( dNum / 1000000 ) ) + "," + dStr.substring( dLen-7, dLen )
    }
    
    retval = dStr + pStr 
    
    if( anynum < 0 ) 
    {
        retval = "(" + retval + ")";
    }
    
    return "$" + retval;
}


//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\
// FRONT PAGE SCRIPTS

function populateSubject( srchType ) 
{ 
    for( var i = document.coveringSearch.subject.options.length - 1; i > 0; i-- ) 
    {
        document.coveringSearch.subject.options[i] = null;
    }
    var j = 1;
    document.coveringSearch.subject.options[0] = new Option( ">> SUBJECTS", "", true );  
    if( srchType == 'wallpapers' )
    {
        for( var i = 0; i < wpids.length; i++ ) 
        {
            document.coveringSearch.subject.options[j] = new Option( wptxt[i], wpids[i] );
            j++;
        }
    }
    else
    {
        for( var i = 0; i < bsids.length; i++ ) 
        { 
            document.coveringSearch.subject.options[j] = new Option( bstxt[i], bsids[i] );
            j++;
        }
    }
} 

function populateColor( srchType ) 
{ 
    for( var i = document.coveringSearch.color.options.length - 1; i > 0; i-- ) 
    {
        document.coveringSearch.color.options[i] = null;
    }
    var j = 1;
    document.coveringSearch.color.options[0] = new Option( ">> COLORS", "", true );
    if( srchType == 'wallpapers' )
    {
        for( var i = 0; i < cwpids.length; i++ ) 
        { 
            document.coveringSearch.color.options[j] = new Option( cwptxt[i], cwpids[i] );
            j++;
        }
    }
    else
    {
        for( var i = 0; i < cbdids.length; i++ ) 
        { 
            document.coveringSearch.color.options[j] = new Option( cbdtxt[i], cbdids[i] );
            j++;
        }
    }
} 

function setupBorderParams(populate)
{
    searchtype = 'borders';
	if (populate){
		populateSubject( 'borders' );
	    populateColor( 'borders' );
	}
	return 'borders';
}

function setupWallpaperParams(populate)
{
    searchtype = 'wallpapers';
	if (populate){
		populateSubject( 'wallpapers' );
	    populateColor( 'wallpapers' );
	}
	return 'wallpapers';
}

var searchtype = "wallpapers";
var themeval   = "";
var subjval    = "";

function handleEnterSubmission( field, evt, frm ) 
{
    var keyCode = evt.which ? evt.which : evt.keyCode;
 
    if( keyCode == 13 ) 
    {
        var val = eval( "document." + frm + "." + field.name + ".value" );
        var url = "searchresults.asp?" + field.name + "=" + val + "&" + frm.toLowerCase() + ".x=1&radsearchtype=" + searchtype;
        
        if( validSearch( frm, field.name ) )
        {
            location.href = url;
            return false;
        }
    }
    else
    { 
        return true;
    }
}

function validSearch( frm, fld )
{
    var str = "document." + frm + "." + fld + ".value";
    if( eval( str ) == "" )
    {
        str = "document." + frm + "." + fld + ".focus()";
        eval( str );
        return false;
    }
    return true;
}

function swapImages( img )
{
    document.coveringSearch.radsearchtype.value = img;
    
    if( document.images )
    {
        if( img == 'borders' )
        {
            document.images['label01'].src = 'images/col1-brdr_keyword_search.gif';    
            document.images['label02'].src = 'images/col1-brdr_filtered_search.gif';
        }
        else
        {
            document.images['label01'].src = 'images/col1-wp_keyword_search.gif';    
            document.images['label02'].src = 'images/col1-wp_filtered_search.gif';
        }
    }
}

function init()
{
    var b = new SWBrowserDetect();
    var newbrowser = true;
    if( b.isNS4x ) newbrowser = false;
    if(  b.isIE5x && !b.isIE55 ) newbrowser = false;
        
    if( document.forms[0].radsearchtype[0].checked == false )
    {
        document.images['label01'].src = 'images/col1-brdr_keyword_search.gif';    
        document.images['label02'].src = 'images/col1-brdr_filtered_search.gif';
        if( newbrowser ) 
        {
            //populateSubject( 'borders' );
            //populateColor  ( 'borders' );
            document.coveringSearch.radsearchtype.value = 'borders';
        }
    }
    else
    {
        if( newbrowser ) 
        {
			//populateSubject( 'wallpapers' );
            //populateColor  ( 'wallpapers' );
            document.coveringSearch.radsearchtype.value = 'wallpapers';
        }
    }
    document.coveringSearch.reset();
}

function doGetColors()
{
    var b = new SWBrowserDetect();
    if( b.isNS4x || ( b.isIE5x && !b.isIE55 ) ) 
    {
        var subjname  = document.coveringSearch.subjectname.value;
        var clrname   = document.coveringSearch.colorname.value;
        var url       = 'home.asp?subj=' + subjval + '&radsearchtype=' + searchtype;
        
        if( subjname != "" ) url += '&subjectname=' + escape( subjname );
        if( clrname != "" ) url += '&colorname=' + escape( clrname );
     
        if( subjval != "" && subjval.indexOf( ">>" ) == -1 ) location.href = url;
    }
    else
    {
        top.hiddenfrm.getColorList( searchtype, subjval );
    }
	
    if( document.forms[0].radsearchtype[0].checked == false )
    {
        document.coveringSearch.radsearchtype.value = 'borders';
    }
    else
    {
        document.coveringSearch.radsearchtype.value = 'wallpapers';
    }
}

function submitColor(cID, cName)
{//cID is the color ID
 //cName is the name of the color
window.location = "searchresults.asp?coveringsearch.x=1&radsearchtype=" + document.coveringSearch.radsearchtype.value + "&subject=&subjectname=&pg=&color=" + cID + "&colorname=" + cName;
}

//=//=//=//=//=//=//=//=//=//=//=//=//==\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\=\\