/* ************************
**  Keycode Handling
***************************/

// Grab keycode 
var urlEnd = document.URL.indexOf('?');
var paramstring = "";
var defaultstrSid = "";
var topic_code = "S3828";
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;
		    
      }
	 }
	 
// 	Attach keycode to internal link	

// 	Attach keycode to popup link for SMS Private
function SMSprivate(topic_code)
{
//var url = "http://www.cisco.com/pcgi-bin/sreg2/register/regdetail_private.pl?LANGUAGE=E&METHOD=E&TOPIC_CODE=" + topic_code + "&PRIORITY_CODE=" + strSid;
var url = "http://www.cisco.com/pcgi-bin/sreg2/register/postcookie.pl?SESSION_ID=&USER_TYPE=&LANGUAGE_ID=E&PAGE_NO=SEMINARDETAIL&SEMINAR_TYPE=T&DETAIL_ID_AND_LOCATION=34438:-:8436:-:OPEN&SEMINAR_ID=7580&SESSION_KEY=&METHOD=E&PRIORITY_CODE=" + strSid + "&BANNER_FLAG=&COUNTRY_ID=&CITY_ID=&STATE_ID=&START_DATE=&END_DATE=&TOPIC_CODE=" + topic_code;
window.open(url,'SMSform').focus();
}


// 	Home browsing to pass the sid within the landing page
function index()
{
var url = "./index.html?sid=" + strSid;
top.location.href = url;
}
function booth()
{
var url = "./booth.html?sid=" + strSid;
top.location.href = url;
}

function demo()
{
var url = "./demo.html?sid=" + strSid;
top.location.href = url;
}

function speaking()
{
var url = "./speaking.html?sid=" + strSid;
top.location.href = url;
}

function home_booth()
{
var url = "http://www.cisco.com/offer/globalcomm/booth.htm?sid=" + strSid;
top.location.href = url;
}
//  Home browsing to pass the sid through the landing pages


// 	Attach keycode to popup link for SMS Public
function SMSpublic(topic_code)
{
var url = "http://www.cisco.com/pcgi-bin/sreg2/register/banner.pl?LANGUAGE=E&METHOD=E&TOPIC_CODE=" + topic_code + "&PRIORITY_CODE=" + strSid;

window.open(url,'SMSform').focus();
}

// 	Attach keycode to popup link for WST
function GIST(target)
{
var url = "https://tools.cisco.com/gdrp/coiga/showsurvey.do?surveyCode=" + target + "&keyCode=" + strSid;
	window.open(url,'form').focus();
}

// 	Attach keycode to popup link for WST
function bufferkc(target)
{
var url = target + paramstring;
location.href=(url);
}

function bufferkcNW(target)
{
var url = target + paramstring;
window.open(url,'form').focus();
}