var uAgent = navigator.userAgent;
var IE = ie = (uAgent.indexOf('MSIE')!=-1)?true:false;
var firefox = (uAgent.indexOf('Firefox')!=-1)?true:false;
if(ie) {
	var bVersion = uAgent.match(/MSIE [0-9\.]+[^;]/).toString();
	bVersion = parseInt(bVersion.match(/[0-9\.]+$/));
}
else if(firefox) var bVersion = parseInt(uAgent.match(/[^\/][0-9\.]+$/));

$j.ajaxSetup({
	url: ajURL+"?"+sess_name+"="+sess_id,
	global: false,
	type: "POST",
	async: true,
	dataType: "json",
    complete:function(){return false;},
	error:function(r){ddbg(r,"AJ-Error:")}
});

var myBrowser = {
	version: function() {
		switch(this.name())	{
			case "msie":
				var bv = uAgent.match(/MSIE [0-9\.]+[^;]/).toString();
				return bv.match(/[0-9\.]+$/);
				break;
			case "firefox":
				return uAgent.match(/[^\/][0-9\.]+$/);
				break;
			case "konqueror":
				return (uAgent.match(/.+(?:khtml)[\/]([\d.]+)/i))[1];
				break;
			default:
				return (uAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1];
				break;
		}
	},
	safari: new RegExp(/webkit/i).test(uAgent),
	konqueror: new RegExp(/konqueror/i).test(uAgent),
	opera: new RegExp(/opera/i).test(uAgent),
	msie: new RegExp(/msie/i).test(uAgent) && !new RegExp(/opera/).test(uAgent),
	firefox: new RegExp(/firefox/i).test(uAgent),
	netsape: new RegExp(/(netscape)|(navigator)/i).test(uAgent),
	name: function(){
		if(this.safari) return "safari";
		else if(this.konqueror) return "konqueror";
		else if(this.opera) return "opera";
		else if(this.netsape) return "netsape";
		else if(this.firefox) return "firefox";
		else if(this.msie) return "msie";
		else return "unbekannt";
	},
	screen: function() {
		return screen.width.toString()+"x"+screen.height.toString();
	},
	os:function(){
		var os=navigator.platform;
		return os;
	},
	info: function(){
		alert(uAgent+"\n"+this.name()+": "+this.version())
	}
}

function logVisits(here,id) {
	$j.ajax({
		data:{
			logUser:"count",
			here:(typeof here=="undefined")?"":here,
			id:id,
			screen:myBrowser.screen(),
			os:myBrowser.os(),
			name:myBrowser.name(),
			version:myBrowser.version()
		},
		success:function(r){}
	});
}
 
var but = new Array();
var buttons = new Array('start','drucken','schliessen','pfeillinks','pfeilrechts','zoomin','zoomout','pakete','touren','zurueck');

/*
function video(video) {
	var w = 320;
	var h = 240;
	var pre = (arguments[1])?arguments[1]:"";
	var winV = window.open(pre+"video.php5?video="+video+"&w="+w+"&h="+h+"","winV","width="+(w+20)+",height="+(h+40)+",scrollbars=0,resizable=1,dependent=0,screenX="+parseInt(screen.width-w-20)+",screenY=10,position=absolute,left="+parseInt(screen.width-w-20)+",top=10");
	winV.focus();
}
*/
for(n=0; n<buttons.length; n++) {
	but[buttons[n]]	= new Array();
	but[buttons[n]][0]		= new Image();
	but[buttons[n]][1]		= new Image();
	but[buttons[n]][0].src	= 'grafiken/neu/but_'+buttons[n]+'1.gif';
	but[buttons[n]][1].src	= 'grafiken/neu/but_'+buttons[n]+'2.gif';
}

