// 
// $Workfile: common.js $
// $Revision: 3 $
// $Date: 10.08.05 17:48 $
// $Author: Schwama8 $, Manuel Schwarze, Novartis Pharma AG, GISM, PKI
//

function printContent(f) {

        var sContent = '<html><link href="/css/package.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,"; w = w+16; }
	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();
}

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 && document.activeElement.name == "SearchField") {
		gosearch();
		return false;
	} else {
		return true;
	}
};

function setDisclaimerTarget(disclaimertarget){
	target="";
	target=disclaimertarget;
}

function openDisclaimer(urlt,w,h) {
	if (!urlt) url = "external_disclaimer.html";
	else url = urlt;
	var scrl; var resze;
	scrl="scrollbars=no,";
	resze="resizable=no,";
	if (!w) w = 400;
	if (!h) h = 300;
	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)
}

// 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};

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;
	}
};

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();
}
