function html_entity_decode(str){
 var tarea=document.createElement('textarea');
 tarea.innerHTML = str; return tarea.value;
 tarea.parentNode.removeChild(tarea);
}

function weather(city) {
//$('#weather_container').html($('#weather_cities'+city).html());
//$('#weather_container').html("sad sd s");

//alert($('#weather_cities3').html());
$('#weather_container').html(html_entity_decode($('#weather_cities'+city).html()));

 $(".weather_wrap").jCarouselLite({
        btnNext: "#w_right",
        btnPrev: "#w_left",
		visible: 3,
		easing: "easeout",
		speed: 500,
		circular: false
    });
city_flash(city);
}

function kalendar(){
var tmp;
tmp =$("#kalendar_hidden").html();
 if ($.browser.webkit) {
$.post("/ajax/htmldecode", { "txt": tmp },
 function(data){
   $("#feature_cont").html(data);
 });   
  }else{
$("#feature_cont").html(html_entity_decode( $("#kalendar_hidden").html() ));	
  }
	
$("ul#submenu_links li").removeClass('active');
$("#kalendar_tab").addClass('active');
}

function hello(){
var tmp;
tmp =$("#hello_hidden").html();
 if ($.browser.webkit) {
$.post("/ajax/htmldecode", { "txt": tmp },
 function(data){
   $("#feature_cont").html(data);
 });   
  }else{
$("#feature_cont").html(html_entity_decode( $("#hello_hidden").html() ));	
  }

$("ul#submenu_links li").removeClass('active');
$("#hello_tab").addClass('active');



}

function coffee(){
var tmp;
tmp =$("#coffee_hidden").html();
 if ($.browser.webkit) {
$.post("/ajax/htmldecode", { "txt": tmp },
 function(data){
   $("#feature_cont").html(data);
 });   
  }else{
$("#feature_cont").html(html_entity_decode( $("#coffee_hidden").html() ));	
  }

$("ul#submenu_links li").removeClass('active');
$("#coffee_tab").addClass('active');
}

function sport(){
var tmp;
tmp =$("#sport_hidden").html();
 if ($.browser.webkit) {
$.post("/ajax/htmldecode", { "txt": tmp },
 function(data){
   $("#feature_cont").html(data);
 });   
  }else{
$("#feature_cont").html(html_entity_decode( $("#sport_hidden").html() ));	
  }
	
$("ul#submenu_links li").removeClass('active');
$("#sport_tab").addClass('active');

}

function eva(){
var tmp;
tmp =$("#eva_hidden").html();
 if ($.browser.webkit) {
$.post("/ajax/htmldecode", { "txt": tmp },
 function(data){
   $("#feature_cont").html(data);
 });   
  }else{
$("#feature_cont").html(html_entity_decode( $("#eva_hidden").html() ));	
  }
		
$("ul#submenu_links li").removeClass('active');
$("#eva_tab").addClass('active');
}



