// ////////////////////////////////File Header ///////////////////////////////
// Purpose: This javascript file is used to define the menu & UI link values 
// of Hospira.com.
// Developed by: 
// Created on:    
// Modified by: Cognizant
// Modified on: 07/12/2006
// Reason for change: Changed & newly defined condition to pre-populated subject field 
//		      with VisIV Information Request in contactus form.
// ///////////////////////////////File Header ///////////////////////////////

//---- Set this variable only! ----
var buildDir = "/_layouts/scripts/";

//---------------------------------

var ie4 = false, ie5_mac = false, ie55 = false;
var nn4 = false, dom = false, opera = false, safari = false;
var agent = navigator.userAgent.toLowerCase();

if (agent.indexOf("opera") != -1)
	opera = true;
else if (agent.indexOf("safari") != -1)
	safari = true;
else if (document.all)
{
	var version = parseFloat(agent.substr(agent.indexOf("msie")+5, 3));
	if (agent.indexOf("mac") != -1 && version >= 5)
		ie5_mac = true;
	else
	{
		if (version >= 5.5)
			ie55 = true;
		else if (version >= 4)
			ie4 = true;
	}
}
//else if (document.layers)
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4 && 
	parseInt(navigator.appVersion) < 5)
	nn4 = true;
else if (document.getElementById)
	dom = true;

var blank = new Image();
blank.src = buildDir + "blank.gif";

if (ie4)
	document.write('<script type="text/javascript" src="' + buildDir + 'ie4-build.js"></script>');
else if (ie5_mac)
	document.write('<script type="text/javascript" src="' + buildDir + 'ie5m-build.js"></script>');
else if (ie55)
	document.write('<script type="text/javascript" src="' + buildDir + 'ie55-build.js"></script>');
else if (nn4)
	document.write('<script type="text/javascript" src="' + buildDir + 'ns4-build.js"></script>');
else if (dom)
	document.write('<script type="text/javascript" src="' + buildDir + 'dom-build.js"></script>');
else if (opera)
	document.write('<script type="text/javascript" src="' + buildDir + 'op7-build.js"></script>');
else if (safari)
	document.write('<script type="text/javascript" src="' + buildDir + 'saf-build.js"></script>');
else
{
	alert("Your browser doesn't support this script.");
	//location.href = buildDir + "upgrade.html"; NAVINT
	document.write('<script type="text/javascript" src="' + buildDir + 'no-build.js"></script>');
}

function drawFooterNav_com(boolIsCorp)
{
  var i;
  var strOutput = "";
  var strSep = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  
  if (boolIsCorp != true)
    strOutput += "<a href=\"http://www.hospira.com\" title=\"Hospira.com\" class=\"footer\" target=\"_new\">Hospira.com</a>" + strSep;
  
  for (i = 0; i < arrFooterLinks.length; i++)
  {
    strOutput += "<a href=\"" + arrFooterLinkHREFs[i] + "\" title=\"" + arrFooterLinks[i] + "\" class=\"footer\">" + arrFooterLinks[i] + "</a>";
    
    if (i != arrFooterLinks.length - 1)
      strOutput += strSep;
  }
  
  
  document.write(strOutput);
}


function drawFooterNav(boolIsCorp)
{
  var i;
  var strOutput = "";
  var strSep = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  
  if (boolIsCorp != true)
    strOutput += "<a href=\"http://www.hospira.com\" title=\"Hospira.com\" class=\"footer\" target=\"_new\">Hospira.com</a>" + strSep;
  
  for (i = 0; i < arrFooterLinks.length; i++)
  {
    strOutput += "<a href=\"" + arrFooterLinkHREFs[i] + "\" title=\"" + arrFooterLinks[i] + "\" class=\"footer\">" + arrFooterLinks[i] + "</a>";
    
    if (i != arrFooterLinks.length - 1)
      strOutput += strSep;
  }
  
  if (boolIsCorp)
    strOutput += "<div style=\"padding: 10px;\">" + strCopyrightNotice + "</div>";
  else
    strOutput += "<div style=\"padding-top: 5px;\">" + strCopyrightNotice + "</div>";
  
  document.write(strOutput);
}


