function stripSpan(str) {

	if (str.indexOf('<span') > -1)
	{
		str = str.substring(str.indexOf('>')+1);
		str = str.substring(0,str.indexOf('<'));	
	}
	return str;
}

//TOGGLE, DISPLAY, HIDE LAYER FUNCTIONS
function toggleLayer( whichLayer )
    {  
        var elem, vis;  
        if (document.getElementById) // this is the way the standards work
            elem = document.getElementById( whichLayer );  
        else if( document.all ) // this is the way old msie versions work
            elem = document.all[whichLayer];  
        else if( document.layers ) // this is the way nn4 works 
            elem = document.layers[whichLayer]; 
        vis = elem.style;          
        // if the style.display value is blank we try to figure it out here
        if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) 
            vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';             
        vis.display = (vis.display==''||vis.display=='block')?'none':'block';
    }


function displayLayer( whichLayer )
   {  
        var elem, vis;  
        if (document.getElementById) // this is the way the standards work
            elem = document.getElementById( whichLayer );  
        else if( document.all ) // this is the way old msie versions work
            elem = document.all[whichLayer];  
        else if( document.layers ) // this is the way nn4 works 
            elem = document.layers[whichLayer]; 
        vis = elem.style;          
        // if the style.display value is blank we try to figure it out here
        if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
          vis.display = 'block';          
        vis.display = 'block';
   }

function hideLayer( whichLayer )
   {  
        var elem, vis;  
        if (document.getElementById) // this is the way the standards work
            elem = document.getElementById( whichLayer );  
        else if( document.all ) // this is the way old msie versions work
            elem = document.all[whichLayer];  
        else if( document.layers ) // this is the way nn4 works 
            elem = document.layers[whichLayer]; 
        vis = elem.style;          
        // if the style.display value is blank we try to figure it out here
        if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) 
        	vis.display = 'none';
        vis.display = 'none';
   }


/****************************************************************/
//	COOKIE FUNCTIONS
/****************************************************************/

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function setCookieInMinutes(c_name,value,minsval)
{
var now = new Date();
now.setMinutes(now.getMinutes() + minsval);
var c_value=escape(value) + ((now==null) ? "" : "; expires="+now.toUTCString());
document.cookie=c_name + "=" + c_value;
}




/****************************************************************/
//	SET TEST VARIABLES
/****************************************************************/
var currentURL = window.location.href;

var dToday = new Date();
var iSelectedID, sCookieVal,bNoRedirect;
var sTestName = 'CareersAB2011';
var dStartDate = new Date(2011,2,1);
var dEndDate = new Date(2011,2,26);
var iDaysToEnd = dEndDate.getDate() - dToday.getDate();
var arrCareers = new Array(2);
arrCareers[0] = "/us/aboutamd/careers/pages/careers.aspx";
arrCareers[1] = "/us/aboutamd/careers/pages/careers2.aspx";

currentURL = currentURL.toLowerCase();

if (currentURL.indexOf(arrCareers[0]) > 0){

	if ((dToday > dStartDate) && (dToday < dEndDate)) 
	{
	
		//alert('inside date window');
		sCookieVal = getCookie(sTestName);

		if (sCookieVal)
		{
		//alert('cookie found' + sCookieVal);
			if (currentURL.indexOf(sCookieVal) > 0)
			{
				//alert('no redirect needed with cookie= ' + sCookieVal);	
				bNoRedirect = true;		
			}
			else
			{
				//alert('redirect with cookie = ' + sCookieVal);
				window.location.href = 'http://' + window.location.hostname + sCookieVal;	
			}
		}

		else{

			iSelectedID = Math.floor(Math.random()*arrCareers.length);
			setCookie(sTestName,arrCareers[iSelectedID],iDaysToEnd);
						
			if (currentURL.indexOf(arrCareers[iSelectedID]) > 0)
			{
				//alert('no redirect needed without cookie= ' + arrCareers[iSelectedID]);
				bNoRedirect = true;
			}
			else
			{
				//alert('redirect without cookie= ' + arrCareers[iSelectedID]);
				window.location.href = 'http://' + window.location.hostname + arrCareers[iSelectedID];
	
			}
		}
	}
}




// Flash Pop ups
function PlaySWF(link, size, name) {
	window.open("http://enterpriseevent.amd.com/enterprise_assets/player_" + size + ".html?vid=" + name, "win", "width=500,height=225");
}

function PopUpSWF(link, name, width, height){
	if(width) window.open(link, name, "width="+width+",height="+height);
	else window.open(link, name);
}


//GLOBAL SEARCH FUNCITONS
var GblSearch_hostName = 'http://search.amd.com/';

