﻿var navXML;
var gallery_array;
var gallery_current;

function nav(num1,num2){
	var request = createXMLHttpRequest();

	request.open('GET', 'js/navigation.xml.php', true);
	request.onreadystatechange = function() {
	    if (request.readyState == 4) {
	        navXML = request.responseXML;
	        mainnav(num1,num2);
	    }
	}
	request.send(null);
}

function mainnav(num1,num2){
	 var t = document.getElementById('nav');
	
	 var tempx = navXML.getElementsByTagName('navigation')[0].getElementsByTagName('item')
	 var names = new Array();
	 var links = new Array();
	 for(var i=0; i<tempx.length;i++){
	 	names.push(tempx[i].getElementsByTagName('label')[0].childNodes[0].nodeValue);
	 	links.push(tempx[i].getElementsByTagName('label')[0].getAttribute('href'));
	}
	
	 if(FlashDetect.versionAtLeast(9, 0, 115)){
			var ftemp = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="940" height="236" align="top" name="flashnav" id="flashnav"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="nav.swf" /><param name="quality" value="best" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" />';
			ftemp += '<param name="flashvars" value="nav='+ num1 + ',' + num2 + ',' + links.join('~') + ',' + names.join('~') + '" />';
			ftemp += '<embed align="top" width="940" height="236" name="flashnav" src="nav.swf" FlashVars="nav='+ num1 + ',' + num2 + ',' + links.join('~') + ',' + names.join('~') + '" quality="best" scale="noscale" wmode="transparent" bgcolor="#ffffff" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" /></object>';
			t.innerHTML = ftemp;
			
    }else{
    	var out = '<table width="940" border="0" cellspacing="0" cellpadding="0" height="236"><tr><td align="left" valign="top" style="padding-top: 115px">';
    	out += '<img src="images/head' + num1 + '.gif" alt="" height="50" width="940" usemap="#top_map" border="0"><map name="top_map">';
    	out += '<area shape="rect" coords="13,7,71,44" href="' + links[0] + '" alt="">';
    	out += '<area shape="rect" coords="81,7,166,44" href="' + links[1] + '" alt="">';
    	out += '<area shape="rect" coords="178,7,267,44" href="' + links[2] + '" alt="">';
    	out += '<area shape="rect" coords="281,7,342,44" href="' + links[3] + '" alt="">';
    	out += '<area shape="rect" coords="578,7,655,44" href="' + links[4] + '" alt="">';
    	out += '<area shape="rect" coords="666,7,743,44" href="' + links[5] + '" alt="">';
    	out += '<area shape="rect" coords="754,7,862,44" href="' + links[6] + '" alt="">';
    	out += '<area shape="rect" coords="880,7,916,44" href="' + links[7] + '" alt="">';
    	out += '</map></td></tr>';
			out += '<tr height="50"><td height="50"><img src="images/page_top_reservierung.gif" alt="" height="50" width="940" usemap="#res_map" border="0"><map name="res_map"><area shape="rect" coords="719,7,881,45" href="nix" alt=""></map></td></tr></table>';
			t.innerHTML = out;
      //document.location.href = "flash_install.html";
    }
    if(num2 != 0){
			subnav(num1-1,num2-1,navXML.getElementsByTagName('navigation')[0].getElementsByTagName('item')[num1-1].getElementsByTagName('sub'));
	}
}


function subnav(num1,num2,subXML){
	var t = document.getElementById('subnav');
	//document.getElementById('main').style.width = '650px';
	t.style.width = '170px';
	t.style.paddingTop = '10px';
	t.style.paddingLeft = '20px';
	var out = '';
	for(i=0;i<subXML.length;i++){
		var link = subXML[i].getAttribute('href');
		var lab = subXML[i].childNodes[0].nodeValue;
		if(i == num2){
			var arrow = '<img src="images/arrow_right.gif" alt="" height="7" width="10" border="0">';
		}
		else{
			var arrow = '<img src="images/blank.gif" alt="" height="7" width="10" border="0">';
		}
		out +='<table width="150" border="0" cellspacing="0" cellpadding="0" height="24" class="subnav_table" style="text-transform:uppercase"><tr><td width="18">'
		out += arrow + '</td><td><a href="' + link + '">' + lab + '</a></td></tr></table>';
	}
	t.innerHTML = out;
}

function mouseStuff(obj,mo,sec){
	if(sec == 'gallery'){
		if(mo == 'over'){
			obj.className = 'gallery_thumb_table_hi';
		}
		if(mo == 'out'){
			obj.className = 'gallery_thumb_table';
		}
	}
}

function showMedia(id,type){
	gallery_array = pic_ids;
	gallery_current = id;
	
	path = 'http://pschorr.raum.com/cms/inc/download.inc.php?ft=0&t=thumb&s=4&login=flash&password=a39401275d1b300aa789fb22aea4148a&md5=1&ids=' + gallery_array[gallery_current];
	w = wopen('galerie_popup.html','Bild',800,700);

//	w.onload=function(){
//		w.document.getElementById('gallery_pict').innerHTML = '<img src="' + path + '" alt="" border="0">';
//		w.document.getElementById('gallery_lab').innerHTML = 'Bild ' + (id+1) + ' von ' + pics.length;
//		w.pict_array = pics;
//		w.pict_current = id;
//		alert('loaded');
//	}
}



function pageNum(obj,mo,n){
	if(obj.className != 'page_num_ac'){
		if(mo == 'over'){
			obj.className = 'page_num_hi';
			document.body.style.cursor = 'pointer';
		}
		if(mo == 'out'){
			obj.className = 'page_num_td';
			document.body.style.cursor = 'auto';
		}
		if(mo == 'click'){
			for (var i=1;i<=pages.length-1;i++) {
				document.getElementById('p' + i).className = 'page_num_td';
			}
			obj.className = 'page_num_ac';
			document.getElementById('cardpic').src = pages[n];
		}
	}
}

// Tools
// ###################################################################################

function createXMLHttpRequest() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    } else if (typeof ActiveXObject != 'undefined') {
        return new ActiveXObject('Microsoft.XMLHTTP');
    } else {
        throw new Error('XMLHttpRequest not supported');
    }
}


function wopen(url, name, w, h) {
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');

  win.resizeTo(w, h);
  win.moveTo(wleft, wtop);
  win.focus();
  return win;
}

function new_win(url, name, w, h) {
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=yes, resizable=yes');

  win.resizeTo(w, h);
  win.moveTo(wleft, wtop);
  win.focus();
}





