
/*************************************************** Externe Links vorbereiten */

function externalLinks() 
	{	
	if (!document.getElementsByTagName) return; 
 	var anchors = document.getElementsByTagName("a"); 
 	for (var i=0; i<anchors.length; i++)
		{ 
   		var anchor = anchors[i]; 
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "blank")anchor.target = "_blank"; 
		} 
	} 
	
/*************************************************** IE6 */

function handleIE6()
	{
	if($.browser.msie && $.browser.version<7)
		{
		var input = $("input[type='text']").addClass("ie6textinput");
		var textarea = $("textarea").addClass("ie6textinput");
		var password = $("input[type='password']").addClass("ie6textinput");
		}
	}

/*************************************************** cycle_slideshow */

function cycle_slideshow()
	{
	if($('.slideshow').length)
		{
		var slideshows = $('.slideshow').each(function(){
			if($(this).find('.element').length>1)
				$(this).cycle({slideExpr:'.element', timeout:6000, cleartype: true, cleartypeNoBg: true})
			});
		}
	}

/*************************************************** set & get Cookies */

function setCookie(name,value,days) 
	{
	if (days) 
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	}

function getCookie(name) 
	{
	var name_eq = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
		{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(name_eq) == 0) return c.substring(name_eq.length,c.length);
		}
	return null;
	}

/*************************************************** ghostVal */

function ghostVal(el,txt)
	{
	
	$(el).attr('value',txt);
	$(el).data('txt',txt);
	
	if($(el).attr('type')=='password')
		{
		repField = "<input onfocus=\"replaceField(this,'"+$(el).attr('id')+"')\" type=\"text\" value=\""+txt+"\" id=\""+$(el).attr('id')+"\" style=\""+$(el).attr('style')+"\" maxlength=\""+$(el).attr('maxlength')+"\" name=\""+$(el).attr('name')+"\" />";
		orgField = "<input onblur=\"replaceField(this,'"+$(el).attr('id')+"')\" type=\"password\" value=\"\" id=\""+$(el).attr('id')+"\" style=\""+$(el).attr('style')+"\" maxlength=\""+$(el).attr('maxlength')+"\" name=\""+$(el).attr('name')+"\" />";
		
		$(el).replaceWith(repField);
		
		}
	else
		{
		$(el).bind('focus',function() 
			{ 
			if($(this).attr('value')==$(el).data('txt'))
				{
				$(this).attr('value',''); 
				}
			});
		$(el).bind('blur',function() 
			{ 
			if($(this).attr('value')=='')
				{
				$(this).attr('value',$(el).data('txt')); 
				}
			});
		}
	}

/************************* Shadowbox ******************************/

var sbTimer,sbBodyHeight,setHeight;

function reloadPage()
	{
	location.reload(true);
	}
	
function sbAutoHeight()
	{
	var body = $('body:first');
	var sbWrapper = $('#sb-wrapper');
	var sbWrapperInner = $('#sb-wrapper-inner');
	
	var _setHeight = function()
		{
		var bodyHeight = $(window).height();	
		var sbOuterHeight = sbWrapper.height();
		var _sbBodyHeight = sbBodyHeight+4;
		if(sbBodyHeight>bodyHeight-100)
			_sbBodyHeight=bodyHeight-100;
		var newYpos = parseInt((bodyHeight/2)-(sbOuterHeight/2));	
		
		sbWrapperInner.height(_sbBodyHeight);
		sbWrapper.css({'top':newYpos+'px'});
		}
	sbTimer = setInterval(_setHeight,50);
	}


function initShadowboxes()
	{
		
	Shadowbox.init({overlayColor:'#2c2c2e',overlayOpacity: 0.8, modal: true, skipSetup: true, onClose:function(){ reloadPage(); clearInterval(sbTimer); } });
	
	// Standard
	var stdOverlays = $('.shadowbox');
	if(stdOverlays.length) {
		stdOverlays.click(function(event){
			event.preventDefault();
			Shadowbox.open({
				player: 'iframe',
				content: url=$(this).attr('href'),
				width: 800,
				height: 600				
				});
			});
		}
		
	}

/************************* schriftersetzung mit cufon ******************************/

function cufonFontReplace()
	{
	//Cufon.replace('.loginregister .sep', { fontFamily: 'AntennaCond Regular' });
	}


/************************* Animations ******************************/

function animations(){
	var logo = $('header h1 a');
	logo.hover(function(){
			$(this).parent().stop(true,true).animate({'padding-left':'50px'},500,"easeOutBounce");
		},function(){
			$(this).parent().stop(true,true).delay(250).animate({'padding-left':'40px'},750,"easeOutCirc");
		}
	);
	$('#nav').find('a:not([class="active"])').hover(function(){
			$(this).stop(true,true).animate({'color':'#0098d4'},150);
			$(this).parent().parents('li').find('a:first:not([class="active"])').stop(true,true).animate({'color':'#0098d4'},150);
		},function(){  
			$(this).stop(true,true).delay(250).animate({'color':'#58585a'},250);
			$(this).parent().parents('li').find('a:first:not([class="active"])').stop(true,true).delay(250).animate({'color':'#58585a'},250);
		}
	);
	/*$('#subnav').find('a:not([class="active"])').hover(function(){
			$(this).stop(true,true).animate({'color':'#000'},150);
		},function(){  
			$(this).stop(true,true).delay(250).animate({'color':'#58595b'},500);
		}
	);
	$('.black, button').hover(function(){
			$(this).stop(true,true).animate({'background-color':'#414042'},150);
		},function(){
			$(this).stop(true,true).delay(250).animate({'background-color':'#000'},500);
		}
	);*/
	
}

/************************* subnav ******************************/

function subnav() {
	subnavs = $('#nav').find('li > ul');
	if(subnavs.length>0) {
		subnavs.each(function() { 
			var _this = $(this);
			var _parent = _this.parent();
			_this.css({'min-width':parseInt(_parent.outerWidth())+15+'px','display':'block'});
			_this.hide();
			_parent.hover(function(){
				_this.stop(true,true).slideDown(250);
				},function(){
				_this.stop(true,true).delay(150).slideUp(150);
			});
		});
	}
}
/*************************************************** Funktionsaufrufe */

$(document).ready(function(){
	externalLinks();
	handleIE6();
	subnav();
	animations();
	
	$('.gallerylist').find('li:nth-child(3n)').css({'margin-right':0});

	var $buoop = {} 
		$buoop.ol = window.onload; 
		window.onload=function(){ 
		if ($buoop.ol) $buoop.ol(); 
		var e = document.createElement("script"); 
		e.setAttribute("type", "text/javascript"); 
		e.setAttribute("src", "files/js/buoop/buoop.js"); 
		document.body.appendChild(e); 
	} 	
});

