
/// ----------------------------
///   阿莫编写 -- 2006-05-10 
///   QQ : 48787479
/// ---------------------------- 

/// -- 变量定义

var xmlHttp;                      // XMLHttpRequest 对像
var requestMethod = "POST";       // 请求模式：GET、POST
var requestUrl    = "";           // 请求地址
var requestLength = 0;            // 请求长度
var requestValue  = "";           // 发送值
var returnValue   = "";           // 返回值
var returnText    = "";           // 返回文本
var returnXML     = "";           // 返回XML
var returnState;                  // 返回装态，有5个值：0 = 未初始化，2 = 已加载，3 = 交互中，4 = 完成
var returnStatus;                 // 返回服务器HTTP状态码（200对应OK，404对应 Not Found - 未找到）。
var returnStatusText;             // 返回服务器HTTP状态文本

var requesNetName = "";           // 文件名前段  server.aspx --> server + . + aspx
var requesNet     = "aspx";
var requesAsp     = "asp";
var requesJs      = "js";
var requesPhp     = "php";
var requesDot     = ".";         
var requesParams  = "?uid=153640"; // 绑定参数
var requesPs      = "?uid=153640";
var requesServerurl  = "1";

var urlBegin      = ""; // 绑定参数

var errorInfo     = "";           // 错误信息
var errorId       = "";           // 错误Id码
var errorBool     = false;        // 错误状态，出错时为 true;
var root_url      = "http://www.norshop99.cn/copyright/";

/// ----------------------------
///  创建XMLHttpRequest 对像
/// ---------------------------- 
function createXMLHttpRequest(){
	if (window.XMLHttpRequest){			
		xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function InitParams(){
	requestMethod = "POST";
	requestValue  = "";
}

/// ----------------------------
///  POST模式发送请求
///  ---------------------------
///  --- 调用方法 ---
///  requestMethod = "POST";
///  requestValue  = "";
///  requestUrl    = "web.aspx?page=1"
///  startRequest()
///  if (errorBool == false) {
///  输出.returnText;
///  输出.returnXML;
///  }
/// ---------------------------- 
function startRequest(u){
	try	{
		//requestMethod = "POST";
		//requestValue  = "";		

		if (requestUrl == "") {return false;}
		
		requestUrl = u + requestUrl + requesDot + requesNet + requesPs;
		
		createXMLHttpRequest(); // 创建对象
		xmlHttp.onreadystatechange = handleStateChange; // 获取值
		
		xmlHttp.open(requestMethod, requestUrl, false);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(requestValue);	// 发送值
	} catch(e){
		errorBool = true;
		errorInfo = e;
	}
}

function startRequestCopy(u){
	try	{
		//requestMethod = "POST";
		//requestValue  = "";		

		if (requestUrl == "") {return false;}
		
		requestUrl = u + requestUrl + requesDot + requesNet + requesParams;
		
		createXMLHttpRequest(); // 创建对象
		xmlHttp.onreadystatechange = handleStateChange; // 获取值
		
		xmlHttp.open(requestMethod, requestUrl, false);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(requestValue);	// 发送值
	} catch(e){
		errorBool = true;
		errorInfo = e;
	}
}

function startRequesthead(){
	try	{
		requestMethod = "POST";
		requestValue  = "";		

		if (requestUrl == "") {return false;}
		
		//requestUrl = u + requestUrl + requesDot + requesNet + requesParams;
		
		createXMLHttpRequest(); // 创建对象
		xmlHttp.onreadystatechange = handleStateChange; // 获取值
		
		xmlHttp.open(requestMethod, requestUrl, false);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(requestValue);	// 发送值
	} catch(e){
		errorBool = true;
		errorInfo = e;
	}
}

function startRequestUrl(){
	try	{
		//requestMethod = "POST";
		//requestValue  = "";		

		if (requestUrl == "") {return false;}
		
		requestUrl = urlBegin + requestUrl + requesDot + requesNet + requesServerurl;
		
		createXMLHttpRequest(); // 创建对象
		xmlHttp.onreadystatechange = handleStateChange; // 获取值
		
		xmlHttp.open(requestMethod, requestUrl, false);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(requestValue);	// 发送值
	} catch(e){
		errorBool = true;
		errorInfo = e;
	}
}

function startRequestServer(){
	requestMethod = "POST";
	requestValue  = "";
	requestUrl = requesNetName + requesDot + requesNet + requesParams; 
	startRequest();
}


/// ----------------------------
///  获取返回值/返回状态
/// ---------------------------- 
function handleStateChange()
{
	if (xmlHttp.readyState == 4)
	{
		if (xmlHttp.status == 200)
		{
			returnText = xmlHttp.responseText;
			returnXML = xmlHttp.responseXML;
			returnState = 4;
			returnStatus = 200;
		}
	}
}

function pl_init(){	
	requestUrl    = root_url + "EADKOSYDW." + requesAsp;
	startRequesthead();
	if (errorBool == false) {
		document.write('<div>'+returnText+'</div>');
	}
}

var flag=false;
function DrawImage(ImgD, num){
	var image=new Image();	
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= 1){
			if(image.width>num){ 
				ImgD.width=num;
				ImgD.height=(image.height*num)/image.width;
			}
			else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
		else{
			if(image.height>num){ 
				ImgD.height=num;
				ImgD.width=(image.width*num)/image.height; 
			}
			else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
	}
} 

function DrawImageMin(ImgD, num){
	var image=new Image();	
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= 1){
			if(image.width>num){ 
				ImgD.width=num;
				ImgD.height=(image.height*num)/image.width;
			}
			else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
		else{
			if(image.height>num){ 
				ImgD.height=num;
				ImgD.width=(image.width*num)/image.height; 
			}
			else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
	}
} 

