function printContent(f) {

        var sContent = '<html><link href="/css/novartisnew.css" rel="stylesheet" type="text/css"><body><table>'
        if (f == "single") {
                sContent += "<tr><td valign='top'>"+document.getElementById('columnB_top').innerHTML+"</td>";
                sContent += "<td valign='top'>"+document.getElementById('bufferBC_top').innerHTML+"</td>";
                sContent += "<td valign='top'><table><tr>"+document.getElementById('columnC_top').innerHTML+"</tr></table></td>";
//                sContent += "<tr valign='top'><td><table width='100%'><tr>"+document.getElementById('columnB_bottom').innerHTML+"</tr></table></td>";
        } else {
                sContent += "<tr><td valign='top'>"+document.getElementById('columnB_top').innerHTML+"</td>";
 //               sContent += "<tr valign='top'><td><table width='100%'><tr>"+document.getElementById('columnB_bottom').innerHTML+"</tr></table></td></tr>";
        }
        sContent += '</table></body></html>';
        var printwindow=window.open("","","toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480,screenX=200,screenY=50");
        printwindow.document.open();
        printwindow.document.write(sContent);
        printwindow.document.close();
        printwindow.focus();
}

function openwin(url,w,h,s,r) {
	var scrl; var resze;
	if (s) { scrl ="scrollbars=yes,";  }
	else { scrl ="scrollbars=no,";   }
	if (r) { resze = "resizable=yes,"; }
	else { resze="resizable=no,";    }
	if (!w) w = 640;
	if (!h) h = 480;
	fenster = window.open(url,"_blank",scrl+resze+"width="+w+",height="+h+",screenX=200,screenY=50");
    fenster.focus();
}

function openWindow(url,name,width,height){
		      window.open (url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+width+",height="+height)
}

function panelWindow() {
	panelWin = window.open('/panel/panel.html','panel','height=375,width=160,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menuBar=no');
	panelWin.focus();
}

/* JavaScript functions by iRIX Software Engineering AG, Basel */
/* Author: Daniel Fleig - 03/2001                              */
/* For use with Novartis Intranet Search by Inktomi            */

function searchsubmit(scope)
{
/* Opens pop up window and passes parameters for immediate search */

 var params = "";
 if (document.SearchForm)
   {params = "?qt=" + myescape(document.SearchForm.query.value);
   for (var j=0; j<document.SearchForm.elements.length; j++)
     if (document.SearchForm.elements[j].type=="hidden")
        params = params + "&" + document.SearchForm.elements[j].name + "=" + document.SearchForm.elements[j].value;
   }
 else
   for (var i=0; i<document.forms.length; i++)
      for (var j=0; j<document.forms[i].elements.length; j++)
        if (document.forms[i].elements[j].name=="query")
          params = "?qt=" + myescape(document.forms[i].elements[j].value);

 if (arguments.length==0 || scope=="") scope = "";
 else scope = "&scope=" + myescape(scope);
 if (document.images) {
     searchWin = window.open("http://search.novartis.intra" + "/index.html" + params + scope, "InktomiSearch","left=100,top=0,scrollbars=yes,dependent=yes,width=675,height=600,hotkeys=no,locationbar=no,menubar=no,resizable=yes,status=no");
     searchWin.focus();
    }
}

function searchpopup(scope)

/* Opens pop up windows with start screen of Search Engine */

  {
  if (arguments.length==0 || scope=="") scope = "";
  else scope = "?scope=" + myescape(scope);
  if (document.images) {
      searchWin = window.open("http://search.novartis.intra" + "/index.html" + scope, "InktomiSearch","left=100,top=0,scrollbars=yes,dependent=yes,width=675,height=600,hotkeys=no,locationbar=no,menubar=no,resizable=yes,status=no");
      searchWin.focus();
     }
}

function myescape(str) {

 str = escape(str);

 for (var i=0; i<str.length; i++)
   {if (str.charAt(i)=="+")
       str = str.substring(0,i) + "%2b" + str.substring(i+1, str.length);
   }
 return str;
}


function searchWindow() {
	s_type = document.selectList.searchType.value;
	if (s_type == 'people') {
		peoplesearch();
	}
	else if (s_type == 'webcentral') {
		intrasearch();
	}
	else if (s_type == 'intra') {
		intrasearch();
	}
	else if (s_type == 'inter') {
		intersearch();
	}
	else if (s_type == 'companies') {
		companysearch();
	}
}

