/*
* Göckelesmeier
* standard.js
*
* Author: Holger M. Stangl
* Company: Limeflavour | http://www.limeflavour.com
* Date: July 2008
*/



jQuery(document).ready(function(){
	

	if(jQuery.browser.msie){
		jQuery('#selectPlan').fancybox({
			'frameWidth':840,
			'frameHeight':530,
			'overlayShow' : true,
			'overlayColor' : '#000',
			'overlayOpacity' : 0.8,
			'zoomOpacity':false
		}); 
	} else {
		jQuery('#selectPlan').fancybox({
			'frameWidth':800,
			'frameHeight':470,
			'overlayShow' : true,
			'overlayColor' : '#000',
			'overlayOpacity' : 0.8,
			'zoomOpacity':false
		});
	}
	
	/*
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
		return '<span>Bild ' + (currentIndex + 1) + '/' + currentArray.length + ':</span> ' + title;
	}
		'titlePosition' : 'inside',
		'titleFormat' : formatTitle,
	*/
	
	jQuery("a.lightbox").fancybox({
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayColor' : '#000',
		'overlayOpacity' : 0.8,
		'padding' : 10,
		'zoomSpeedIn' : 500,
		'zoomSpeedOut' : 500
	});

	
	jQuery("map *").tooltip({
		track: true, 
		delay: 0, 
	    showURL: false, 
	    bodyHandler: function() { 
			var image=jQuery("<img/>").attr("src", this.href);
	        return image; 
	    }
	})
	
	
	jQuery("area").click(function(){
		var rel = this.attributes.rel.value;
		jQuery('#'+rel).attr("checked","checked");
		jQuery.fn.fancybox.close();
		return false;
	});
	
	
	jQuery('.selectBoxHover').hoverIntent({
		sensitivity: 3,   
		interval: 100,  
		over: nothing,  
		timeout: 500,
		out: closeQuickBox
	}).click(function(){
		jQuery(this).toggleClass('selectBoxActive');
		
	}).find('.option span').click( function() {
		var thisClicked = jQuery(this);
		var thisSelectBox = jQuery(this).parent().parent().parent();
		thisSelectBox.find('.selected').text( thisClicked.text() ).end()
	})
	function closeQuickBox(){
		jQuery(this).removeClass('selectBoxActive');
	}
	function nothing(){ return true;}
	
	
	
	
	jQuery('#pswdForgot').click(function(){
	
		if ( jQuery(this).attr('checked') ){
			jQuery('#pswd').parent().parent().hide();
		} else {
			jQuery('#pswd').parent().parent().show();
		}
	
	});
	
	
	
});



window.onload = new Function("blurLinks();setSound();"); //setHeight();


function blurLinks() {
	var aTags = document.getElementsByTagName('a');
	var i;
	for ( i=0; i < aTags.length; i++ )
	{
		var Fokus = document.createAttribute("onfocus");
		Fokus.nodeValue = "if(this.blur)this.blur()";
		document.getElementsByTagName("a")[i].setAttributeNode(Fokus);
	}
}


function setHeight() {
	
	/*// Höhe des Browserfensters ermitteln
	var screenHeight = innerHeight;
	
	// Abstand oben abziehen
	var heightMain = screenHeight - 7;
	
	// MindestHöhe setzen (Browserabhängig)
	document.getElementById('container').style.minHeight = heightMain+"px";*/

}


/*
function popup(url,name,windowWidth,windowHeight)
{
      myleft=(screen.width)?(screen.width-windowWidth)/2:100;
      mytop=(screen.height)?(screen.height-windowHeight)/2:100;
      properties = "width="+windowWidth+",height="+windowHeight+",scrollbars=yes, top="+mytop+",left="+myleft;
      window.open(url,name,properties)
}
*/


function popitup(destination,win_name,width,height,withScrollbar,toolBar) 
{
	
	var myleft = (screen.width)?(screen.width-width)/2:100;
    var mytop = (screen.height)?(screen.height-height)/2:100;
	
	if (popitup.arguments.length < 5) withScrollbar = true;	// default ist mit scrollbars
	if (width==0 ||  height == 0)
	{
		fs = window.open (destination,win_name);
	} else {
		if (withScrollbar){
			fs = window.open (destination,win_name,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,toolbar=' +toolBar + ',status=no,directories=no,menuebar=no,location=tabelle,top=' + mytop + ',left=' + myleft); //
		} else {
			fs = window.open (destination,win_name,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=no,toolbar=' +toolBar + ',status=no,directories=no,menuebar=no,location=tabelle,top=' + mytop + ',left=' + myleft);
		}
		fs.resizeTo(width,height);
	}
	fs.focus();
}



function setSound()
{	
	var isSound = soundCheck();
	
	if ( isSound == true )
	{
		document.getElementById('sound').style.backgroundImage = "url(files/static/images/gif/icon_sound_on.gif)";
	}
	else
	{
		document.getElementById('sound').style.backgroundImage = "url(files/static/images/gif/icon_sound_off.gif)";
	}
	
}


function soundCheck()
{
	// Cookie lesen
	var cookieName = "GoeckelesmaierSound";
	var soundStatus = readCookie(cookieName);
	
	if(!soundStatus || soundStatus == 1)
	{
		return true
	}
	else if (soundStatus == 0)
	{
		return false;
	}
	
	return soundStatus;
}


function toggleSound()
{
	// Cookie lesen
	var cookieName = "GoeckelesmaierSound";
	var soundStatus = readCookie(cookieName);
	
	if(soundStatus == null) soundStatus = 1;

	// Cookie-Wert wechseln
	if(!soundStatus)
	{
		var cookieValue = 0;
		createCookie(cookieName,cookieValue,0);
	}
	
	// Ausschalten
	if(soundStatus == 1)
	{	
		var cookieValue = 0;
		createCookie(cookieName,cookieValue,0);
		
		// Music
		if(soundManager){
			soundManager.pause('intromusic');
		}

		document.getElementById('sound').style.backgroundImage = "url(files/static/images/gif/icon_sound_off.gif)";
		
		//Flash
		if(thisMovie("keyFlash"))
		{
			thisMovie("keyFlash").toogleSound(false);
		}
	}
	
	// Einschalten
	if(soundStatus == 0)
	{	
		var cookieValue = 1;
		createCookie(cookieName,cookieValue,0);
		
		// Music
		if(soundManager){
			soundManager.createSound('intromusic','files/static/mp3/DemXaverseineTuba.mp3');
			soundManager.play('intromusic');
		}
	
		document.getElementById('sound').style.backgroundImage = "url(files/static/images/gif/icon_sound_on.gif)";
		
		//Flash
		if(thisMovie("keyFlash"))
		{
			thisMovie("keyFlash").toogleSound(true);
		}

	}	
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
	return window[movieName]
	}
	else {
	return document[movieName]
	}
}
