// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


// COOKIE FUNCTIONS

function setCookie(c_name,value,expiredays) {
  hostname = location.hostname;
  var hostnameLoc = hostname.indexOf(".hughesnet.com");
  var hostused = hostname.substring(hostnameLoc + 1, hostname.length);
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	";domain="+hostused+
	";path=/"+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)	{
	if (document.cookie.length>0)	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}

function deleteCookie(c_name) {
	document.cookie = c_name + '=;path=/;expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

function getParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



// SET AND READ CAMPAIGN-BASED COOKIES
var campaign_token_param = getParam('campaign_token'); 
if (campaign_token_param) { setCookie('campaign_token',campaign_token_param,30); }
