$(function(){
    $("input.hint").each(function(){
        var defaultText = $(this).val();
        $(this)
            .val(defaultText)
            .focus(function(){
        		$(this).addClass("active");
        		if ($(this).val() == defaultText){
        			$(this).val("");
        		}
        	})
        	.blur(function(){
        		if ($(this).val() == ""){
        			$(this).removeClass("active");
        			$(this).val(defaultText);
        		}
        	});
    })
    	
    	
});

$(document).ready(function() {
			$("#s_login #pass_txt").focus(function(){
                //chrome bug: when hide before show, element don't display
				$("#s_login #pass").show().focus();
                $(this).hide();
			});
            $("#s_reg #pass_txt").focus(function(){
                //chrome bug: when hide before show, element don't display
				$("#s_reg #pass").show().focus();
                $(this).hide();
			});
            
            
			$("#s_login #pass").blur(function(){
				if ($(this).val() == ""){
					$(this).hide();
					$("#s_login #pass_txt").show();
				}
			});
            $("#s_reg #pass").blur(function(){
				if ($(this).val() == ""){
					$(this).hide();
					$("#s_reg #pass_txt").show();
				}
			});
            
            
            $("#rpass_txt").focus(function(){
				$("#rpass").show().focus();
                $(this).hide();
			});
			$("#pass_txt_q").focus(function(){
				$("#pass_q").show().focus();
                $(this).hide();
			});
            
            
            $("#rpass").blur(function(){
				if ($(this).val() == ""){
					$(this).hide();
					$("#rpass_txt").show();
				}
			});
			$("#pass_q").blur(function(){
				if ($(this).val() == ""){
					$(this).hide();
					$("#pass_txt_q").show();
				}
			});
            
            ///
			
      $(".prev").attr("disabled", "disable");
      $(".prev").addClass("dis");
			$(".next").removeAttr("disabled");
			
			var show_li_qty;
			$(".next").click(function(){
  		   $(".v_arrow").hide();
			   $(this).attr("disabled", "disable");
			   $(".prev").removeAttr("disabled");
			   $(".prev").removeClass("dis");
			   shift_to_left = parseInt($(".stream_indent ul li").width()) + parseInt($(".stream_indent ul li").css("margin-right"));
			   $(".stream_indent ul").animate({"left": "-=" + shift_to_left + "px"}, "slow", function(){
			     if (Math.abs(parseInt($(this).css("left"))) >= (($(".stream_indent ul li").size() - show_li_qty) * shift_to_left)) {
			       $(".next").attr("disabled", "disable");
			       $(".next").addClass("dis");
			     }
			     else
			       $(".next").removeAttr("disabled");
         });
      });
      
      $(".prev").click(function(){
			   $(".v_arrow").hide();
			   $(this).attr("disabled", "disabled");
			   $(".next").removeAttr("disabled");
			   $(".next").removeClass("dis");
			   shift_to_left = parseInt($(".stream_indent ul li").width()) + parseInt($(".stream_indent ul li").css("margin-right"));
			   $(".stream_indent ul").animate({"left": "+=" + shift_to_left + "px"}, "slow", function(){
			     if (parseInt($(this).css("left")) >= 0) {
			       $(".prev").attr("disabled", "disable");
			       $(".prev").addClass("dis");
			     }
			     else
			       $(".prev").removeAttr("disabled");
         });
      });
            
      var delta = 0;
      var li_item_id;
			/*$("li").click(function(e){
			  $(".video_popup").hide();
			  $(".v_arrow").hide();
			  max_width = parseInt($("#index .live").css("max-width"));
			  diff_width = (($(window).width() - max_width) / 2) + 15;
			  if (diff_width < 0) diff_width = 0;
			  li_step = parseInt($(this).css("width")) + parseInt($(this).css("margin-right"));
			  rev_x = e.pageX - diff_width - parseInt($("#header .live .indent").css("padding-left"));
			  number_li = Math.floor(rev_x / li_step);
			  popup_left = diff_width + 200 + li_step*number_li + delta;
			  if (number_li < 2)
          $(".aleft").show();
        else{
          $(".aright").show();
          popup_left -= 457;
        }
			  li_item_id = $(this).attr("id");
			  $("#" + li_item_id + "p").css("left", popup_left + "px");
			  $("#" + li_item_id + "p").show();
			});*/

			/*$(".video_popup a.close").click(function(){
				$(this).parent("div").hide();
			});*/
			$("#index .top_nav p.p_login").hover(function(){
				$(".login_pass").show();
			});
			$(".login_pass a.close").click(function(){
				$(this).parent("div").hide();
			});
			/*$(".login_pass").mouseout(function(){
				$(this).hide();
			});*/
			
			$("#faq td.answer p.pager a.t_prev").hover(function(){
				$("#faq td.answer p.pager a.prev").toggleClass("press");
			});
			$("#faq td.answer p.pager a.t_next").hover(function(){
				$("#faq td.answer p.pager a.next").toggleClass("press");
			});
			
			function hideElements()
			{			 
			 if ($(window).width() <= parseInt($("#index .live").width())){
			   $("#header .live .indent").css("max-width", "970px");
			   $("#header .live .indent").css("min-width", "970px");
			   delta = 30 + (parseInt($("#index .live").width()) - 1200) / 2;
			   show_li_qty = 4;
       }
       else{
			   $("#header .live .indent").css("max-width", "1215px");
			   $("#header .live .indent").css("min-width", "1215px");
         delta = 0;
         show_li_qty = 5;        
       }
			 var in_width = $(".in").width();
			 var screens_all_img_width = 0;
			 var screens_img_margin_right = 0;
			 var list_img_width = 0;
       $(".screens img").each(function(i){
          screens_all_img_width += $(this).width();          
          list_img_width = screens_all_img_width + screens_img_margin_right;
          if (in_width < list_img_width)
            $(this).hide();
          else
            $(this).show();
          screens_img_margin_right += parseFloat($(this).css("margin-right").replace(/[^-\d\.]/g, ''));
       });
      }
      
     $(window).resize(function(){
        hideElements();
      }).load(hideElements);
      
		});
