// wap_portal_setup.js

if (location.pathname.indexOf(".")>-1) {
	var pathObj = ParseURLPathName( location.pathname.toLowerCase());
}
else {
	var pathObj = ParseURLPathName( location.pathname.toLowerCase() +"/" );
}



// ParseURLPath()
//        input:  string - the URL path name of the web page in question
//       output:  object - pathObject { dir[], fullDir, fileName }
//  description:  parses the URL path into its component directories and file name.
//                e.g. "/a/b/foo.htm" becomes pathObject.dir[0] = "a",
//			      pathObject.dir[1] = "b", pathObject.fullDir = "/a/b/",
//				  pathObject.fileName = "foo.htm"
//
function ParseURLPathName(strURL)
{		
	var pathObject = new Object();
	pathObject.dir = new Array();

	// Assumed input string format:  
	// <URL_path><file_name> i.e. <dir1><dir2>...<dirN><file_name>
	//
	// /^             // match at beginning of string
	//   (.+?)        // non-greedily match and capture all.  Targets <dir1>
	//   (?:\/)+      // match zero or more "/" without capture
	//   (.*)         // greedily match all.  Targets <dir2>...<dirN><file_name>
	// /
	//
	// Note:  This is a much more complicated approach than strURL.split("/"),
	// but I thought it necessary for the rare case when multiple forward-slashes
	// are included in the URL path, e.g. a/b//c/d//foo.htm
	//
	i = 0;
	pathObject.fullDir = "/";
	strURL = strURL.replace(/^\//,"");  // Remove any beginning / in our URL
	while ((node = strURL.match(/^(.+?)(?:\/)+(.*)/)) && node[0].length)
	{
		pathObject.dir[i++] = node[1]; 					
		pathObject.fullDir += node[1] + "/";
		strURL = node[2];
	}
	pathObject.fileName = strURL;
	return pathObject;
}

function consGetOrg4(){

var pathObj3=(typeof pathObj.dir[3] == "undefined") ? "landing" : pathObj.dir[3].toLowerCase();

	//Check to see if p_org is being passed in. If it is, use it.
	if (typeof window.p_org4 != "undefined"){
		var p_org4=window.p_org4;
	}else{
		p_org4 = pathObj3;
	}
	p_org4 = wa_org3 + ":" + p_org4;
	return unescape(p_org4);
}

function consGetOrgX(){
	
	var pathObj4=(typeof pathObj.dir[4] == "undefined") ? "|" + wa_org4 + ":" : pathObj.dir[4].toLowerCase();

	var p_orgX = pathObj4 + "|" + thepathandpage;

	p_orgX = wa_org4 + ":" + p_orgX;
	return unescape(p_orgX);
}	

if(sectionsName=="embedded"){
  function setContentCatEmbedded(){
	  var loc = location.pathname.toLowerCase();
	  if(loc.indexOf('/p/s/') != -1){
		  loc = loc.split(pathObj.dir[2]);
		  loc = loc[1];
	  }
	  else{
		  loc = loc.split(pathObj.dir[1]);
		  loc = loc[1];
	  }
	  loc=loc.replace(/\/$/,""); //remove / if last char

	  for (var i=0; i < metricsArray.length; i++){
		var thisUrlValuePair = metricsArray[i];
		if(loc==thisUrlValuePair.url){
			p_contentcat = thisUrlValuePair.val; //match 
			break;
		}
		else{
			p_contentcat = "ssc:detail"; //default
		}
	  }
  }
    
  function urlValuePair(_url,_val){
	  this.url = _url.toLowerCase();
	  this.val = _val.toLowerCase();
  }
  
  var p_contentcat = "";
  var metricsArray = [];

  //============================================================================
  // Add URLs and Values here:
  //============================================================================
  metricsArray.push(new urlValuePair("/embedded","ssc:nav"));
  metricsArray.push(new urlValuePair("/embedded/hwsw","ssc:nav"));
  
  metricsArray.push(new urlValuePair("/embedded/hwsw/hardware","ssc:intro"));
  metricsArray.push(new urlValuePair("/embedded/hwsw/software","ssc:intro"));  
  metricsArray.push(new urlValuePair("/embedded/hwsw/technology","ssc:intro"));
  metricsArray.push(new urlValuePair("/embedded/applications","ssc:intro"));
  metricsArray.push(new urlValuePair("/embedded/designcenter","ssc:intro"));
  
  metricsArray.push(new urlValuePair("/embedded/hwsw/hardware/atom","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/hwsw/hardware/xeon","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/hwsw/hardware/core","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/designcenter/migration","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/designcenter/contactus","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/designcenter/tools","ssc:overview"));
  metricsArray.push(new urlValuePair("/embedded/designcenter/glossary","ssc:overview"));
    
  metricsArray.push(new urlValuePair("/embedded/applications/communications-infrastructure","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/connected-gateway","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/digital-security-surveillance","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/digital-signage","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/embedded-gaming","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/energy","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/enhanced-thin-client","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/in-vehicle-infotainment","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/industrial","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/machine-to-machine","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/media-phone","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/medical","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/military","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/security","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/retail","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/routers-switches","ssc:detail"));
  metricsArray.push(new urlValuePair("/embedded/applications/wireless-infrastructure","ssc:detail"));
  //============================================================================
  setContentCatEmbedded();	
}
