/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

jQuery(function($){

	/* Accordion menu */
	$('.menu-accordion').accordionMenu({ mode:'slide' });
	
	/* Follower */
	$('div.mod-line ul.menu').follower({effect: {transition: 'linear', duration: 200}})

	/* Smoothscroll */
	$('a[href="#page"]').smoothScroller({ duration: 500 });
      
    $(window).bind('load',function() {
	
		/* Dropdown menu */
		$('#menu').dropdownMenu({ mode: 'slide', dropdownSelector: 'div.dropdown', fancy:{ mode: 'move', duration: 500, transition: 'easeOutBack' } });
		
		/* Match height of div tags */
		$('div.topbox div.deepest').matchHeight(20);
		$('div.bottombox div.deepest').matchHeight(20);
		$('.content-wrapper-2, #contentleft, #contentright, #left, #right').matchHeight($(window).height()-40);
	
	});
	
	logo();	
	$(window).resize(function(){logo();});	
	
	
	$('.fade-effect').each(function(){
		
		var $background=$(this).css('background-image');		
		$(this).append('<span></span>');
		$(this).find('span').css('background-image',$background);

	
	});
	$('.fade-effect span').css({visibility:'visible'}).hide();
	$('.fade-effect').hover(function(){
		$(this).find('span').stop(true, true).fadeIn(1000);
	}, function(){
		$(this).find('span').stop(true, true).fadeOut(1000);
	});
	
	$('#contentright .deepest').each(function(){
		var $title=$(this).find('.header-3').text();
		
		if($title == ''){
			$(this).find('h3').hide();
		}
			
	});
	fadeLabel();
	function fadeLabel() {
        j = $;
        j('.jquery_form label').click(function() {
            j(this).next('input').focus();
        });
        
        var formItems = j('.jquery_form input[type="text"],.jquery_form input[type="url"],.jquery_form input[type="email"], .jquery_form textarea, .jquery_form input[type="password"], #searchform input[type="text"]');                           
        
        formItems.each(function(){
        	var label = j(this).prev('label');
        	
	        if(j(this).val()=="") label.show();
	        else  label.hide();

	        j(this)
	        .focus(function() {
					                
	            label.hide();
	            
	        })
	        .blur(function() {
	            if(j(this).val() == '') {            
	                var label = j(this).prev('label');
	                label.show();  
	             }
	        });
 
        });
        
    }
    
    $('#follow div').each(function(i,el){
      el = $(el);
      if(el.attr('data-url')){
        el.click(function(){
          window.open(el.attr('data-url'),'_blank');
        });
        el.css('cursor','pointer');
      }
    })

	
});


function logo() {
	var pos = jQuery('div.wrapper').offset();
	jQuery('#logo').offset({left:pos.left});
}


