/*globals  $$, window, document, location, browserType, portlet_with_empty_content, ie, displaySignInfo, displaySignInfo1, subnav, winName, setTimeout, strSearchURL */

"use strict";
// JavaScript Document
var activeSearchItem = "0";
var gebi = document.getElementById;
var navLabels = [];
var searchLabels = [];
var navSearchLink = [];
var subMenu;
var searchIndex = 0;

var navIds = ['nav0', 'nav1', 'nav2', 'nav3', 'nav4'];

var navArray = [];
var navLinkArray = [];
var navLinkArrayLabels = [];
var iIndex = 0;
var jIndex = 0;
var mouseOut = false;
var id = "";
var omniturelocaleMap =  {"products:en_US": "eng", "support:en_US": "eng","products:ja_JP": "jpn","products:es_XL": "spanish","products:pt_BR": "portuguese"};
var omnituregeoMap =  {"products:en_US": "asmo-na", "support:en_US": "asmo-na","products:ja_JP": "ijkk","products:es_XL": "asmo-lar","products:pt_BR": "asmo-lar"};
var omnitureorg1Map =  {"products:en_US": "cim", "support:en_US": "supp","products:ja_JP": "ijkk","products:es_XL": "lar","products:pt_BR": "lar"};
var omniturereportSuitesMap =  {"products:en_US": "intelcorpcim,intelcorpprod", "support:en_US": "intelcorpsupp","products:ja_JP": "intelcorpcimijkk, intelcorpijkkprod","products:es_XL": "intelcorplar,intelcorplarspa,intelcorplarspaprod","products:pt_BR": "intelcorplar,intelcorplarpor,intelcorplarporprod"};

function hidePortlet() {
    var parent,
    i,
    j,
    temp,
    child,
    portlet;
    
    if (portlet_with_empty_content) {

        parent = document.getElementsByTagName('span');        
        
        for (i = 0; i < parent.length; i += 1) {

            if (parent[i].className.match("SkinForShowHide") !== null) {
                temp = parent[i];
                child = temp.getElementsByTagName('div');
                for (j = 0; j < child.length; j += 1) {
                    if (child[j].title === "IdForSkin") {
                        portlet = child[j].innerHTML;
                        if (portlet.length === 0) {
                            parent[i].style.display = 'none';
                        }
                    }
                }
            }
        }
    }

}


   function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }
   

function changeLanguage() {
//alert('in change lang');
  if (!document.getElementById("HAT-gh4")) 
  { 
  	//alert('cookie not found '); 
  	return false; 
  }
          var cookielang = unescape(readCookie("countrylang"));
          if (cookielang != null) {
              for (var i = 0; i < HAT.languages.countries.length; i++) {
                  if (HAT.languages.countries[i].name == cookielang) {
                      document.getElementById("HAT-gh4").getElementsByTagName("a")[0].innerHTML = HAT.languages.countries[i].localizedCountry + ' (' + HAT.languages.changeTxt + ')';
                  }
              }
        }

}



function jump(target) {
    location = target;
}

function addVals(a, b) {
    return a + b;
}

function layswap(id, xPos, yPos) {
    document.getElementById(id).style.left = xPos + "px";
    document.getElementById(id).style.top = yPos + "px";
    if (document.getElementById(id).style.display === "none") {
        document.getElementById(id).style.display = "inline";
    } else {
        document.getElementById(id).style.display = "none";
    }
}