if (document.layers) document.captureEvents(Event.KEYDOWN);
document.onkeydown = function (evt) {
	var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
	if (keyCode == 13 && document.activeElement.name == "SearchField") {
		s_type = document.selectList.searchType.value;
		if (s_type == 'people') {
			peoplesearch();
		}
		else if (s_type == 'webcentral') {
			intrasearch();
		}
		else if (s_type == 'intra') {
			intrasearch();
		}
		else if (s_type == 'inter') {
			intersearch();
		}
		else if (s_type == 'companies') {
			companysearch();
		}
		return false;
	} else {
		return true;
	}
};

/*---------
if checkbox is selected, selects every entries from multiplebox, else deselect all
----------*/
function selectAll(multiplebox,checkbox) {
    for (var i = 0; i < multiplebox.length; i++) {
    multiplebox.options[i].selected = checkbox.checked;
  }
}

/*---------
if checkbox is checked, disable the multiplebox, else enable it
----------*/
function selectAllAndDisable(multiplebox,checkbox) {
  selectAll(multiplebox,checkbox);
  if (checkbox.checked) {
    multiplebox.disabled = true;
  }
  else {
    multiplebox.disabled = false;
  }
}

/*---------
if checkbox is selected, selects every entries from the list, else deselect all
----------*/
function selectAllCheckBox(checkbox, nbOfCheckboxes) {
	var checked = false;

  if (checkbox.checked) {
    checked = true;
	}
  else {
    checked = false;
  }
  for (var i = 0; i < nbOfCheckboxes; i++) {
    document.forms[0].elements['productCheckbox[' + i + ']'].checked = checked;
  }
}

/*---------
if checkbox is selected, selects every entries from the list, else deselect all
----------*/
function selectAllCheckBox(checkbox, multibox, nbOfCheckboxes) {
	var checked = false;

  if (checkbox.checked) {
    checked = true;
	}
  else {
    checked = false;
  }
  for (var i = 0; i < nbOfCheckboxes; i++) {
    document.forms[0].elements[multibox + '[' + i + ']'].checked = checked;
  }
}

/*---------
if value is null, display a popup and return false, else return true
----------*/
function checkIfNull(value) {
  if (value == null) {
		return false;
  }
  else {
		return true;
  }
}

function intrasearch() {
	document.SearchForm.query.value = document.selectList.searchField.value;
	searchsubmit('');
}

function peoplesearch() {
	peoplewin =  window.open('http://peoplesearch.novartis.intra?lname='+document.selectList.searchField.value,'','height=580,width=680,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,menuBar=0');
	peoplewin.focus();
}

function companysearch() {
	peoplewin =  window.open('http://peoplesearch.novartis.intra/groupcompanies?company='+document.selectList.searchField.value,'','height=580,width=680,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,menuBar=0');
	peoplewin.focus();
}

// function acronymsearch() {
// 	window.open('/NovartisAcronyms/acronymsearch_en.jsp?searchstring=' + document.selectList.searchField.value, '');
// }

function intersearch() {
	newwin = window.open('','_blank','height=525,width=700,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,menuBar=0');
	newwin.document.open();
	newwin.document.write("<ht"+"ml>\n");
	newwin.document.write("<scr"+"ipt language='JavaScript'>\n");
	newwin.document.write("function loadresult()" + unescape("%7b") +" \n");
	if (document.selectList.searchField.value) {
		newwin.document.write("top.main.location.href='http://search.novartis.com/query.html?la=en&qlang=&qp=&col=&qt=" + document.selectList.searchField.value + "';\n");
	}
	else {
		newwin.document.write("top.main.location.href='http://search.novartis.com/simple.html?la=en&qlang=&qp=&col=&qt=" + document.selectList.searchField.value + "';\n");
	}
	newwin.document.write(unescape("%7d") +"\n");
	newwin.document.write("<"+"/"+"sc"+"ript>\n");
	newwin.document.write("<FRA"+"MESET COLS='180,*' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' LEFTMARGIN='0' TOPMARGIN='0' onload='loadresult()'>\n");
	newwin.document.write("<FR"+"AME NAME='navigation' scrolling='no' SRC='http://search.novartis.com/tip.html?la=en&qp=&col=' noresize>\n");
	newwin.document.write("<FRA"+"MESET ROWS='42,*' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' LEFTMARGIN='0' TOPMARGIN='0' scrolling='no'> \n");
	newwin.document.write("<FR"+"AME NAME='top' SRC='http://search.novartis.com/top.html?la=en&qlang=&qp=&qt=' noresize scrolling='no'> \n");
	newwin.document.write("<F"+"RAME NAME='main' scrolling='yes'>\n");
	newwin.document.write("</FRA"+"MESET>\n");
	newwin.document.write("</FR"+"AMESET>\n");
	newwin.document.write("</ht"+"ml>\n");
	newwin.document.close();
}
function highlightFormElements() {
    // add input box highlighting
    if (!addFocusHandlers(document.getElementsByTagName("input"), 'text')) {
      addFocusHandlers(document.getElementsByTagName("textarea"), '');
    }
    //addFocusHandlers(document.getElementsByTagName("select"));
}

