//JavaScript - Library
//All rights reserved - Copyright by medialink 2001-2007 - v6.32/24.09.2007


//-----default-settings
var filename = "";
if (self.location.href.indexOf("?") > -1){
	filename=self.location.href.substring(self.location.href.lastIndexOf("/")+1,self.location.href.lastIndexOf("?"));
}else{
	filename=self.location.href.substring(self.location.href.lastIndexOf("/")+1,self.location.href.length);
}

//reading the rubric of file by directory (caused by weblication name-addons as wEdit/wdraft and so on)
rubricdirectory = self.location.href.substring(0,self.location.href.lastIndexOf("/"));
rubricdirectory = rubricdirectory.substring(rubricdirectory.indexOf("pages/")+6,rubricdirectory.indexOf("pages/")+8);
rubric = rubricdirectory;
sls = self.location.search.substring(1,self.location.search.length);





//----- init-section ---------------------------------------------------------------------------
//defining the rubric (also for weblication-edit-filenames)
if ((rubric != "HO") && (rubric != "SP") && (rubric != "PR") && (rubric != "AR") && (rubric != "EX") && (rubric != "SE") && (rubric != "UB") && (rubric != "FO")){
	rubric= "SP"; //default if not specified
}

//Standard
var pathHeaderImage = "templates/swiss/images/bannerimg/banner_" + rubric + ".jpg";

//Projectdescription with individual header image
if (filename.indexOf('_Img') > -1){
	pathHeaderImage = "templates/swiss/images/" + filename.substring(0,filename.lastIndexOf('.php')) + ".jpg";
}


//setting the header images
function doinit(){
	if (document.images){
		document.images['topCenterImage'].src = pathHeaderImage;
	}
}






//----- rollover section ---------------------------------------------------------------------------
if (document.images){
	var imageov = new Array();
	var imageof = new Array();

	for (var z=1; z<=4; z++){
		imageov['fnc'+z] = new Image();
		imageov['fnc'+z].src = "templates/swiss/images/fnc"+z+"ov.jpg";
		imageof['fnc'+z] = new Image();
		imageof['fnc'+z].src = "templates/swiss/images/fnc"+z+"of.jpg";
	}
}

function imgov(i){
	if (document.images){
		document.images[i].src=imageov[i].src;
	}
}

function imgof(i){
	if (document.images){
		document.images[i].src = imageof[i].src;
	}
}




//project section with worldmap
//indizes: 1-Africa, 2-Asia, 3-Southamerica, 4-Centralamerica, 5-EastEurope
if ((filename == "PR.php") || (filename == "PR_Aa.php") || (filename == "PR_An.php") || (filename == "PR_Sa.php") || (filename == "PR_Za.php") || (filename == "PR_Oa.php")){

	if (filename == "PR.php"){
		fi = "0";
	}
	if (filename == "PR_Aa.php"){
		fi = "1";
	}
	if (filename == "PR_An.php"){
		fi = "2";
	}
	if (filename == "PR_Sa.php"){
		fi = "3";
	}
	if (filename == "PR_Za.php"){
		fi = "4";
	}
	if (filename == "PR_Oa.php"){
		fi = "5";
	}

	imageof['rgn'] = new Image();
	imageof['rgn'].src = "templates/swiss/images/rgn"+fi+fi+".gif";

	for (var z=1; z<=5; z++){
		imageov['rgn'+fi+z] = new Image();
		imageov['rgn'+fi+z].src = "templates/swiss/images/rgn"+fi+z+".gif";
	}
}


function mapov(i){
	if (document.images){
		document.images['rgn'].src=imageov[i].src;
	}
}







//----- popup functions ----------------------------------------------------------------------------
//general
function setWinParams(w,h,sb){
	//NS needs other winParams
	if ((ns) && (!safari)){
		wParam = ",outerWidth=";
		hParam = ",outerHeight=";
	}else{
		wParam = ",width=";
		hParam = ",height=";
	}
	
	//centering the window
	posx = (screen.width-w)/2;
	posy = (screen.height-h)/2;
	stats = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + sb + ",resizable=no,copyhistory=no"+wParam+w+hParam+h+",left="+posx+",top="+posy;
}



//window open
function windowOpen(furl,w,h,sb){
	setWinParams(w,h,sb);
	win = null;
	win = window.open(furl,"Window",stats);

	if (win == null){
		alert(msgDeactivatePopupblocker);
	}else{
		win .focus();
	}
}



