/** NAVIGATION **/
var mlddm_shiftx       = 3;
var mlddm_shifty       = -3;	
var mlddm_timeout      = 1000;
var mlddm_effect       = 'fade';
var mlddm_effect_speed = 150;
var mlddm_orientation  = 'h';
var mlddm_direction    = 1;
var mlddm_delay        = 50;
var mlddm_highlight    = 1;
var mlddm_closeonclick = 0;

/** MAIL **/
function RenderMail(user,domain,linktext,cssclass){
	var mailto=user+'@'+domain;
	var txt=linktext;
	if(txt.length<1)txt=mailto;
	if(cssclass.length>0){
		document.write('<a class='+cssclass+' href=mailto:'+mailto+' onMouseOver=this.style.color="'+lnkColor+'"; onMouseOut=this.style.color="#000000";>'+txt+'</a>');
	}else{
		document.write('<a href=mailto:'+mailto+'>'+txt+'</a>');
	}
}


/** JQUERY**/
$(document).ready(function(){
	$('a.popup').colorbox({width: '742px', opacity: 0.65, initialWidth: 0, initialHeight: 0, rel:'gal' });
	
	// Links aktualisieren (rel="external" im neuen Fenster öffnen)
	UpdateLinks();
	/*
	$("a.fancyImage").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'overlayOpacity':	0.6,
		'overlayColor'	:	'#000'
	});
	*/
	$("a.fancyImage").colorbox({width: '742px', opacity: 0.65, initialWidth: 0, initialHeight: 0});
	
	
	// Versteckte Formulare einblenden
	$('#showFrm').click(function(){
		//$('.frmHidden').show();
		$('.frmHidden').slideToggle(1500, 'easeOutQuart');
		$('html,body').animate({scrollTop: $('.frmHidden').offset().top},'slow');
	});
	
	// Cookie suchen
	if(document.cookie && getCookie('fontSize') != undefined){
		var size = getCookie('fontSize');
			size = size.replace('fontSize=', '');
		$('html').css('font-size', parseFloat(size));
	}
	
	// Big Font Size
	$('#fontBig').click(function(){
		var currentFontSize = parseFloat($('html').css('font-size'));
		var newFontSize = 17;
		$('html').css('font-size', newFontSize);
		document.cookie = "fontSize="+newFontSize+"; path=/";
		location.reload(true);
		return false;
	});
	// Normal Font Size
	$('#fontNormal').click(function(){
		var currentFontSize = parseFloat($('html').css('font-size'));
		var newFontSize = 16;
		$('html').css('font-size', newFontSize);
		document.cookie = "fontSize="+newFontSize+"; path=/";
		location.reload(true);
		return false;
	});
	// Small Font Size
	$('#fontSmall').click(function(){
		var currentFontSize = parseFloat($('html').css('font-size'));
		var newFontSize = 14.4;
		$('html').css('font-size', newFontSize);
		document.cookie = "fontSize="+newFontSize+"; path=/";
		location.reload(true);
		return false;
	});
	
});

/** LINKS **/
function UpdateLinks() {  
	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") == "external") anchor.target = "_blank";  
	}
	var imgs = document.getElementsByTagName("img");
	for (var i=0; i<imgs.length; i++){
		var img = imgs[i];
		if(img.getAttribute("src").indexOf("../") == 0) img.src = img.getAttribute("src").replace("../", "http://"+window.location.host+"/");
	}
}

/** COOKIE LESEN **/
function getCookie(c_name){
	var i,x,y,ARRcookies = document.cookie.split(";");
	for(i = 0; i < ARRcookies.length; i++){
		x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x = x.replace(/^\s+|\s+$/g,"");
		if(x == c_name) return unescape(y);
	}
}