function addFocusHandlers(elements, type) {
    for (i=0; i < elements.length; i++) {
        if (type == '' || (type != '' && elements[i].type == type)) {
            if (elements[i].style.display != 'none' && !elements[i].disabled) {
                // set the focus on the first text found in the form
                elements[i].focus();
                elements[i].select();
                return true;
            }
        }
    }
    return false;
}



/*
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/js/custom/custom.js'><\/SCRIPT>");

// START NAVIGATION CODE INTEGRATION -->
// menuing js init begin
	  NS4 = (document.layers)?true:false;
	  IE4 = (document.all)?true:false;
	   IE = (document.all)?true:false;
	  DOM = (document.getElementById)?true:false;
	 ver4 = (NS4 || IE4)?true:false;
	DHTML = (IE4 || DOM || IE)?true:false;

	function popUp(){return};
	function popDown(){return};
	function startIt(){return};

	if ( DHTML) {
	  document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='/js/navigation/inlMenus.js'><\/SCRIPT>");
	}
*/

/* open window to set code and/or label into the source form for the catalog category */
function openAssignCodeCatalogWindow(category, srcForm, srcCodeField, srcTextField, srcSeqField) {
  popupWindow("chemicalCode.do?action=searchCode"+
              "&srcForm="+srcForm+
              "&srcCodeField="+srcCodeField+
              "&srcTextField="+srcTextField+
              "&srcSeqField="+srcSeqField+
              "&category="+category+
              "&time="+new Date(),
              "chemicalCode", 800, 600);
}

/* open window to get thumbs ---- set code and/or label into the source form for the catalog category */
function openGetContentWindow(srcForm, srcGraphicalItemField) {
  popupWindow("contentAction.do?action=openContentPicklist", "Test2", 500, 265);
}

/* open window to get thumbs ---- set code and/or label into the source form for the catalog category */
function openGetPhraseWindow(srcForm, srcGraphicalItemField) {
  popupWindow("phraseAction.do?action=openPhrasePicklist", "Test2", 500, 265);
}

/* open window to get thumbs ---- set code and/or label into the source form for the catalog category */
function openGetGraphicalItemWindow(srcForm, srcGraphicalItemField) {
  popupWindow("../../../graphicalItemAction.do?action=openThumbsPicklist",
              "Test2", 500, 265);
}


/* open window to set code and/or label into the source form for the catalog category */
function openAssignCodeDeclarationWindow(category, srcForm) {
  popupWindow("chemicalCode.do?action=searchCode"+
              "&srcForm="+srcForm+
              "&category="+category+
              "&time="+new Date(),
              "chemicalCode", 800, 600);
}

/* open window to set code and/or label into the source form for a specified category */
function openAssignCodeWindow(category, srcForm, srcCodeField, srcTextField) {
  popupWindow("chemicalCode.do?action=searchCode"+
              "&srcForm="+srcForm+
              "&srcCodeField="+srcCodeField+
              "&srcTextField="+srcTextField+
              "&category="+category+
              "&time="+new Date(),
              "chemicalCode", 800, 600);
}

/* open window to set code and/or label into the source form for a specified category */
function openSearchWindow(url) {
  popupWindow(url + "&time=" + new Date(), "searchWindow", 800, 600);
}

/* open window to display help text */
function openHelpWindow(code, language) {
  popupWindow("searchHelp.do?action=searchHelp"+
              "&searchHelpCodeKey="+code+
              "&searchHelpLanguageKey="+language,
              "helpWindow", 300, 200);
}

