$(document).ready(function(){
    
   /* $.ajax({
	type : "GET",
	url : "livetv.php",
	async : false,
	data : "ch=3",
	success : function(html){
	    $("#live_tv").html(html);
	}
    });
   */
    // $("#tbl_scorer tr:even").addClass("tbl_scorer_tr");
    var flag_twitter = "0";
    var flag_premier = "0";
    var flag_menu1 ="0";
    
        /*$(".techo_news img").each(function(i){
		
		var pos = $("#techo_img"+i).position();
		var height = $("#techo_img"+i).height();
		var width = $("#techo_img"+i).width()-9;
		var left = parseInt(pos.left);
		var top = parseInt(pos.top + height -23);
		var top2 = parseInt(pos.top + height);
		$("#hide_techno_news"+i).attr("style","filter:alpha(opacity=70);opacity:0.7;position:absolute;left:"+left+"px;top:"+top+"px;background-color:#000;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#ffffff");
		$("#hide_techno_news"+i).show();
		$("#news_desc_tech"+i).attr("style","position:absolute;left:"+left+"px;top:"+top2+"px;background-color:#feebeb;width:"+width+"px;height:50px;padding-left:10px;padding-top:7px;font-family:tahoma;font-size:0.8em;color:#000000")
			
		$("#techo_img"+i).mouseover(function(){
			 $(this).removeClass("img_news_remove");
			 $(this).addClass("img_news");
		});
		$("#techo_img"+i).mouseout(function(){
			 $(this).removeClass("img_news");
			 $(this).addClass("img_news_remove");
		});
	});
	*/
       
	$(".football_news img").each(function(i){
		var pos = $("#football_img"+i).position();
		var height = $("#football_img"+i).height();
		var width = $("#football_img"+i).width()-9;
		var left = parseInt(pos.left);
		var top = parseInt(pos.top + height -23);
		var top2 = parseInt(pos.top + height);
		$("#hide_football_news"+i).attr("style","filter:alpha(opacity=70);opacity:0.7;position:absolute;left:"+left+"px;top:"+top+"px;background-color:#000;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#fff");
		$("#hide_football_news"+i).show();
		$("#news_desc_ball"+i).attr("style","position:absolute;left:"+left+"px;top:"+top2+"px;background-color:#feebeb;width:"+width+"px;height:50px;padding-left:10px;padding-top:7px;font-family:tahoma;font-size:0.8em;color:#000000")
		    
		/*$("#football_img"+i).mouseover(function(){
			$(this).removeClass("img_news_remove");
			$(this).addClass("img_news");
		});
		$("#football_img"+i).mouseout(function(){
		    $(this).removeClass("img_news");
		    $(this).addClass("img_news_remove");
		});*/
	});

/*
    $(".techo_news img").each(function(i){
	
       $("#techo_img"+i).mouseover(function(){
            var pos = $(this).position();
            var height = $(this).height();
            var width = $(this).width()-9;
            var left = parseInt(pos.left);
            var top = parseInt(pos.top);
            //alert("left : "+pos.left +" top : "+ pos.top +" height : "+height+" width : "+width);
            $("#hide_techno_news"+i).attr("style","position:absolute;left:"+left+"px;top:"+top+"px;background-color:#60719E;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#fff");
            //$("#hide_techno_news"+i).attr("style","position:absolute;left:10px;top:181px");
            $("#hide_techno_news"+i).show();
            //$("#hide_techno_news"+i).fadeOut();
            //$("#hide_techno_news"+i).slideDown('fast');
            $(this).removeClass("img_news_remove");
            $(this).addClass("img_news");
            
        });
        $("#hide_techno_news"+i).mouseover(function(){
            var pos = $("#techo_img"+i).position();
            var height = $("#techo_img"+i).height();
            var width = $("#techo_img"+i).width()-9;
            var left = parseInt(pos.left);
            var top = parseInt(pos.top);
            //alert("left : "+pos.left +" top : "+ pos.top +" height : "+height+" width : "+width);
            $(this).attr("style","position:absolute;left:"+left+"px;top:"+top+"px;background-color:#60719E;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#fff");
            //$("#hide_techno_news"+i).attr("style","position:absolute;left:10px;top:181px");
            $(this).show();
            //$("#hide_techno_news"+i).fadeOut();
            //$("#hide_techno_news"+i).slideDown('fast');
            $("#techo_img"+i).removeClass("img_news_remove");
            $("#techo_img"+i).addClass("img_news");
        });

      
	$("#techo_img"+i).mouseout(function(){
            $(this).removeClass("img_news");
            $(this).addClass("img_news_remove");
            $("#hide_techno_news"+i).hide()
            $("#hide_techno_news"+i).removeAttr("style");
            $("#hide_techno_news"+i).attr("style","display:none");
        });
	$("#hide_techno_news"+i).mouseout(function(){
            $("#techo_img"+i).removeClass("img_news");
            $("#techo_img"+i).addClass("img_news_remove");
            $(this).hide()
            $(this).removeAttr("style");
            $(this).attr("style","display:none");
        });
       
    });

    $(".football_news img").each(function(i){
       $("#football_img"+i).mouseover(function(){
		    var pos = $(this).position();
		    var height = $(this).height();
		    var width = $(this).width()-9;
		    var left = parseInt(pos.left);
		    var top = parseInt(pos.top);
		    //alert("left : "+pos.left +" top : "+ pos.top +" height : "+height+" width : "+width);
		    $("#hide_football_news"+i).attr("style","position:absolute;left:"+left+"px;top:"+top+"px;background-color:#60719E;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#fff");
		    //$("#hide_techno_news"+i).attr("style","position:absolute;left:10px;top:181px");
		    $("#hide_football_news"+i).show();
		    //$("#hide_techno_news"+i).fadeOut();
		    //$("#hide_techno_news"+i).slideDown('fast');
		    $(this).removeClass("img_news_remove");
		    $(this).addClass("img_news");
 
        });
	$("#hide_football_news"+i).mouseover(function(){
		    var pos = $("#football_img"+i).position();
		    var height = $("#football_img"+i).height();
		    var width = $("#football_img"+i).width()-9;
		    var left = parseInt(pos.left);
		    var top = parseInt(pos.top);
		    //alert("left : "+pos.left +" top : "+ pos.top +" height : "+height+" width : "+width);
		    $(this).attr("style","position:absolute;left:"+left+"px;top:"+top+"px;background-color:#60719E;width:"+width+"px;height:25px;padding-left:10px;font-family:tahoma;font-size:1.0em;font-weight:bold;color:#fff");
		    //$("#hide_techno_news"+i).attr("style","position:absolute;left:10px;top:181px");
		    $(this).show();
		    //$("#hide_techno_news"+i).fadeOut();
		    //$("#hide_techno_news"+i).slideDown('fast');
		    $("#football_img"+i).removeClass("img_news_remove");
		    $("#football_img"+i).addClass("img_news");

	});
	
	$("#football_img"+i).mouseout(function(){
		//if (flag_football ==1 && flag_football_hide ==0)
		//{
		    $(this).removeClass("img_news");
		    $(this).addClass("img_news_remove");
		    $("#hide_football_news"+i).hide()
		    $("#hide_football_news"+i).removeAttr("style");
		    $("#hide_football_news"+i).attr("style","display:none");
		//}   
	});
	$("#hide_football_news"+i).mouseout(function(){
		//if (flag_football ==1 && flag_football_hide ==0)
		//{
		    $("#football_img"+i).removeClass("img_news");
		    $("#football_img"+i).addClass("img_news_remove");
		    $(this).hide()
		    $(this).removeAttr("style");
		    $(this).attr("style","display:none");
		//}   
	});
    });
    */
    var menu1_pos;
    $("#menu1").click(function(){
	if (flag_menu1 == 1)
	{
	    //alert("yyy");
	    $("#live_football").slideUp('slow');
	    $("#live_football").html("");
	    flag_menu1 = 0;
	}
	else
	{
	    
            menu1_pos = $("#menu1").position();
	    $("#live_football").css({
		"left" : menu1_pos.left,
		"top" : menu1_pos.top+25
	    });
	    

	    $.ajax({
		type : "POST",
		url : "live_football.php",
		async : false,
		data : "uid=xxxx123",
		success : function(html){
		    $("#live_football").html(html);
		}
	    });
	    //alert("xxx");
	    $("#live_football").slideDown('fast');
	    flag_menu1 = 1;
	}
    });
    
    var menu3_pos;
    var flag_get_detail = 0;
    $("#menu3").click(function(){
        //alert(flag_premier);

	if (flag_premier == 1 )
        {
             $("#football_table_show").slideUp('slow');
             flag_premier = 0;
        }
        else
        {
	   menu3_pos = $("#menu3").position();
	    $("#football_table_show").css({
		    "left": menu3_pos.left,
		    "top":menu3_pos.top+25
		});
	   $("#football_table_show").slideDown('slow');
	   if(flag_get_detail==0){
		$("#football_table_show").html("<img src='img/image_25182.gif'></img><b>&nbsp;Now loading</b>");
		setTimeout(function(){
		     $.ajax({
			 type : "POST",
			 url : "football_table.php",
			 data : "uid=12345",
			 async : false,
			 success : function(html)
			 {
			     $("#football_table_show").html("");
			     $("#football_table_show").html(html);
			     
			     flag_premier = 1;
			 }
		     });
		 },2000);
		flag_get_detail=1;
	   }
	   else
	   {
	     flag_premier = 1;
	   }
        }

    });
    
    var flag_twitter_menu;   
    $("#menu2").click(function(){
        //alert("xxx");
	//alert(f_t);
	flag_twitter_menu = $("#flag_twitter").val();
        if (flag_twitter_menu == "1")
        {
	    //alert(1);
            $("#twitter").hide('slow');
             $("#flag_twitter").val("0");
	     //$("#flag_twitter").val("0");
        }
        else
        {
            $("#twitter").show('slow');
              //flag_twitter = "1";
	      $("#flag_twitter").val("1");
            $("#friend_timeline").html("<img src='img/image_25182.gif'></img><b>&nbsp;Now loading</b>");
           var chk_authen = $("#f_tweet_authen").val();
            if (chk_authen != "")
            {
		var tweet_up1 = "";
                //tweet_up1 = escape(tweet_up1);
                //alert(tweet_up1);
                //$("#flag_twitter").val("1");
                //flag_twitter = "1";
		
		$.ajax({
		    type : "POST",
		    url : "twitterengine.php",
		    async : false,
		    data : "tweet_update="+tweet_up1,
		    success : function(html){
			$("#friend_timeline").html(html);
			Go();
			//############################################################
			function Go(){
			    setTimeout(function(){
				//alert(1);
				$("#friend_timeline").html("");
				
				$(".loading1").show();
				
				$.ajax({
				    type : "POST",
				    url : "twitterengine.php",
				    async : false,
				    data : "tweet_update="+tweet_up1,
				    success : function(html){
					    $("#friend_timeline").html(html);
					    $(".loading1").hide();
					    Go();
				    }
				});
			    },300000);
				
			}
			//############################################################
		    }
		});

            }
            else
            {
                $.ajax({
                   type : "POST",
                   url : "http://www.fdlite.com/football/start.php",
                   async : false,
                   data : "xxx=1",
                   success : function(html){
                        //alert(html);
                        $("#twitter").html(html);
    
                   }
                });
            }
           
        
        }

    });
    $("#sign_out").click(function(){
	        $.ajax({
                   type : "POST",
                   url : "http://www.fdlite.com/football/start.php",
                   async : false,
                   data : "xxx=1",
                   success : function(html){
                        //alert(html);
                        $("#twitter").html(html);
    
                   }
                });
    });

});