
$(document).ready(function() {
	
	$("#content-innen").css("min-height", $("#rechteSpalte").height());
	$("table tr:odd").addClass("even");
	
	$(".weihnachtswerberei").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	
	$(".galerie").colorbox();
	$(".kopfoderzettel").colorbox({iframe:true, innerWidth:611, innerHeight:500});
	$(".hwsdrehsaeule").colorbox({iframe:true, innerWidth:320, innerHeight:608});
	$(".imcl").colorbox({iframe:true, innerWidth:880, innerHeight:464});
	$(".bax").colorbox({iframe:true, innerWidth:700, innerHeight:525});
	$(".digitec").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	$(".werberei").colorbox({iframe:true, innerWidth:550, innerHeight:375});
	$(".haseball").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	$(".schlittenclaus").colorbox({iframe:true, innerWidth:570, innerHeight:480});
	$(".haus").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	$(".advent2001").colorbox({iframe:true, innerWidth:620, innerHeight:580});
	$(".pharao").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	$(".wiska").colorbox({iframe:true, innerWidth:550, innerHeight:400});
	$(".mp3").colorbox({iframe:true, innerWidth:440, innerHeight:100});
	$(".e_hws").colorbox({iframe:true, innerWidth:810, innerHeight:700});
	$(".e_pm").colorbox({iframe:true, innerWidth:810, innerHeight:700});
	$(".e_raffay1").colorbox({iframe:true, innerWidth:583, innerHeight:192});
	$(".e_raffay2").colorbox({iframe:true, innerWidth:780, innerHeight:447});
	$(".e_raffay3").colorbox({iframe:true, innerWidth:680, innerHeight:480});
	$(".skl_banner").colorbox({iframe:true, innerWidth:828, innerHeight:330});
	$(".skl_kreuzfahrt").colorbox({iframe:true, innerWidth:568, innerHeight:630});
	$(".skl_mobile").colorbox({iframe:true, innerWidth:680, innerHeight:1540});
	$(".skl_shop").colorbox({iframe:true, innerWidth:500, innerHeight:350});
	$(".123online").colorbox({iframe:true, innerWidth:468, innerHeight:60});
	$(".hws2richmedia").colorbox({iframe:true, innerWidth:800, innerHeight:600});
	$(".hws1drehsaeule").colorbox({iframe:true, innerWidth:320, innerHeight:608});
});




/*
	aktiviert einen Menüpunkt per CSS-Zuweisung an die ID
*/
function activateNav(aActive) {
	if(aActive != "" && document.getElementById(aActive)) {
		appendClass(aActive, "active");
		
		if(aActive.indexOf("_")) {
			var mainNav = aActive.substring(0, aActive.indexOf("_"));
			appendClass(mainNav, "active");
		}
	}
}


/*
	erweitert das Attribut "class" eines Elementes
*/
function appendClass(aElem, aClass) {
	if(typeof aElem == "string" && document.getElementById(aElem)) aElem = document.getElementById(aElem);
	if(typeof aElem != "object") return false;
	
	var oldClass = aElem.className;
	if(oldClass != "") {
		if(oldClass.indexOf(aClass) < 0) aElem.className = oldClass + " " + aClass;
	}
	else {
		aElem.className = aClass;
	}
	
	return true;
}


/*
	getStyle()	=>	liest CSS-Eigenschaften und gibt Farben als HEX zurück
	----------------------------------------------------------------------
		versucht zunächst die Style-Angaben im <style> Attribut auszulesen
		dann Abfrage über getComputedStyle für Gecko
		dann Abfrage über currentStyle für MSIE
	
	parameter:	Objekt, abzufragende Style-Eigenschaft
	return:		Wert der Eigenschaft
*/
function getStyle(which, style) {
	if(typeof which == "object") obj = which;
	if(typeof which == "string") obj = document.getElementById(which);
	if(obj == null) return false;
	
	var value = obj.style[convCSStoJSSS(style)];
    if(!value) {
			if(document.defaultView) {
			value = document.defaultView.getComputedStyle(obj, null).getPropertyValue(style);
			if(style.indexOf("color") >= 0) value = convRGBtoHEX(value);		// RGB => HEX bei Moz
		}
		else if(obj.currentStyle) {
			value = obj.currentStyle[convCSStoJSSS(style)];
			if(style.indexOf("color") >= 0) value = value.toUpperCase();		// HEX => toUpperCase bei MSIE
		} 
	}
	
	return value;
}


/*
	convCSStoJSSS()	=>	konvertiert Namenskonventionen von CSS-Eigenschaften in JS-Konventionen
	-------------------------------------------------------------------------------------------
		convCSStoJSSS("z-index");				=>	return zIndex
		convCSStoJSSS("border-bottom-style");	=>	return borderBottomStyle.
	
	parameter:	str(CSS-Eigenschaft)
	return:		str(JS-Eigenschaft)
*/
function convCSStoJSSS(input) {
	var pieces_arr = input.split('-');
	if(pieces_arr.length == 1) return pieces_arr[0];
		
	var output = "";
	for(var i = 0; i < pieces_arr.length; i++) {
		if(i > 0) output += pieces_arr[i].charAt(0).toUpperCase() + pieces_arr[i].substring(1);
		else output += pieces_arr[i];
	}
	
	return output;
}


/*
	convRGBtoHEX()	=>	konvertiert einzelne Werte oder ganze RGB-Angaben inach HEX
	-------------------------------------------------------------------------------
		convRGBtoHEX(255);						=>	return FF
		convRGBtoHEX("0, 153, 255");			=>	return #0099FF
		convRGBtoHEX("rgb(0, 153, 255)");		=>	return #0099FF
	
	parameter:	int(R) oder int(G) oder int(B)
	return:		str(HEX)
	
	parameter:	str("rgb(1,2,3)") oder str("1,2,3")
	return:		str(#HEX)
*/
function convRGBtoHEX(val)
{
	if(val > 255) return null;
	if(val < 0) return null;
	
	var RGB = new Array(256);
	var k = 0;
	var HEX = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
	var output = "";
	
	for(var i = 0; i < 16; i++) {
		for(var j = 0; j < 16; j++) {
			RGB[k] = HEX[i] + HEX[j];
			k++;
		}
	}
	
	// konvertiert eine Zahl nach HEX
	if(typeof val == "number") output = RGB[val];
	
	// konvertiert einen übergebenen RGB-String nach HEX
	else if(typeof val == "string" && val.indexOf(",") > 0) {
		output = "#";
		var rgb_arr = val.split(",");
		
		for(var v in rgb_arr) {
			var rgb_val = rgb_arr[v].match(/[0-9]+/);
			output += RGB[rgb_val];
		}
	}
	
	return output;
}





function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
