//<!-- hiding javascript code
	//   DO NOT ALTER THIS SCRIPT                 
	//   ....unless you really now what you are doing 
	//   These functions work as the "engine", and should not be touched.
	var synonymArray = [[]];
	var boxStyleClass = "v14-header-2";	
function getNumRows(n,locStr){

		return contentArray[n].length;
	}
	function getName(j){
		return bpArray[j]; 
	}
	function getTitleName(j,locStr){

		return subjectArray[j];
	}
	
	function getContentArray(j){
		return contentArray[j];
	}
	function getContentString(j){
		return (j>(contentArray.length+1))?" ":bpArray[contentArray[j]];
		
	}	
	function getArrayColumn(val,locStr){

		return contentArray[val];
		
	}
	function translateLocationState(s){
		for(var i=0;i<locationArray.length;i++){
			if(locationIdentifierArray[i]==s){	
				return i;
			}
		}
		return 0; // nothing were found, shouldnt happen!!!
	}
	//This method is responsible for constructing the table
	function writeBPTable(state,loc,useSynonym,targetStr){
		/*variable declarations */
		targetStr = targetStr + "_xmlid";
		var synonymID=state;
		if(useSynonym){
			state = synonymArray[synonymID][0];
		}
		
		if(state<0||state>=contentArray.length){
			alert("An error has occured, state variable \""+loc+"="+state+"\" is out of range.");
			return null;
		}


		var topheader="<div class=\"ibm-container\"><h2>"+getTitleName(state,loc)+"</h2><div class=\"ibm-container-body\">";		
		var header = "<div style=\"float: left; width: 140px; padding-right: 5px;\"> <ul class=\"ibm-bullet-list\">";	
		var middle = "</ul></div><div style=\"float: left; width: 140px; padding-right:5px;\"> <ul class=\"ibm-bullet-list\">";
		var footer = "</ul></div></div></div>";

		var bpElementHeader = "<li><a class=\"ibm-feature-link\" href=\"";
		var bpElementMiddle = "\">";
		var bpElementFooter = "</a></li>";

				
		//The "original" html source obtained from the old xml files
		//var topheader="<table cellspacing=\"0\" cellpadding=\"0\" width=\"443\" border=\"0\"><tbody><tr><td class=\"v14-header-2\">"+ getTitleName(state,loc) +"</td></tr>";
		//var header = "<tr><td><table class=\"v14-gray-table-border\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody><tr><td width=\"443\"><table cellspacing=\"0\" cellpadding=\"0\" width=\"430\" align=\"left\" border=\"0\"><tbody><tr><td colspan=\"5\"><img height=\"7\" alt=\"\" src=\"//www.ibm.com/i/c.gif\" width=\"1\" /></td></tr><tr><td valign=\"top\" width=\"140\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>";
		//var middle = "</tbody></table></td><td width=\"5\"><img height=\"1\" alt=\"\" src=\"//www.ibm.com/i/c.gif\" width=\"5\" /></td><td valign=\"top\" width=\"140\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>";
		//var footer = "</tbody></table></td></tr><tr><td colspan=\"5\"><img height=\"10\" alt=\"\" src=\"//www.ibm.com/i/c.gif\" width=\"1\" /></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>";
		//var bpElementHeader = "<tr class=\"bullet-list\"><td class=\"bbl\"> </td><td width=\"125\"><a class=\"fbox\" href=\"";
		//var bpElementMiddle = "\">";
		//var bpElementFooter = "</a></td></tr>";
		var name = "";
		var content = "";
			
		/* generate vars that determine the number of elements in each row */
		var numPerRow = Math.ceil(getNumRows(state,loc)/3);
		
		/* Build array */
		
		var array = getArrayColumn(state,loc);
		if(array.length!=1){
			array = sortArray(array);
		}

		/* doc writing */
		document.write(topheader);
		document.write(header);
		
		
		var arrayCnt = 0;
		var dist;
		/*The row loop*/
		for(g=0;g<=2;g++){			
			/*the column loop*/
			if(g!=0 && (array.length%3==g)){
				dist = numPerRow-1;
			}else{
				dist = numPerRow;
			}
			for(h=0;h<dist;h++){
				if(arrayCnt>(array.length-1)){
					break;
				}
				document.write(bpElementHeader);
				//document.write((useSynonym&&synonymArray[synonymID][2])?buildURL(targetStr,bpArray[array[arrayCnt]][2]):bpArray[array[arrayCnt]][1]);
				
				if(useSynonym&&synonymArray[synonymID][2]&&!isNaN(bpArray[array[arrayCnt]][2])&&bpArray[array[arrayCnt]][2]>0){
					document.write(buildURL(targetStr,bpArray[array[arrayCnt]][2]));
				}else{
					document.write(bpArray[array[arrayCnt]][1]);
				}
				document.write(bpElementMiddle);
				document.write(bpArray[array[arrayCnt]][0]);
				document.write(bpElementFooter);
				arrayCnt++;
			}
			if(g!=2){
			document.write(middle);
			}
		}
		document.write(footer);
	}
	
	
	function buildURL(tStr, tURL){ //used with synonyms, to build urls correctly. Main usage is nordic simple solutions partners.
		//var sitePath = "http://www-03preview.ibm.com/businesscenter/smb/dk/da/rss/some_xmlid/securitypartners/gcl_xmlid/39721";
		var sitePath = (window.location.href);
		//alert("before:\n"+sitePath);
		if(sitePath.match(tStr)){
			var tmpSlashedSplitArr = sitePath.split("/");
			var tmpString = "";
			if(tmpSlashedSplitArr.length>0){
				for(var t=0;t<tmpSlashedSplitArr.length;t++){
					if((t==0)||((t-1>=0) && tmpSlashedSplitArr[t]!=tStr && tmpSlashedSplitArr[t-1]!=tStr)){
							tmpString +=tmpSlashedSplitArr[t] + "/";
					}
					
				}
			}
			sitePath = tmpString;
		}
		//alert("after:\n"+sitePath);
		
		
		var tmpSplitArr = sitePath.split("?");
		var url_path;
		if(tmpSplitArr.length==2){
			url_path= tmpSplitArr[0];
			if(url_path.charAt(url_path.length-1)!="/"){
				url_path +="/";
			}
			url_path += tStr + "/" + tURL + "?" + tmpSplitArr[1]; 
		}else{
			url_path = sitePath;
			if(url_path.charAt(url_path.length-1)!="/"){
				url_path +="/";
			}
			url_path += tStr + "/" + tURL;
			
		}
		//alert("done:\n"+url_path);
		return url_path;
	}
	
	//This function sorts the business partners alphabetically
	// Its not a very fast sorting algorithm (O(n^2)) but works well with few elements (n<100 approximately) 
	function sortArray(array){
		var tmpVal=0;
		var b=0;
		for(a=0;a<=(array.length-1);a++){
			for(b=a;b<=(array.length-1);b++){
				var dist;
				var bool=false;
				if(bpArray[array[a]][0].length<=bpArray[array[b]][0]){
					dist=bpArray[array[b]][0].length;
				}else{
					dist=bpArray[array[a]][0].length;
				}
				for(c=0;c<=(dist-1);c++){						
					if(bpArray[array[a]][0].toLowerCase().charAt(c)>bpArray[array[b]][0].toLowerCase().charAt(c)){
						bool=true;
						break;
					}
					if(bpArray[array[a]][0].toLowerCase().charAt(c)!=bpArray[array[b]][0].toLowerCase().charAt(c)){
						break;
					}
				}
				if(bool){
					tmpVal=array[b];
					array[b]=array[a];
					array[a] = tmpVal;
				}
			}		
		}
		return array;
	}
	function gup(name){
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp(regexS);
		var results = regex.exec(window.location.href);
		if( results == null ){
			return null;
		}else{
			return results[1];
		}
	}
	
	function analyzePathSynonyms(){
		var splitArr = [];		
		if(synonymArray.length!=0){
			for(var k=0;k<synonymArray.length;k++){
				splitArr = window.location.href.split(synonymArray[k][1]);
				if(splitArr.length == 2){
					//alert("found: "+k);
					return k;
				}
			}
		}
		//alert("found nothing");
		return null;
	}
	function displayTable(elementString){
		var elementValue = gup(elementString);
		if(elementValue!=null){
			writeBPTable(elementValue,elementString,false,"");
		}
	}
	//deprecated, should 
	function displayPathGovernedTable(target){	
		elementValue = analyzePathSynonyms();
		if(elementValue!=null){
			writeBPTable(elementValue,"",true,target);
		}
	}
	function displayCategory(elementValue, shouldUseTargets,targetString){
		writeBPTable(elementValue,"",shouldUseTargets,targetString);
	}
// end hiding -->