// Menü
var aktiv;
var aktivlayer;
var max_menu = 10;

function Aktivsub(open_sub){
	if (aktiv) window.clearTimeout(aktiv);
	Close_fast(open_sub);
}

function Show(show_name){
  if (aktivlayer == show_name) {Aktivsub();}
	if(document.getElementById){
  		if(document.getElementById(show_name))document.getElementById(show_name).style.visibility = "visible";
	}
	Close_fast(show_name);
}

function Hide(hide_name){
  aktivlayer = hide_name;
  aktiv = window.setTimeout("CloseMenu('"+hide_name+"')",250);
}

function CloseMenu(close_name){
  if(document.getElementById){
  	if(document.getElementById(close_name))document.getElementById(close_name).style.visibility = "hidden";
  }
}

function Close_fast(my_open_name){
	for(i=1;i<max_menu;i++){
		my_close_name = "layer" + i;
		if(my_open_name != my_close_name){
			if(document.getElementById(my_close_name))document.getElementById(my_close_name).style.visibility = "hidden";
		}
	}
}

// Anreise PopUp
function anreise(){
	anreisefenster = window.open("anreise.html","anreisefenster","height=413,width=382,locationbar=no,toolbar=no,scrollbars=yes,menubar=yes,resizable=0,status=0");
	anreisefenster.moveTo(100,100);
    anreisefenster.focus();
}

// Referenzen PopUp
function referenz(my_url){
	referenzfenster = window.open("referenz.php?"+my_url,"referenzfenster","height=215,width=430,locationbar=no,toolbar=no,scrollbars=no,menubar=no,resizable=0,status=0");
	referenzfenster.moveTo( (screen.width /2) +20, (screen.height /2) +50 );
    referenzfenster.focus();
}

// Referenzen Bild-Groß PopUp
function ShowImage(parameter,breite,hoehe){
	if(window.referenzbild){window.referenzbild.close();}
	referenzbild = window.open("","referenzbild","height="+ hoehe +",width="+ breite +",locationbar=no,toolbar=no,scrollbars=0,menubar=no,resizable=no,status=no");
	//referenzbild.moveTo( screen.width /2 - 407, screen.height /2 - 265);
	window.referenzbild.document.open();
	window.referenzbild.document.write("<html>\n<head>\n<title>Hämmerle und Kathan Werbeagentur</title>\n</head>\n<body  bgcolor=\"#656565\"  topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\">\n");
	window.referenzbild.document.write("<center><img src='images/"+parameter+"' name=\"myimage\" border=\"0\">\n");
	//window.referenzbild.document.write("<script>\n");
    //window.referenzbild.document.write("function groesse(){\n");
	//window.referenzbild.document.write("	my_x = document.myimage.width + 11; \n");
	//window.referenzbild.document.write("	my_y = document.myimage.height + 31; \n");
	//window.referenzbild.document.write("	window.resizeTo(my_x,my_y); \n");
	//window.referenzbild.document.write("}\n");
	//window.referenzbild.document.write("</script>\n");
	window.referenzbild.document.write("</center></body>\n</html>\n");
	window.referenzbild.document.close();
    referenzbild.focus();

}
// Referenzen PopUp schlißen
function closeWindow(){
	if(window.referenzbild){window.referenzbild.close()};
}

// Bildwechsel
var bildanimation;
var bilderklein;
var bildergross;
var bildanzahl;
var bilder_array;
var bild_a;
var bild_zeit = 4000;
var bild_i = 0;
var bildfenster;

function initanimation(){
  if(bildanimation){
	if(bilderklein.length > 0 && bildergross.length > 0){
	bildanzahl = bilderklein.length;
    bilder_array = new Array();
		for (bild_a=0; bild_a < bildanzahl; ++bild_a){
			bilder_array[bild_a] = new Image(); bilder_array[bild_a].src = "images/" + bilderklein[bild_a];
		}
		window.setTimeout("Animation()",100);
	}
  }
}


function Animation(){
        if(bild_i >= bildanzahl){bild_i = 0;}
        window.document.myimage.src = bilder_array[bild_i].src;
        bild_i = bild_i + 1;
        window.setTimeout("Animation()",bild_zeit);
}

function myimage(){
	bildfenster = window.open("","bildfenster","height=180,width=270");
	bildfenster.document.open();
	bildfenster.document.write("<html><head><title>www.hk-werbung.com<\/title><\/head><body bgcolor=\"#000000\">");
	bildfenster.document.write("<img src=\"images/"+ bildergross[bild_i-1]+"\">");
	bildfenster.document.write("<\/body><\/html>");
	bildfenster.document.close();
	bildfenster.moveTo( screen.width /2 -400, screen.height /2 -280);
	bildfenster.focus();
}