/* PRELOAD FUNKTION */
(function($){
    $.fn.preloadImages = function(options){

        var defaults = {
            showSpeed: 500,
            easing: 'easeOutQuad'
        };
			
        var options = $.extend(defaults, options);
		
        return this.each(function(){
            var container = $(this);
            var image = container.find('img');
		
            $(image).bind('load error', function(){
                $(this).css({ "visibility": "visible" }).animate({ opacity:"1" }, {duration:options.showSpeed, easing:options.easing}).parent(container).removeClass('preload');                
                $('.preload').removeClass('preload')
            }).each(function(){
                if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) { $(this).trigger('load');}
            });
        });
    }
})(jQuery);

// Cufon
function CufonReplace(){	
		Cufon.replace('h1', { fontFamily: 'HoheSalve', fontStyle: 'normal', fontWeight : 'normal', letterSpacing: '-0.5px' });
		Cufon.replace('.mainlink', { fontFamily: 'MetaBold', fontSize:'13px',fontStyle: 'normal', fontWeight : 'bold'});			
}	

// Sprachnavigation anzeigen 
function showLanguages() {
	document.getElementById('languageslist').style.display='block';
}


// Rollover Effect Over
function buttonOver(button, color) {
	button.style.backgroundColor = color;
}

// Rollover Effect Out		
function buttonOut(button){
	button.style.backgroundColor = "";
}

// Rollover Effect Tabs
function TabOver(button) {
	document.getElementById(button).style.backgroundColor = "#3567A0";
}

// Rollover Effect Tabs		
function TabOut(button){
	document.getElementById(button).style.backgroundColor = "#FFFFFF";
}

// Formularfeld löschen
function clearField(){
	document.getElementById("button_smallsearch").value="";
}

// Zoombild anzeigen	 im Content		
function popup1(file){
	document.getElementById("zoom_img").style.height=495;
	document.getElementById("zoom_img").src=file;
	document.getElementById("close_button").style.display="inline";
}

function closePopup(){
	document.getElementById("zoom_img").style.height=1;
	document.getElementById("zoom_img").src="de/images/space.gif";
	document.getElementById("close_button").style.display="none";
}

// Zoombild anzeigen			
function popup(file){
	var zentrierenX = (screen.width/2)-235; 
	var zentrierenY = (screen.height/2)-210;
	var pos = "left="+zentrierenX+",top="+zentrierenY; 
	window.open(file,"help","width=600, height=500, resizable=no, scrollbars=no, menubar=no, toolbar=no, directories=no, location=no, status=no, " + pos);
}


// Flash Film schreiben
function writeFlash(Path,Width,Height,Parameter) {

	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' height='" +  Height + "' width='" + Width + "'>");
	document.write("<param name='movie' value='" + Path + Parameter + "'>");
	document.write("<param name='quality' value='best'>");
	document.write("<param name='play' value='true'>");
	document.write("<param name='menu' value='false'>");
	document.write("<param name='scale' value='noscale'>");
	document.write("<param name='wmode' value='opaque'>");
	document.write("<embed scale='noscale' menu='false' height='" + Height + "' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" + Path + Parameter + "' type='application/x-shockwave-flash' width='" + Width + "' quality='best' wmode='opaque' play='true'>");
	document.write("</object>");
	
}

// Flash Film schreiben
function writeFlashWithBackground(Path,Width,Height,Parameter,BGColor) {

	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' height='" +  Height + "' width='" + Width + "'>");
	document.write("<param name='movie' value='" + Path + Parameter + "'>");
	document.write("<param name='quality' value='best'>");
	document.write("<param name='play' value='true'>");
	document.write("<param name='menu' value='false'>");
	document.write("<param name='scale' value='noscale'>");
	document.write("<param name='wmode' value='opaque'>");
	document.write("<param name='bgcolor' value='"+BGColor+"'>");
	document.write("<embed scale='noscale' bgcolor='"+BGColor+"' menu='false' height='" + Height + "' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" + Path + Parameter + "' type='application/x-shockwave-flash' width='" + Width + "' quality='best' wmode='opaque' play='true'>");
	document.write("</object>");
	
}

// Windows Film schreiben 
function writeMediaplayer(Path,Width,Height,Autoplay) {

	document.write("<object id='MediaPlayer' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'   height='" + Height + "' width='" + Width + "'>");
	document.write("<param name='filename' value='"+ Path + "'>");
	document.write("<param name='autostart' value='" + Autoplay + "'>");
	document.write("<embed src='" + Path + "' width='" + Width + "' height='" + Height + "' autostart='" + Autoplay + "' />");
	document.write("</object>");

}

// Quicktime Film schreiben
function writeQuicktime(Path,Width,Height,Autoplay) {

	document.write("<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab' type='video/quicktime' height='" + Height + "' width='" + Width + "'>");
	document.write("<param name='src' value='" + Path + "'>");
	document.write("<param name='autoplay' value='" + Autoplay + "'>");
	document.write("<param name='controller' value=''>");						
	document.write("<embed height='" + Height + "' pluginspage='http://www.apple.com/quicktime/download/' src='" + Path + "' type='video/quicktime' width='" + Width + "' autoplay='" + Autoplay + "'>");
	document.write("</object>");
	
}

function PopupFeratel(file){
	var zentrierenX = (screen.width/2)-350; 
	var zentrierenY = (screen.height/2)-300;
	var pos = "left="+zentrierenX+",top="+zentrierenY; 
	window.open(file,"book","width=750, height=600, resizable=no, scrollbars=no, menubar=no, toolbar=no, directories=no, location=no, status=no, " + pos);

}

function showQuickProgress(){
	
	document.getElementById("quickbutton").style.display="none";
	document.getElementById("quickwait").style.display="block";
}

/* Drop-down */
function togglecmsblock(id) {				

	if (document.getElementById(id).style.display == 'block'){
		document.getElementById(id + "_link").style.backgroundImage = "url(images/dropdown.gif)";
		jQuery('#' + id).hide();
	}
	else {
		jQuery('#' + id).slideDown('fast',function(){  if (jQuery.browser.msie) { this.style.removeAttribute("filter");}; document.getElementById(id).style.display = 'block'});			
		document.getElementById(id + "_link").style.backgroundImage = "url(images/dropup.gif)";		
	}	
	
}


function clearfield(feld,wert){
	if (feld.value == wert) {feld.value="";}
}

var Browser = {  
	Version: function() {   
	var version = 999; 
	if (navigator.appVersion.indexOf("MSIE") != -1)   
	version = parseFloat(navigator.appVersion.split("MSIE")[1]);    
	return version;  
	}
}

function load_facebook_script(lang) {
	var fbscript = document.createElement('script'); 
	fbscript.type = 'text/javascript';
	if (lang=='de') { fbscript.src = 'http://connect.facebook.net/de_DE/all.js#xfbml=1';}
	if (lang=='en') { fbscript.src = 'http://connect.facebook.net/en_US/all.js#xfbml=1';}
	if (lang=='nl') { fbscript.src = 'http://connect.facebook.net/nl_NL/all.js#xfbml=1';}
	document.getElementsByTagName('head')[0].appendChild(fbscript);	
}

