//skiforum (c) fiwo.sk 2011

$(document).ready(function() {
	
	
//  komentare
	$('#commentAddBoxShow').hide();  
	
	$('#commentAddBoxMoreButton').click(function() {
		
       	$('#commentAddBoxMoreButton').hide(); 	//hide text
       	$('#commentAddBoxMoreButton2').show(); 	//show text
       	$('#commentAddBoxMoreButton2').css('display', 'block'); 	//show text css

       	$('#commentAddBoxShow').slideDown(200); 	//show box
       	return false;
  	});	
  	
  	$('#commentAddBoxMoreButton2').click(function() {
		
       	$('#commentAddBoxMoreButton').show(); 	//hide text
       	$('#commentAddBoxMoreButton2').hide(); 	//show text
       	$('#commentAddBoxMoreButton').css('display', 'block'); 	//show text css

       	$('#commentAddBoxShow').slideUp(100); 	//show box
       	return false;
  	});	
  	
  	
  	
  

//form odrb predmet
	$('#addCommentSubj').click(function() {
		if($('#addCommentSubj').val()=='Predmet'){
			$('#addCommentSubj').val('');
			$('#addCommentSubj').css('color', '#666');
  			return false;
		}
  	});
	
//form odrb text
	$('#addCommentText').click(function() {
		if($('#addCommentText').val()=='Text spravy'){
			$('#addCommentText').val('');
			$('#addCommentText').css('color', '#666');
  			return false;
		}
  	});	

// ratrak popup
$('#addCommentPopup').hide();
$('#addCommentPopupAddFoto').hide();
$('#addCommentPopupNewResort').hide();

//priloha
	$('#addCommendAttachmentBtn').click(function() {
		$('#addCommentPopupAddFoto').show();
		$('#addCommentPopupNewResort').hide();
		$('#addCommentPopup').fadeIn(200);
  		return false;
  	});	
  	
//new resort  
	$('#addCommentNewResort').click(function() {
		$('#addCommentPopupAddFoto').hide();
		$('#addCommentPopupNewResort').show();
		$('#addCommentPopup').fadeIn(200);
  		return false;
  	});	
  	
  	
//zavri popup
	$('#addCommentPopupClose, #addCommentPopupAdd1, #addCommentPopupAdd2').click(function() {
		$('#addCommentPopup').fadeOut(200);
		$('#addCommentPopupAddFoto').hide();
		$('#addCommentPopupNewResort').hide();
  		return false;
  	});	
  	
 // zmen ikonku na prilohe
 $('#addCommentPopupAdd1, #addCommentPopupAdd2').click(function() {
		$('#addCommendAttachmentBtn img').attr("src", "img/priloha_ok.png");
  		return false;
  	});	
 

// popup upload img/  add gal link
	$('#addCommentPopupUpload').hide();
	$('#addCommentPopupLink').hide();

	//foto
	$('#addCommentPopupAddFotoSlider1').click(function() {
		$('#addCommentPopupUpload').show();
		$('#addCommentPopupLink').hide();
		$('#addCommentPopupAddFotoSlider1').addClass('active');
		$('#addCommentPopupAddFotoSlider2').removeClass('active');
		return false;
  	});	
	//picasa
	$('#addCommentPopupAddFotoSlider2').click(function() {
		$('#addCommentPopupUpload').hide();
		$('#addCommentPopupLink').show();
		$('#addCommentPopupAddFotoSlider2').addClass('active');
		$('#addCommentPopupAddFotoSlider1').removeClass('active');
		return false;
  	});	



//ajax loady login box

//newpass ->forumContent
	$("#newpass").click(function(){		
		$("#forumContent").fadeOut(100, function(){ 
			$("#forumPaginate").hide();
			$("#showMoreComments").hide();
			$("#forumContent").load("includes/login.php?login=newpass", function(){ 
				$("#forumContent").fadeIn(100);
				$("#errResetMail").hide();  
				
	
	});})});
	$("#register").click(function(){		
		$("#forumContent").fadeOut(100, function(){ 
			$("#forumPaginate").hide();
				$("#showMoreComments").hide();
			$("#forumContent").load("includes/login.php?login=register", function(){ 
				$("#forumContent").fadeIn(100);
				$("#errPass, #errNick, #errMail").hide();
	
	});})});



//  zmena hesla logged
	$("#loginBoxChangePass").click(function(){	
		$("#forumContent").fadeOut(100, function(){ 
			$("#forumPaginate").hide();
				$("#showMoreComments").hide();
			$("#forumContent").load("includes/login.php?login=changepass", function(){ 
				$("#forumContent").fadeIn(100);
				$("#errPass, #errNick").hide();
	
	});})});



// nick change facebook loginFbNickChange


	$("#loginFbNickChange").click(function(){	
		$("#forumContent").fadeOut(100, function(){ 
			$("#forumPaginate").hide();
				$("#showMoreComments").hide();
			$("#forumContent").load("includes/login.php?login=changenick", function(){ 
				$("#forumContent").fadeIn(100);
				$("#errNick").hide();
	
	});})});




$("#addCommentSend").click(function(){ 
		if($('#addCommentForum').val()==0){ 
			alert('Nevybral si tému!');
			return false;
		}else{
            if($('#addCommentText').val()=='' || $('#addCommentText').val()=='Text spravy' || $('#addCommentText').val()=='Text správy'){ alert('Nezadal si text správy'); return false;}else{
            return true;		
            }
		}
	});




// fancybox komentare
			$(".forumItemText a.thumb").fancybox({ 
				openEffect	: 'elastic',
				closeEffect	: 'elastic' 
			});
  
 
 // video iframe
	 	$(".videoIframe").fancybox({
		maxWidth	: 800,
		maxHeight	: 600,
		fitToView	: false,
		width		: '70%',
		height		: '70%',
		autoSize	: false,
		closeClick	: false, 
		openEffect	: 'elastic',
		closeEffect	: 'elastic'
	});
	

// fancybox komentare gallery
			$(".galBoxImgs a.show").fancybox({ 
				openEffect	: 'elastic',
				closeEffect	: 'elastic' 
			});
	
 
	/*
	$(".videoIframe").fancybox({
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.3,
		maxWidth	: 800,
		maxHeight	: 600,
		width		: '70%',
		height		: '70%'
	});
	*/
	
	

   	$("#addCommentForum").sexyCombo({
    		emptyText: "Vyber temu …",
    		autoFill: true,
    		skin: "custom"
    	});



	


//mini search

	$("#miniSearchTxt").click(function(){
		$(this).css('color','#666');
		if($(this).val()=='Hľadaj diskusiu')$(this).val('');
		
		});


 
	 
	$("#miniSearchTxt").autocomplete('includes/minisearch_ajax.php');


//galeria








}); //end document ready





