// javascripts.js
// Author: Alexander Aberer
// Date: 27.7.2000
// Last modified: 8.6.2001 (Andreas Ritter)
// Last modified: 2.7.2003 (Alexander Aberer)
// ....
// Last modified: 25.08.2006 (Hannes Hofstätter) added CountIT 
// Last modified: 05.09.2006 (Hannes Hofstätter) added sl() for BMI calculator 
// Last modified: 19.1.2007 (Hannes Hofstätter) added scrips for new vienna nav

// !!!Wichtig!!! Die folgende Variable muß gesetzt werden wenn über open_window()
// Seiten auf externen/fremden Webservern geöffnet werden sollen.
var blank_page = "about:blank"; 

function sl() {
	myWindow = window.open('http://apps.vienna.at/tools/bmi/', 'BMI', 'width=420,height=280,location=no,menubar=no,resizable=no,scrollbars=auto,status=no,titlebar=yes,toolbar=no');
	myWindow.focus();
}

function SwitchWebservice(switchform,formelement) {
	var fe, dummy;
	if(typeof formelement != "undefined") {
		fe = formelement;
	} else {
		fe = switchform.elements[0];
	}
	if (fe.selectedIndex != 0) {
		var pulldownindex = fe.selectedIndex;
		var url = fe.options[pulldownindex].value;
		locarray = url.split("|");
		if ( locarray.length > 1 ) {
			windata = locarray[0].split(",");
			dummy = open_window(locarray[1],windata[0],windata[1],windata[2],0,0,"scrollbars=" + windata[3] + ",location=no,toolbar=no,status=no,menubar=no,resizable=yes,dependent=yes");
		} else {
			dummy = open_window(url,"",700,480,10,10,"location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,dependent=no");
		}
	}
}

function realmedia(path,name,content) {
	var datestr = new Date();
	url = 'http://apps.vol.at/tools/realaudio/embed.asp?cont=' + content + '&title=' + escape(name) + '&file=' + escape(path) + "&" + escape(datestr.toLocaleString());
	if (content=='video') {
		var rc_video=window.open(url,'rc_video','width=230,height=310,resizable=yes');
		rc_video.focus();
	} else {
		var rc_audio=window.open(url,'rc_audio','width=400,height=40');
		rc_audio.focus();
	}
}

function open_window(target,name,width,height,posx,posy,windowoptions,init_target) {
	var it, wo, px, py, host;

	it = target;
	wo = "location=no,toolbar=no,status=no,statusbar=no,scrollbars=no,resizable=no,dependent=yes";
	px = py = 0;

	if(typeof new_window != "undefined") {
		if(new_window.closed != true) {
			new_window.close();
		}
	}

	if (typeof posx != "undefined") px = posx;
	if (typeof posy != "undefined") py = posy;
	if ((typeof windowoptions != "undefined") && (windowoptions != "")) wo = windowoptions;
	if (typeof init_target != "undefined") {
		it = init_target;
	} else {
		if (target.indexOf("http://") != -1) {
			host = "http://" + window.location.hostname;
			if (target.indexOf(host) == -1) it = blank_page;
		}
	}
	new_window = window.open(it,name,"width=" + width + ",height=" + height + "," + wo);
	new_window.moveTo(px,py);
	new_window.location.replace(target);
	new_window.focus();
	return false;
}

function setUrlForPrint() {
	sUrl = document.location.href;
	if ((document.all) || (document.layers)){
		sUrl = sUrl.replace(/\?/, "\\/");
		sUrl = sUrl.replace(/\&/, "//");
	}
	document.printform.url.value = sUrl;
}

function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerHeight;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

function openWindow(url,name,sonst) {
  popupWin = window.open(url,name,sonst)
}

function open_window_astitle(target,name,width,height) { 
	var dummy;
	dummy = open_window(target,name,width,height);
}
	
//Script to invoke OEWA measurement on page events (click)
function CountIt(what) {
	var OEWA1="http://austria.oewabox.at/cgi-bin/ivw/CP/"+what+"/VIENNA";
	var OEWA2="http://a-vienna.oewabox.at/cgi-bin/ivw/CP/"+what+"/VIENNA";
	var counter1 = new Image;
	var counter2 = new Image;
	counter1.src = OEWA1+"?r="+escape(document.referrer);
	counter2.src = OEWA2+"?r="+escape(document.referrer);
}

//Diashow popup für Reiseseite International
function PopUpDiashow(target) {
var cb = document.getElementById('diashow_combo') ;
var target = cb.options[cb.selectedIndex].value;
return open_window(target,'SERIE',720,660);
}

/* new vienna-nav */
var vM_menuOpen = null;
var vM_timerHandle = null;
var vM_resetTime = 1250;

function vM_resetTimer() {
	clearTimeout(vM_timerHandle);
}

function vM_setTimer() {
	if(vM_menuOpen != null) {
		vM_timerHandle = setTimeout('vM_openMenu()', vM_resetTime);
	}
}


function vM_setBodyHandler() {
	var b = document.getElementsByTagName('body')['0'];
	b.onclick = vM_openMenu;
}

function vM_mouseOver(id) {
	if(id != null && id != vM_menuOpen && vM_menuOpen != null) {
		menu = document.getElementById(vM_menuOpen + "Menu");
		menu.style.display = "none";
		menu = document.getElementById(id + "Menu");
		menu.style.display = "block";
		vM_menuOpen = id;					
	}
}

function vM_openMenu(id) {
	var b = document.getElementsByTagName('body')['0'];
	b.onclick = null;			
	var menu;
	var vM_menuOpenOld = null;
	if(vM_menuOpen != null) {
		vM_menuOpenOld = vM_menuOpen;
		menu = document.getElementById(vM_menuOpen + "Menu");
		menu.style.display = "none";
		vM_menuOpen = null;
		if(document.getElementById('vM_iframe')) {
			var iframe = document.getElementById('vM_iframe');
			iframe.style.visibility = 'visible';
		}
		if(document.getElementById('AdverservePositionTop')) {
			var top = document.getElementById('AdverservePositionTop');
			top.style.visibility = 'visible';
		}				
	}

	if(id != null && id != vM_menuOpenOld) {
		menu = document.getElementById(id + "Menu");
		menu.style.display = "block";
		vM_menuOpen = id;
		vM_timer_handle_body = setTimeout('vM_setBodyHandler()', 100);
		if(document.getElementById('vM_iframe')) {
			var iframe = document.getElementById('vM_iframe');
			iframe.style.visibility = 'hidden';
		}
		if(document.getElementById('AdverservePositionTop')) {
			var top = document.getElementById('AdverservePositionTop');
			top.style.visibility = 'hidden';
		}		
	}
}

function mm(suf,vn){
	a = String.fromCharCode(109,97,105,108,116,111,58)+vn+String.fromCharCode(64); 
	z = suf;
	window.location.href=a+z;
}
