// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

//-END------------------------------------------- 



$(document).ready(function(){
  
  //-------------------------------------------- 
  // ADD PANEL
  //-------------------------------------------- 
	$(".addvid_open").click(function(){
    $("#addpanel").animate({ left: "4.7em", opacity: 'show' }, 500);
  
	});
	
	$(".addvid_close").click(function(){
    $("#addpanel").animate({ left: 0, opacity: 'hide' }, 500);
    $("#addpanel_rules").animate({ left: "10em", width: "2em", opacity: 'hide' }, 700);
	});
	
	
  //-------------------------------------------- 	 
  // RULES POPUP 
  //-------------------------------------------- 
	$(".addvideo_rules").toggle(function(){
    $("#addpanel_rules").animate({ left: "20.7em", width: "34em", opacity: 'show' }, 700);
    }, function() {
	  $("#addpanel_rules").animate({ left: "20.7em", width: "0em", opacity: 'hide' }, 700);
	}); 

  //-------------------------------------------- 
  // RULES POPUP 
  //-------------------------------------------- 
	$(".about_open").toggle(function(){
    $("#about").animate({  opacity: 'show' }, 700);
    }, function() {
	  $("#about").animate({ opacity: 'hide' }, 700);
	}); 

  //-------------------------------------------- 
  // CLICK DIV
  //-------------------------------------------- 
	$("#about").click(function(){
	  	$("#about").animate({ opacity: 'hide' }, 700);
	});

              
  //--------------------------------------------              
  // HOVER IMGS 
  //--------------------------------------------   


  $(".item .img_cont").hover(function() {
  		$(this).find('.item_info').animate({opacity: "show", top: "12em"}, "slow", 'easeOutCubic');
  	}, function() {
  		$(this).find('.item_info').animate({opacity: "hide", top: "14em"}, "fast", 'easeOutCubic');
  });

});




//--------------------------------------------
// INPUT SUGGEST SCRIPT ON STATE
//--------------------------------------------

$(function(){ 
	$('input:text').hint();
});
// INPUT SUGGEST PLUGIN
jQuery.fn.hint = function () {
  return this.each(function (){
    // get jQuery version of 'this'
    var t = jQuery(this); 
    // get it once since it won't change
    var title = t.attr('title'); 
    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      t.blur(function (){
        if (t.val() == '') {
          t.val(title);
          t.addClass('blur');
        }
      });
      // on focus, set value to blank if current value 
      // matches title attr
      t.focus(function (){
        if (t.val() == title) {
          t.val('');
          t.removeClass('blur');
        }
      });

      // clear the pre-defined text when form is submitted
      t.parents('form:first()').submit(function(){
          if (t.val() == title) {
              t.val('');
              t.removeClass('blur');
          }
      });

      // now change all inputs to title
      t.blur();
    }
  });
}


//---------------------------------
// Items Scale
//---------------------------------


// initialize the jquery code
 $(document).ready(function(){
// changer links when clicked
$("a.changer").click(function(){
//set the div with class mainText as a var called $mainText 
var $mainText = $('div.item');
// set the current font size of .mainText as a var called currentSize
var currentSize = $mainText.css('font-size');
// parse the number value out of the font size value, set as a var called 'num'
var num = parseFloat(currentSize, 10);
// make sure current size is 2 digit number, save as var called 'unit'
var unit = currentSize.slice(-2);
// javascript lets us choose which link was clicked, by ID
if (this.id == 'linkLarge'){
num = num * 1.2;
} else if (this.id == 'linkSmall'){
num = num / 1.2;
} else if (this.id == 'linknormal'){
num = 16;
}
// jQuery lets us set the font Size value of the mainText div
$mainText.css('font-size', num + unit);
   return false;
});

});


//---------------------------------
// Functions Fade
//---------------------------------

var timer=0;
$(document).ready(function(){
  $(".img_cont img").each(
    function(){
      timer+=500;
      var $el=$(this);
      var delayFunc=delayLoad($el,timer);
    }
  );
});
function delayLoad($el, time){
    window.setTimeout( function(){
            $el[0].onload= function(){$el.fadeIn(2000);};
            $el.attr('src', $el.attr('srctmp'));
            },time);
}