function navigateFromSearch(strTitle, strListName, strURL)
{
  strTitle = unescape(strTitle);
  strListName = unescape(strListName);
  strURL = unescape(strURL);
  
  if (strTitle.substring(strTitle.length - 5, strTitle.length) == ".aspx")
    window.location.href = "/" + strTitle;
  else
    window.location.href = strURL;  
}

function warnOnLeave(strURL)
{
  var boolExitHospira = confirm(strWarnOnLeaveMsg);
  
  if (boolExitHospira)
  {
    window.open(strURL);
  }
  else
    return;
}

function showLines()
{
  if (!opera)
  {
    var i;
  
    for (i = 0; i < arrDivIDs.length; i ++)
    {
      document.getElementById(arrDivIDs[i]).style.zIndex = "1000000000";
      document.getElementById(arrDivIDs[i]).style.visibility = "visible";
    }
  }
}
function showLines_yes()
{
if (!opera)
  {
    var i;
  
    for (i = 0; i < arrProdDivIDs.length; i ++)
    {
      document.getElementById(arrProdDivIDs[i]).style.zIndex = "1000000000";
      document.getElementById(arrProdDivIDs[i]).style.visibility = "visible";
    }
  }
}

function Querystring()
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		name = temp.join(' ');

		temp = unescape(pair[1]).split('+');
		value = temp.join(' ');

		this[name]=value;
	}

	this.get=Querystring_get;
}


function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}

	return value;
}

function dynamiccontentNS6(elementid,content)
{
  if (document.getElementById)
  {
    rng = document.createRange();
    el = document.getElementById(elementid);
    rng.setStartBefore(el);
    htmlFrag = rng.createContextualFragment(content);

    while (el.hasChildNodes())
      el.removeChild(el.lastChild);

    el.appendChild(htmlFrag);
  }
}

function fillApplyButton()
{
  document.getElementById("btnApplyNow").value = strApplyNowButtonText;
}
function fillApplyButtonMex()
{
  document.getElementById("btnApplyNow").value = strApplyNowButtonTextCoMex;
}


function applyNow(strPath)
{
  var strJobTitle = document.getElementById("divJobTitle").value;
  var strURL = "/" + strPath + "/apply.aspx?pos=" + encodeURI(strJobTitle);
  location.href = strURL;
}
//Newly added for australia site including email in job application
function applyNowWithEmail(strPath)
{
  var strJobTitle = document.getElementById("divJobTitle").value;
  var strJobEmail = document.getElementById("divJobEmail").value;
  strJobEmail =strJobEmail.split('>');
  if(strJobEmail.length==3)
	strJobEmail =strJobEmail[1].replace("</A","");
  else
	strJobEmail="";
  var strURL = "/" + strPath + "/apply.aspx?pos=" + encodeURI(strJobTitle) + "&email="+encodeURI(strJobEmail);
  location.href = strURL;
}
//End 
function loadJobDetail(strURL)
{  
  var qs = new Querystring()
  var strID = qs.get("ID", null);
  var strURL = strURL + "/jobopeningdetail.aspx?ID=" + strID;
  window.frames["iFrameTemp"].location = strURL;
}


function loadPRDetail(strURL)
{  
  var qs = new Querystring()
  var strID = qs.get("ID", null);
  var strURL = strURL + "/pressrelease.aspx?ID=" + strID;
  window.frames["iFrameTemp"].location = strURL;
}

function checkParent()
{
  if (parent.document.getElementById("divContentPlaceHolder") != null)
  {  
    var htmlData = document.getElementById("jobContent").innerHTML;
    parent.document.getElementById("divContentPlaceHolder").innerHTML = htmlData;
    parent.document.getElementById("divJobTitle").value = document.getElementById("cellJobTitle").innerHTML;
  }
}

function checkPRParent()
{
  if (parent.document.getElementById("divContentPlaceHolder") != null)
  {  
    var htmlData = document.getElementById("jobContent").innerHTML;
    parent.document.getElementById("divContentPlaceHolder").innerHTML = htmlData;
  }
}

