String.prototype.trim      = function() { return this.replace(/(^\s*)|(\s*$)/, ""); }
      String.prototype.toInt     = function() { return (isNaN(parseInt(this, 10))) ? 0 : parseInt(this, 10); }
      String.prototype.padZero   = function() { return (this.toInt() < 10) ? "0" + this : this; }
      String.prototype.repeat    = function(n) { var s = "", t = this.toString(); while(--n >= 0) s += t; return s; }

      var g_sObjectType = "";

function ShowEmail()
{
document.getElementById("email_link").style.display="none";
document.getElementById("login_link").style.display="block";
document.getElementById("LoginFormDiv").style.display="none";
document.getElementById("password_self_service").style.display="block";
}
function ShowLogin()
{
document.getElementById("email_link").style.display="block";
document.getElementById("login_link").style.display="none";
document.getElementById("LoginFormDiv").style.display="block";
document.getElementById("password_self_service").style.display="none";
}


      function funcSetup() {
         var i = 0;
         var sTemp = null;
         var nIndent = 0;
         var sIndent = new String("&nbsp;&nbsp;&nbsp;");
         var oLoginImage = document.getElementById("LoginImage");
         var oLoginAttempt = document.getElementById("VerLoginAttempt");
         var oUsername = document.getElementById("VerLoginID");
         var oPassword = document.getElementById("VerPassword");
         var oDivs = document.getElementsByTagName("div");

         if(oLoginImage) {
            // oLoginImage.src = "/SiteGen/Uploads/Public/Skin_EpriseDemo01/btn_login.gif";
         }

         if(oLoginAttempt) {
         }

         if(oUsername) {
            oUsername.focus();
         }

         if(oPassword) {
         }

         if(oDivs) {
            for(i = 0; i < oDivs.length; i++) {
               if(oDivs[i].id.indexOf("SubNavLink_Level") == 0) {
                  nIndent = parseInt(oDivs[i].id.replace("SubNavLink_Level", ""));
                  sTemp = oDivs[i].innerHTML;
                     oDivs[i].innerHTML = sIndent.repeat(nIndent) + sTemp;
               }
            }
         }
      }

 function funcWriteMainNav(sMainNavId,sObjDelimiter,sItemDelimiter) {
     var sOutput = new String();
     var sClass = null;
     var sUrl = null;
     var sText = null;
     var aryThisLink = null;

   //Retrieve string hidden in a div with the id passed in as a parameter
     var oMainNav = document.getElementById(sMainNavId);
     if (oMainNav) {
         sMainNav = oMainNav.innerHTML;

  //alert("sMainNav is " + sMainNav);

       //Manipulate TopNav string if you want to

       //Here we split it apart by delimiters
       //and set up the anchors with that information
         var aryTopNav = decodeURIComponent(sMainNav);
         aryTopNav = aryTopNav.split(sObjDelimiter);
         var nLen = aryTopNav.length;

            for(var i = 0; i < nLen; i++) {
               aryThisLink = aryTopNav[i].split(sItemDelimiter);

               sText = aryThisLink[0];
               sUrl = aryThisLink[1];

               //Assign results to sOutPut
               sOutput += "<a href='" + sUrl + "'>" + sText + "</a>";
               sOutput += "&nbsp;";

            }
      }

  return sOutput;
}


function funcWriteSubNav(sSubNavId) {
   var sOutput = new String();

   //Retrieve string hidden in a div with the id passed in as a parameter
   var oSubNav = document.getElementById(sSubNavId);
   if ( oSubNav ) {
       sSubNav = oSubNav.innerHTML;

       //Manipulate subNav string if you want to


       //Assign results to sOutPut
       sOutput = sSubNav ;
   }

  return sOutput;
}


function funcWriteBodyLinks(sBodyLinksId) {
   var sOutput = new String();

   //Retrieve string hidden in a div with the id passed in as a parameter
   var oBodyLinks = document.getElementById(sBodyLinksId);
   if ( oBodyLinks ) {
       sBodyLinks = oBodyLinks.innerHTML;

       //Manipulate BodyLinks string if you want to
       //(NOTE: Style.css hides some of the BodyLink content)

       //Assign results to sOutPut
       sOutput = sBodyLinks ;
   }

  return sOutput;
}



function funcWriteBreadcrumbNav(BreadCrumbList) {
	var sOutputBreadcrumbNav = new String();
	var sClass = null;
	var sUrl = null;
	var sText = null;
	var nLevel = null;
	var aryThisLink = null;
       
        var sTemp = "";

	var arySubNav = unescape(BreadCrumbList);
	//arySubNav = arySubNav.split("");
	arySubNav = arySubNav.split(";");

    sOutputBreadcrumbNav += "<div id='breadcrumbs'>"

	var nLen = arySubNav.length;
	for(var i = 0; i < nLen; i++) {
		//aryThisLink = arySubNav[i].split("");
		aryThisLink = arySubNav[i].split(",");
                sText = aryThisLink[0];
		sUrl = aryThisLink[1];
		sClass = (parseInt(aryThisLink[2])) ? "_on" : "";
		pageLevel = aryThisLink[3];
			
		sOutputBreadcrumbNav += "<!-- breadcrumb trail -->";
		// items

            var sIndex = sText.indexOf("_subnav");
         //   sOutputBreadcrumbNav += sIndex;

             if(sText!=sTemp && sIndex < 0){ // added to prevent duplicates in list
		if (i<nLen-1) {
			//--- loop thru regular items
			//sOutputBreadcrumbNav += "<a href='" + sUrl + "'>" + sText.toLowerCase() + "</a> &gt; ";
			sOutputBreadcrumbNav += "<a href='" + sUrl + "'>" + sText + "</a> &gt; ";
		} else {
			//--- last item
			sOutputBreadcrumbNav += "<span class='breadcrumb_item" + sClass + "'>" + sText + "</span>";
			//sOutputBreadcrumbNav += "<span class='breadcrumb_item" + sClass + "'>" + sText.toLowerCase() + "</span>";
			//sOutputBreadcrumbNav += "<a href='" + sUrl + "'>" + sText.toLowerCase() + "</a>";
		}
              sTemp = sText;
	     }
		sOutputBreadcrumbNav += "<!-- end breadcrumb trail -->";
			
	}
	
    sOutputBreadcrumbNav += "</div>";

	return sOutputBreadcrumbNav;
}