function myOver(name,n) {
	document[name].src = but[name][n].src;
}
function show() {
	var a=arguments;
	var aLen=a.length
	for(i=0; i<aLen; i++) {
		if (ie) document.all[a[i]].style.visibility = "visible"
		else document.getElementById(a[i]).style.visibility='visible'
	}
}
function hide() {
	var a=arguments;
	var aLen=a.length
	for(i=0; i<aLen; i++) {
		if (ie) document.all[a[i]].style.visibility = "hidden"
		else document.getElementById(a[i]).style.visibility='hidden'
	}
}
function getMouseX(e) {
	return (document.all) ? event.clientX+document.body.scrollLeft : e.pageX;
}
function getMouseY(e) {
	return (document.all) ? event.clientY+document.body.scrollTop : e.pageY;
}
function getMsg(msg) {
	var ok = prompt('Link zu Dieser Seite',msg);
	if(ok==msg) {
		var newWin = window.open(msg,'newWin');
	}
}

function popup(anreise,modus,id) {
	var w,h,scroll
	var a = arguments
	var status = 0
	eval("var win_"+modus)
	switch(modus) {
		case 'visitenkarte':
			scroll=0
			w=615
			h=505
			break
		case 'panorama':
			scroll=0
			w=500
			h=430
			break
		case 'anreise':
			scroll=0
			w=500
			h=320
			break
		case 'veranstaltung':
			scroll=0
			w=500
			h=415
			break
	}
	var m = "";
	for(var i=0; i<a.length; i++) { m += a[i]+"\n"; }
	var k = (a[3]==0 || !a[3])?0:1;
	
	eval("var win_"+modus+" = window.open('popup.php5?anreise="+anreise+"&modus="+modus+"&id="+id+"&showKontakt="+k+"','win_"+modus+"','width="+w+",height="+h+",position:absolute,top=10,left="+parseInt(screen.width-w-20)+",scrollbars="+scroll+",resizable=1,status="+status+"')");
	eval("if(win_"+modus+") win_"+modus+".focus()");
}

function popupPanorama(id) {
	var scroll = 0
	var w,h
	w=500
	h=470
	winPanorama = window.open('java/panorama.php5?id='+id,'winPanorama','width='+parseInt(w)+',height='+parseInt(h)+',position:absolute,top=10,left='+parseInt(screen.width-w-20)+',scrollbars='+scroll+',resizable=1')
	winPanorama.focus()
}

function popupPrint(id,modus,getLink,sess,mode) {
	var f = document.frmSend
	var scroll = 1
	l_left=(mode=='luftbild' && f)?f.l_left.value:''
	l_top=(mode=='luftbild' && f)?f.l_top.value:''
	l_file=(mode=='luftbild' && f)?f.l_file.value:''
	var w = 670
	var h = 620
	var a = arguments
	var etc = ''
	var i
	winPrint = window.open('print.php5?sess='+sess+'&modus='+modus+'&id='+id+'&getLink='+getLink+'&mode='+mode+'&l_left='+l_left+'&l_top='+l_top+'&l_file='+l_file,'winPrint','width='+parseInt(w)+',height='+parseInt(h)+',position:absolute,top=10,left='+parseInt(screen.width-w-20)+',scrollbars='+scroll+',resizable=yes')
	winPrint.focus()
}

function sendHtml(strLink) {
	document.location.href = strLink+'.html'
}

function send() {
	var a = send.arguments;
	var strElem = '';
	for(var i=0; i < a.length; i++) {
		if(i%2==0) {
			var elem = "document.frmSend."+a[i]+".value='"+a[i+1]+"';";
			eval(elem);
			strElem += elem+"\\\n";
		}
	}
	document.frmSend.submit();
	//alert(strElem);
}

function sendToPopup() {
	var a = sendToPopup.arguments;
	var strElem = '';
	for(var i=0; i<a.length; i++) {
		if(i%2==0) {
			var elem = "document.frmSendToPopup."+a[i]+".value = '"+a[i+1]+"';";
			eval(elem);
			strElem += elem+"\\\n";
		}
	}
	document.frmSendToPopup.submit();
	//alert(strElem);
}
