// 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: 19.2.2004 (Stephan Schw&auml;rzler) - Opera
// Last modified: 10.12.2004 (Norbert Kujbus) - Google callback function
// Last modified: 15.01.2005 (Norbert Kujbus) - Remove Google callback function
// Last modified: 14.04.2005 (Csaba Mezo) - Introduce CountIt function

// !!!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 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(targetX,name,width,height,posx,posy,windowoptions,init_target) {
	var it, wo, px, py, host,target;
 
	it = targetX;
	wo = "location=no,toolbar=no,status=no,statusbar=no,scrollbars=no,resizable=no,dependent=yes";
	px = py = 0;
	target = targetX;
	
	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 (targetX.indexOf("http://") != -1) {
			host = "http://" + window.location.hostname;
			if (navigator.appName != "Opera") {
				if (targetX.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(targetX);
	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;
}

//Script to invoke OEWA measurement on page events (click)
function CountIt(what)
{
	var OEWA1="http://austria.oewabox.at/cgi-bin/ivw/CP/"+what;
	var OEWA2="http://a-vol.oewabox.at/cgi-bin/ivw/CP/"+what;
	var counter1 = new Image;
	var counter2 = new Image;
	counter1.src = OEWA1+"?r="+escape(document.referrer);
	counter2.src = OEWA2+"?r="+escape(document.referrer);
}

// Function for URL (GET) Parameter
function getURLParam(name) {
	var q = document.location.search;
	var i = q.indexOf(name + '=');
	if (i == -1) {
		return false;
	}
	var r = q.substr(i + name.length + 1, q.length - i - name.length - 1);
	i = r.indexOf('&');
	if (i != -1) {
		r = r.substr(0, i);
	}
	return r.replace(/\+/g, ' ');
}
