/* ************************
**  Keycode Handling Keycode Handling Keycode Handling
***************************/


// Grab keycode
var myDate=new Date()
	myDate.setFullYear(2009,07,01); //set alert date 1 month earlier is good (months from 0 to 11 where 11=december and 0=january)
	
var lob = "Empresas em Crescimento"; //Name of the Line of Business microsite
var valid = "01-AUG-2009"; //Default Keycode expiration date
var add = "http://www.cisco.com/web/BR/solucoes/pequenas_empresas.html"; //address url
var urlEnd = document.URL.indexOf('?');
var paramstring = "";
var defaultstrSid = "182542_4";
if (urlEnd != -1) {
 
paramstring = "?" + document.URL.substring(urlEnd+1, document.URL.length);
  }
else {
paramstring = "noquerystring";
}		
		// Extracts the values from the url
		function getQueryString(){
			var urlEnd = document.URL.indexOf('?');
			var values = new Array();
			var names;
			
		
			if (urlEnd != -1){
				var params = document.URL.substring(urlEnd+1, document.URL.length).split('&');
				for(i=0; i<params.length; i++) {
					names = params[i].split('=');
					values[names[0]] = names[1];
				
				}
			}
			return values;
		}
		values = getQueryString();
		
		
		//Check to see if sid is Defined.  If not, assign default and append to parameters
		var strSid = unescape(values["sid"]);
		
		if (strSid == 'undefined') {
		    // Check to see if PR_CODE Parameter Exists if Sid not found.
			strSid = unescape(values["PR_CODE"]);
			
		// Default value for strSid when there is no PR_CODE or sid value found
			if (strSid == 'undefined')  {
            strSid = defaultstrSid;
	
			}
			
		// Append Sid to Paramstring
		    defaultstrSid = strSid;
			if (paramstring == 'noquerystring') {
			paramstring = "?sid=" + strSid;
			
			} else {
			paramstring = paramstring + "&sid=" + strSid;
		    
      }
	 }

// Attache keycode to internal link to another in link in same window
	 
function link1(target)
{
var url = target + paramstring;
location.href=(url);
}

function GIST(target)
{
var url = "https://apps.cisco.com/gdrp/coiga/showsurvey.do?surveyCode=" + target + "&keyCode=" + strSid;

	window.open(url,'form').focus();
}

// GIST Function with URL passing
function GISTURL(target, urlpar)
{
var url = "https://apps.cisco.com/gdrp/coiga/showsurvey.do?surveyCode=" + target + "&retUrl=" + urlpar + "&keyCode=" + strSid;
 
 window.open(url,'form').focus();
}


// 	Attach keycode to internal link	- link 2 internal link to pop up form
function link2(target)
{
	var url = target + "&PR_CODE=" + strSid;
	window.open(url,'form').focus();
}

// 	Attach keycode to popup link - link3 internal link to pop up
function link3(target)
{
	var url = target + paramstring;
	window.open(url,'new').focus();
}

// Attach keycode to form in same window (source was pop-up link 3)

 function link4(target)
{
	var url = target + "&PR_CODE=" + strSid;
	location.href=(url);
}

//Attach keycode to SMS Public English
 function sms_public_english(topic_code)
{
	var url = "http://www.cisco.com/pcgi-bin/sreg2/register/banner.pl?PRIORITY_CODE=" + strSid + "&LANGUAGE=E&METHOD=E&TOPIC_CODE=" + topic_code;
	location.href=(url);
}


//Attach keycode to SMS Public Portuguese
 function sms_public_spanish(topic_code)
{
	var url = "http://www.cisco.com/pcgi-bin/sreg2/register/banner.pl?PRIORITY_CODE=" + strSid + "&LANGUAGE=P&METHOD=E&TOPIC_CODE=" + topic_code;
	location.href=(url);
}

//Attach keycode to SMS Public Spanish

 function sms_public_spanish(topic_code)
{
	var url = "http://www.cisco.com/pcgi-bin/sreg2/register/banner.pl?PRIORITY_CODE=" + strSid + "&LANGUAGE=S&METHOD=E&TOPIC_CODE=" + topic_code;
	location.href=(url);
}



// 	Attach keycode to fast track popup link
function fasttrackChildWindow(target, windowname) {
	var url = target + "&PR_CODE=" + strSid;
	//alert (url);
	var appwindow = window.open( url , windowname, "toolbar=yes,status=yes,top=25,left=0,outerWidth=798,outerHeight=547,width=798,height=547,scrollbars=yes,resizable=yes,menubar=yes,locationbar=no,");
  	appwindow.focus();
}

// 	Attach keycode to Quickstart popup link
function quickstartChildWindow(target, windowname) {
	var url = target + paramstring;
	//alert (url);
	var appwindow = window.open( url , windowname, "toolbar=yes,status=yes,top=25,left=0,outerWidth=798,outerHeight=547,width=798,height=547,scrollbars=yes,resizable=yes,menubar=yes,locationbar=no,");
  	appwindow.focus();
}