function funcSetupLink(sSiteName , sLinkUrlId, sTarget, sViewMode8 ) {

   if( (sViewMode8 =="") ||  (sViewMode8 == undefined) )  sViewMode = decodeURIComponent("");
   if( (sViewMode8 =="") ||  (sViewMode8 == undefined) )  sViewMode = "0";

   var sSiteNameParseKey = "SITENAME";

   var sHomepagePath = "/main/SiteGen/SITENAME/Content/Home.html";
   var sHomepageUrl = sHomepagePath.replace(sSiteNameParseKey, sSiteName);

   var sExternal = new String(">");
   var sLink = new String("");
   var sLinkA = new String("");

   //Retrieve string hidden in a div with the id passed in as a parameter
   var oStandardLinks = document.getElementById(sLinkUrlId );
   if ( oStandardLinks ) {
       sExternal = oStandardLinks.innerHTML;
   }

   oStandardLinks = document.getElementById(sLinkUrlId+"_Link" );
   if ( oStandardLinks ) {
       sLink = oStandardLinks.innerHTML;
   }

   oStandardLinks = document.getElementById(sLinkUrlId+"_LinkA" );
   if ( oStandardLinks ) {
       sLinkA = oStandardLinks.innerHTML;
   }


   //Manipulate StandardLink strings if you want to
   var sUrl = (sLinkA.indexOf("/eprise") == 0) ? sLink : sExternal;
   sUrl = (sUrl.length > 0) ? sUrl : sHomepageUrl;

    if (sViewMode8 != "8") {

      if(sUrl.length > 0 && sUrl.indexOf("/") >= 0) {
        if (sTarget=='Yes')
        {
           // alert ("newWindow=='yes'")
           history.back();         
            var openWindow = window.open(sUrl, '_blank'); 
            openWindow.focus();
            //history.back(); 

        } else {
         top.location.replace(sUrl);
     }   
    }
   }
}

//This function will format the passed eprised date based on site name. To add more formating, add values to switch statement - by jwl 12.23.2011
function funcGetFullDate(myEpriseDate, myMonthString, mySiteName)
{
    var theDate = myEpriseDate
    var defaultMonthString = "January,February,March,April,May,June,July,August,September,October,November,December"
    if (myMonthString == '')
    {
        myMonthString = defaultMonthString
    }
    var arry_Month = myMonthString.split(",")
    
    str_Year = myEpriseDate.substr(0,4)
    str_Month = myEpriseDate.substr(5,2)
    num_Month = str_Month
    if (num_Month.charAt(0) == "0")
    {
        num_Month = num_Month.substr(1);
    }

    var str_MonthName = ""
    if (IsNumeric(num_Month))
    {
        var num_MonthLessOne = str_Month-1
        var str_MonthName = arry_Month[num_MonthLessOne];
    }

    str_Day = myEpriseDate.substr(8,2)
    num_Day = str_Day
    if (num_Day.charAt(0) == "0")
    {
        num_Day = num_Day.substr(1);
    }

    //add site names to this switch for additional formatting
    switch (mySiteName)
    {   
        case "SRT__FR": 
            theDate = str_Day + " " +  str_MonthName + " " + str_Year
	        break;
        case "SRT__DE": 
            theDate = str_Day + ". " +  str_MonthName + " " + str_Year
	        break;
        default:
            theDate = str_MonthName + " " +  num_Day + ", " + str_Year
    }

    return theDate         
}

//This function will get the correct language short name for the month - by JWL 12.27.2011
function funcGetShortMonth(myEpriseDate, myShortMonthString, mySiteName)
{
    
    var theDate = myEpriseDate
    var defaultShortMonthString = "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC"
    if (myShortMonthString == '')
    {
        myShortMonthString = defaultShortMonthString
    }

    var arry_ShrtMonth = myShortMonthString.split(",")
    
    str_Month = myEpriseDate.substr(5,2)
    num_Month = str_Month
    if (num_Month.charAt(0) == "0")
    {
        num_Month = num_Month.substr(1);
    }

    var str_MonthName = ""
    if (IsNumeric(num_Month))
    {
        var num_MonthLessOne = str_Month-1
        var str_MonthName = arry_ShrtMonth[num_MonthLessOne];
    }

    return str_MonthName         
}

//function to see if a var is numeric - added by jwl 12.23.2011
function IsNumeric(sText)
{
    sText = sText.toString();
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    if (sText=="")
    {
        IsNumber=false;
    }
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
	        IsNumber = false;
        }
    }
    return IsNumber;
}