//poll


$(function(){
	var loader=$('#loaderPoll');
	var pollcontainer=$('#pollcontainer');
	loader.fadeIn();
	//Load the poll form
	$.get('includes/poll_ajax.php', '', function(data, status){
		pollcontainer.html(data);
		pollcontainer.find('#viewresult').click(function(){
			//if user wants to see result
			loader.fadeIn();
			$.get('includes/poll_ajax.php', 'result=1', function(data,status){
				pollcontainer.fadeOut(100, function(){
					$(this).html(data);
					$(this).fadeIn(250);
				});
				loader.fadeOut(100);
			});
			//prevent default behavior
			return false;
		}).end()
		.find('#pollform').submit(function(){
			var selected_val=$(this).find('input[name=poll]:checked').val();
			if(selected_val!=''){
				//post data only if a value is selected
				loader.fadeIn();
				$.post('includes/poll_ajax.php', $(this).serialize(), function(data, status){
					$('#formcontainer').fadeOut(100, function(){
						$(this).html(data);
						$(this).fadeIn(250);
						loader.fadeOut(100);
					});
				});
			}
			//prevent form default behavior
			return false;
		});
		loader.fadeOut(100);
	});
	 
	
});


//top 20 resorts


$(function(){
	var loader=$('#top20resortsLoading');
	var topcontainer=$('#top20resortsContent');
	loader.fadeIn();
	//Load the top 20
		$.get('includes/topresorts_ajax.php', '', function(data, status){
		topcontainer.html(data); 
		loader.fadeOut(100);
	});
	 
	
});
















		
		
		
		
		
		

















