jQuery.fn.preLoad = function() {
   var extAr=$(this).attr('src').split('.');
		var filename=extAr[0];
		var ext=extAr[1];
		var newName=filename+"_h."+ext;
		var image1 = $('<img />').attr('src', newName);
};

$(window).bind('pageshow',function(){
$('img.hover').each(function(){
	 if($(this).attr('src').indexOf('_h')>0){
		 $(this).attr('src',$(this).attr('src').replace('_h',''));
	 }
 });

});

$(document).ready(function() {	
	$('body').css('background','url(ximg/body_bg.jpg) no-repeat top center #ffffff');
	
	$('#home_pic').flash({
				swf: 'xmedia/startseite_banner.swf',
				width: 833,
				height: 152
				});
	
	$(".dropshadow").shadowOn({
    imagepath: "xjs/images", //Path to the shadowOn image folders
    imageset: "41", //Shadow to use, 1 to 88
    autoresize: true,
    resizetimer: 250 //Timer to check it the resize have happened, set in milliseconds
	});
	
$('img.hover').hover(
	function(){
		var extAr=$(this).attr('src').split('.');
		var filename=extAr[0];
		var ext=extAr[1];
		$(this).attr('src',filename+"_h."+ext);
	},
	function(){
		var extAr=$(this).attr('src').split('.');
		var filename=extAr[0].replace('_h','');
		var ext=extAr[1];
		$(this).attr('src',filename+"."+ext);
	}).each(function(){
	 	$(this).preLoad();
	 });

$('img.bet_left').mouseover(
	function(){
		var extAr=$(this).attr('src').split('.');
		var filename=extAr[0];
		var ext=extAr[1];
		if($(this).attr('src').indexOf("_h")<1){
		$(this).attr('src',filename+"_h."+ext);
		}
		$.bet_left_up=$(this).attr('src');
		$('img.bet_left').each(
		 function(){
			 if($(this).attr('src')!==$.bet_left_up){
				 $(this).attr('src',$(this).attr('src').replace('_h',''));
			 }
		 }
		 );
		var getVar=$(this).attr('id');
		var ajax_load="<div width='100%' style='text-align:center'><img src='ximg/loading.gif' alt='loading...' /></div>";  
		$('#bet_right_content').html(ajax_load).load('returntext.php',getVar,function(){});
	})

$('img.bet_left:first').mouseover();


$('div.team_left').mouseover(	
	function(){
		$(this).css('background-image','url(ximg/team_left_h.jpg)');
		$('div.team_left').not($(this)).css('background-image','url(ximg/team_left.jpg)');
		var getVar=$(this).attr('id');
		var ajax_load="<div width='100%' style='text-align:center'><img src='ximg/loading.gif' alt='loading...' /></div>";  
		$('#bet_right_content').html(ajax_load).load('returntext.php',getVar,function(){});
	});

$('img.bet_left:first').mouseover();
$('div.team_left:first').mouseover();




	$('#header_menu .menu_tab').hover(
	function(){
		$(this).css({'background' : '#ffffff' , 'color' : '#000000'});
	},
	function(){
		if($(this).attr('id')!="menutab"+$.menuup){
		$(this).css({'background' : 'none' , 'color' : '#ffffff'});
		}
	}
	);
	
	$('#header_menu .menu_tab[id=menutab'+$.menuup+']').mouseover();
	
	$('input.hp').hide();
	$('input.form_small').focus(
			function(){
				if($(this).attr('name').indexOf($(this).val())>0){
					$(this).val("");;
				}
			}
		);
	
	$('.send').click(function(){
			$.send=true;
			$('.form_in').each(function(index){
				if($(this).attr('name').indexOf('*')>0){
			  if($(this).val().length<2){
				$.send=false;
				$(this).css("border","1px solid #000000");
			}else{
				$(this).css("border","1px solid #abaaab");
			}
				}
			  });
		if($('.hp').val().length>0){
			$.send=false;
		}
		if($.send){
			$('form').submit();
		}
		 });
	
	
	
	
});