function alignTop(el, lay, pixwidth, pixheight) {
    var vContentLayer,
    vEl,
    xPos,
    yPos,
    tempEl;
    vContentLayer = document.getElementById(lay);
    vEl = document.getElementById(el);
    xPos = vEl.offsetLeft;
    yPos = vEl.offsetTop;
    tempEl = vEl.offsetParent;
    while (tempEl !== null) {
        xPos += tempEl.offsetLeft;
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    if (ie) {
        layswap(lay, addVals(xPos, pixwidth), addVals(yPos, pixheight));
    } else {
        //layswap(lay, eval(xPos + 100), eval(yPos + 75));
    }
}

function createSubMenu(parname, linkname) {
    navLabels[iIndex] = parname;
    navLinkArrayLabels[iIndex] = linkname;
    jIndex = 0;
    navArray[iIndex] = [];
    navLinkArray[iIndex] = [];

}

function addToSubMenu(name, link) {

    navArray[iIndex][jIndex] = name;
    navLinkArray[iIndex][jIndex] = link;
    jIndex += 1;

}

function linkSubMenu() {
    iIndex += 1;
    jIndex = 0;
}

function writeSearchMenu(active, isFly) {
    var mouseOverPosition;
     var pageurl = String(location.href);
    var pos = pageurl.indexOf("support");
    // with(document) {
    mouseOverPosition = 4;
    document.write('<li class="search" >');
    document.write('<Form name="themes_intel_search" onsubmit="getText(\'all\');return false;">');
    document.write('<span>');
    if (browserType === "ie") {
        document.write('<input class="HAT-searchbox" style="width:116px;"type="text" id="input-search" name="input-search" size="10" maxlength="255" autocomplete="off"/>');
    } else if (browserType === "Moz") {
        document.write('<input class="HAT-searchbox" style="width:117px;"type="text" id="input-search" name="input-search" size="10" maxlength="255" autocomplete="off"/>');
    } else {
        document.write('<input class="HAT-searchbox" style="width:114px;"type="text" id="input-search" name="input-search" size="10" maxlength="255" autocomplete="off"/>');
        mouseOverPosition = 2;
    }
    if (pos>0){
    
    	if (browserType === "ie") {
    		mouseOverPosition = 2 ;
    	}
    	
    	else if (browserType === "chrome") {
		mouseOverPosition = -2 ;
    	}
    	else if (browserType === "Moz") {
    		mouseOverPosition = -1 ;
    	}
    	else {
    		mouseOverPosition = 19;
    	}
     
    }
    document.write('</span>');
    document.write('<div id="snav">');
    document.write('<a style="cursor:hand;" onMouseOver="showsearchide(\'subnav\',\'snav\',' + mouseOverPosition + ',19.5)"  onfocus="showsearchide(\'subnav\',\'snav\',' + mouseOverPosition + ',19.5)" id="input-search"><img src='+strSearchImageURL+' alt='+strSearchALTText+' onclick=getText("all") onmouseout="hideThisMenu(\'subnav\')" onblur="hideThisMenu(\'subnav\')"></a></div>');
    document.write('</Form>');
    document.write('</li>');
    // }
}

function writeNavHome(active, isFly) {

    var cssClass,
    i;
    var pageurl = String(location.href);
    var pos = pageurl.indexOf("products");
    var navagent = navigator.userAgent.toLowerCase();
    
    //    with(document) {
     if (browserType === "chrome") {
    
        if (centeralign === "false") {
		document.getElementById("fly_Style").style.marginTop = 5 + 'px';		
       }else {       
	document.getElementById("fly_Style").style.marginTop = 5 + 'px';
       }
        
    } else if (browserType === "Moz") {	
	document.getElementById("fly_Style").style.marginTop = 5 + 'px';
         

    } 
    document.write('<table id="subnav"  align="right" border="0" valign="bottom" >');
    document.write('<tr>');
    document.write('<td id="Intel_td1" align="center"  valign="bottom">&nbsp;&nbsp;&nbsp;' + displaySignInfo);
    document.write('</td>');
    document.write('<td id="Intel_td" align="center" valign="bottom">' + displaySignInfo1);
    document.write('</td>');
    document.write('<td valign="right">');

    cssClass = "minitabs_themes";

    if (isFly === "true") {

        document.write('<div>');
        document.write('<ul>');
    } else {
        document.write('<ul>');
    }
    for (i = 0; i < navLabels.length; i += 1) {

        document.write('<li id="' + navIds[i] + '"');

        if (i < (navLabels.length)) {
            if (isFly === "true") {                                
                if (browserType === 'ie') {
                    document.write(' onMouseEnter="showhide(\'subnav' + i + '\',\'nav' + i + '\',40,60,false)" onMouseLeave="showhide(\'subnav' + i + '\',\'nav' + i + '\',10,7,true)"');
                } else {
                    document.write(' onMouseOver="showhide(\'subnav' + i + '\',\'nav' + i + '\',45,62,false)" onfocus="showhide(\'subnav' + i + '\',\'nav' + i + '\',45,62,false)" onMouseOut="showhide(\'subnav' + i + '\',\'nav' + i + '\',10,12,true)" onblur="showhide(\'subnav' + i + '\',\'nav' + i + '\',10,12,true)"');
                }

            }
        }        
        if (pos>0 & navLabels[i].indexOf("Products") >= 0) {                     
            document.write('"><a class="on" href="' + navLinkArrayLabels[i] + '">' + navLabels[i] + '</a></li>');
        } else {           
            document.write('"><a style="color:#0860A8;" href="' + navLinkArrayLabels[i] + '">' + navLabels[i] + '</a></li>');
        }
    }
    document.write('</ul>');
    document.write('</td>');
    document.write('</tr>');
    document.write('</table>');
    document.write('</div>');
    document.write('</div><div class="HAT-clear"> </div>');
    document.write('<div id="test"></div>');

    document.write('<div id="forFlyOutHiding" style="display:none"></div>');
    //  }
}

function subnavSearchHome() {
    var whole,
    start,
    end,
    j,
    thepage,
    tabWidth,
    searchColWidth,
    searchCategory,
    heightTotal,
    res;
    whole = location.toString();
    start = whole.lastIndexOf("/");
    end = whole.length;
    thepage = whole.substring(start + 1, end);
    tabWidth = "160";
    heightTotal = 20;
    res = "Filter Your Results";
    //  with(document) {
    document.write('<table width="170px" id="subnav" class="subnavSrchIE" style="position:absolute;display:none;z-index:6;cursor:hand;background:#ECEEED none repeat scroll 0 0;border:1px solid #82A1BC;"  onMouseOver="activateThisMenu(\'subnav\')" onfocus="activateThisMenu(\'subnav\')" onmouseout="hideThisMenu(\'subnav\')" onblur="hideThisMenu(\'subnav\')" name="button" id= "button" onClick="getButton(input-search)" align="" cellspacing="0" cellpadding="0">');
    document.write('<tr height="' + heightTotal + '" >');
    document.write('<td ><table  border="0" align="right" cellspacing="0" cellpadding="0">');
    for (j = 0; j < searchLabels.length; j += 1) {
        searchCategory = searchLabels[j].filter;

        if (browserType === "ie") {
            searchColWidth = 144;
        } else if (browserType === "Moz") {
            searchColWidth = 145;
        } else {
            searchColWidth = 147;
        }
        if(j==0){
        
         document.write('<tr height="' + heightTotal + '">');	
	 document.write('<td class="HAT-filterhead" style="padding-left:20px;border:solid 1px #82a1bc" onMouseOver="activateThisMenu(\'subnav\')" onfocus="activateThisMenu(\'subnav\')">' + searchLabels[j].term + '</td>');
	 document.write('</tr>');
   }
        else{
        document.write('<tr height="' + heightTotal + '">');
        document.write('<td id="' + j + '" align="left"  style="color:#666666;font-size:80%;font-weight:normal;Verdana,Sans-Serif;" ><div style="margin:1px;height:20;width:' + searchColWidth + 'px;padding-left:20px;padding-top:3px;padding-bottom:2px;margin-top:2px;margin-bottom:3px;" onMouseOver="this.className=\'hilite\'" onfocus="this.className=\'hilite\'" onMouseOut="this.className=\'mouseout\'" onblur="this.className=\'mouseout\'" name="text" id= "text" onClick="getText(\'' + searchCategory + '\')">' + searchLabels[j].term + '</div></td>');
        document.write('</tr>');
        }
    }

    document.write('</table>');
    document.write('</td>');
    document.write('</tr>');
    document.write('</table>');

    //  }
}

function subnavHome() {
    var flagalter,
    whole,
    start,
    end,
    thepage,
    tabWidth,
    i,
    j,
    strMain,
    str,
    heightTotal;
    flagalter = 1;
    whole = location.toString();
    start = whole.lastIndexOf("/");
    end = whole.length;
    thepage = whole.substring(start + 1, end);
    tabWidth = "195";
    i = 0;
    j = 0;
    //    with(document) {
    for (i = 0; i < navArray.length; i += 1) {

        strMain = "subnav";
        str = strMain + i;

        heightTotal = navArray[i].length * 25;

        document.write('<div id="' + str + '" style="position:absolute;left:0;top:0;display:none;z-index:3" onmouseover="activateThisMenu(\'' + str + '\')" onfocus="activateThisMenu(\'' + str + '\')" onmouseout="hideThisMenu(\'' + str + '\')" onblur="hideThisMenu(\'' + str + '\')">');
        document.write('<div >');
        if (browserType === 'ie') {
	            document.write('<table width="180" border="0" cellspacing="0" cellpadding="0">');
	            document.write('<tr style="margin:0 !important;>');
	            document.write('<td style="margin:0 !important;">');
	            document.write('<table class="subnavIE" border="0" cellspacing="0" cellpadding="0">');
	            for (j = 0; j < navArray[i].length; j += 1) {
	                document.write('<tr>');
	                document.write('<td>');
	                document.write('</td>');                
	                document.write('<td align="bottom" style="color:#0860A8;font-family:Verdana,sans-serif;letter-spacing:-0.05em"><div style="width:155px;padding-left:20px;padding-top:4px;padding-bottom:6px;padding-right:20px;margin-top:5px;margin-bottom:3px;" onMouseOver="this.className=\'hiliteIE\'" onfocus="this.className=\'hiliteIE\'" onMouseOut="this.className=\'mouseoutIE\'" onblur="this.className=\'mouseoutIE\'" onclick="jump(\'' + navLinkArray[i][j] + '\')">' + navArray[i][j] + '</div></td>');
	                document.write('</tr>');
	            }
	            document.write('</table>');
	            document.write('</td>');
	            document.write('</tr>');
	            document.write('</table>');
	        } else {
	            document.write('<table width="180" border="0" cellspacing="0" cellpadding="0">');
	            document.write('<tr style="margin:0 !important;">');
	            document.write('<td style="margin:0 !important;">');
	            document.write('<table class="subnav" border="0" cellspacing="0" cellpadding="0">');
	            for (j = 0; j < navArray[i].length; j += 1) {
	                document.write('<tr style="margin:0 !important;">');
	                document.write('<td>');
	                document.write('</td>');                
	                document.write('<td style="margin:0 !important;color:#0860A8;font-family:Verdana,sans-serif;letter-spacing:-0.05em;"><div style="width:138px;padding-left:20px;padding-top:4px;padding-bottom:6px;padding-right:20px;margin-top:5px;margin-bottom:3px;wrap:wrap;" onMouseOver="this.className=\'hilite\'" onfocus="this.className=\'hilite\'" onMouseOut="this.className=\'mouseout\'" onblur="this.className=\'mouseout\'" onclick="jump(\'' + navLinkArray[i][j] + '\')">' + navArray[i][j] + '</div></td>');
	                document.write('</tr>');
            }
            document.write('</table>');
            document.write('</td>');
            document.write('</tr>');
            document.write('</table>');
        }
        document.write('</div><div class="HAT-clear"> </div>');
        document.write('</div>');

    }
    // }
}

function createSearchSubMenu(searchCategory, searchLabel, index) {

    searchLabels[index] = {
        filter: searchCategory,
        term: searchLabel
    };  
    
}

function hideThisMenu(winName) {
    subMenu = false;
    //displaySubMenu();
    document.getElementById(winName).style.display = "none";
    if(browserType === 'ie' && document.getElementById('language-selector')){
	    if(document.getElementById('selectLang')){
	    	document.getElementById('selectLang').style.visibility = "visible";
	    }
    }
}

function hideSearchMenu(idName) {
    //alert("aleell"+document.getElementById(activeSearchItem).className);
    if (document.getElementById(activeSearchItem).className === subnav) {
        //alert("inside if");
        document.getElementById(winName).style.display = "none";
    } else {
        //alert("else");
        document.getElementById(winName).style.display = "inline";
    }
}
function activateThisMenu(winName) {
    subMenu = true;
    document.getElementById(winName).style.display = "inline";
    if(browserType === 'ie' && document.getElementById('language-selector')){
	    if(document.getElementById('selectLang')){
    		document.getElementById('selectLang').style.visibility = "hidden";
    		}
    }    
}

function test(id) {
    var i,
    strId;
    return function () {

        if (subMenu === true) {
            for (i = 0; i < 5; i += 1) {
                strId = 'subnav' + i;
                if (strId === id) {
                    document.getElementById(strId).style.display = "inline";
                } else {
                    document.getElementById(strId).style.display = "none";
                }
            }
        }
        if (subMenu === false) {
            for (i = 0; i < 5; i += 1) {
                document.getElementById(id).style.display = "none";
            }
        }
        mouseOut = '';

    };
}

function showhide(id, parentId, pixwidth, pixheight, mouseOut) {
    var i,
    xPos,
    yPos,
    tempEl,
    vEl,
    strId,
    pageurl,
    pos;
    
    pageurl = String(location.href);
    pos = pageurl.indexOf("support");
    if (mouseOut === true) {
    	if(parentId === 'nav4'){
		if(browserType === 'ie' && document.getElementById('language-selector')){
	   		if(document.getElementById('selectLang')){
	  			document.getElementById('selectLang').style.visibility = "visible";
	  		}
		}
        }
        setTimeout(test(id), 250);
    } else if (mouseOut === false) {
        for (i = 0; i < navIds.length; i += 1) {
            strId = 'subnav' + i;
            document.getElementById(strId).style.display = "none";

        }
        if(parentId === 'nav4'){
        	if(browserType === 'ie' && document.getElementById('language-selector')){
	    		if(document.getElementById('selectLang')){
        			document.getElementById('selectLang').style.visibility = "hidden";
        		}
        	}
        }
        subMenu = false;

        vEl = document.getElementById(parentId);

        xPos = 0;
        yPos = 0;

        if (vEl.offsetParent) {
		do {
			xPos += vEl.offsetLeft;		
			yPos += vEl.offsetTop;
		} while (vEl = vEl.offsetParent);	
	} 
	
	if(pos > 0)
	    {   
	    	 if(parentId === 'nav4'){
	    	 
	    	 	if (browserType === "ie") {
		     		xPos -= 110;      	 
				//alert("xPos1 " + xPos);
				while(xPos<806){
					xPos+=4;
				}
				while(xPos>806){
					xPos-=2;   
				}
	    		}	
	    		//alert("xPos2 " + xPos);
	    		if (browserType === "Moz") {
				xPos -= 96;      	 
				//alert("xPos1 " + xPos);
				while(xPos<822){
					xPos+=4;
				}
				while(xPos>822){
					xPos-=2;   
				}
			}	
			if (browserType === "chrome") {
			
				xPos -= 90;      	 
				while(xPos<822){
				xPos+=4;
				}
				while(xPos>822){
				xPos-=2;   
				}
				
	    		}	
		}
	 }	  
	//for the higher resolutions

	if(screen.width > 1024){
		if(pos > 0)
		    {   
			if(parentId === 'nav4'){	    	
				if (browserType === "ie") {			
					while(xPos<870){
						xPos+=4;
					}
					while(xPos>870){
						xPos-=2;   
					}
					
			    	}
			    	else if(browserType === "chrome") {			  	 
					while(xPos<895){
						xPos+=4;
					}
					while(xPos>895){
						xPos-=2;   
					}			
			    	}	
			    	else if(browserType === "safari") {						
					while(xPos>932){
						xPos-=4;
					}
					while(xPos<932){
						xPos+=2;
					}
			    		}
			    	else {	    		
			    		while(xPos<886){
						xPos+=4;
					}
					while(xPos>889){
						xPos-=2;   
					}			
			    	}
			}
		}
	}
	
        yPos = yPos - 20;

        xPos = xPos - 40;

        layswap(id, addVals(xPos, pixwidth), addVals(yPos, pixheight));
        //alert("mouse out false");
        mouseOut = '';
    }
}

function showsearchide(id, parentId, pixwidth, pixheight) {

    var vEl,
    xPos,
    yPos,
    tempEl;
    vEl = document.getElementById(parentId);
    
    xPos = yPos = 0;   
    var pageurl = String(location.href);
    var pos = pageurl.indexOf("support");
	
	if (vEl.offsetParent) {
	do {
		xPos += vEl.offsetLeft;		
		yPos += vEl.offsetTop;
	} while (vEl = vEl.offsetParent);
	} 
	
    if(pos > 0)
    {   
    	xPos -= 115;   
    		if(browserType === "safari"){
    			while(xPos>809){
    				xPos-=4;
    			}
    			while(xPos<809){
    				xPos+=2;
    			}
    	   	
    		}    	
    }
    
    else
    {
    	xPos-=115
    	
    }
    
    //when the flyout exceeds 
    while (xPos>831){
    	xPos-=2;
    }    
    
    //for the higher resolutions
    if(xPos > 880){
    	
    	if (browserType === "chrome") {
    		xPos -= 73;
    	}
    	
    	else if(browserType === "safari") {
    		xPos -= 133;
    	}
    	else{
    		xPos-=64;
    	}    	    	
    } 
    else{
    }

    layswap(id, addVals(xPos, pixwidth), addVals(yPos, pixheight));
}

function getText(id) {
    var search,
    category,
    advanceOption,
    searchCulture,
    query,
    finalURL;
    
    //value of text box
    search = document.getElementById("input-search").value;
    
    //selected value from fly out
    category = id;
    advanceOption = "0";
    
    if (category === "HATadv1") {
        category = "all";
        advanceOption = "1";
    }    
    query = "q=" + search;
    category = "&category=" + category;
    
    searchCulture = "culture="+strLocaleSearch+"&";
    
    finalURL = strSearchURL + searchCulture + query + category + "&adv=" + advanceOption + "&value=0";
    location.href = finalURL;
    window.location.assign(finalURL);
}

/* Function used by language selector module.Expects the reference to a select box HTML element to be passed as a parameter.*/

function changeLocale(selectObj) 
{ 
	var pageName;
	pageName = getPageName();
	waCustomLink(this, pageName+':links','o','wa_iid='+pageName+':lang_selector');
	window.location.href=selectObj.options[selectObj.selectedIndex].value;
	

}
 

function checkUniqueOmnitureCookie()
{	

	var pagename,
	loopcnt,
	urlval,
	urlParameters,
	friendlyURL,
	corefriendlyURLarray,
	corefriendlyURL,
	urlpartsarray,
	localecode,
	linksecondparam,
	iidval,	
	linkthirdparam;
	
	pagename = location.href;		
	urlval = "";
	urlParameters = pagename.split('?'); 
	friendlyURL = urlParameters[0];
	corefriendlyURLarray = friendlyURL.split('/p/');
	corefriendlyURL =corefriendlyURLarray[1];
	urlpartsarray = corefriendlyURL.split('/');	
	localecode = urlpartsarray[0];	
	for (loopcnt=1;loopcnt<urlpartsarray.length;loopcnt=loopcnt+1){
	   urlval = urlval+ urlpartsarray[loopcnt];
	   if (loopcnt +1 <= urlpartsarray.length-1) {
	     urlval = urlval +":";
	   }
	}

	linksecondparam = urlval+":links";
	iidval = "wa_iid="+urlval+":prod_sel_start";
	linkthirdparam=iidval+"&wa_custom45="+localecode+"&wa_eCustom45="+localecode;	


	    // Check if a cookie has been found
	    if ( omnitureFamilyclick === false)
	    {
		// The key_value cookie was not found so set it now
		omnitureFamilyclick = true;
		//Invoking Omniture function only once per user session

	       waCustomLink (this,linksecondparam,'o',linkthirdparam);
	    } 


}

function getOmnitureMapedValue(map)
{	

	var pagename,	
	urlParameters,
	friendlyURL,
	corefriendlyURLarray,
	corefriendlyURL,
	urlpartsarray,
	localecode,
	linksecondparam,
	localekey,
	mapValue;	
	
	pagename = location.href;		
	urlval = "";
	urlParameters = pagename.split('?'); 
	friendlyURL = urlParameters[0];
	corefriendlyURLarray = friendlyURL.split('/p/');
	corefriendlyURL =corefriendlyURLarray[1];
	urlpartsarray = corefriendlyURL.split('/');	
	localecode = urlpartsarray[0];
	linksecondparam = urlpartsarray[1];
	if(linksecondparam=="support"){
	localecode = "en_US";	
	}
	localekey = linksecondparam+":"+localecode;
	//alert ("locale key = "+localekey);
	//alert ("locale value = "+omniturelocaleMap[localekey]);
	
	if(map=="omnituregeoMap"){
		mapValue = omnituregeoMap[localekey];
	}
	else if(map=="omniturelocaleMap"){
		mapValue = omniturelocaleMap[localekey];
	}
	else if(map=="omnitureorg1Map"){
		mapValue = omnitureorg1Map[localekey];
	}
	else if(map=="omniturereportSuitesMap"){
		mapValue = omniturereportSuitesMap[localekey];
	}
	//alert(mapValue);
	return mapValue;
	
	
}

function getPageName() {
    var pagename,
    	loopcnt,
    	urlval,
    	urlParameters,
    	friendlyURL,
    	corefriendlyURLarray,
    	corefriendlyURL,
    	urlpartsarray,
    	localecode,
    	linksecondparam,
    	iidval,	
    	linkthirdparam;
    	
    	pagename = location.href;		
    	urlval = "";
    	urlParameters = pagename.split('?'); 
    	friendlyURL = urlParameters[0];
    	corefriendlyURLarray = friendlyURL.split('/p/');
    	corefriendlyURL =corefriendlyURLarray[1];
    	urlpartsarray = corefriendlyURL.split('/');	
    	localecode = urlpartsarray[0];	
    	for (loopcnt=1;loopcnt<urlpartsarray.length;loopcnt=loopcnt+1){
    	   urlval = urlval+ urlpartsarray[loopcnt];
    	   if (loopcnt +1 <= urlpartsarray.length-1) {
    	     urlval = urlval +":";
    	   }
	}
	return urlval;
}

/* Function to show language selector module with select box only when JS is enabled */

function showLangSelectorJSVersion() {
	document.getElementById("blog-name").style.display="block";
}

/* Function to select default option from language selector module based on user selected locale */

function setLangSelectorDefault(){
	
	 var pagename, urlval, urlParameters, friendlyURL, corefriendlyURLarray, corefriendlyURL, urlpartsarray, localecode;
	 var select = document.getElementById("blog-name");
	 var locale_cd = "";
	 pagename = location.href;		
	 urlval = "";
	 urlParameters = pagename.split('?'); 
	 friendlyURL = urlParameters[0];
	 corefriendlyURLarray = friendlyURL.split('/p/');
	 corefriendlyURL =corefriendlyURLarray[1];
	 urlpartsarray = corefriendlyURL.split('/');	
	localecode = urlpartsarray[0];	
	 for (i=0; i<select.length; i++){
	 	
		 // Value of options in the form of locale-URL, ex - en_US-/p/en_US/support
		 locale_cd = select.options[i].lang;

	 	//Using global variable locale code 
		 if ( locale_cd == localecode) {
	 		select.options[i].selected=true;
	 	}
	 	
	 }
}
function expandLeftNavigation()
{
	var b,
        e,
        scrollHeight,
        bodyHeight;	
	
	b = document.body;
	e = document.documentElement;
	scrollHeight = 0;
	bodyHeight = 0;

	if (e) {
        scrollHeight = e.scrollHeight - 150;
        bodyHeight = e.offsetHeight;
    } else if (b) {
        scrollHeight = b.scrollHeight - 150;
        bodyHeight = b.offsetHeight;
    }
    if (document.getElementById("wrapper_Nav") !== null) {
        document.getElementById("wrapper_Nav").style.height = scrollHeight + 'px';
    }
}
