﻿function DrawImage(MyPic, W, H) {
    var flag = false;
    var image = new Image();
    image.src = MyPic.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= W / H) {
            if (image.width > W) {
                MyPic.width = W;
                MyPic.height = (image.height * W) / image.width;
            }
            else {
                MyPic.width = image.width;
                MyPic.height = image.height;
            }
        }
        else {
            if (image.height > H) {
                MyPic.height = H;
                MyPic.width = (image.width * H) / image.height;
            }
            else {
                MyPic.width = image.width;
                MyPic.height = image.height;
            }
        }
    }
}

function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=$('#'+name+i);
		var con=$("#con_"+name+"_"+i);
		menu[0].className=i==cursel?"hover":"";
		con[0].style.display=i==cursel?"block":"none";
	}
}

$(document).ready
(
	function()
	{
		$.ajax
		(
			{
				type: "get",
				cache:false,
				url:"?act=loadhits",
				timeout:20000,
				error:function(){$("#hits").html("0");},
				success:function(_){$("#hits").html(_+" ");}
			}
		)
		
		$(".down").click
		(
			 function()
			 {
				$.ajax
					(
						{
							type: "get",
							cache:false,
							url:"./?act=addhits",
							timeout:20000,
							error:function(){},
							success:function(_){}
						}
					) 
			 }
		);
		
	}
)
