function copy_smiley(text) 
	{
	text = ' ' + text + ' ';
	if (document.post.message.createTextRange && document.post.message.caretPos) 
		{
		var caretPos = document.post.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		document.post.message.focus();
		} 
	else 	
		{
		document.post.message.value  += text;
		document.post.message.focus();
		}
	}

function FT_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function FT_preloadImages() { 
  var d=document; if(d.images){ if(!d.FT_p) d.FT_p=new Array();
    var i,j=d.FT_p.length,a=FT_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.FT_p[j]=new Image; d.FT_p[j++].src=a[i];}}
}

function FT_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FT_findObj(n,d.layers[i].document); return x;
}

function FT_swapImage() { 
  var i,j=0,x,a=FT_swapImage.arguments; document.FT_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=FT_findObj(a[i]))!=null){document.FT_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function FT_swapImage2() { 
  var i,x,a=document.FT_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
 //-->


  function openWindow (nameurl, namewindow, width, height){

    x = (640 - width)/2, y = (480 - height)/2;
    scrollb = 'no';
    res = 'no';
    if (screen) {

        y = (screen.availHeight - height)/2;

        x = (screen.availWidth - width)/2;

    }
    if ((namewindow == 'big') || (namewindow == 'highscore')) {
    	scrollb = 'yes';
	res = 'yes';
    }

    var prevwin = window.open(nameurl,namewindow,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars='+scrollb+',resizable='+res);
    prevwin.focus();
  }


$(document).ready(function()
	{
	$("a[rel^='prettyPhoto']").prettyPhoto();
	});

function CycleRefs() 
	{
	$('#nachrichtenticker').cycle(
		{ 
    		fx:     'scrollUp', 
    		xspeed:   2400, 
    		timeout: 6000,
    		delay: -1000,
    		pause:   1,
    		xsync: 1
 		});
	} 

function onBefore() 
	{}
 
function onAfter() 
	{}

$(document).ready( function()
	{ 
  	CycleRefs();
	});

$(document).ready(function() 
	{ 
        $('ul.sf-menu').superfish({ 
            speed:       'fast'
        }); 
    });

$(document).ready(function() 
	{
        $('#slider').s3Slider({
            timeOut: 4500
        });
    });






$(document).ready(function(){

	//Adjust panel height
	$.fn.adjustPanel = function(){ 
		$(this).find("ul, .subpanel").css({ 'height' : 'auto'}); //Reset subpanel and ul height
		
		var windowHeight = $(window).height(); //Get the height of the browser viewport
		var panelsub = $(this).find(".subpanel").height(); //Get the height of subpanel	
		var panelAdjust = windowHeight - 100; //Viewport height - 100px (Sets max height of subpanel)
		var ulAdjust =  panelAdjust - 25; //Calculate ul size after adjusting sub-panel (27px is the height of the base panel)
		
		if ( panelsub >= panelAdjust ) {	 //If subpanel is taller than max height...
			$(this).find(".subpanel").css({ 'height' : panelAdjust }); //Adjust subpanel to max height
			$(this).find("ul").css({ 'height' : ulAdjust}); //Adjust subpanel ul to new size
		}
		else if ( panelsub < panelAdjust ) { //If subpanel is smaller than max height...
			$(this).find("ul").css({ 'height' : 'auto'}); //Set subpanel ul to auto (default size)
		}
	};
	
	//Execute function on load
	$("#infopanel").adjustPanel(); //Run the adjustPanel function on #infopanel
	$("#alertpanel").adjustPanel(); //Run the adjustPanel function on #alertpanel
	
	//Each time the viewport is adjusted/resized, execute the function
	$(window).resize(function () { 
		$("#infopanel").adjustPanel();
		$("#alertpanel").adjustPanel();
	});
	
	//Click event on Chat Panel + Alert Panel	
	$("#infopanel a:first, #alertpanel a:first").click(function() { //If clicked on the first link of #infopanel and #alertpanel...
		if($(this).next(".subpanel").is(':visible')){ //If subpanel is already active...
			$(this).next(".subpanel").hide(); //Hide active subpanel
			$("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger
		}
		else { //if subpanel is not active...
			$(".subpanel").hide(); //Hide all subpanels
			$(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
			$("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
			$(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
		}
		return false; //Prevent browser jump to link anchor
	});
	
	//Click event outside of subpanel
	$(document).click(function() { //Click anywhere and...
		$(".subpanel").hide(); //hide subpanel
		$("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
	});
	$('.subpanel ul').click(function(e) { 
		e.stopPropagation(); //Prevents the subpanel ul from closing on click
	});
	
	//Delete icons on Alert Panel
	$("#alertpanel li").hover(function() {
		$(this).find("a.delete").css({'visibility': 'visible'}); //Show delete icon on hover
	},function() {
		$(this).find("a.delete").css({'visibility': 'hidden'}); //Hide delete icon on hover out
	});
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

function openMdL(url) {
	jQuery.facebox(function() { 
		jQuery.get(url, function(data) {
			jQuery.facebox(data);
		});
	});
};

$(function(){
	if ( !jQuery.browser.msie ) return;
	$('object, embed, applet').each(function() {
		this.outerHTML = this.outerHTML;
	});
});

jQuery(document).ready(function($) {
	
	$('a[rel*=facebox]').facebox();
	
	$('.fb_form_submit a').live("click", function() {
		validate_error =0;
		var params = {send: 1};
		params['click'] = $(this).attr('class');
		
		$('form.ajaxform > *').each(function() {
			$(this).removeClass('form_required_marker');
			if ($(this).hasClass('form_required') && !$(this).val() )
			{
				$(this).addClass('form_required_marker');
				validate_error =1;
			}
			params[$(this).attr('name')] = $(this).val();
		});
		
		if (validate_error) {
			$('.ajaxformRespond').html('<p class="error">Bitte f&uuml;llen Sie alle gekennzeichneten Pflichtfelder aus!</p>');
			$('.ajaxformRespond:hidden').fadeIn(200);
		}
		else		
			$.post('{base_http}/include/ajax-actions.php', params, function(txt) {
			if(txt=='Ok') {
				$('#contactform').slideUp(600,function(){
					$("#success").fadeIn(600)
				});
			} else {
				$('.ajaxformRespond').html(txt);
				$('.ajaxformRespond:hidden').fadeIn(200);
				}
			});
	});
});

