/* --- Premium Content Code --- */
/* this file must be used in conjunction with /web/fw/j/utils.js and /web/fw/j/premium.js */
/* premiumURL is the URL of the survey - with Kana this is the short form URL */
var premiumURL='https://tools.cisco.com/gdrp/coiga/showsurvey.do?surveyCode=1679&keyCode=';
/* defaultKeyCode is the default keycode passed, ie the "organic traffic" keyCode */
var browserURL=document.location.href;
var hrefID=browserURL.split("?&keycode=");
var defaultKeyCode;

if(hrefID[1]!=undefined)
{
	defaultKeyCode=String(hrefID[1].substr(0,8));
	set_cookie("keycodeID",defaultKeyCode);
}else
{
	if(get_cookie('keycodeID')!="")
	{ defaultKeyCode=String(get_cookie('keycodeID')); }
	else
	{ defaultKeyCode='163818_1' }
}

/*if(get_cookie('keycodeID')!=emailKeyCode)
{
	defaultKeyCode='158436_5';
}else
{
	defaultKeyCode=String(get_cookie('keycodeID'));	
}*/

function get_cookie(Name) 
{
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime() + (30 * 24 * 3600 * 1000));

function set_cookie(name, value) 
{
	var argv = set_cookie.arguments; 
	var argc = set_cookie.arguments.length; 
	var expires = largeExpDate; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 

	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) + 
	((domain == null) ? "" : ("; domain=" + domain)) + 
	((secure == true) ? "; secure" : "");
}

/* showLock=true will add a padlock icon next to each premium content link */
var showlock=true;
/* The following variables define which padlock image is used, its size and alt attribute */
var lockImg='http://www.cisco.com/swa/i/padlock.gif';
var lockW='7';
var lockH='9';
var lockMsg='Requires log in';

addEvent(window,'load',rewriteLinks);
/* --- Premium Content Code --- */