function checkProductionJob(strNo)
{
  var strDisplay = "block";
  if (opera || dom)
    strDisplay = "table-row";

  document.getElementById("rowProductionPosition").style.display = "none";

  if (document.getElementById("cellProductionPosition").value == strNo)
    document.getElementById("rowTimeShift").style.display = "none";
  else
    document.getElementById("rowTimeShift").style.display = strDisplay;  
}

function writeYear()
{
  var today = new Date();
  var year = today.getYear();
  
  if (year < 1000)
    year += 1900;
    
  return year;

}

var strPageSearchTerm = "";
function CacheSearchString()
{
    var frm = document.forms["frmSearch"];
    strPageSearchTerm = frm.elements["SearchString"].value;
}
function SubmitSiteSearch(rwNextListPage, rwNextDocPage, rwLastPage)
{
    var strCategory;
    var frm = document.forms["frmSearch"];
    var bRestoreSearchString = true;
    if (rwNextListPage > 0)
        strCategory = "Lists";
    else if (rwNextDocPage > 0)
        strCategory = "Documents";
    else
    {
        bRestoreSearchString = false;
        strCategory = "";
        frm["ListPagePosition"].value = "";
        frm["DocPagePosition"].value = "";
    }
    frm["Category"].value = strCategory;
    rwLastPage = (rwLastPage > 0) ? rwLastPage + 1 : 0;
    frm["PageFirstRow"].value = rwLastPage;
    if (bRestoreSearchString)
        frm["SearchString"].value = strPageSearchTerm;
    frm.submit();
}

function encodeHTML(strTextToEncode)
{
  strTextToEncode = strTextToEncode.replace(/</g, "&lt;");
  strTextToEncode = strTextToEncode.replace(/>/g, "&gt;");  
  return strTextToEncode;
}

function writeSearchLink(strLink, strURL)
{
  var strReturnOutput = "";
  strReturnOutput = "<a href=\"" + strURL + "\" title=\"" + strLink + "\">" + strLink + "</a><br />";
  document.write(strReturnOutput);
}

function fillSearchTerm()
{
  var strSearchText = document.forms[0].SearchString.value;
  
  strSearchText = encodeHTML(strSearchText);

  if (document.getElementById("searchQueryText"))
    document.getElementById("searchQueryText").innerHTML = strSearchResultsBegin + "<em>" + strSearchText + "</em>" + strSearchResultsEnd;
  
  if (document.getElementById("noResultsFound"))
    document.getElementById("noResultsFound").innerHTML = strSearchNoResults;
}

function checkEnter(iKeyCode, strStringToSearch)
{
  if (iKeyCode == 13)
    submitSearchFormFromTop(strStringToSearch);
}

function submitSearchFormFromTop(strStringToSearch)
{
  document.forms("frmSearch").SearchString.value = strStringToSearch;
  document.forms("frmSearch").submit();
}

function drawCommodityNumber(strAppend)
{
  if (document.getElementById("pageIdentifierHospira"))
    document.getElementById("pageIdentifierHospira").childNodes[0].nodeValue =  document.getElementById("pageIdentifierHospira").childNodes[0].nodeValue + strAppend;
}

function drawLanguageToggle(strPath1, strLang1, strPath2, strLang2)
{
  document.write("<div style=\"text-align: center; padding-top: 5px;\">");
  document.write("<a href=\"javascript:toggleLanguage('" + strPath1 + "');\">");
  document.write(strLang1 + "</a>&#160;|&#160;<a href=\"javascript:toggleLanguage('" + strPath2 + "');\">" + strLang2 + "</a></div>");
}

function drawThreeLanguageToggle(strPath1, strLang1, strPath2, strLang2, strPath3, strLang3)
{
  document.write("<div style=\"text-align: center; padding-top: 5px;\">");
  document.write("<a href=\"javascript:toggleLanguage('" + strPath1 + "');\">");
  document.write(strLang1 + "</a>&#160;|&#160;<a href=\"javascript:toggleLanguage('" + strPath2 + "');\">" + strLang2 + "</a>&#160;|&#160;<a href=\"javascript:toggleLanguage('" + strPath3 + "');\">" + strLang3 + "</a></div>");
}

