 // Grab querystring values from any page
 var sSource=getQueryValue('source');
 var sEvent=getQueryValue('event');
 var sID=getQueryValue('eventid');
 // Set cookies expire end of session path root of site
 if (sSource!=""){
 setCookie('source', sSource, '', '/');
 }
 if (sEvent!=""){
 setCookie('event', sEvent, '',  '/');
 }
 if (sID!=""){
 setCookie('eventid', sID, '',  '/');
 }
 
function Certify() {
popupWin = window.open ('http://www.bbbonline.org/r2.cfm?ID=1186001321', 'Participant', 'location,scrollbars,width=450,height=300') 
                              window.name = 'opener'; 
}
 

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getQueryValue(name) {
    var regex = new RegExp( "[\?&]"+name+"=([^&#]*)" );
    var results = regex.exec( window.location.href );
    if( results == null )
        return "";
    else
        return results[1];
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function setEventIDField() {
 // Set Dealerlocator form hidden field eventid value function call onload
 document.getElementById('eventid').value=getCookie('eventid');
}





//show hide
function showInline(elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {theElemenet.style.display = "inline";	}
	}
function hideInline(elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {theElemenet.style.display = "none";}
	}

//search box clear code
function clear_searchbox(){
	//if (document.Order.ZipCode.value == "US Enter ZIP")  {
		if (document.Order.ZipCode.value == "US/CAN Postal Code")  {
		document.Order.ZipCode.value = "";
	}
}	


function clear_searchbox2()
{
	//if (document.Order.ZipCode.value == "US Enter ZIP")  {
		if (document.Order2.ZipCode.value == "US/CAN Postal Code")  {
		document.Order2.ZipCode.value = "";
	}
}	

//pop window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function sendBrochure(answer) {
	var theElemenet = document.getElementById("send_brochure");
	if(answer == "yes"){
	theElemenet.value="true";
	}else{
	theElemenet.value="false";
	}
}

// popups

function go_mailinglist_link(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=600,height=560,top=0,left=0,resizable=yes');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=600,height=560,top=0,left=0,resizable=yes');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=600,height=560,top=0,left=0,resizable=yes');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=600,height=560,top=0,left=0,resizable=yes');
    }
  }
}

function go_financing(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=610,height=320,top=0,left=0,resizable=yes');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=610,height=320,top=0,left=0,resizable=yes');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=610,height=320,top=0,left=0,resizable=yes');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=610,height=320,top=0,left=0,resizable=yes');
    }
  }
}

function go_intl_popup(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=350,height=295,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=350,height=295,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=350,height=295,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=no,scrollbars=no,width=350,height=295,top=0,left=0,resizable=no');
    }
  }
}

function go_selector(url)
{
  var strWinName = 'spa_locator';
  
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=760,height=560,top=20,left=20,resizable=no');
    }
    else // IE Win
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=760,height=560,top=20,left=20,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=760,height=560,top=20,left=20,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=760,height=560,top=20,left=20,resizable=no');
    }
  }
}

function go_colorselector(url)
{
  var strWinName = 'color_selector';
  
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=600,height=650,top=20,left=20,resizable=no');
    }
    else // IE Win
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=600,height=650,top=20,left=20,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=600,height=650,top=20,left=20,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,strWinName,'status=no,scrollbars=no,location=no,menubar=no,toolbar=no,width=600,height=650,top=20,left=20,resizable=no');
    }
  }
}

function go_friend(url)
{
  var strWinName = 'WDPopUp';
  
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,width=595,height=520,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,strWinName,'status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,width=595,height=520,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,strWinName,'status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,width=595,height=520,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,strWinName,'status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,width=595,height=520,top=0,left=0,resizable=no');
    }
  }
}

function go_accessories(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=420,height=360,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=420,height=360,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=420,height=360,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=420,height=360,top=0,left=0,resizable=no');
    }
  }
}

function go_360tour(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=yes,scrollbars=no,width=550,height=480,top=0,left=0,resizable=yes');
    }
    else // IE Win
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=yes,scrollbars=no,width=550,height=480,top=0,left=0,resizable=yes');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=yes,scrollbars=no,width=550,height=480,top=0,left=0,resizable=yes');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=yes,scrollbars=no,width=550,height=480,top=0,left=0,resizable=yes');
    }
  }
}


