// ---------------------------------------------------------------------------
// Name: allscript.js
// ---------------------------------------------------------------------------
// list of funktions in this file:
//
// home()
// randomImage(images)
// druckversion()
// makeGuidedSearchApplet()
//
// ---------------------------------------------------------------------------




// ---------------------------------------------------------------------------
// Name: printWindow
// Funktion: Druckfunktion
// ---------------------------------------------------------------------------



function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}







// ---------------------------------------------------------------------------
// Name: home
// Funktion: Umleitung auf die jeweilige Startseite secure. intranet. oder portal.is-energy.de
// ---------------------------------------------------------------------------
function toHome(){
	var srcUrl = window.location.href;
	var redirUrl = "";
	if(srcUrl.indexOf("https://secure.is-energy.de") == 0){
		redirUrl = "https://secure.is-energy.de";
	} else {
		if(srcUrl.indexOf("http://intranet.is-energy.de") == 0){
			redirUrl = "http://intranet.is-energy.de";
		} else {
			redirUrl = "http://intranet.is-energy.de";
		}
	}
	window.location.href= redirUrl;
}

// ---------------------------------------------------------------------------
// Name: RandomImage
// Funktion: Aufruf des Zufallsgenerators
// ---------------------------------------------------------------------------
//
//	Use this script tag in the HTML page
//
// <script language="JavaScript">
// <!--
//      document.write(randomImage("COMMASEPERATED LIST OF URLs"));
// //-->
// </script>
//
function randomImage(images)
{
 imageSet = new Array();
 urlSet = new Array();
 si = 0;
 ci=0;
 cc=0;
 ei = images.length;

  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ',')
    {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() * cc);

  mystring = "<img src="+imageSet[ind]+">\n\n";

  return mystring;
}

// ---------------------------------------------------------------------------
// Name: druckverion()
// Funktion: öffnet druckversion.php in einem neuen Fenster
// ---------------------------------------------------------------------------
function druckversion(){
	var srcUrl = window.location.href;

	// eingefuegt wegen Ressourcenmanagement (Sven Sonnleitner am 9.9.02)
	if ( srcUrl.indexOf("https://secure.is-energy.de/do/_Ressourcenmanagement/") == 0 ) {
		alert("Bitte benutzen Sie zum Drucken die Druckfunktionalität Ihres Browsers");
		return;
	}

	if(srcUrl.indexOf("https://intranet.is-energy.de") == 0){
		pvurl = "https://intranet.is-energy.de/_e/_php/_druckversion.php";
	} else {
		if(srcUrl.indexOf("https://secure.is-energy.de") == 0){
			pvurl = "https://secure.is-energy.de/_e/_php/_druckversion.php";
		}else{
			if(srcUrl.indexOf("http://intranet.is-energy.de") == 0){
				pvurl = "http://intranet.is-energy.de/_php/_druckversion.php";
			} else {
				alert(" Druckversion nicht möglich.\n Fehler: unbekanter Host\n");
				return;
			}
		}
	}

	clean = srcUrl.replace(/&/g,"HEX26");
    phpurl = pvurl + "?URL=" + clean;

    druck = open(phpurl, 'Druckversion','width=800,height=600,locationbar=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes');
    druck.focus();
    return;
}

