/************************

jQuerx Plugin webkitTransform for a simple webkitTransform which does not forget the previous settings.

use freely with the "do whatever your want with it" public domain license 

*************************/
(function($){

	jQuery.fn.webkitTransform = function(cssstring) {

        return this.each(function() {
            var element = $(this);
            var wtstring;
            if($(element).attr('remember_webkit_transform'))
            {
            	wtstring=$(element).attr('remember_webkit_transform');
            }
            else
            {
            	;
            }
        
            if(!wtstring)
            {
            	wtstring=cssstring;
            }
            else
            {
            	
            	csA= new Array();
            	csA=cssstring.split(' ');
            	csAA=new Array();
            	for (var i=0; i<csA.length; i++)
            	{
            	
            		tempA=csA[i].split('(');
            		
            		if(tempA.length==2)
            		{
            			tempA[0]=jQuery.trim(tempA[0]);
            			tempA[1]=jQuery.trim(tempA[1]);
            			tempA[1]=tempA[1].substring(0,(tempA[1].length-1));
            		}
            		csAA[tempA[0]]=tempA[1];
            	}
    		
            	
            	wtA= new Array();
            	wtA=wtstring.split(' ');
            	wtAA=new Array();
            	for (var i=0; i<wtA.length; i++)
            	{
            	
            		tempA=wtA[i].split('(');
            		
            		if(tempA.length==2)
            		{
            			tempA[0]=jQuery.trim(tempA[0]);
            			tempA[1]=jQuery.trim(tempA[1]);
            			tempA[1]=tempA[1].substring(0,(tempA[1].length-1));
            		}
            	
            		wtAA[tempA[0]]=tempA[1];
            		
    			}
            
            	for (j in csAA)
            	{
            		wtAA[j]=csAA[j];
            	}
            	
            	var tempwtstring='';
            	for(z in wtAA)
            	{
            		if(wtAA[z])
            		{
            			tempwtstring=tempwtstring+z+'('+wtAA[z]+') ';
            		}
            	}
            
            	wtstring=tempwtstring;
            }
     
            $(element).css('-webkit-transform', wtstring);
            $(element).css('-moz-transform', wtstring);
            $(element).css('-o-transform', wtstring);
            $(element).attr('remember_webkit_transform', wtstring)
       
            return element;
        });
	};
 
	
 
})(jQuery);

function scale_object(obj,to)
{
	
}

function load_site(name)
{
		$.ajax({
		  url: "sites/"+ name +".php",
		  success: function(data) {
			$('#content').html(data);
		  }
		});
}

function load_episode(id)
{
		$.ajax({
		  url: "sites/epguide_episode.php?toonid="+id,
		  success: function(data) {
			$('#inhalt').html(data);
		  }
		});
}

function load_episode_list(cat)
{
		$.ajax({
		  url: "sites/epguide_auflistung.php?cat="+cat,
		  success: function(data) {
			$('#episodes').html(data);
		  }
		});
}

function change_youtube_player(yt_id)
{
	$('#yt_player').html('<iframe width="100%" height="100%" src="http://www.youtube.com/embed/'+yt_id+'?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe>');
}


//// yt player zeug /////

var klein = false;

function yt_verkleinern()
{
	if(klein==false)
	{
		$("#size_toggle").html("Vergrößern");
		$('#yt').animate({
		width: 213,
		height: 132,
		left: $(window).width()-223,
		top: $(window).height()-182
	  }, 1000, function() {
		// Animation complete.
	  });
		$('#yt_player').animate({
		width: 213,
		height: 127
	  }, 1000, function() {
		// Animation complete.
	  });
			
		klein=true;
	}
	else
	{
		$("#size_toggle").html("Verkleinern");
		$('#yt').animate({
		width: 853,
		height: 530,
		left: 0,
		top: 20
		  }, 1000, function() {
			// Animation complete.
		  });
			$('#yt_player').animate({
			width: 853,
			height: 510
		  }, 1000, function() {
			// Animation complete.
		  });
		klein=false;
	}
}

/////////////////////////
var i = 0;

$(document).ready(function() {
  $("#headder").find('a').mouseover(
  function ()
  {
	 // $(this).find("img").webkitTransform("rotate(10deg)");
  }
  );
});

    // shim layer with setTimeout fallback
    window.requestAnimFrame = (function(){
      return  window.requestAnimationFrame       || 
              window.webkitRequestAnimationFrame || 
              window.mozRequestAnimationFrame    || 
              window.oRequestAnimationFrame      || 
              window.msRequestAnimationFrame     || 
              function( callback ){
                window.setTimeout(callback, 1000 / 60);
              };
    })();
 
 
    // usage: 
    // instead of setInterval(render, 16) ....
 
    (function animloop(){
      requestAnimFrame(animloop);
     // render();
    	// $("#headder").webkitTransform("rotate("+i+"deg)");
		 i++;
	})();
    // place the rAF *before* the render() to assure as close to 
    // 60fps with the setTimeout fallback.
