//jquery.leafletPXL.js
//author: 			Bjoern Sellnau @ PIXELTEX
//project:			jQuery Plugin 'LeafletPXL'
//description:	this is the main js class for the 'Leaflet-Functionality'
//added:				14-08-2009
//modified:			21-08-2009
//version				0.10
//=====================================================

(function($){
	$.fn.leafletPXL = function(options)
	{
	
		var defaults = {
			url: '/leaflet/leaflet.cfm',
			iframeClass: 'leaflet_frame',
			language: 'de'
		};	
		var options = $.extend(defaults, options);
		$('.leaflet').data('leaflet_options', options);
		return this.each(function(){
			$('.'+options.iframeClass).append('<iframe src="'+options.url+'?lang='+options.language+'" style="display:none;" id="leaflet_frame" border="0" frameborder="0" framespacing="0" ALLOWTRANSPARENCY="true"></iframe>');		
		});
	
	};

	$.fn.leafletPXL.addItem=function(ITEM){
		var title = $(ITEM).attr('title');

		var id_type_print = $(ITEM).attr('rel');
		id_type_print = id_type_print.split(',');
		
		var id_type = id_type_print[0];	
		var printable = id_type_print[1].split(':');
		printable = printable[1];	
				
		var url = $(ITEM).attr('href');
		id_type = id_type.split(':');
		var type = id_type[0];
		var id = id_type[1];

		var options = $('.leaflet').data('leaflet_options');
		//window.console.log(options)

//		$('.'+$.fn.leafletPXL.options.iframeClass).attr('src',$.fn.leafletPXL.options.url+"?action=saveItem&amp;title="+title);
			//$('.'+options.iframeClass).append('<iframe id="leaflet_frame" border="0" frameborder="0" framespacing="0" ALLOWTRANSPARENCY="true"></iframe>');	
			$('.leaflet_frame').find(":nth-child(1)").attr('src',options.url+'?lang='+options.language+'&action=saveItem&title='+title+"&id="+id+"&type="+type+"&url="+url+"&print="+printable).slideDown('fast');
	}

})(jQuery);