function stripSpan(str) {

	if (str.indexOf('<span') > -1)
	{
		str = str.substring(str.indexOf('>')+1);
		str = str.substring(0,str.indexOf('<'));	
	}
	return str;
}


// 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);
}

function goToLanguage(selectedLanguage)
{   
var lang = location.href.indexOf('&lang');   
var loc = location.href.substring(0, lang);   
loc = loc + '&lang=' + selectedLanguage;   
location.href = loc;
}

//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;
		
		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;
		}
		//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;
}

/****************************************************************/
//	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;
}


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';
	var str = '';
	var element;
//	var tmpAcct = hbx.acct;
	var pathArray = new Array();
	
	pathArray = top.location.pathname.split( '/' );

	str = whichLayer;

	if (str!='')
	{
		str = 'SUP_DriverDL_' + pathArray[1].toString().toUpperCase() + '_' + str;
		if (70 < String(str).length)   // Invalid bound, return
			str = String(str).substring(0,70);
		
		//Process Omniture Tracking
		var s=s_gi('amdvsupport,amdvglobal');
		s.linkTrackVars='events';
		s.linkTrackEvents='event15';
		s.events='event17';
		s.trackingServer="metrics.amd.com";
		s.tl(this,'o',str);
	}
   }
  
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';
   }
  
  
    
function ToggleTracking()
{
	var str = '';
	var element;
//	var tmpAcct = hbx.acct;
	var pathArray = new Array();
	
	pathArray = top.location.pathname.split( '/' );

	str = whichLayer;

	if (str!='')
	{
		str = 'SUP_DriverDL_' + pathArray[1].toString().toUpperCase() + '_' + str;
		if (70 < String(str).length)   // Invalid bound, return
			str = String(str).substring(0,70);
		
		//Process Omniture Tracking
		var s=s_gi('amdvsupport,amdvglobal');
		s.linkTrackVars='events';
		s.linkTrackEvents='event15';
		s.events='event17';
		s.trackingServer="metrics.amd.com";
		s.tl(this,'o',str);

	}
}

