//Pluginfile for IMX.jQuery Plugins
//Author: Axel Güldner (gueldner@infomax-it.de)
//Version 1.2
//Date 02.12.2008

jQuery.fn.extend({

//accordion
  accordion: function(value,direction,speed,callback){
		if(direction == "v"){
			newHeight = value + "px";
			return this.animate({height: newHeight}, speed, callback);
		}else{
			newWidth = value + "px";
			return this.animate({width: newWidth}, speed, callback);
		}
	}
});

jQuery.fn.extend({

//horizontal slide
  hslide: function(pixel,speed,callback){
		if(this.css("left") == "auto" || this.css("left") == "" || this.css("left") == "undefined"){
			this.css("left","0px");			
		}
		if(this.width() - parseInt(pixel) + 10 <= -1 * (parseInt(this.css("left"))- parseInt(pixel))){
			return this.animate({left: "0px"}, speed, callback);
		}else{
			pixel = parseInt(this.css("left")) - pixel + "px";			
			return this.animate({left: pixel}, speed, callback);
		}
	}
});

//Funktion zum Setzen eines Cookies 
setCookie = function(name, value){
		document.cookie = name+"="+value+";";
	};

//Funktion zum Abfragen eines Cookies mit bestimmtem Label
getCookie = function(name){
		myCookies = document.cookie.split(";");  		
  		for(var i = 0; i < myCookies.length; i++){
  			var cookie = jQuery.trim(myCookies[i]);  			
  			if (cookie.substring(0, name.length + 1) == (name + '=')){
  				return decodeURIComponent(cookie.substring(name.length + 1));  				
				break;
			}
  		}
	};

jQuery.fn.extend({
  fontsizer: function(value){
	if(value == "+"){
		steps = getCookie("steps");		
		if (!steps) steps = 0;
		setCookie("steps",++steps);
		
		$("embed").height(parseInt($("embed").height())/(10+parseInt(steps)-1)*(10+parseInt(steps)));
		$("embed").width(parseInt($("embed").width())/(10+parseInt(steps)-1)*(10+parseInt(steps)));		
		$("body").css("font-size",parseInt($("body").css("font-size"))+1+"px");				
	}
	else if(value == "="){
		$("embed").height(parseInt($("embed").height())/(10+parseInt(steps))*10);
		$("embed").width(parseInt($("embed").width())/(10+parseInt(steps))*10);		
		$("body").css("font-size",parseInt($("body").css("font-size"))-parseInt(steps)+"px");
		
		setCookie("steps",0);		
	}
	else if(value == "init" && getCookie("steps") && getCookie("steps") > 0){
		steps = getCookie("steps");		
		if (!steps) steps = 0;
		
		//Resize des Flashfilmes findet aufgrund der Ladereihenfolge in der htmlHeader.html.tpl statt		
		$("body").css("font-size",parseInt($("body").css("font-size"))+parseInt(steps)+"px");
	}
  }
	
});	

jQuery.fn.extend({

//tagCloud
  tagCloud: function(){
		$.each($(this).children("a"), function(key, value){
			$(value).css("position","relative");
			$(value).css("top",Math.round(Math.random()*5-2.5)+"px");
		});		
	}
});