// ---------------------------------------------------------------------------
// Name: makeGuidedSearchApplet
// Funktion: erstellt das Fenster zur erweiterten Suche mit browserspezifischem Applet
// Diese Funktion musste ausgelagert werden, da Gauss jeweils nur ein Pärchen <HTML>
// und <BODY> Tags bei HTML Seiten zu lässt. Dummerweise würde hier ein zweites Pärchen
// in der HTML Seite stehen und Gauss weigert somit diese Datei einzustellen. <Dirk Benkert>
// ---------------------------------------------------------------------------
function setLiveConnectOn(){
        // see whether LiveConnect is there
        if (navigator.appName == "Netscape" &&
           (parseInt(navigator.appVersion) == 3 ||
            parseInt(navigator.appVersion) == 4) &&
            navigator.javaEnabled()){
                LiveConnectOn = 1;
        }
}
function setIFC(){
        if (navigator.appName == "Netscape" &&
            parseInt(navigator.appVersion) == 4 &&
            navigator.javaEnabled()){
                hasIFC = 1;
        }
}
function setJava(){
        if ((navigator.appName == "Netscape" &&
            parseInt(navigator.appVersion) >= 4 ||
            navigator.appName == "Microsoft Internet Explorer") &&
             navigator.javaEnabled()){
                hasJava = 1;
        }
}
function GuidedSearchApplet(){
        str = '';
        makeGuidedSearchApplet();
        var myWin = open("", 'guidedSearchApplet','resizeable=0,width=440,height=310,toolbar=no,scrollbars=no');
        myWin.document.write(str);
        myWin.document.close();
}
function makeGuidedSearchApplet(){

        str='<html><head><title>GuidedSearch@home.intranet.is-energy.de</title>';
        str+='<meta http-equiv="content-type" content="text/html;charset="></head>';
        str+='<body bgcolor=#FFFFFF>';
        str+='<center>';
        if(hasIFC){
        str+='<applet codebase="http://home.intranet.is-energy.de/search-ui/applet" archive="SearchApplet.jar" code="NetscapeApplet"  width=390 height=265>';
        } else {
        str+='<applet codebase="http://home.intranet.is-energy.de/search-ui/applet" archive="SearchAppletIE.jar" code="NetscapeApplet"  width=390 height=265>';
        }
        str+='<param name="ApplicationClass" value="SearchInterface">';
        str+='<param name="search-applet-search-in" value="';
        str+='Search in:'; str+='">';
        str+='<param name="search-applet-search" value="';
        str+='Search'; str+='">';
        str+='<param name="search-applet-for" value="';
        str+='for:'; str+='">';
        str+='<param name="search-applet-advanced" value="';
        str+='Advanced'; str+='">';
        str+='<param name="search-applet-help" value="';
        str+='Help'; str+='">';
        str+='<param name="search-applet-add-line" value="';
        str+='Add Line'; str+='">';
        str+='<param name="search-applet-undo-line" value="';
        str+='Undo Line'; str+='">';
        str+='<param name="search-applet-clear" value="';
        str+='Clear'; str+='">';
        str+='<param name="search-applet-and-search-for" value="';
        str+='and search for ...'; str+='">';
        str+='<param name="search-applet-or-search-for" value="';
        str+='or search for ...'; str+='">';
        str+='<param name="search-applet-words" value="';
        str+='Words'; str+='">';
        str+='<param name="search-applet-words-in-proximity" value="';
        str+='Words in proximity'; str+='">';
        str+='<param name="search-applet-phrase" value="';
        str+='Phrase'; str+='">';
        str+='<param name="search-applet-literal" value="';
        str+='Literal'; str+='">';
        str+='<param name="search-applet-attribute" value="';
        str+='Attribute'; str+='">';
        str+='<param name="search-applet-any-pattern" value="';
        str+='Any Pattern'; str+='">';
        str+='<param name="search-applet-that" value="';
        str+='that'; str+='">';
        str+='<param name="search-applet-contains" value="';
        str+='Contains'; str+='">';
        str+='<param name="search-applet-starts" value="';
        str+='Starts'; str+='">';
        str+='<param name="search-applet-ends" value="';
        str+='Ends'; str+='">';
        str+='<param name="search-applet-matches" value="';
        str+='Matches'; str+='">';
        str+='<param name="search-applet-has-a-substring" value="';
        str+='Has a substring'; str+='">';
        str+='<param name="NS-collection" value="';
        str+='EEAIntranet'; str+='">';
        str+='<param name="NS-display-query" value="';
        str+='Test'; str+='">';
        str+='</applet>';
        str+='</center>';
        str+='</body></html>';
}

function GuidedSearch() {
        setJava();
        setIFC();
   if (hasJava) {
         GuidedSearchApplet();
      }
   else {
      var myWin = open('/search?NS-query-pat=/text/NS-advquery.pat', '_self');
      }
}


function bookmark(){
	var dummy=window.open("https://secure.is-energy.de/_e/_x/_pages/_bookmark.htm?action=show","bookmark","height=500,width=300,status=no,menubar=no,scrollbars=yes");
	dummy.focus();
}

function add_bookmark(){

	var dummy=window.open("https://secure.is-energy.de/_e/_x/_pages/_bookmark.htm?action=insert&URL=" + window.location.href,"bookmark","height=500,width=300,status=no,menubar=no,scrollbars=yes");
	dummy.focus();
}



function imgover(imgname, imgsrc){
     imgname.src = imgsrc
}

function imgout(imgname, imgsrc){
     imgname.src = imgsrc
}
