/*
 * Plugin: link selector
 */
(function(jQuery){  
	
	jQuery.fn.extend({
		yagendoo_dropdown: function() {			
			
			return this.each(function(i) {
				
				var el = jQuery(this);
				var head = jQuery(this).find('.yagendoo_dropdown_active');
				var body = jQuery(this).find('.yagendoo_dropdown_body');
				body.find('a').wrapAll('<div class="yagendoo_dropdown_body_scroller"></div>');
				var scroller = body.find('.yagendoo_dropdown_body_scroller');
				scroller.css({'overflow-y':'auto'});
				scroller.css({'overflow-x':'hidden'});
				
				el.hover(function(){
					body.fadeIn(300);
					head.css('background-position','bottom left');
				},function(){
					body.fadeOut(300);
					head.css('background-position','top left');
				});
				
				
				jQuery(this).find('a[rel!=""]').each(function(){
					var a = jQuery(this);
					
					a.hover(function(){
						el.append('<div class="yagendoo_dropdown_preview" style="display:none;"><div style="position:relative;"><span>'+a.html()+'</span><img src="'+a.attr('rel')+'" alt="" /></div></div>');
						el.find('.yagendoo_dropdown_preview').show();
					},function(){
						el.find('.yagendoo_dropdown_preview').remove();
					});
					
					
				});
				
			
			});
		}  
	});         
 })(jQuery);



jQuery(document).ready(function(){
	jQuery('body').append('<iframe id="yagendoo_demo_frame" scrolling="auto" frameborder="0" src="'+yagendoo_template+'"></iframe>');
	
	jQuery(window).resize(function() {
		var w = parseInt(jQuery('html').width());
		var h = parseInt(jQuery('html').height());
		
		

		var t = parseInt(jQuery('#yagendoo_demochooser_wrapper').height());
		var f = jQuery('#yagendoo_demo_frame');
	
	
		f.css('width',w);
		f.css('height',(h-t));
		
	});
	
	jQuery(window).trigger('resize');
	
	
	jQuery('.yagendoo_dropdown').yagendoo_dropdown();
	
});
