
Cufon.replace('.top_menu, .top_menu_index, .f16, .time',{fontFamily: 'PF Square Sans Pro'} );
Cufon.replace('.main_title, .index_title, .watch_title, .siandien, .footer_now, .contact_headers, .s_date, .laida_title, .censor, .dienos, .bendraukime',{fontFamily: 'PF Square Sans Pro Light'} );

          (function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/lt_LT/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
        
		$(function(){
		$("input, textarea, select").uniform();
		});	  
	  
        $(function() {
        var d = new Date();
		

	function getUrlVars()
		{
			var vars = [], hash;
			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
			for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
		}
			
		var cat_  =  getUrlVars()["category"];
		if (cat_){ var nowt = 24 - 0; } else{ var nowt = 24 - d.getHours(); 
		//var d = new Date();            
        hideelement(d.getHours());
		}

		
		$( "#slider-vertical" ).slider({
			orientation: "vertical",
                        range: "max",
			min: 0,
			max: 18,
                        value: nowt,
			slide: function( event, ui ) {
                            valanda = 24 - ui.value;
                            $( "#amount" ).val( valanda + "val. rodo");
							
                            hideelement(valanda);
			}
		});
		$( "#amount" ).val($( "#slider-vertical" ).slider( "value" ) + "val rodo:" );
		});
	
	  	function validate(formData, jqForm, options) { 
        	for (var i=0; i < formData.length; i++) { 
                if (!formData[i].value) { 
                	alert (errors['all']);                     
                    return false; 
                } 
            } 
        }   
        
        function processJson(data) { 
            if (data.error) alert (errors[data.error]);
            else if (data.success) { 
            alert ('Priminimas sėkmingai įrašytas.');
             $('#popup_priminti').hide();
             $('.social_icons').show();
            } else  alert (errors.unknown);
        }
		

		hideelement = function(tm){
			var filmai = $(".col_box");  
				filmai.each(function(){
				var sltime = $(this).attr('id');
				sltime =  sltime.substr(3,10);    
				if (sltime < tm){
					$(this).slideUp(500);
				}
                                else{
					$(this).slideDown(500);
				}
			});
		}    

	
$(document).ready(function(){

	$("#imgwr").height($("#wraper").height());

            start_height = 650//$(window).height(); 
            doc_height = $(window).height();
            if (doc_height > 600){
                new_h=  doc_height * 1000 / start_height;
                $("#pic").height(new_h);
            }
            /*else {
                start_height500 = 800//$(window).height(); 
                new_h=  doc_height * 1000 / start_height500;
                $("#pic").height(new_h);
            }*/
                  
            $(window).resize(function() {
            start_height = 700//$(window).height(); 
            doc_height = $(window).height();
            if (doc_height > 700){
                new_h=  doc_height * 1000 / start_height;
                $("#pic").height(new_h);
            }   
    });
	
	
    $('#popup_priminti').draggable();

    $('#close').click (function(){
        $('#overlay').remove();
        $('#popup_priminti').hide();
        $('.social_icons').show(); 
    });     

    $('#opener').click (function(){
        $('.social_icons').hide();    
        $('#popup_priminti').show();
        //$("<div id='overlay'></div>").appendTo('body');
    });

    $('input[type="text"]').focus(function() {
    if (this.value == this.defaultValue){
    this.value = '';
    }
    if(this.value != this.defaultValue){
    this.select();
    }
    });
    
    $('input[type="text"]').blur(function() {
    if ((this.value == '')){
    this.value = (this.defaultValue ? this.defaultValue : '');
    }
    });
    
        var status = false;

        $("#LAIDOS").click(function () {      
            $("#tooltip_FILMAI,#tooltip_SERIALAI").fadeOut(0, function(){status = false;});  
            $("#tooltip_LAIDOS").fadeIn(500, function(){status = true;});            
            
        });
	$("#FILMAI").click(function () {      
            $("#tooltip_LAIDOS,#tooltip_SERIALAI").fadeOut(0, function(){status = false;});  
            $("#tooltip_FILMAI").fadeIn(500, function(){status = true;});            
        });
        $("#SERIALAI").click(function () {      
            $("#tooltip_SERIALAI").fadeIn(500, function(){status = true;});
            $("#tooltip_LAIDOS,#tooltip_FILMAI").fadeOut(0, function(){status = false;});             
        });

         $("#wraper,#wraper_next").click(function () { 
            if (status){
            $("#tooltip_LAIDOS,#tooltip_FILMAI,#tooltip_SERIALAI").fadeOut(500); 
            status = false;
          }
        });

				
		$('.dienos').each(function(){
		var date_id = $(this).attr('class').split(' ').slice(-1); 
		$('#'+date_id).parent().addClass('active');
		});

		
 });