function GblSearch_DoSubmit(hostName, variationName, keywordTerm, collectionName){

		if (hostName == '')
			hostName = 'http://search.amd.com/';
		if (variationName.length != 2)
			variationName = 'us';
		if (collectionName == '')
			collectionName = 'all-us';
		
    	var newURL = hostName + variationName + '/_layouts/search/search.aspx?csquery=' + keywordTerm + '&collection=' + collectionName;

		document.location = newURL;
		return true;
}

function GblSearch_checkEnter(e){ 
	 	e = e || window.event;
		var keynum = e.keyCode || e.which;
		if(keynum === 13){
			GblSearch_DoSubmit(GblSearch_hostName, GblSearch_variationName, document.forms[0].search_csquery.value, GblSearch_collectionName);
			return false;
		}
		else
			return true;
}

function GblSearch_disableKeypress(value){ 
		if (value != '')
			document.forms[0].onkeypress = '';
}

function GblSearch_findCollectionName(variationName){ 
		var tmpCollectionName;
		var tmpCurrentURL = window.location.href;
		tmpCurrentURL = tmpCurrentURL.toLowerCase();
		
		if (variationName.length != 2)
			variationName = 'us';
		//WWW SITE COLLECTIONS
		if (tmpCurrentURL.indexOf('http://www') > -1){
			if (tmpCurrentURL.indexOf('/products/') > -1)
				tmpCollectionName = 'products-' + variationName;
			else if (tmpCurrentURL.indexOf('/aboutamd/') > -1)
				tmpCollectionName = 'corporate-' + variationName;
			else
				tmpCollectionName = 'all-' + variationName;
		}
		//DEVELOPER SITE COLLECTIONS
		else if (tmpCurrentURL.indexOf('http://developer') > -1){
			tmpCollectionName = 'developer-' + variationName;
		}
		//SUPPORT SITE COLLECTIONS
		else if (tmpCurrentURL.indexOf('http://support') > -1){
			tmpCollectionName = 'support-' + variationName;
		}
		else{
			tmpCollectionName = 'all-' + variationName;
		}
			
		return tmpCollectionName;
}



//QUERY STRING FUNCTIONS

function $Querystring(qs) {
    return new Querystring(qs);
}
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	this.keys = new Array();
	this.path = (qs && qs.indexOf('?') > 0) ? qs.split('?')[0] : location.protocol +location.host + location.pathname;
 
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;
	if (qs.indexOf('?') > 0)
	    qs = qs.split('?')[1];
 
    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
 
    // split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
 
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
 
		this.keys[i] = name;
		this.params[name] = value;
    }
}
 
Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}
Querystring.prototype.set = function(key, value) {
    value = encodeURI(value);
    this.params[key] = value;
    var index = this.indexOfKey(key);
    if (index < 0)
        this.keys[this.keys.length] = key;
 
    return this;
}
Querystring.prototype.indexOfKey = function(key) {
	for (var i = 0; i < this.keys.length; i++)
    {
        if(this.keys[i] == key)
            return i;
    }
    return -1;
}
Querystring.prototype.remove = function(key) {
    var index = this.indexOfKey(key);
    if (index >= 0) {
        this.params[key] = null;
        this.keys.splice(index, 1);
    }
    return this;
}
Querystring.prototype.toString = function() {
    var ret = "";
    for (var i = 0; i < this.keys.length; i++)
    {
        if(this.keys[i])
            ret += ((i == 0) ? "?" : "&") + this.keys[i] + "=" + this.params[this.keys[i]];
    }
    return ret;
}
Querystring.prototype.getAbsolutePath = function() {
    return this.path;
}
Querystring.prototype.toAbsoluteUrl = function() {
   return this.path + this.toString();
}
Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

//TRUETAG INSTALLATION
// Copyright Channel Intelligence, Inc. 2002-2008
var ci_vid= 16775070;
var ci_cookieDomain=".amd.com";
var ci_refDomain=".amd.com";
var ci_imgs=[];

