$(document).ready(function() {
	
		$("#contact-form").validate();

		
		//smoothscroll
		$('#top-link').click(function(e) {
			e.preventDefault();
			$.scrollTo(0,300);
		});
		
		$('.vid-link').click(function(e) {
			e.preventDefault();
			$.scrollTo(224,300);
		});

		
		
	    var hide = false;
		
        //photos
		$("#nav li a.photos").hover(function(){
			  if (hide) clearTimeout(hide);
			$("ul#nav-1").slideDown(800);
			}, function() {
			hide = setTimeout(function() {$("ul#nav-1").delay(100).fadeOut(200);});
		});

		$("ul#nav-1").hover(function(){
			  if (hide) clearTimeout(hide);
			}, function() {
			hide = setTimeout(function() {$("ul#nav-1").delay(100).fadeOut(200);});
		});
		
        //about
		$("#nav li a.about").hover(function(){
			  if (hide) clearTimeout(hide);
			$("ul#nav-2").slideDown(800);
			}, function() {
			hide = setTimeout(function() {$("ul#nav-2").delay(100).fadeOut(200);});
		});

		$("ul#nav-2").hover(function(){
			  if (hide) clearTimeout(hide);
			}, function() {
			hide = setTimeout(function() {$("ul#nav-2").delay(100).fadeOut(200);});
		});
		
		
		
		
		//Default Action
	    $(".tab_content").hide(); //Hide all content
	    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
	    $(".tab_content:first").show(); //Show first tab content
	
	    //On Click Event
	    $("ul.tabs li").click(function() {
		 $("ul.tabs li").removeClass("active"); //Remove any "active" class
		 $(this).addClass("active"); //Add "active" class to selected tab
		 $(".tab_content").hide(); //Hide all tab content
		 var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		 $(activeTab).fadeIn(); //Fade in the active content
		 return false;
	    });
		
		
		
		
		
		//Default Action for Video
	    $(".featured-video").hide(); //Hide all content
	    $("ul.list li:first").addClass("active").show(); //Activate first tab
	    $(".featured-video:first").show(); //Show first tab content
	
	    //On Click Event for Video
	    $("ul.list li").click(function() {
		 $("ul.list li").removeClass("active"); //Remove any "active" class
		 $(this).addClass("active"); //Add "active" class to selected tab
		 $(".featured-video").hide(); //Hide all tab content
		 var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		 $(activeTab).fadeIn(); //Fade in the active content
		 return false;
	    });
		
		
		
		
		//ajax load for videos
		
		//ATFL
		$.ajax({
          url: "vids/vid-01.html",
          cache: false,
          success: function(html){
          $("#vid1").append(html);
         }
        });
		
		//GSGR
		$.ajax({
          url: "vids/vid-02.html",
          cache: false,
          success: function(html){
          $("#vid2").append(html);
         }
        });
		
		//SAGU
		$.ajax({
          url: "vids/vid-03.html",
          cache: false,
          success: function(html){
          $("#vid3").append(html);
         }
        });
		
		//ELOW
		$.ajax({
          url: "vids/vid-04.html",
          cache: false,
          success: function(html){
          $("#vid4").append(html);
         }
        });
		
		//BUOW
		$.ajax({
          url: "vids/vid-05.html",
          cache: false,
          success: function(html){
          $("#vid5").append(html);
         }
        });


		
		
	    // The values below will overwrite the ones on the Juitter default configuration. 
	    $.Juitter.start({
		 searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
		 searchObject:"piranga", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.
		 lang:"en", // restricts the search by the given language
		 live:"live-15", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
		 placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
		 loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
		 imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
		 total: 5, // number of tweets to be show - max 100
		 readMore: "Read on Twitter", // read more message to be show after the tweet content
		 nameUser:"image", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
		 filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
	    });

        $("#juitterSearch").submit(function(){
		$.Juitter.start({
			searchType:"searchWord",
			searchObject:$(".juitterSearch").val(),
			live:"live-20", // it will be updated every 180 seconds/3 minutes
			filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"
		});
        return false;
	    });
        $(".juitterSearch").blur(function(){
            if($(this).val()=="") $(this).val("Type a word and press enter");
        });
        $(".juitterSearch").click(function(){
            if($(this).val()=="Type a word and press enter") $(this).val("");
        });
		
});

$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'random',
		slices:15,
		animSpeed:500,
		pauseTime:5000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		controlNav:true //1,2,3...
	});
});


jQuery.fn.topLink = function(settings) {
		settings = jQuery.extend({
			ieOffset: 50
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = $(this);
			$(window).scroll(function() {
				if(!jQuery.support.hrefNormalized) {
					el.css({
						'position': 'relative',
						'top': $(window).scrollTop() + $(window).height() - settings.ieOffset
					});
				}
				if($(window).scrollTop() >= settings.min)
				{
					el.fadeIn(settings.fadeSpeed);
				}
				else
				{
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};
