/**
 * imgnotes jQuery plugin
 * version 0.1
 *
 * Copyright (c) 2008 Dr. Tarique Sani <tarique@sanisoft.com>
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * @URL      http://www.sanisoft.com/blog/2008/05/26/img-notes-jquery-plugin/
 * @Example  example.html
 *
 **/

//Wrap in a closure
(function($) {

	$.fn.imgNotes = function(n, notes) {
	
		if(undefined != n){
			notes = n;
		} 
	
		imgOffset = $(this).offset();
		//alert($(this).attr('src'))
		//$(notes).each(function(){
		appendnote(this, notes);
		//});	
	
		$(this).hover(
			function(){
				$('.note').show();
			},
			function(){
				$('.note').hide();
			}
		);
	
		$('.note').hover(
			function(){
				$('.note').show();
				$(this).next('.notep').show();
				$(this).css("z-index", 10000);
			},
			function(){
				$('.note').show();
				$(this).next('.notep').hide();
				$(this).css("z-index", 0);
			}
		);
	} 
	
	function appendnote(img, note_data){
		
		note_left  = parseInt(note_data.x1) + 466; //parseInt(imgOffset.left) //
		note_top   =  parseInt(note_data.y1) ;//parseInt(imgOffset.top)//
		
		
		note_area_div = $("<div class='note'></div>").css({ left: note_left + 'px', top: note_top + 'px', width: note_data.width + 'px', height: note_data.height + 'px' });
		
	
	
		img.after(note_area_div);
	}

// End the closure
})(jQuery);