jQuery(document).ready(function()
{
	jQuery('.scandiTvPopup').attr('rel', 'shadowbox;width=800;height=730').addClass('option');
	jQuery('#switcher').each(function(header)
	{
		var pfeil = jQuery('#header-pfeil', header);
		
		var pfeil_a = jQuery('a', pfeil); 
		pfeil_a.hover(
				function() 
				{
					jQuery(this).parent().addClass("header-hover");
				},
				function()
				{
					jQuery(this).parent().removeClass("header-hover");
				});
		
		pfeil_a.click(function()
				{
					var header = jQuery('#switcher');
					var par = jQuery('#top_shadow');
					var nummer = jQuery('#nummernschild');
					
					var cclass = "header-collapsed";
					if (header.hasClass(cclass))
					{
						
						header.children().fadeOut(250, function()
						{
							header.removeClass(cclass);
							nummer.removeClass('verbergen');
						});
						
						par.animate(
						{
							marginTop:	'0px'
						}
						, 500, function()
						{
							header.children().fadeIn(500);
						});
						header.addClass(cclass);
					}
					else
					{
						header.children().fadeOut(250);
						nummer.addClass('verbergen');
						par.animate(
						{
							marginTop:	'-60px'							
						}
						, 500, function()
						{
							header.addClass(cclass);
							header.children().fadeIn(500);
							
						});
						
					}
					
					jQuery(this).blur();
					return false;
					
				});
	});
	


});

function popup12 (img,w,h, url2) {
// für ScandiRace bzw. andere zeitkritische Popups - öffnet Popup und leitet zu einer URL um, auf der hoffentlich weniger Flash die Geschwindigkeit des Popups drückt
 fenster = window.open(img, "", "width="+w+",height="+h+",status=0,scrollbars=0,resizable=0");
 fenster.focus();
 
 if (url2 && (url2 != 'undefined'))
 {
	 window.location.href = url2;
 }
} 


function popup11 (img,w,h) {
 fenster = window.open(img, "", "width="+w+",height="+h+",status=0,scrollbars=0,resizable=0");
 fenster.focus();
} 

function popupRundgang(img,w,h,next) {
	fenster2 = window.open(img, "", "width="+w+",height="+h+",status=0,scrollbars=0,resizable=0");

	window.location=next;
	fenster2.focus();
} 

function getWindowWidth(win) {   
     if (win == undefined) win = window;   
     if (win.innerWidth) {   
         return win.innerWidth;   
     }   
     else {   
         if (win.document.documentElement &&   
             win.document.documentElement.clientWidth) {   
             return win.document.documentElement.clientWidth;   
         }   
         return win.document.body.offsetWidth;   
     }   
}   

function hideScandis() {
	document.getElementById("scandi_01").style.display = "none";
	document.getElementById("scandi_02").style.display = "none";

}

function checkWidth() {
	
	
	if(getWindowWidth() < 1145) {
		hideScandis();
	} else {
		showScandis();
	}
	
}



function showScandis() {
	document.getElementById("scandi_01").style.display = "block";
	document.getElementById("scandi_02").style.display = "block";

}

window.onDomReady = initReady;

// Initialize event depending on browser
function initReady(fn)
{
	//W3C-compliant browser
	if(document.addEventListener) {
    document.addEventListener("DOMContentLoaded", fn, false);
  }
	//IE
	else {
    document.onreadystatechange = function(){readyState(fn)}
  }
}

//IE execute function
function readyState(func)
{
	// DOM is ready
	if(document.readyState == "interactive" || document.readyState == "complete")
	{
		func();
	}
}

//execute as soon as DOM is loaded
window.onDomReady(onReady);
 
window.onresize = checkWidth;
//do when DOM is ready
function onReady()
{
	
	checkWidth();
}