//----- div functions
function divset(divname,displaytype){
	if (w3c){
		eval("document.getElementById('" + divname + "').style.display = '" + displaytype + "'");
	}
}






//----- tooltip-handling ---------------------------------------------------------------------------
var leftOffset = 0;
var topOffset = 0;
tooltip = null;

if (w3c){
	document.onmousemove = updateTooltip;
}


function updateTooltip(e) {
	try {
		x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
		y = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
		if (tooltip != null) {
			tooltip.style.left = (x + leftOffset) + "px";
			tooltip.style.top = (y + topOffset) + "px";
		}
	} catch (error) { error=null; }
}


function showTooltip(id,l,t) {
	if (w3c){
	
		leftOffset = l;
		topOffset = t;

		//calculation depends on doctype of html-document!
		if (ie && win){ 
			if (document.body.scrollTop > 0){
				topOffset = topOffset - document.body.scrollTop;
			}
		}else{
			if (document.body.clientWidth > 990){
				leftOffset = leftOffset - ((document.body.clientWidth - 990)/2);
			}
		}

		try {
			tooltip = document.getElementById(id);
			tooltip.style.display = "block"
		} catch (error) { error=null; }
	}
}


function hideTooltip() {
	if (w3c){
		try {
			tooltip.style.display = "none";
		} catch (error) { error=null; }
	}
}







//-----gallery-handling---------------------------------------------------------------------------

var displaydocumentpath = "";
var imgfolder = "";


function getScreenImage(imgfolder,imgnumber,imgamount){
	if (rubric == "XY"){  //((Section?))
		displaydocumentpath = "/" + lang + "/pages/EH/EH_LyBl.php";
	}	
	
	var imgpath = "/any/galleries/";
	self.location.href = displaydocumentpath + "?" + escape(imgpath) + "&" + escape(imgfolder) + "&" + escape(imgnumber) + "&" + escape(imgamount);
}

function getScreenImageInfo(){
	if (sls != ""){
		sls_arr   = sls.split("&");
		imgpath   = unescape(sls_arr[0]);
		imgfolder = unescape(sls_arr[1]);
		imgnumber = unescape(sls_arr[2]);
		imgamount = unescape(sls_arr[3]);
		imgScreen = imgpath + imgfolder + "/" + imgnumber + "_screen.jpg";
		imgPrint  = imgpath + imgfolder + "/" + imgnumber + "_print.jpg";
	}
}


function getNextScreenImage(){
	if (imgnumber == imgamount){
		getScreenImage(imgfolder,'1',imgamount)
	}else{
		imgnumber = "" + (parseInt(imgnumber,10) + 1);
		getScreenImage(imgfolder,imgnumber,imgamount)
	}
}



function writeGalleryImageList(){
	if (rubric == "XY"){  //((Section?))
		imgfolder = filename.substring(filename.lastIndexOf('XY_Zz')+6,filename.lastIndexOf('_'));
	}	
	imgamount = parseInt(filename.substring(filename.lastIndexOf('_')+1,filename.lastIndexOf('.')),10);



	for(var z=1; z<=imgamount; z++){
		document.write('<div>');
			//image left
			document.write('<div style="width:160:px; height:160px; padding-left:20px; padding-bottom:20px; float:left;">');		
				document.write('<table width="160" border="0" cellspacing="0" cellpadding="0">');
				document.write('<tr height="160">');
				document.write('<td class="tdImageBorder" align="center" valign="middle" width="160" height="160"><a href="JavaScript:getScreenImage(\'' + imgfolder + '\',\'' + z + '\',\'' + imgamount + '\')" ><img src="/any/galleries/' + imgfolder + '/' + z + '_view.jpg" border="0"  alt=""></a></td>');
				document.write('</tr>');
				document.write('</table>');
			document.write('</div>');
			z++;
		
			document.write('<div>');
			//image center
			if (z<=imgamount){
				document.write('<div style="width:160:px; height:160px; padding-left:20px; padding-right:20px; padding-bottom:20px; float:left;">');
					document.write('<table width="160" border="0" cellspacing="0" cellpadding="0">');
					document.write('<tr height="160">');
					document.write('<td class="tdImageBorder" align="center" valign="middle" width="160" height="160"><a href="JavaScript:getScreenImage(\'' + imgfolder + '\',\'' + z + '\',\'' + imgamount + '\')" ><img src="/any/galleries/' + imgfolder + '/' + z + '_view.jpg" border="0"  alt=""></a></td>');
					document.write('</tr>');
					document.write('</table>');
				document.write('</div>');
			z++;
			}

			//image right
			if (z<=imgamount){
				document.write('<div style="width:160:px; height:160px; padding-bottom:20px;">');
					document.write('<table width="160" border="0" cellspacing="0" cellpadding="0">');
					document.write('<tr height="160">');
					document.write('<td class="tdImageBorder" align="center" valign="middle" width="160" height="160"><a href="JavaScript:getScreenImage(\'' + imgfolder + '\',\'' + z + '\',\'' + imgamount + '\')" ><img src="/any/galleries/' + imgfolder + '/' + z + '_view.jpg" border="0"  alt=""></a></td>');
					document.write('</tr>');
					document.write('</table>');
				document.write('</div>');
				z++;
			}
			document.write('</div>');
		document.write('</div>');
		z = z-1;
	}
	
	document.write('<div style="clear:left;"></div>');
}