function go_360help(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,width=400,height=300,top=0,left=0,resizable=yes');
    }
    else // IE Win
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,width=400,height=300,top=0,left=0,resizable=yes');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,width=400,height=300,top=0,left=0,resizable=yes');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,width=400,height=300,top=0,left=0,resizable=yes');
    }
  }
}


function go_help(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,menubar=no,width=400,height=300,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,menubar=no,width=400,height=300,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,menubar=no,width=400,height=300,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,menubar=no,width=400,height=300,top=0,left=0,resizable=no');
    }
  }
}
function go_selector1(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
  }
}
function go_selector2(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=600,height=420,top=0,left=0,resizable=no');
    }
  }
}
function go_enews(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=360,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=360,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=360,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=360,top=0,left=0,resizable=no');
    }
  }
}
function go_colors(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=555,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=555,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=555,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=560,height=555,top=0,left=0,resizable=no');
    }
  }
}
function go_colors_wide(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=640,height=525,top=0,left=0,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=640,height=525,top=0,left=0,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=640,height=525,top=0,left=0,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=yes,toolbar=yes,menubar=no,width=640,height=525,top=0,left=0,resizable=no');
    }
  }
}

function go_reg(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=500,height=525,top=0,left=0,resizable=yes');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=500,height=525,top=0,left=0,resizable=yes');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=500,height=525,top=0,left=0,resizable=yes');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,menubar=no,toolbar=yes,scrollbars=yes,width=500,height=525,top=0,left=0,resizable=yes');
    }
  }
}

function go_color_selector(url)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // IE Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=no,toolbar=no,menubar=no,width=600,height=650,top=50,left=50,resizable=no');
    }
    else // IE Win
    {
      window.open(url,'','status=yes,location=no,scrollbars=no,toolbar=no,menubar=no,width=600,height=650,top=50,left=50,resizable=no');
    }
  }
  if (navigator.appName != "Microsoft Internet Explorer")
  {
    if ( navigator.appVersion.indexOf( "Macintosh" ) != -1 ) // Netscape Mac
    {
      window.open(url,'','status=yes,location=no,scrollbars=no,toolbar=no,menubar=no,width=600,height=650,top=50,left=50,resizable=no');
    }
    else // Netscape WIn
    {
      window.open(url,'','status=yes,location=no,scrollbars=no,toolbar=no,menubar=no,width=600,height=650,top=50,left=50,resizable=no');
    }
  }
}



// adtrack code

var sStr = "";
function checkSelection(value) {
  //alert(value);
  //alert(document.Order.ZipCode.value);
  //alert(document.Order.canada.value);
  if (value == 'us') {sStr += checkZIPCode(document.Order.ZipCode, 'ZipCode', false);}
  if (value == 'canada') {sStr += checkCAZIPCode(document.Order.Province, 'Canadian ZipCode', false);}

  if (value == 'intl') {
    if (document.Order.Country.selectedIndex == 0) {sStr += "Please choose an international country.\r";}
  }


	if (value == 'form')
	{
		if (sStr != '')
		{
			alert(sStr);
			sStr = '';
			return false;
		}
		
	}
	
	if (sStr != '') {
		return false;
	}	
	return true;

}


//query string cookies

/**
 * Sets a Cookie with the given name and value.
 * names for HS are 'source', 'event', 'id' values are grabbed via getQueryValue from querystring.
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 * setCookie('name',value,'','/'); = root of domain
 */
 // Grab querystring values
 var sSource=getQueryValue('source');
 var sEvent=getQueryValue('event');
 var sID=getQueryValue('eventid');
 // Set cookies expire end of session path root of site
 if (sSource!=""){
 setCookie('source', sSource, '', '/');
 }
 if (sEvent!=""){
 setCookie('event', sEvent, '',  '/');
 }
 if (sID!=""){
 setCookie('eventid', sID, '',  '/');
 }
 
 
 function setEventIDField() {
 // Set Dealerlocator form hidden field eventid value function call onload
 document.getElementById('eventid').value=getCookie('eventid');
}  
 function getQueryValue(name) {
    var regex = new RegExp( "[\?&]"+name+"=([^&#]*)" );
    var results = regex.exec( window.location.href );
    if( results == null )
        return "";
    else
        return results[1];
}
 
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 * name  Name of the desired cookie.
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