function ci_FP(ci_pix_url,protocol){var ci_pic=document.createElement('img');ci_pic.src=(protocol!==undefined ? protocol + '://' : (window.location.protocol.toLowerCase() == 'http:' ? 'http://' : 'https://'))+ci_pix_url;ci_imgs[ci_imgs.length]=ci_pic;}
function ci_FP_SCRIPT(ci_pix_url, protocol){document.write('<script type="text/javascript" src="' + (protocol !== undefined ? protocol + '://' : (window.location.protocol.toLowerCase() == 'http:' ? 'http://' : 'https://')) + ci_pix_url + '"></script>');}
function ci_RQV(name,dValue){
    var qArg=new RegExp('[\\?&]'+name+'=?([^&#]*)','i').exec(window.document.location);
    if(qArg===null){return dValue===undefined?null:dValue;}else if(qArg.length<2){return '';}else{return qArg[1];}
}
function CI_GetValue(ci_vName,ci_dValue) {
	if (typeof(window[ci_vName])!=="undefined"){return window[ci_vName];}else{return ci_dValue===undefined?null:ci_dValue;}
}
function CI_LogError(err, customIdentifier) {
	try {
		var oI=new Image();oI.src='https://secure.channelintelligence.com/links/support/js.error.asp?nVID='+ci_vid+'&sCustomerIdentifier='+customIdentifier+'&sMessage='+encodeURIComponent(err.message)+'&sName='+encodeURIComponent(err.name)+'&nNumber='+(err.number&0xFFFF).toString();
	}catch (err1) {}
}
function ci_CC(name,value,daysTillExpire){
	if (daysTillExpire){
		var exDate=new Date();
		exDate.setTime(exDate.getTime()+(daysTillExpire*24*60*60*1000));
		document.cookie=name+'='+value+'; expires='+exDate.toGMTString()+'; domain='+ci_cookieDomain+'; path=/';
	}
}
function ci_UID(value){
	var today=new Date();
	var UID=ci_vid+"-"+value+"-"+Math.floor(Math.random()*9999999999)+today.getFullYear().toString()+today.getMonth().toString()+ today.getDay().toString()+today.getHours().toString()+today.getMinutes().toString()+today.getSeconds().toString()+today.getMilliseconds().toString();
	return UID;
}
function ci_PIX(loc,eid,tid,src,sku,tag){
	try{
		var url='';
		if (loc===2){url=window.location.protocol.toLowerCase()=='http:'?'cts-log.channelintelligence.com?':'ttwbs.channelintelligence.com?';}
		if (loc===3){url='rdr.tag.channelintelligence.com/log.aspx?';}
		url+='vid='+ci_vid+'&eid='+eid+'&tid='+tid;
		if(src!==null){url+='&src='+src;}
		if(sku!==null){url+='&sku='+sku;}
		if(tag!==null){url+='&tag='+tag;}
		url += "&ref="+escape(document.referrer);
		return ci_FP(url);
	}catch(err){CI_LogError(err, 'landing_ci_PIX_function');}
}
try {
	var ci_cpncode=ci_RQV('cpncode');
	var ci_srccode=ci_RQV('srccode');
	var ci_src=ci_RQV('ci_src');
	var ci_sku=ci_RQV('ci_sku');
	var ci_tag=ci_RQV('ci_tag');
	
	//This is the variable that needs to have the SKU value.
	var ci_itemid=CI_GetValue('',null);
	
	var ci_tid=ci_RQV('ci_tid', '');
	if(ci_tid===''){
		ci_tid=ci_UID(ci_sku);
	}
	
	try{
		if(document.referrer.toLowerCase().indexOf(ci_refDomain)===-1){
			ci_FP_SCRIPT('segment-pixel.invitemedia.com/pixel?code=VID_16775070_S&clientID=2874&key=segment&returnType=js');
		}	
		if(ci_itemid!==null){
			ci_FP(
				'ads.youknowbest.com/default.ashx?vid=' + ci_vid
				+(ci_itemid===null?'':'&sku='+ci_itemid)
			);
		}
	}catch(err){CI_LogError(err, 'landing_PerformanceMkting');}

	if(ci_cpncode!==null){
		ci_CC('ci_cpncode',ci_cpncode,30);
		ci_CC('ci_src',ci_srccode,30);
		ci_CC('ci_tid',"",-1);
	} else if(ci_src!==null && ci_sku!==null) {
		ci_CC('ci_cpncode',"",-1);
		ci_CC('ci_tid',ci_tid,30);
		ci_CC('ci_src',ci_src,30);
		ci_PIX(2,23,ci_tid,ci_src,ci_sku,null);
	} else if(ci_tag!==null) {
		ci_CC('ci_cpncode',"",-1);
		ci_CC('ci_tid',ci_tid,30);
		ci_PIX(2,7,ci_tid,null,ci_itemid,ci_tag);
	} else if(document.referrer.toLowerCase().indexOf(ci_refDomain)===-1&&document.referrer!==''){
	    ci_PIX(2,13,null,null,ci_itemid,null);
	}
	ci_PIX(2,49,null,null,ci_itemid,'landing');
}catch(err1){CI_LogError(err1, 'landing');}

