function clearAllTabs(ts)
{
 for( k=1; k<=ts; k++ )
	{
		document.getElementById('link'+k).className='normal';
		document.getElementById('tab'+k).style.display='none';
	}
		document.getElementById('link'+ts).className='t-last';
}

function selectTab(id)
{
var el = document.getElementById("nav-tabs");
var children = el.childNodes;
var lis = children.length

if (lis == 9)
{
lis = 4;
}
else if (lis == 7)
{
lis = 3;
}

else if (lis == 5)
{
lis = 2;
}
   
	clearAllTabs(lis);
	document.getElementById('link'+id).className='selected';
	document.getElementById('tab'+id).style.display='inline';
}

function show(caption)
{
	window.status=caption;
}
function clearWindowStatus()
{
	window.status='';
}

function currencyDropdown(id, flag) {
	var d = document.getElementById(id);
	if (d) {
            if (flag=='show') {
                        d.style.display='block';
            } else {
                        d.style.display='none';
            }
	}
}

/*Get the browser version*/
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );

/*Function will return the Selected Currency description*/
function getSelectedCurr() {
	var strSrcCurrDesc = "";
	var objCurrEle = document.getElementById('Curr-nav');
	var objLIs = objCurrEle.getElementsByTagName('LI');
	
	for ( i=0; i<objLIs.length; i++ ) {
		if ( objLIs[i].className == "selected" ) {
			strSrcCurrDesc = objLIs[i].childNodes[0].innerHTML;
		}
	}
	return strSrcCurrDesc;
}

/*This function will read the content from div and replace the SOURCE and DEST currencies*/
function ReplaceCurrencyDesc(strSrcCurrDesc, strDestCurrDesc) {
	var objEleTxt = document.getElementById('curerrtxt');
	var strTxt = new String(objEleTxt.innerHTML);
	
	strTxt = strTxt.replace("[%SOURCE%]", strSrcCurrDesc);
	strTxt = strTxt.replace("[%DEST%]", strDestCurrDesc);
	
	objEleTxt.innerHTML = strTxt;
}

var strDestURL;

/*
Function will show exception based on browser type.
If browser is IE6 then show iFrame else show DIV
*/
function ShowException(objEle, strUrl, strCurrid, strLangCode, strIscartemptySiteidAffid, strSrcCurrId) {
	//To be commented
	//strIscartemptySiteidAffid = "no-15-0";
	
	//Assign the destination url
	strDestURL = strUrl;
	if (strIscartemptySiteidAffid != null && strIscartemptySiteidAffid.length > 0)
	{
		if ( strIscartemptySiteidAffid.indexOf("yes") < 0 )
		{
			if (strCurrid != "") {
				
				var objMainDiv = document.getElementById('errorMsg');
				
				//Get old and new CurrIds
				var strDestCurrId = strCurrid;
				
				//Get currency description for old and new selected currencies.
				var strSrcCurrDesc = getSelectedCurr();
				
				var strDestCurrDesc = objEle.innerHTML;
				
				if ( strSrcCurrId != strDestCurrId ) {
					objMainDiv.style.display="block";
					if (is_ie6 == true) {
						window.frames['exceptionFrame'].location.href = location.protocol + "//" + location.hostname + "/" + strLangCode + "/global/html/wrapper/cx_currency_exception.asp?srcCurrId=" + strSrcCurrId + "&destCurrId=" + strCurrid + "&DestURL=" + strDestURL;
					}
					else {
						ReplaceCurrencyDesc(strSrcCurrDesc, strDestCurrDesc);
					}
				} 
				else
					objMainDiv.style.display="none";
			}
		}
		else
			location.href = unescape(strDestURL);
	}
	else
		location.href = unescape(strDestURL);
}

/*Close the Currency exception div*/
function CloseException() {
	document.getElementById('errorMsg').style.display = "none";
}

/*Change the href if user clicks in Continue button*/
function ChangeLocation() {
	location.href = unescape(strDestURL);
}

/*Function will read the cookie value*/
function get_cookie_val(name) 
{  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;
  
  var i = 0;  

  while (i < clen) 
  {    
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)   
    {   
      var endstr = document.cookie.indexOf (";", j);  
        
      if (endstr == -1)    
        endstr = document.cookie.length;
     
      return unescape(document.cookie.substring(j, endstr));
    }

    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;   
  }  

  return null;
}
/* DashBoard TAB Scripts */
function showDwnld(obj) {
	var oCell = obj.parentNode;

	for (c=0;c<oCell.childNodes.length;c++) {
		var node = oCell.childNodes[c];
		var oPos = obj.offsetLeft - 120;
		if (node.nodeName=="UL") {
			node.style.left = oPos + "px";
			node.style.display="block";
		}
	}
}
function hideDwnld(obj) {
	var oCell = obj.parentNode;

	for (c=0;c<oCell.childNodes.length;c++) {
		var node = oCell.childNodes[c];
		if (node.nodeName=="UL") {
			node.style.display="none";
		}
	}
}
function MakeTabActive(obj)
{
	
	if(obj.className!="selected")
	{
	var ulobject=document.getElementById('nav-tabs');
	var aElemnts=ulobject.getElementsByTagName('a');
	for(i=0;i<aElemnts.length;i++)
	{
		aElemnts[i].className="";
		document.getElementById(aElemnts[i].rel).style.display="none";
	}
	document.getElementById(obj.rel).style.display="inline";
	obj.className="selected";}
	
}