/* change disable property of all elements of the specified form to false.
   This allow to keep all values on form submit */
function enableAllFormElements(formName) {
  if (window.document.getElementById(''+formName+'').elements) {
    elements = window.document.getElementById(''+formName+'').elements;
    for (i = 0; i < elements.length; i++) {
      if (elements[i].disabled) {
        elements[i].disabled=false;
      }
    }
  }
}

/* set the onmouseover and onmouseout event of rows of the table given in parameter*/
function HighlightRow (tableName) {
if (document.getElementById(tableName)) {
    var table = document.getElementById(tableName);
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
        rows[i].onmouseover = function() {this.className+=' over';return true};
        rows[i].onmouseout = function() {this.className = this.className.substring(0,this.className.lastIndexOf(" over"));return true};
  /*      if (i % 2) rows[i].onmouseout = function() {this.className="even";return true};
        else rows[i].onmouseout = function() {this.className="odd";return true};*/
/*        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            var link = cell.getElementsByTagName("a")[0];
            if (link) {
	            location.href = link.getAttribute("href");
	            this.style.cursor="wait";*/
    }
}
}

/* Hide readonly input text field and disabled select object and display their content
*/
function viewForm(formID) {
	var mySource = document.getElementById(formID);
	var myFormSelect = mySource.getElementsByTagName('select');
	var myFormInput = mySource.getElementsByTagName('input');
	for (var i=0; i < myFormInput.length;i++){
		if ((myFormInput[i].getAttribute('readonly') != '') && (myFormInput[i].getAttribute('type') == 'text')) {
			document.getElementsByName(myFormInput[i].getAttribute('name'))[0].style.display = 'none';
			var newSPAN = document.createElement('span');
       		newSPAN.setAttribute("id",myFormInput[i].getAttribute('name')+'SPAN');
			var newText = document.createTextNode(myFormInput[i].getAttribute('value')+'');
			newSPAN.appendChild(newText);
			myFormInput[i].parentNode.insertBefore(newSPAN,myFormInput[i]);
            document.getElementById(myFormInput[i].getAttribute('name')+'SPAN').className = "inputView";
		}
	}
	for (var i=0; i < myFormSelect.length;i++){
		if (myFormSelect[i].getAttribute('disabled') != '') {
			var mySelect = document.getElementsByName(myFormSelect[i].getAttribute('name'))[0];
			mySelect.style.display = 'none';
			var newSPAN = document.createElement('span');
    		newSPAN.setAttribute("id",myFormSelect[i].getAttribute('name')+'SPAN');
			var newText = document.createTextNode(mySelect.options[mySelect.selectedIndex].text+'');
			newSPAN.appendChild(newText);
			myFormSelect[i].parentNode.insertBefore(newSPAN,myFormSelect[i]);
            document.getElementById(myFormSelect[i].getAttribute('name')+'SPAN').className = "inputView";
		}
	}
}

function textCounter(field,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
}

// automatically set the size of the leftMenu and the hitList
function autoResizeLayers() {
var messageHeight = 0;
resizeHitList();
if (document.getElementById('leftMenuContent'))
	document.getElementById('leftMenuContent').style.height = document.body.offsetHeight-document.getElementById('structureHeader').offsetHeight-document.getElementById('structureToolbar').offsetHeight-document.getElementById('leftMenuHeader').offsetHeight-document.getElementById('leftMenuFooter').offsetHeight-23+"px";
if (document.getElementById('searchResultContent')) {
  if (document.getElementById('message'))
  	messageHeight = document.getElementById('message').offsetHeight;
	document.getElementById('searchResultContent').style.height = document.body.offsetHeight-document.getElementById('structureHeader').offsetHeight-document.getElementById('structureToolbar').offsetHeight-document.getElementById('headerCentralContent').offsetHeight-messageHeight-document.getElementById('options').offsetHeight-35+"px";
}
}

function resizeHitList() {
if (document.getElementById('hitlistContent'))
	document.getElementById('hitlistContent').style.height = document.body.offsetHeight-document.getElementById('structureHeader').offsetHeight-document.getElementById('structureToolbar').offsetHeight-document.getElementById('hitListHeader').offsetHeight-document.getElementById('hitListFooter').offsetHeight-23+"px";
}