function toggleLanguage(strLanguage)
{
  var strBaseURL = top.location.href;
  var strRoot;
  var strFile;
  var iFirstIndexDouble = strBaseURL.indexOf("//");
  var strRootWorkVar = strBaseURL.substring(iFirstIndexDouble + 2, strBaseURL.length);
  var iFirstIndex = strRootWorkVar.indexOf("/");
  var iQSIndex;
  var arrExcludedFiles = new Array();
  var i;
  
  var iLastIndex;
  var index = strBaseURL.indexOf("/");

  arrExcludedFiles[0] = "search.aspx";
  arrExcludedFiles[1] = "jobopeningdetail.aspx";
  arrExcludedFiles[2] = "pressrelease.aspx";
  arrExcludedFiles[3] = "apply.aspx";
  
  while (index != -1)
  {
    index = strBaseURL.indexOf("/", index + 1);
    
    if (index != -1)
      iLastIndex = index;
  }
  
  strRoot = strBaseURL.substring(0, iFirstIndex + 7);
  strFile = strBaseURL.substring(iLastIndex + 1, strBaseURL.length);
  iQSIndex = strFile.indexOf("?");

  if (iQSIndex != -1)
     strFile = strFile.substring(0, iQSIndex);

  for (i = 0; i < arrExcludedFiles.length; i ++)
  {
    if (strFile == arrExcludedFiles[i])
    {
      strFile = "default.aspx";
      break;
    }
  }

  top.location.href = strRoot +"/" + strLanguage + "/" + strFile;
}

function SecondarySiteSearchKeyDown(event, strUrl, strSearchTerm)
{
    if (SecondarySiteIsKeyDownSubmit(event))
    {
        DoSecondarySiteSearch(strUrl + strSearchTerm);
        return false;
    }
    return true;
}

function SecondarySiteIsKeyDownSubmit(event)
{
    if (event != null)
    {
        var charCode;
        var bKeyModifiers;
        if (browseris.ie)
        {
            charCode = event.keyCode;
            bKeyModifiers = event.altKey || event.ctrlKey;
        }
        else
        {
            charCode = event.which;
            bKeyModifiers = event.modifers &
                           (event.ALT_MASK | event.CONTROL_MASK);
        }
        if ((charCode == 13) && !bKeyModifiers)
            return true;
    }
    return false;
}

function DoSecondarySiteSearch(strURL)
{
  window.location.href = strURL;
}

function resizeIFrameParent(strID, iFrameHeight)
{
  document.getElementById(strID).style.height = iFrameHeight;
}

function loadContactUsParams(strURL)
{
  var qs = new Querystring();
  var strCtype = qs.get("ctype", null);
  var strRtype = qs.get("rtype", null);
  
  strURL = strURL + "?ctype=" + strCtype + "&rtype=" + strRtype;
  getQueryVariable(strURL)
}

//Cognizant 07/12/2006 Start
//Changed & newly defined condition to pre-populated subject field with VisIV Information Request in contactus form.

function getQueryVariable(strURL) 
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++)
  { 
    var pair = vars[i].split("=");
    if (pair[0] == "site" && pair[1] == "inv")
    {
      strURL = strURL + '&site=inv';
      window.frames["iframeContactUs"].location = strURL;
    }
    else if (pair[0] == "site" && pair[1] == "VisIV")
    {
      strURL = strURL + '&site=VisIV';
      window.frames["iframeContactUs"].location = strURL;
    }
    else if (pair[0] == "site" && pair[1] == "TPN")
        {
          strURL = strURL + '&site=TPN';
          window.frames["iframeContactUs"].location = strURL;
    }
     else if (pair[0] == "site" && pair[1] == "SC")
    {
      strURL = strURL + '&site=SC';
      window.frames["iframeContactUs"].location = strURL;
    } 
     else if (pair[0] == "site" && pair[1] == "Others")
    {
      strURL = strURL + '&site=Others';
      window.frames["iframeContactUs"].location = strURL;
    } 
     else
    {
      window.frames["iframeContactUs"].location = strURL;
    }   
  }
}

//Cognizant 07/12/2006 End 













