jQuery.noConflict();
(function($) { 
  	$(document).ready(function() {
  		
  		//Dropdown Menü  		 		
  		$(".dropdown").each(function(){
			$(this).append('<a href="'+$(this).children('.ml').attr('href')+'" class="sml">'+$(this).children('.ml').html()+'</a>');
			if($.browser.msie && parseInt($.browser.version)==6){
				rueber=$(this).children('.ml').width()*-1;
  				$(this).children('.sml').css('marginLeft',rueber-28+'px');
  			}
		});
		
		$(".activedd .sml").show();
  		
  		var dds=$(".dropdown");
  		var jetzt;
		var ddd=200;
		var open=new Array();
		for(i=0;i<$('.dropdown').size();i++){
			open[i]=0;
		}
		
  		$(".dropdown").mouseenter(
  			function(){  		
  				if($(this).children('.sml').is(":visible")==false || ($(this).children('.ddsm').is(":visible")==false && $(this).attr('class').indexOf('activedd')>-1)){
  					if($.browser.msie && parseInt($.browser.version)==6){
  						rueber=$(this).children('.ml').width()*-1;
  						$(this).children('.ddsm').css('marginLeft',rueber-28+'px');
  						$(this).children('.ddsm').fadeIn(ddd);
  					}else{
  						$(this).children('.ddsm').slideDown(ddd);
  					}
  					$(this).children('.sml').fadeIn(ddd);
  					$(this).children('.sho').fadeIn(ddd);
  				}
   			}
   		).mouseleave(
  			function(event){
  				if($(this).children('.sml').is(":visible")==true){
  					$(this).children('.ddsm').fadeOut(ddd);
  					if($(this).attr('class').indexOf('activedd')==-1)
  						$(this).children('.sml').fadeOut(ddd);
  					$(this).children('.sho').fadeOut(ddd);
   				}
  			}
  		);	
  		
  		//Fontsize
  		$('.textplus').click(function(){
  			ac=parseInt($('#content').css('font-size').slice(0,-2));
    		if($('#content table td').size()>0)
    			ac2=parseInt($('#content table td').css('font-size').slice(0,-2));
			setto=ac+1;
			if($('#content table td').size()>0) 
				setto2=ac2+1;   
    		
    		if(ac<25){
	    		$('#content').css('font-size',setto+"px");
	    		if($('#content table td').size()>0) 
	    			$('#content table td').css('font-size',setto2+"px");
    		}
    		return false;
  		});
  		
		$('.textminus').click(function(){
  			ac=parseInt($('#content').css('font-size').slice(0,-2));
    		if($('#content table td').size()>0)
    			ac2=parseInt($('#content table td').css('font-size').slice(0,-2));
			setto=ac-1;
			if($('#content table td').size()>0) 
				setto2=ac2-1;   
    		
    		if(ac>12){
    			$('#content').css('font-size',setto+"px");
    			if($('#content table td').size()>0) 
    				$('#content table td').css('font-size',setto2+"px");
    		}
    		return false;
  		});
  		
  		
  		//Slider
  		var firstrun=0;
		var intval=4000;
  		var gotime=500;
  		var mt=-120;
  		var active=true;
  		var i=0;
  		var nextclick=true;
  		var prevclick=true;
  		
  		$(".slideback").click(function(){	
  			acmt=parseInt($('.slide').css('marginTop'));
  			if(isNaN(acmt))
		    	acmt=mt*-1;
		    	
  			if(acmt%mt==0 && prevclick){
  			    active=false;
  			    $(".slide .crboxcon").stopTime('slidetime');
  			    $(".slideplay").show();
  			    $(".slidepause").hide();
  			    gomt=acmt-mt;
  			    if(acmt==0){
		    		$('.slide').animate({marginTop:($('.slide').children(".crboxcon").size()-1)*mt+"px"}, gotime,function(){prevclick=true});
  			    	prevclick=false;
		    	}else if(acmt<0){
  			    	$('.slide').animate({marginTop:gomt+"px"}, gotime,function(){prevclick=true});
  			    	prevclick=false;
  			    }
  			}
  				
  			return false;
  		});
  		
  		$(".slideplay").click(function(){
  			active=true;
  			$(".slidepause").show();
  			$(".slideplay").hide();
  			goslide(true); 
  			return false;
  		});
  		$(".slidepause").click(function(){
  			active=false; 
  			$(".slide .crboxcon").stopTime('slidetime');
  			$(".slideplay").show();
  			$(".slidepause").hide();
  			return false;}
  		);
  		$(".slidenext").click(function(){
  			acmt=parseInt($('.slide').css('marginTop'));
  			if(isNaN(acmt))
		    	acmt=mt*-1;
  			
  			if(acmt%mt==0 && nextclick){
  				active=false;
  				$(".slide .crboxcon").stopTime('slidetime');
  				$(".slideplay").show();
  				$(".slidepause").hide();
  				maxmt=($('.slide').children(".crboxcon").size()-1)*mt;
  				if(acmt==($('.slide').children(".crboxcon").size()-1)*mt){
  					$('.slide').animate({marginTop:"0px"}, gotime,function(){nextclick=true});
  					nextclick=false;
  				}else if(acmt>maxmt){
  					$('.slide').animate({marginTop:(acmt+mt)+"px"}, gotime,function(){nextclick=true});
  					nextclick=false;
  				}
  			}
  			return false;
  		});

  		if($('.slider .crboxcon').size()>1){
  			startslide();  		
  		}else{
  			$('.slidesteuer').hide();
  			$('.slidehr').hide();
  		}
  		
  		function goslide(fr,nowis){
  			if(active){
  				if(fr){
  					acmt=parseInt($('.slide').css('marginTop'));
  					if(isNaN(acmt))
		    			acmt=mt*-1;
  					if(acmt%mt==0){
  						maxmt=($('.slide').children(".crboxcon").size()-1)*mt;
  						if(acmt>maxmt){
  							var nowis=acmt+mt;
  							$('.slide').animate({marginTop:(acmt+mt)+"px"}, gotime);
  							startslide();
  						}else{
		    				$(".slide .crboxcon").stopTime('slidetime');
		    				$('.slide').animate({marginTop:"0px"}, gotime);
		    				startslide();
		    			}
  					}		
  				}else{
  					$(".slide .crboxcon").everyTime(intval,'slidetime',function(i){
		    			acmt=parseInt($('.slide').css('marginTop'));
		    			if(isNaN(acmt))
		    				acmt=mt*-1;
		    			if(acmt==($('.slide').children(".crboxcon").size()-1)*mt)
		    				acmt=mt*-1;
  						if(acmt%mt==0){
  							maxmt=($('.slide').children(".crboxcon").size()-1)*mt;
		    				if(acmt>maxmt)
		    				     $('.slide').animate({marginTop:(acmt+mt)+"px"}, gotime);
		    				else{
		    				     $(".slide .crboxcon").stopTime('slidetime');
		    				     $('.slide').animate({marginTop:"0px"}, gotime,function(){startslide();});
		    				}
		    			}
		    		});
		    	}
		    }
		
		}
				
		function startslide(){
			active=true; 
		    goslide(false);
		}
		
		//Accordeon
		$('#accordeon .accordeon .crboxcon').first().slideDown(1000);
		
		$('#accordeon .accordeon h2').click(function(){
			if($(this).siblings('.crboxcon').css('display')=="none")
				$(this).siblings('.crboxcon').slideDown(300);
			else
				$(this).siblings('.crboxcon').slideUp(300);
			
			$(this).parent('.accordeon').siblings('.accordeon').children('.crboxcon').slideUp(300);
		
		});
  	
  		//Safari Rondell
  		if ($.browser.webkit && (location=="http://www.zielgruppenmarketing.de/" || location=="http://www.zielgruppenmarketing.de/home.html" || location=="http://zielgruppenmarketing.de/" || location=="http://zielgruppenmarketing.de/home.html")){
   			safarikeks=false;
   			kekse=document.cookie.split('; ');
   			for(i=0;i<kekse.length;i++){
   				keks=kekse[i].split('=');
   				if(keks[0]=="safariload"){
	  				safarikeks=true;
	  			}
   			}   		
   			
   			if(!safarikeks){
   				$('#coverflow').hide();
   				var a=new Date();
				a=new Date(a.getTime() +1000*60*60*24);
				document.cookie = 'safariload=1; expires='+a.toGMTString()+';'; 
				window.setTimeout('location.href = "http://www.zielgruppenmarketing.de/home.html"', 1000);
			}
 		}
 	});
 	
})(jQuery);


function sfcheck(){
 	jQuery.noConflict();
	(function($) { 
 		if($('#suchfeld').val().length<2){
 			$('#suchfeld').val('Bitte angeben');
 			$('#suchfeld').css('color',"#ff0000");
 			$('#suchfeld').click(function(){$('#suchfeld').val(""); $('#suchfeld').css('color',"#fff");});
 			$('#suchfeld').focus(function(){$('#suchfeld').val(""); $('#suchfeld').css('color',"#fff");});
 			return false;
 		}else{
 			$('#suchform').submit();
 		}
 	})(jQuery);
 }
