var seamonkey, opera, ie, nn = false;
var browsername = "Netscape";
var ua = window.navigator.userAgent
var version = navigator.appVersion
/* which browser */
if (ua.indexOf("MSIE") >= 0)  { browsername = "Microsoft" }
if (ua.indexOf("Opera") >= 0) { browsername = "Opera" } 
/* Which version number */
if (ua.indexOf("/4.") > 0) 		{ version = 4 }
if (ua.indexOf("/5.") > 0) 		{ version = 5 }
if (ua.indexOf("MSIE 5.") > 0){ version = 5 }
/* Put it all together */
if (browsername == "Microsoft") { ie  = true; }
if (browsername == "Opera") 		{ opera   = true; }
if (browsername == "Netscape"  && version == 4) { nn  = true; }
if (browsername == "Netscape"  && version == 5) { seamonkey = true; }
function checkFrames(){
   if(typeof bot == 'undefined' || !bot) {
      if (top.frames.length <= 2){
         reloadFrames();
//      }else if(top.frames["header"] == null){
//	reloadFrames();
     }
      else if(top.frames["header"] != null){
         setValues();
         checkCampaign();
      }
   }
}
function reloadFrames()
{
    if(typeof bot == 'undefined' || !bot) {
       top.location.replace("/" + mainDb + "!OpenDatabase&db=/" + thisDb + "&v=" + categoryCode + "&e=" + language + menuredirect + "&c=" + unid);
    }
}
function setValues() {
	i1 = this.location.href.indexOf('http://');
	if (i1 >= 0) return false;
	if (this.frames.name != 'external') {
		headerform = top.frames["header"].document.forms[0];
		if (headerform) {
			headerform.Page.value=window.location.href;
		}
	}
}
function checkFramesMain()
{
  if (top.frames.length == 0)
  {
    reloadFramesMain();
  }
  else
  {
    setValues();
    checkCampaign();
  }
}
function reloadFramesMain()
{
    if(typeof bot == 'undefined' || !bot) {
     top.location.replace("/" + thisDb + "!OpenDatabase&main=/" + thisDb + "/vwMainPage/" + unid);
  }
}
function Jump(newurl)
{
  if (newurl == 'skip') return;
  result = newurl.split('|');
  url = result[0];
  target = result[1];
  //target = '3' is used from template 4, where the content frame is split into 2 new frames.
  //target = '4' is used when "left" is the target. (Link page - link to left menu)
  //target = '5' is used when this is a link page to contact us.
  if (target == '0') top.location.href = url;
  if (target == '1') top.frames["main"].location.href = url;
  if (target == '2') window.open(url, "pieviewer", "menubar=1,status=1,location=1,toolbar=1,scrollbars=1,resizable=1,width=640,height=480");
  if (target == '3') top.frames["main"].frames["content"].location.href = url;
  if (target == '4') top.frames["main"].frames["left"].location.href = url;
  if (target == '5') window.location.href = url;
}
function go(newurl)
{
  if (newurl == 'skip') return;
  if (newurl.indexOf('|') > 0) {
     Jump(newurl);
  }  else {
     window.location.href = newurl;
  }
}
function openContactusFromPage(contactdb, siteTitle)
{
  var soPageURL;
  soPageURL = new String(window.location.href);
  i1 = soPageURL.indexOf('http://');
  if (i1 >= 0) soPageURL = escape(soPageURL.substring(7, soPageURL.length));
  contactus = window.open(contactdb + "/frmWebFeedback!OpenForm&Site=" + siteTitle + "&Section=" + categoryName + "&Page=" + soPageURL + "&Language=" + language, "contactus","width=420,height=435,toolbar=0,directories=0,menubar=0,status=no,resizable=0,location=0,scrollbars=0,copyhistory=0,alwaysRaised=1");
  contactus.focus();
}
function openSearchFromPage() {
	 var popupsearch = window.open("http://"+document.searchForm.searchIp.value+"/inside/index.asp?template=normal&maxdocs=200&resultperpage=10&search=search&attachment=false&query1="+utfEncode(document.searchForm.searchInput.value) ,"popupsearch","width=740,height=500,toolbar=0,directories=0,menubar=0,status=1,resizable=1,location=0,scrollbars=1,copyhistory=0");
popupsearch.focus();
}
function openContextSearchFromPage() {
	if (document.searchForm.context[0].checked==true)
		 { var popupsearch = window.open("http://"+document.searchForm.searchIp.value+"/inside/index.asp?template=normal&maxdocs=200&resultperpage=10&search=search&attachment=false&query1="+utfEncode(document.searchForm.searchInput.value) ,"popupsearch","width=740,height=500,toolbar=0,directories=0,menubar=0,status=1,resizable=1,location=0,scrollbars=1,copyhistory=0");
popupsearch.focus();
		}
	else
		{openSearchFromPage()}
}
function openSearchFromPageWithIp( ip, searchText ) {
	 var popupsearch = window.open("http://"+ ip+"/inside/index.asp?template=normal&maxdocs=200&resultperpage=10&search=search&attachment=false&query1="+utfEncode(searchText) ,"popupsearch","width=740,height=500,toolbar=0,directories=0,menubar=0,status=1,resizable=1,location=0,scrollbars=1,copyhistory=0");
	popupsearch.focus();
}
function hexEncode(invalue) {
	return "%" + invalue.toString(16);
}
function utfEncode(inputstring) {
	outcode = "";
	for (a=0; a<inputstring.length; a++) {
		c = inputstring.charCodeAt(a);
		// Code characters to UTF-8 and append to outcode
		if (c < 0x80){
			outcode += inputstring.charAt(a); 
		} else if (c < 0x800){
 			outcode += hexEncode((0xC0 | c>>6));
			outcode += hexEncode((0x80 | c & 0x3F));
		} else if (c < 0x10000) {
			outcode += hexEncode((0xE0 | c>>12));
			outcode += hexEncode((0x80 | c>>6 & 0x3F));
			outcode += hexEncode((0x80 | c & 0x3F)); 
		} else if (c < 0x200000) {
			outcode += hexEncode((0xF0 | c>>18));
			outcode += hexEncode((0x80 | c>>12 & 0x3F));
			outcode += hexEncode((0x80 | c>>6 & 0x3F));
			outcode += hexEncode((0x80 | c & 0x3F));
		}
	}
	// Return result
	return outcode;
}
function openSalesContacts(scCategory,scCountry)
{
  href = document.URL;
  window.open("/" + "global/seitp/seitp179.nsf" + "/frmWebFrameset?ReadForm&SClang=" + language + "&SCcat=" + scCategory +   "&SCcountry=" + scCountry + "&SCref=" + href + "&SC", "Feedback","width=420,height=544,resizable=no,toolbar=no,titlebar=yes,status=no,scrollbar=no,menubar=no,location=no");
}
function onChangeCountryCategory(scCat,cntry)
{
  if (scCat != "" & scCat != "skip" & cntry !="skip")
  {
      openSalesContacts(scCat,cntry);
  }
}
function openUrl( urlStr, target )
{
  if( target == '' ){
    this.window.location.href = urlStr;
  }
  else if(parent.frames[target]){
    parent.frames[target].document.location = urlStr;
  }
  else if( parent.parent.frames[target] ){
    parent.parent.frames[target].document.location = urlStr;
  }
  else {
    window.open( urlStr, target );
  } 
}
function replaceUrl( urlStr, target )
{
  re = /viewInside/gi;
  newUrl=urlStr.replace(re, "0");
  re = /\$percent\$/gi;
  pos = newUrl.indexOf( 'javascript' );
  fixedUrl = "";
  if( pos > -1 ) {
     eval( newUrl.replace( re, '%' ) );
  }
  else {
     i1 = newUrl.indexOf('://');
     if (i1 > 0 && (target == '' || target == 'main' || target == 'content' || target == 'left' || target == '_self' )) {
        fixedUrl = newUrl.substring(0, i1) + '%$$' + newUrl.substring(i1 +3, (newUrl.length + i1));
        newUrl="/" + thisDb + "/frmRedirect!ReadForm&&url=" + escape(fixedUrl);
     }
     else {
        newUrl = newUrl.replace( re, '%' );
     }
  openUrl( newUrl, target );
  }
}
function printDocument( type) {
  if (type == 1) {
    if (nn) {
        printWindow = window.open("../lupLongPrint/" + unid + "!OpenDocument&r=2");
    } else {
        printWindow = window.open("../lupLongPrint/" + unid + "!OpenDocument&r=2", "printWindow", "width=665, height=540, toolbar=1, directories=0, menubar=1, status=1, resizable=1, location=0, scrollbars=1, copyHistory=0, alwaysRaised=1");
    }
  } else {
    if (nn) {
       printWindow = window.open("/" + thisDb + "/lupPrintUNID/" + unid + "?OpenDocument&r=2");
    } else {
       printWindow = window.open("/" + thisDb + "/lupPrintUNID/" + unid + "?OpenDocument&r=2", "printWindow", "width=665, height=540, toolbar=1, directories=0, menubar=1, status=1, resizable=1, location=0, scrollbars=1, copyHistory=0, alwaysRaised=1");
    }
  }
    printWindow.focus();
}
function emailPage() {
    emailWindow = window.open("/" + thisDb + "/wfrmMailToFriend?ReadForm&charset=UTF-8&c=" + unid +
"&db="+ thisDb, "emailWindow", "menubar=0,status=0,location=0,toolbar=0,scrollbars=0,resizable=0,height=360,width=430");
    emailWindow.focus();
}
function bookmarkPage() {
    if (ie) {
         var strProfDocID = getCookie( "MPUserName" );
        if (  strProfDocID != null ) {
           newUrl = "/global/seitp/seitp241.nsf/agnAddNewLink!OpenAgent&**title=" + headline + "&**url=" + this.location.href + "&**unid=" + strProfDocID;
           openUrl( escape( newUrl ), "content"  )
        } else {
            window.external.AddFavorite(this.location.href, document.title);
        }
    } else {
        alert("Your browser does not support opening of the bookmark/favorites window.\n\nBookmark this page manually by clicking on your right mouse button in the content part of the window.");
    }
}
function openCalculator()
{
  calcWindow = window.open("/global/abbzh/abbzh252.nsf/pgCalc?OpenPage","calcWindow","width=420,height=485,toolbar=0,directories=0,menubar=1,status=no,resizable=1,location=0,scrollbars=1,copyhistory=0,alwaysRaised=1");
}
function openVisualIdentitySearch()
{
  viSearchWindow = window.open("/global/abbzh/abbzh252.nsf/frmSearch?ReadForm","viSearchWindow","width=670,height=485,toolbar=0,directories=0,menubar=0,status=no,resizable=1,location=0,scrollbars=1,copyhistory=0,alwaysRaised=1");
}
function getCookie(name) {
  var cookieString = document.cookie;
  var valueStart = cookieString.indexOf(name);
  if(valueStart == -1) {
    return null;
  }
  valueStart += name.length + 1;
  var valueEnd = cookieString.indexOf(";", valueStart);
  if(valueEnd == -1) {
    valueEnd = cookieString.length;
  }
  var value = cookieString.substring(valueStart, valueEnd);
  return unescape(value);
}
//function: setCookieExp
//scope: local but general
//purpose: stores a cookie
//param: nam - name of the cookie
//param: val - value of the cookie
//param: day - expiration time in days
function setCookieExp(nam,val,day) {
	var exp=new Date();
	exp.setTime(exp.getTime()+day*86400000);
	document.cookie=nam+'='+escape(val)+'; expires='+exp.toGMTString()+';path=/';
}
//function: setCookie
//purpose: setCookieExp with default expiration in 365 days
//see: setCookieExp()
function setCookie(nam,val) {
	setCookieExp(nam,val,365);
}
		function submitIt(winheight){
			form = document.forms.pollForm;			
			qField = form.AnswerID;			
			i=0
			isChecked = false
			if( qField.type != "select-one" ){
				while( i < qField.length ){
					if (qField[i].checked){
						isChecked = true;
					}
					i++;
				}
			}
			else{
				isChecked = true
			}
			
			if( isChecked ){
				newWin = window.open("", "submitWin", "toolbar,height=" + winheight + ",width=450,resizable")
				form.submit();
				newWin.focus()
			}
			else{
				alert("You have to select an answer alternative before submitting");
			}
		}
		function openWin( urlStr, name, parameters ){
  			newWin = window.open(urlStr, name, parameters);
  			newWin.focus();
		}

