﻿function $(obj){return document.getElementById(obj);}

function AjaxPost(m,posturl,data,callback)
{
	var req=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
	data=data+"&m="+Math.random()
	if (m=="1"){
		req.open("POST",posturl,true);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.setRequestHeader("CharSet","GB2312");
		req.send(data);
	}else{
		req.open("GET",posturl+"?"+data,true);
		req.send(null);
	}
	req.onreadystatechange = function() {
		if (req.readyState == 4 && req.status == 200) {
			var reqtext=req.responseText;
			if(callback=="Art"){$("art_hits").innerHTML=reqtext;}
		}
	}	
}
function setHits(ID,aTy){
	AjaxPost(1,"/Hits.asp","Act=UpdateHits&ID="+ID,aTy);
}
var flag=false;
function DrawImage(ImgD,ImgW,ImgH){
	var image=new Image();
	var iwidth = ImgW;
	var iheight = ImgH;
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
	if(image.width/image.height>= iwidth/iheight){
		if(image.width>iwidth){  
		ImgD.width=iwidth;
		ImgD.height=(image.height*iwidth)/image.width;
		}else{
		ImgD.width=image.width;  
		ImgD.height=image.height;
		}
		}
	else{
		if(image.height>iheight){  
		ImgD.height=iheight;
		ImgD.width=(image.width*iheight)/image.height;		
		}else{
		ImgD.width=image.width;  
		ImgD.height=image.height;
		}
		}
	}
}