// light specific js

function jFadeInit(){
	// jFade init
	jQuery(".post").jFade({
		trigger: "mouseover",
		property: 'background',
		start: 'ffffff',
		end: '27bdbe',
		steps: 8,
		duration: 8
	}).jFade({
		trigger: "mouseout",
		property: 'background',
		start: '27bdbe',
		end: 'ffffff',
		steps: 8,
		duration: 8
	});
	
}

jQuery(document).ready(function() {
	
	// setting the tabs in the sidebar hide and show, setting the current tab
		jQuery('div.tabbed div').hide();
		jQuery('div.t1').show();
		jQuery('div.tabbed ul.tabs li.t1 a').addClass('tab-current');

	// SIDEBAR TABS
	jQuery('div.tabbed ul li a').click(function(){
		var thisClass = this.className.slice(0,2);
		jQuery('div.tabbed div').hide();
		jQuery('div.' + thisClass).show();
		jQuery('div.tabbed ul.tabs li a').removeClass('tab-current');
		jQuery(this).addClass('tab-current');
	});
	
	jFadeInit();
	jQuery(".post").css({opacity: 0});
	jQuery(".post").fadeTo("slow", 1);
	
	var prevScroll = jQuery(document).scrollTop();
	jQuery(window).scroll(function() {
		/*var newScroll = jQuery(document).scrollTop();
		if(newScroll < prevScroll) {
			// Scrolled up
			if(jQuery(window).scrollTop()<160) {
				//alert('up');
				var logoPosition_up = jQuery('.logo-header').position();
				//alert(logoPosition_up.top);
				if (logoPosition_up.top > 101) {
					jQuery('.logo-header').animate({ 
								top: "-=20px",
							}, 0 );
				}
			} else {
				
			}
		} else {
			// Scrolled down
			if(jQuery(window).scrollTop()>=160) {
				//alert('down');
			} else {
				var logoPosition_down = jQuery('.logo-header').scrollTop();
				//alert(logoPosition_down);
				if (logoPosition_down < 20) {
					jQuery('.logo-header').animate({ 
								top: "+=20px",
							}, 0 );
				}
			}
		}
		prevScroll = newScroll;*/

		if(jQuery(window).scrollTop()>=160) {
			jQuery('#header-small').fadeIn('fast', function() {
				// Animation complete.
				
				//jQuery('#header-small-content').fadeIn('slow');
				jQuery('#header-small .logox').fadeIn('slow');
				jQuery('#header-small #menu-small').fadeIn('slow');
				jQuery('#header-small .logo').fadeIn('slow');
				jQuery('#header-small #top_link').fadeIn('slow');
				jQuery('#header .logo-header').fadeOut('slow');
				jQuery('#header #menu-large').fadeOut('slow');
				jQuery('#header .logo').fadeOut('slow');
			});
			
		} else {
			//jQuery('.logox').fadeOut();
			jQuery('#header-small .logox').fadeOut('fast', function() {
			//jQuery('#header-small-content').fadeOut('fast', function() {
				// Animation complete.
				jQuery('#header-small').fadeOut('fast', function() {
					//jQuery('#header-small #menu-small').fadeOut('slow');
					jQuery('#header .logo-header').fadeIn('fast');
					jQuery('#header .logo').fadeIn('fast');
					jQuery('#header #menu-large').fadeIn('fast');
				});
			});
			
		}

	});
	
});


// Función que comprueba si hay escrito en texto inicial en un input[text]
// Si está escrito, lo borra para que puedas escribir lo que quieras...
function checkForTextFocus(el, defaultText) {
	if (el.value == defaultText){
		el.value = '';
	}
}

// Función que comprueba si hay escrito en texto inicial en un input[text]
// Si está escrito, lo borra para que puedas escribir lo que quieras...
function checkForTextBlur(el, defaultText){
	if (el.value == ''){
		el.value = defaultText;
	}
}
