/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		$("body").append("<p id='preview'><img class='vorschau' src='"+ this.id +"' alt='"+this.id+"' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
	$("a.menue_unten").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		$("body").append("<div id='preview'><img class='link_vorschau' src='grafik/"+ this.id +"' alt='"+this.id+"' />"+ c +"</div>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.menue_unten").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
		
	
};

/*
jQuery.preloadImages = function()
{
        for(var i = 0; i<arguments.length; i++)
        {
                jQuery("<img>").attr("src", arguments[i]);
        }
}
*/

function unhideDivsAfterImageonload ($id) {
	document.getElementById($id).style.visibility = "visible";
} 

function changeImage ($id, $titel, $aktion) {
   if (document.getElementById("grossBild").src != "http://www.margitmeister.de/" + $id) {
  
  	 $('#divGBild').animate({ opacity: 0.0 }, 200, function() {  
  	    document.getElementById("grossBild").src = $id;
  	    document.getElementById("titel").innerHTML = $titel;
  	    document.getElementById("grossBild").name=document.getElementById($id).name;
  	 	$('#divGBild').animate({ opacity: 1.0 }, 700, function() {
    	// Animation complete. 
    	});
  	 });
  
	}
} 


function nextImage(bildArray){
	aktBild=document.getElementById("grossBild").name;
	if (aktBild < anzBilder-1) {
		aktBild++;
	} else {;
		aktBild=0;
	}
	$('#divGBild').animate({ opacity: 0.0 }, 000, function() {
		document.getElementById("grossBild").src=bildArray[aktBild];
  	    document.getElementById("titel").innerHTML = bildUnter[aktBild]; 
  	    document.getElementById("grossBild").name=aktBild;
		$('#divGBild').animate({ opacity: 1.0 }, 000, function() {
    	// Animation complete. 
    });
	});
}



(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