function tabs1() {
	
			$("#tab2, #tab3, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$("#tab1").addClass("active");
			
			$("#story1").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");
			
			$("#story2, #story3, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");	
			
		}
		
		
function tabs2() {	
							  					  
			$("#tab1, #tab3, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$("#tab2").addClass("active");
			
			$("#story2").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story3, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		}
		
function tabs3() {
								  
			$("#tab1, #tab2, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$("#tab3").addClass("active");
			
			$("#story3").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		}
		
function tabs4() {
								  
			$("#tab1, #tab2, #tab3, #tab5, #tab6, #tab7").removeClass("active");					  
			$("#tab4").addClass("active");
			
			$("#story4").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		}
		
function tabs5() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab6, #tab7").removeClass("active");					  
			$("#tab5").addClass("active");
			
			$("#story5").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		}
		
function tabs6() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab5, #tab7").removeClass("active");					  
			$("#tab6").addClass("active");
			
			$("#story6").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story5, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		} 
		
function tabs7() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab6, #tab5").removeClass("active");					  
			$("#tab7").addClass("active");
			
			$("#story7").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story5, #story6").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		} 


function getScrollY() {
    scrOfY = 0;
    if( typeof( window.pageYOffset ) == "number" ) {
        scrOfY = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        scrOfY = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        scrOfY = document.documentElement.scrollTop;
    }
    return scrOfY;
}

// emoticons

function emoticon(theSmilie)
{
    document.myForm.limitedtextarea.value += " " + theSmilie + " ";
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

$(document).ready(function() { 
//var onair=parseInt($("#onair").val());
//alert(onair);

	$("#accordion").accordion({
		autohight:false,
		animated: 'easeslide',
		active: parseInt($("#onair").val())
	});
	
    var upprev_closed = false;
    var upprev_hidden = true;
    $(window).scroll(function() {
        var lastScreen = (getScrollY() + $(window).height() + 900) < $(document).height() * 1 ? false : true;
        if (lastScreen && !upprev_closed) {
            $("#upprev_box").stop().animate({right:"0px"}, 200);
            upprev_hidden = false;
        }
        else if (upprev_closed && getScrollY() == 0) {
            upprev_closed = false;
        }
        else if (!upprev_hidden) {
            upprev_hidden = true;
            $("#upprev_box").stop().animate({right:"-400px"}, 200);
        }
    });
    $("#upprev_close").click(function() {
        $("#upprev_box").stop().animate({right:"-600px"}, 200);
        upprev_closed = true;
        upprev_hidden = true;
    });

//topBar show/hide
	$(".hide_cp").click(function() {
        $(".top_bar_holder").stop().animate({top:"-40px"}, { "duration": "slow", "easing": "easeout" });
		$("#outerwrap").stop().animate({top:"-40px"}, { "duration": "slow", "easing": "easeout" });
		$("#myFloating_reg").addClass("offscreen");	
		$("#show_cp").stop().animate({top:"130px"}, { "duration": "slow", "easing": "bouncein" });
		
		if(navigator.appName == "Microsoft Internet Explorer"){
			$("body").stop().animate({backgroundPositionY:'-40px'}, { "duration": "slow", "easing": "easeout" });
		}else{
			$("body").stop().animate({backgroundPosition:'center -40px'}, { "duration": "slow", "easing": "easeout" });
		}
		
    });
	$("#show_cp").click(function() {
		$("#show_cp").stop().animate({top:"0px"}, { "duration": "slow", "easing": "bounceout" });
        $(".top_bar_holder").stop().animate({top:"0px"}, { "duration": "slow", "easing": "easeout" });
		
		$("#outerwrap").stop().animate({top:"0px"}, { "duration": "slow", "easing": "easeout" });
		$("#myFloating_reg").addClass("offscreen");
		
		if(navigator.appName == "Microsoft Internet Explorer"){
			$("body").stop().animate({backgroundPositionY:'0px'}, { "duration": "slow", "easing": "easeout" });
		}else{
			$("body").stop().animate({backgroundPosition:'center 0px'}, { "duration": "slow", "easing": "easeout" });
		}
		
    });

// opacity changes for the reportages	
		$(".rep-over").css({
				opacity: 0
			});
		$(".rep-over").hover(function() {
			$(this).stop().animate({
				opacity: 1
				}, 300);
			},function() {
			$(this).stop().animate({
				opacity: 0
				}, 300);
		});

//carousel news gallery pics




//carousel novaPlay
$(function() {
    $("#novaplay").jCarouselLite({
        btnNext: "#novaplay_right",
        btnPrev:  "#novaplay_left", 
		easing: "easeout",
		speed: 500,
		circular: false
   });
});


$(function() {
    $("#show_news").jCarouselLite({
        btnNext: "#show_news_right", 
        btnPrev: "#show_news_left",
		easing: "easeout",
		speed: 500,
		circular: false
   });
});


$(function() {
    $("#comming_soon").jCarouselLite({
        btnNext: "#comming_soon_right", 
        btnPrev: "#comming_soon_left",
		easing: "easeout",
		speed: 500,
		circular: false
   });
});

//weather days carousel
$(function() {
    $(".weather_wrap").jCarouselLite({
        btnNext: "#w_right",
        btnPrev: "#w_left",
		visible: 3,
		easing: "easeout",
		speed: 500,
		circular: false
    });
});





			
 // opacity changes
		$(".focus_news_img").css({
				opacity: 1
			});
		$(".focus_news_img").hover(function() {
			$(this).stop().animate({
				opacity: 0.8
				}, 300);
			},function() {
			$(this).stop().animate({
				opacity: 1
				}, 500);
		});
		
		$("#upprev_box").css({
				opacity: 0.9
			});
		$("#upprev_box").hover(function() {
			$(this).stop().animate({
				opacity: 1
				}, 300);
			},function() {
			$(this).stop().animate({
				opacity: 0.9
				}, 500);
		});
		
 // opacity changes for the small pics of the main news		
		$(".pic-over").css({
				opacity: 0
			});
		$(".pic-over").hover(function() {
			$(this).stop().animate({
				opacity: 1
				}, 300);
			},function() {
			$(this).stop().animate({
				opacity: 0
				}, 300);
		});
	

//accent function
		
		/*$("#tab1").hover(function() {
	
			$("#tab2, #tab3, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story1").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");
			
			$("#story2, #story3, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");	
			
		});
		
		
		$("#tab2").hover(function() {	
							  					  
			$("#tab1, #tab3, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story2").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story3, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});
		
		$("#tab3").hover(function() {
								  
			$("#tab1, #tab2, #tab4, #tab5, #tab6, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story3").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story4, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});
		
		$("#tab4").hover(function() {
								  
			$("#tab1, #tab2, #tab3, #tab5, #tab6, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story4").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story5, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});
		
		$("#tab5").hover(function() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab6, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story5").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story6, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});
		
		$("#tab6").hover(function() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab5, #tab7").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story6").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story5, #story7").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});
		
		$("#tab7").hover(function() {
								  
			$("#tab1, #tab2, #tab3, #tab4, #tab6, #tab5").removeClass("active");					  
			$(this).addClass("active");
			
			$("#story7").stop().animate({					
				opacity: 1
			}, 800).css("z-index", "1");

			$("#story1, #story2, #story3, #story4, #story5, #story6").stop().animate({				
				opacity: 0
			}, 800).css("z-index", "-1");
	
		});*/


// floating login box
	
    $("#login_btn").click(function () { 
        $("#myFloating_reg").removeClass("offscreen");

		if($.browser.msie){
			
  		  $("#myFloating_reg").css({	
				filter:alpha(opacity=0)
		});
		
		
		$("#myFloating_reg").stop().animate({	
				filter:alpha(opacity=100)
		},500);
			
   		}else{
			
   		  $("#myFloating_reg").css({
				opacity:0	
			});

		$("#myFloating_reg").stop().animate({
				opacity:1		
		},500);	
  		 }

		
    });
	 $("#outerwrap").click(function(){
	    $("#myFloating_reg").addClass("offscreen");			
 	});
	 
	 $("#close_reg_form").click(function () {
		$("#myFloating_reg").addClass("offscreen");										  
	});
	 
// TWITTER FEED!

$(".tweet").tweet({
    join_text: "auto",
    username: ["novatv_bg", "Az_Obicham_BG"],
    count: 1,
    auto_join_text_default: "Novatv_bg:", 
    auto_join_text_ed: "Ние",
    auto_join_text_ing: "Бяхме",
    auto_join_text_reply: "Отговорихме",
    auto_join_text_url: "Разглеждахме",
    loading_text: "Зареждане..."
});

	 


// carousel

	
	
	// sliding Boxes captions

	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	//Vertical Sliding
	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	//Horizontal Sliding
	$('.boxgrid.slideright').hover(function(){
		$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
	});
	//Diagnal Sliding
	$('.boxgrid.thecombo').hover(function(){
		$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
	});
	//Partial Sliding (Only show some of background)
	$('.boxgrid.peek').hover(function(){
		$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	});
	//Full Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});
	});
	//Caption Sliding (Partially Hidden to Visible)
	$('.thumb_holder2').hover(function(){
		$(".cover", this).stop().animate({top:'65px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'80px'},{queue:false,duration:160});
	});
	//MOST POPULAR
	$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});
	
	//Caption Sliding Schedule!
	$(".black_screen").css({
		opacity: 0
	});
	$('.current_show').hover(function(){
		$(".cover", this).stop().animate({top:'290px'},{queue:false,duration:150});
		
		$('.black_screen').stop().animate({
				opacity: 0.3
				}, 300);
		
	}, function() {
		$(".cover", this).stop().animate({top:'307px'},{queue:false,duration:150});
		
		$('.black_screen').stop().animate({
				opacity: 0
				}, 300);
		
	});

	
	 
});


$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});

//news from nova play home
$(function() {
    $(".carousel_main").jCarouselLite({
        btnNext: "#a_right",
        btnPrev: "#a_left",
		visible: 6,
		easing: "easeout",
		speed: 500
    });
});

//news from shows home
$(function() {
    $(".carousel_news").jCarouselLite({
        btnNext: "#s_right",
        btnPrev: "#s_left",
		visible: 6,
		easing: "easeout",
		speed: 500
    });
});