//-----form-handling---------------------------------------------------------------------------
function registerevent(en,ed){
	top.location.href = "/" + lang + "/pages/HO/HO_Ag.php" + "?" + escape(en) + "&" + escape(ed);
}


function setregisterform(){
	if (sls != ""){
		sls_arr = sls.split("&");
		document.formula.eventname.value = unescape(sls_arr[0]);
		document.formula.eventdate.value = unescape(sls_arr[1]);
	}
}


function formSend(t){

	//register event
	if (t == "registerevent"){
		if ((document.formula.eventname.value=='') || (document.formula.eventdate.value=='') ||(document.formula.firstname.value=='') || (document.formula.lastname.value=='') || (document.formula.address.value=='') || (document.formula.ziplocation.value=='') || (document.formula.email.value=='')){
			alert(msgFormRequired);
		}else{
			document.formula.submit();
		}	
	
	
	}

	//online donation
	if (t == "donation"){
		if ((document.formula.firstname.value=='') || (document.formula.lastname.value=='') || (document.formula.address.value=='') || (document.formula.ziplocation.value=='') || (document.formula.country.value=='') || (document.formula.email.value=='')){
			alert(msgFormRequired);
		}else{
			document.formula.submit();
		}	
	}
	
	
	
		
	//search
	//hidden-field	0		ac
	//hidden-field	1		q
	//hidden-field	2		tpl_results (resultPage)
	//hidden-field	3		tpl_form (noResultPage)
	//hidden-field	4-7		limit[x] (searched directories)
	//hidden-field	8		displaylang
	//input-field 	9		buscar
	//hidden-field	10		mode
	//hidden-field	11		word_match
	//hidden-field	12-15	type[x] (searched file types)	
	
	if (t == "search"){
		document.formSearch.q.value = document.formSearch.buscar.value;
		if (document.formSearch.q.value == ""){
			alert(msgnosearchentry);
		}else{
			document.formSearch.submit();
		}
	}
	
}


function getDonationForm(t,n){
	self.location.href = "/" + lang + "/pages/SP/SP_Sr.php?" + escape(t) + "&" + escape(n);
}


function getDonationInfo(){
	var donationtyp;
	var donationproject;
	 
	if ((sls != "") && (sls.indexOf('anchor') == -1)){
		sls_arr=sls.split("&");
		donationtyp = unescape(sls_arr[0]);
		donationproject = unescape(sls_arr[1]);
		
		if (donationtyp != ""){
			eval("document.formula."+donationtyp+".checked = true")
		}
		if (donationproject != ""){
			document.formula.projectname.value = donationproject;
		}
	}
}






//-----fnc-handling---------------------------------------------------------------------------

//print functions
function printPage(){
	if ((self.print) || (ie && win)){
		if (self.print){
			if (self.focus){
				self.focus();	//for E5W
			}
			self.print();
		}else{
			printo();	//E4W
		}
	}else{
		alert(msgPrintingFailed);
	}
}

function printo() {
	var OLECMDID_PRINT = 6;
	var OLECMDEXECOPT_DONTPROMPTUSER = 2;
	var OLECMDEXECOPT_PROMPTUSER = 1;
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	oldHandler = window.onerror;
	window.onerror = deal;
	WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
	WebBrowser1.outerHTML = "";
	window.onerror = oldHandler;
}

function deal(){
	WebBrowser1.outerHTML = "";
	window.onerror = oldHandler;
	return true;
}


//bookmark-functions
function setBookmark(){
	var bookmarkurl = self.location.href;
	var bookmarktitle = document.title;
	if (window.external && nomac){
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
	}else{
		alert(msgBookmarkingFailed);
	}
}


//--- end of file
