var DEBUG=0;
var a_vars = Array();
var pagename='My TestPage';

var phpmyvisitesSite = 1;
var phpmyvisitesURL = "http://phpvisit.local/phpmyvisites.php";

var openmenu=Array();
var lastmenu;

function openBox(id,node){
	var menu_len=openmenu.length;	
	if(node==0 && menu_len > 0){
		//alert('CLOSE-ALL: '+openmenu.join(", "));
		for (var i = 0; i < menu_len; ++i){
			var box = document.getElementById(openmenu[i]);
			box.style.display='none';
		}
		var box = document.getElementById(id);
		box.style.display='block';
	} else if(node==0) {
		//alert('OPEN NODE')
		var box = document.getElementById(id);
		box.style.display='block';
	}else{
		//alert('else');
		var box = document.getElementById(id);
		
		if(lastmenu){
			//alert('CLOSE-ONE: '+lastmenu+' - '+node);
			var last = document.getElementById(lastmenu);
			last.style.display='none';
		}
		//alert('OPEN-ONE: '+id);
		box.style.display='block';
		lastmenu=id;
	}	
	openmenu.push(id);
}

function openMap(adr){
	var url="/maps.php?addr="+adr;
	self.open( url, "mapPopUp", "width=800,height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
	self.focus;
}

function goURL(url)
{
	parent.location.href=url;
}

function vPlayer(mov){
url="player_mov.php?mov="+mov;
self.open( url, "vPlayer", "width=450,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=0,resizable=0");
self.focus;
}

function vote(){
url="voting.php";
self.open( url, "contentPopUp", "width=500,height=250,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function viewColors(id,n){
w=500;
ref="index.php?app=colors&style=single&id="+id+"&_name="+n
self.open( ref, "Colors", "width="+w+",height="+w+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}


function galerieBook(url,w){
ref=url+"&style=diabook";
h=500;
self.open( ref, "galerieBook", "width="+w+",height="+h+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function galerieDiashow(url,w){
ref=url+"&style=diashow";
h=500;
self.open( ref, "galerieBook", "width="+w+",height="+h+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function xxlImg(img){
ref="big_img.php?img="+img;
self.open( ref, "xxlImg", "width=800,height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function BigImg(url,w,h){
w=(w+10);
h=(h+10);
//ref=url+"&style=book";
ref=url;
self.open( ref, "bigImg", "width="+w+",height="+h+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function BigSImg(url,w){
w=(w+100);
ref=url
self.open( ref, "bigSImg", "width="+w+",height="+w+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function popUp(url){
self.open( url, "contentPopUp", "width=800,height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function db_content(sid,table,field,id,printing,lang)
{
url="viewfield.php?_sid="+sid+"&lang="+lang+"&paket_id="+id+"&printing="+printing+"&table="+table+"&field="+field;
self.open( url, "fieldcontent", "width=450,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
self.focus;
}

function printDoc(url)
{
	self.open( url, "printDoc", "width=800,height=550,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=1,resizable=1");
	self.focus;
}

function tip(lang,id,table,sid,hint)
{
url="tip.php?_sid="+sid+"&lang="+lang+"&table="+table+"&id="+id+"&hint="+hint;
self.open( url, "tip", "width=400,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=0,resizable=0");
self.focus;
}

function regNL()
{
self.open( "", "newsletter", "width=400,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=0,resizable=0");
self.focus;
}

function printPopup() {
	parent.frames[1].focus();
	parent.frames[1].print();
}

function checkCard(){
	if(document.card.sendername.value == "")  {
		alert("Bitte Name eingeben!");
		document.card.sendername.focus;
		return false;
	}

	if(document.card.receivermail.value == "")  {
		alert("Bitte eMail eingeben!");
		document.card.receivermail.focus;
		return false;
	}
	if(document.card.sendermessage.value == "")  {
		alert("Bitte Nachricht eingeben!");
		document.card.sendermessage.focus;
		return false;
	}
}

function checkContact(){
	if(document.contact.sendername.value == "")  {
		alert("Bitte Name eingeben!");
		document.contact.sendername.focus;
		return false;
	}
	if(document.contact.sendermail.value == "")  {
		alert("Bitte eMail eingeben!");
		document.contact.sendermail.focus;
		return false;
	}
	if(document.contact.sendermessage.value == "")  {
		alert("Bitte Nachricht eingeben!");
		document.contact.sendermessage.focus;
		return false;
	}
}

function viewBlock(id)
{
	var selID=document.getElementById(id);
	state=selID.style.display;
	if( state == 'none' )
	{
		selID.style.display = 'block';
	}
	else
	{
		selID.style.display = 'none';
	}
}

function dispDeliverAddrRow()
{
	var selVisible=document.getElementById('deliver_adr_row');
	if(document.adress_edit.deliver_addr_merge.checked == true)
	{
		selVisible.style.display = 'block';
	}
	else
	{
		selVisible.style.display = 'none';
	}
}


function getUPI(){
	http_request = false;
	if (window.XMLHttpRequest){
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType){
			http_request.overrideMimeType('text/plain');
		}
	}
	else if(window.ActiveXObject){
		try{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {} 
		}
	}
	//alert(url);
	http_request.open('GET', url, true);
	http_request.send(null);
http_request.onreadystatechange = ajaxContent;
}

function ajaxContent() {
	switch (http_request.readyState) {
		// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
		case 4:
			if (http_request.status != 200) {
				//alert("Der Request wurde abgeschlossen, ist aber nicht OK\nFehler:"+http_request.status);
			} else {
				var content = http_request.responseText;
				//document.forms[current_form].elements[address_field].innerHTML = content;
				//content_box.innerHTML = content;
				if(DEBUG==1)alert(content);
				//document.forms['tracklist_range'].submit();
			}
			break;
		default:
			break;
	}
}

