// ------------------------------------------------------------------------------------------
//  File: wwp_scripts.js
//	Desc: wwp javascripts fuer die standard wwp features
//  Version: 0.9
//  Datum:   04/05/2001
//  History:
//  28/04/2001 lsimma
//    	+ Version, Datum und History eingefuegt   
//    	! an default_wwp.xsl version 0.9 angepasst
//	01/05/2001 lsimma
//			+ Rollovereffekte fuer Images mit viewImg und loadImg realisiert
//			  Diese funktion kann auch zum Austausch von Bildern andersweitig verwendet werden 
//				bsp. Agentur-BAP einblenden von Mitarbeiterbildern
//	01/05/2001 lsimma
//			+ globale Variable lang, wird vom XSL automatisch uebergeben nachdem das script geladen wurde
//				ist dann global verwendbar zur ermittlung welche sparche die webseite hat
// 			+ mehrsprachiges Messages ueber getMsg(id) abrufbar
//      09/08/001 lsimma
//                      + messages in www_scripts_form verlagert da nur in forms verwendet
// ------------------------------------------------------------------------------------------


// Diese Varible wird durch das XSL im HEAD vom HTML gesetzt mit de, en oder it
var lang = "";
function setLang(l) {
	lang=l;
}

// Rollovereffekte bei Images
// ermoeglicht preloading mit der fkt. rolloverLoad()
loadedImages=new Array();

function viewImg(imgid,name) {
	var img1=document.images[imgid];
	var img2=loadedImages[name];

	if (img1&&img2) { // pruefen ob beide objekte vorhanden sind
		img1.src=img2.src;
	}
}

function loadImg(name,img) {
  loadedImages[name]=new Image();
  loadedImages[name].src=img;
}

// Oeffnen von Seiten in neuen Fenstern
function openpopup(url,width,height) {
	if (width != "" && height != "") {
		win1 = window.open(url, "_new_","width="+width+",height="+height+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else if (width != "")  {
		win1 = window.open(url, "_new_","width="+width+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else if (height != "")  {
		win1 = window.open(url, "_new_","height="+height+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else {
		win1 = window.open(url, "_new_","toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	}
	win1.focus();
}

// Oeffnen von Seiten in neuen Fenstern
function openpopup1(url,width,height) {
	if (width != "" && height != "") {
		win1 = window.open(url, "_new1_","width="+width+",height="+height+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else if (width != "")  {
		win1 = window.open(url, "_new1_","width="+width+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else if (height != "")  {
		win1 = window.open(url, "_new1_","height="+height+",toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	} else {
		win1 = window.open(url, "_new1_","toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,location=no,menubar=no");
	}
	win1.focus();
}

// Oeffnen von Seiten in neuen Fenstern
function openpopup2(url,width,height) {
	if (width != "" && height != "") {
		win1 = window.open(url, "_checkout_","width="+width+",height="+height+",toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=yes");
	} else if (width != "")  {
		win1 = window.open(url, "_checkout_","width="+width+",toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=yes");
	} else if (height != "")  {
		win1 = window.open(url, "_checkout_","height="+height+",toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=yes");
	} else {
		win1 = window.open(url, "_checkout_","toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=yes");
	}
	win1.focus();
}


// Oeffnen von Seiten in neuen Fenstern zentriert
function openpopupcenter(url,width,height) {
   var left=(screen.width-width)/2;
   var top=(screen.height-height)/2;
   var attrstr = "toolbar=no,directories=no,status=no,scrollbars=no,resizable=no,location=no,menubar=no";
   attrstr += ',screenX='+top+',top='+top;                   
   attrstr += ',screenY='+left+',left='+left;       
   win1 = window.open(url, "_blank","width="+width+",height="+height+","+attrstr);
	win1.focus();
}

// dieses wenn der abstand vom rand im link festgelegt wird
function openpopup(url,width,height,top,left,attribute,windowname) 
{
            var attrstr = "toolbar=yes,directories=no,status=no,scrollbars=no,resizable=yes,location=no,menubar=no";
            if (attrstr != "") {
                        attrstr = attribute;
            }
 
            if (top != "") {
                        var x = 0;
                        if (document.all) {
                                    x = window.screenTop + top;
                        }
                        else if (document.layers) {
                                    x = window.screenX + top;
                        }
                        
                        attrstr += ',top='+x+',screenX='+x;
            }
            
            if (left != "") {
                        var y = 0;
                        if (document.all) {
                                    y = window.screenLeft + left;
                        }
                        else if (document.layers) {
                                    y = window.screenY + left;
                        }
                        
                        attrstr += ',screenY='+y+',left='+y;           
            }
            
            if (! windowname) { windowname = "_new_"; }
            
            if (width != "" && height != "") {
                        win1 = window.open(url, windowname,"width="+width+",height="+height+","+attrstr);
            } else if (width != "")  {
                        win1 = window.open(url, windowname,"width="+width+","+attrstr);
            } else if (height != "")  {
                        win1 = window.open(url, windowname,"height="+height+","+attrstr);
            } else {
                        win1 = window.open(url, windowname,attrstr);
            }
            win1.focus();
            return false;
}

// Oeffnen von Seiten in neuen Fenstern
function openwindow(url,width,height) {
	if (width != "" && height != "") {
		win1 = window.open(url, "_new_","width="+width+",height="+height+",toolbar=yes,directories=yes,statusbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,dependent=yes");
	} else if (width != "")  {
		win1 = window.open(url, "_new_","width="+width+",toolbar=yes,directories=yes,statusbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,dependent=yes");
	} else if (height != "")  {
		win1 = window.open(url, "_new_","height="+height+",toolbar=yes,directories=yes,statusbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,dependent=yes");
	} else {
		win1 = window.open(url, "_new_","toolbar=yes,directories=yes,statusbar=yes,scrollbars=yes,resizable=yes,location=yes,menubar=yes,dependent=yes");
	}
	win1.focus();
}

function closewindow() {
	self.close();
}

function openSiteInOpener(url) {
	opener.location.href=url;
	self.close();
}

function spamstop(adress, domain) { 
window.location.replace('mailto:' +adress+ '@' +domain); 
}

function printmail(adress, domain) {
        document.write(adress + '@' + domain);
}

function printclosewindow() {
        if (lang == "de") {
		 document.write('FENSTER SCHLIESSEN');
	}

        if (lang == "en") {
		 document.write('CLOSE WINDOW');
	}
	
        if (lang == "it") {
		 document.write('CHIUDI FINESTRA');
	}	
}


function UnCryptMailto( s )
    {
        var n = 0;
        var r = "";
        for( var i = 0; i < s.length; i++)
        {
            n = s.charCodeAt( i );
            if( n >= 8364 )
            {
                n = 128;
            }
            r += String.fromCharCode( n - 1 );
        }
        return r;
    }

    function linkTo_UnCryptMailto( s )
    {
        location.href=UnCryptMailto( s );
    }