// Csn.js
var theDOMAIN=".vrp.com"
var cid="",aid="",bid="",UrlA="",UrlB="",ctyp="";
UrlA=String(window.location.href);
UrlB=String(UrlA.toUpperCase());
if(UrlB.indexOf("?")!=-1) {
    UrlB=UrlB.substring(UrlB.indexOf("?")+1);
    var parms=UrlB.split("&");
    for (var i=0; i < parms.length; i++) {
        var NameSet = parms[i].split("=");
        if ("AID" == NameSet[0]) { aid=NameSet[1]; SetCookie("aid",aid); }
        if ("BID" == NameSet[0]) { bid=NameSet[1]; SetCookie("bid",bid); }
        if ("CID" == NameSet[0]) { cid=NameSet[1]; SetCookie("cid",cid); }
        if ("CTYPE" == NameSet[0]) { ctyp=NameSet[1]; SetCookie("CTYPE",ctyp); }
    } 
}
if(String(cid)=="") {
    cid=String(GetCookie("cid"));
    if(cid=="") { 
        cid=GetMilliSeconds(); 
        SetCookie("cid",cid); 
        //window.location.href=window.location.href; 
        Dstr=String(window.location.href);
        Dstr=Dstr.toUpperCase();
        if(Dstr.indexOf("CHECKOUT.ASPX") > 0 ) {
            //
        } else {
            window.location.href="/cookiecheck.aspx?zz="+window.location.href;
        }
    }
}
function SetCookie(sName, sValue) {
Set_Cookie(sName,sValue,'/',theDOMAIN,'');
}
function GetCookie(sName) {
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  return "";
}
function Set_Cookie( name, value, path, domain, secure ) {
document.cookie = name + "=" +escape( value ) +
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}  function GetCookie(sName) {
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  return "";
}
function DelCookie(sName) {
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
function GetMilliSeconds() {
	var the_date = new Date();
	var the_secs = parseInt(( the_date.getTime() ));
	return the_secs;
}
function showDialog(flag) {
	if (flag=='') {
		divUserPrefs.style.display = ''; //'none' or 'block'
		URLString=window.location.href;
	}
	if (flag=='none') {
		var value='';
		//saving the values set by the user by sending them in the request for the next load
		if (URLString.indexOf("config")!=-1) {URLString=URLString.substring(0,URLString.indexOf("config")-1)}
		if (URLString.indexOf("?")==-1)
			{URLString = URLString + "?";}
		else
			{URLString = URLString + "&";}
		URLString = URLString + 'config=true';
		value=document.getElementById('SearchTopStrip_ChckExplanation').checked;
		URLString = URLString + '&AllowExplain=' + value;
		value=document.getElementById('SearchTopStrip_ChckShowHighlights').checked;
		URLString = URLString + '&ShowHighlights=' + value;
		value=document.getElementById('SearchTopStrip_cmbItemsPerPage').value;
		URLString = URLString + '&ItemsPerPage=' + value;
		window.location.href = URLString;
	}
}
function ignore(val) {
}
/*Setting the collapse\expand state of the filters.  
The function is called from each filter object but appears once in the search page*/
function SwitchStyle(imgObj) 		{
			if (imgObj.title=='Expand') {
				//img.td.tr.tbody.table.siblingTable = children table
				imgObj.parentElement.parentElement.parentElement.parentElement.nextSibling.style.display='';	
				imgObj.title = 'Collapse';
				imgObj.src = './Images/ListCollapse.gif';
			} else {
				//img.td.tr.tbody.table.siblingTable = children table
				imgObj.parentElement.parentElement.parentElement.parentElement.nextSibling.style.display='none';
				imgObj.title = 'Expand';
				imgObj.src = './Images/ListExpand.gif';				
			}
}
function SwitchStyle2(imgID,optID) 		{
			if ( document.getElementById(imgID).title=='Expand') {
			    document.getElementById(optID).style.display='';
				document.getElementById(imgID).title = 'Collapse';
				document.getElementById(imgID).src = './Images/ListCollapse.gif';
			} else {
				//img.td.tr.tbody.table.siblingTable = children table
				document.getElementById(optID).style.display='none';
				document.getElementById(imgID).title = 'Expand';
				document.getElementById(imgID).src = './Images/ListExpand.gif';				
			}
}
function Chngr( what2add) {
    URLString=String(window.location.href);
    URLString=URLString.replace(" ","%20");
   what2add=what2add.replace(" ","%20");
   if(URLString.indexOf("attribute_value_date_range")>0) {
       URLString=URLString.substring(0,URLString.indexOf("attribute_value_date_range")-1);
   }
   if(URLString.indexOf("attribute_value_number_range")>0) {
       URLString=URLString.substring(0,URLString.indexOf("attribute_value_number_range")-1);
   }
    window.location.href=URLString+what2add;
}

