function setCookie(c_name,value,expiredays) {
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+((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 jsQuerystring(qs) {
	this.params = new Object()
	this.get=jsQuerystring_get	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)
	if (qs.length == 0) return
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&')
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])
		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name		
		this.params[name] = value
	}
}
function jsQuerystring_get(key, default_) {
	if (default_ == null) default_ = null;	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

var qs=new jsQuerystring();
var cid=qs.get('cid','');

// if this came from a google natural search, autoset cid to 145.
if((cid=='')&&(document.referrer.indexOf('google')>-1)) { cid='145'; }

if(cid!='') setCookie('cid',cid,120);
if(location.href.indexOf('###')>-1) { setCookie('cid','204',120); window.location='http://www.velaro.com?cid=204'; }
if(location.href.indexOf('/irce')>-1) { window.location='http://www.livefluence.com?cid=193'; }
if(document.referrer.indexOf('toptenreviews')>-1) { setCookie('cid','144',120); if(cid=='') window.location='http://www.velaro.com?cid=144'; }
if(document.referrer.indexOf('zazachat')>-1){ setCookie('cid','155',120); if(cid=='') window.location='http://www.velaro.com?cid=155'; }
if(document.referrer.indexOf('linkedin')>-1) {setCookie('cid','168',120); if(cid=='') window.location='http://www.velaro.com?cid=168'; }
if(document.referrer.indexOf('campustechnology.com')>-1) {setCookie('cid','180',120); if(cid=='') window.location='http://www.velaro.com?cid=180'; }
if(location.href.indexOf('/webinar-live-help-registration.asp')>-1) if(cid=='') { window.location='http://www.velaro.com/webinar-live-help-registration.asp?cid=235'; }



var campaignid = getCookie('cid');
if(campaignid!='') {
 campaignid='&CampaignID='+campaignid;
 if(cid=='') {
    cid=getCookie('cid');
 }
}

var vkeywords='';
var kw = getCookie('vkeywords');
vkeywords = kw;
if(kw!='') kw = '&Keywords='+kw;

var actualorigin = '';
actualorigin = escape(window.document.referrer.replace("&","*"));
