﻿CODE:/**
* @author skyzhw
* @filename HttpRequest.class.js
* @function javascript client ajax dealwith
* @datetime 2006-3-20
*/
/* 
* Function: Create a httpRequest object
*/ 
function $$(id)
{
	var objvalue;
	objvalue = document.getElementById(id);
	return objvalue;
	}
function HttpRequest(){
this._httpRequest=null; //HttpRequest request object
this._callBack=null; //Call back function
this._domResult=true; //Result if dom object or text string
this._requestData=null; //Request data
this._requestResult=null; //HttpRequest result
this._stateString=null; //Current request state string
this._error=false; //Current if have error
this._callBackPara=null; //Current callback function parama
//internal method for get HttpRequestObject
this.init=function(){
//Judge if Not IE
if(window.XMLHttpRequest){
this._httpRequest=new XMLHttpRequest();
//Set request mime is text/xml
if(this._httpRequest.overrideMimeType){
this._httpRequest.overrideMimeType('text/xml');
}
}else if(window.ActiveXObject){
try{
this._httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
}catch(ex){
try{
this._httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}catch(ex){
this._setMessage(ex,true);
return;
}
}
}
//Judge HttpRequest object create successful
if(!this._httpRequest){
this._setMessage("HttpRequest object create fail!Please try again......",true);
return;
} 
}
/* 
* Function: Set the request header
* namePar:request's header name
* valuePar:request's header value
*/
this.doSetRequestHeader=function(namePar,valuePar){
if(this._error){
return;
}
this._httpRequest.setRequestHeader(namePar,valuePar);
}
/* 
* Function: Set the request data
* dataPar:request's send data;
*/
this.doSetRequestData=function(dataPar){
if(this._error){
return;
}
this._requestData=dataPar;
}
/*
*Function get RequestHttp Object
*/
this._getRequestObj=function(){
if(this._error){
return;
}
return this._httpRequest;
}
/*
* Function:Set Callback function para
*/
this.doSetCallBack=function(callBack,paraData){
this._callBack=(callBack)?callBack:null;
this._callBackPara=(paraData)?paraData:null;
};
/*
* Function: Get current stateString
*/
this.doGetState=function(){
return this._stateString;
}
/*
* Function: get current Error 
*/
this.doGetError=function(){
return this._error;
}
/*
*
*/
this.doCallBack=function(){
this._callBack(this._requestResult,this._callBackPara);
}

/* 
* Function: Send the request
* urlPar: request's url path
* [methodPar]:request's method
* [domPar]: request's result is dom or string
*/
this.doSendResuest=function(urlPar,methodPar,obj,domPar,asyPar){
if(obj._error){
return;
}
methodPar=((methodPar)?methodPar:"GET");
asyPar=((asyPar)?asyPar:true);
this._domResult=(domPar)?domPar:obj._domResult;
try{
var a=this._getRequestObj();
a.onreadystatechange=function(){
if(obj._error){
return;
}
var readyStateTmp=a.readyState;
if(readyStateTmp==0){
obj._setMessage("No initialize");
}else if(readyStateTmp==1){
obj._setMessage("Reading......");
}else if(readyStateTmp==2){
obj._setMessage("Had read!");
}else if(readyStateTmp==3){
obj._setMessage("Turning each other...... ");
}else if(readyStateTmp==4){
var statusTmp=a.status;
if(statusTmp==404){
obj._setMessage("Not found request file!",true);
}else if(statusTmp==200){
obj._setMessage("Finished"); 
if(this._domResult && window.XMLHttpRequest){
obj._requestResult=a.responseXml;
}else{
obj._requestResult=a.responseText;
}
if(obj._callBack){
obj.doCallBack();
}
}else{
obj._setMessage("Unknow error!");
}
}else{
obj._setMessage("Unknow error!");
} 
}
a.open(methodPar,urlPar,asyPar);
a.send(obj._requestData);
}catch(ex){
obj._setMessage(ex,true);
}
}
/*
* Function: Deal exception error 
* exPar:error string
*/
this._setMessage=function(exPar,mark){
this._stateString=exPar.toString();
this._error=(mark)?mark:false;
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++
//ajax弹出提示---id是预留参数
	function ajaxProcess_alert(url,id){
		//没有loading样式
	
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(ajaxalert,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
	
//********************************************
function ajaxalert(str,id){

	//var jsonlad=str;
	//--------游戏充值部分是否登录ajax判断及提交处理
		if (str=='false09')
		{
			alert('您未登录或登录已超时，请登录后再试！')
			return false;
			}
		else if (str=='true09')
		{
			var checkok;
			checkok='y';
			if(document.game_one.classid.value==""||document.game_one.classid.value=="0000")
				{
					alert("请选择游戏名");
					document.game_one.classid.focus();
					checkok='n';
					return false;
				}
				if(document.game_one.cardid.value==""||document.game_one.cardid.value=="000000")
					{
						alert("请选择面值");
						document.game_one.cardid.focus();
						checkok='n';
						return false;
					}	
					
				if (checkok=='y'){	
					game_one.submit();
				}
			}
		//++++++++++++游戏充值判断部分结束++++++++++++
		else
		{
		alert(str);
		}

	}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++


//ajax中调用ajax
//=======================================================
function ajaxProcess(url,id){
	//alert(id);
	//document.getElementById(id).innerHTML="<img src='/imagesNew/LoadingBox.gif'>";
	if(id!='undefined'){
	document.getElementById(id).innerHTML="<div style='padding-top:15px;padding-bottom:10px;width:80%;'><img src='/imagesNew/loading4.gif'></div>";
	}
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aa,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
	//＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋
	function ajaxProcess_2(url,id){
		//没有loading样式
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aa,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
	//＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋＋
	
function aa(str,id){

	var jsonlad=str;
	jsonlad=jsonlad.split("{}");
	document.getElementById(id).innerHTML=jsonlad[0];

	if (jsonlad.length>1 &&  str.indexOf('{}')>0)
	  {
		for(var k=1;k<jsonlad.length;k++){
	
		jsstr=jsonlad[k].split(";");
				for(var i=0;i<jsstr.length;i++)
				{
				operatestr=jsstr[i].split(",");
				
				//ajaxProcess(''+operatestr[0]+'',''+operatestr[1]+'');
	 			setTimeout("ajaxProcess('"+operatestr[0]+"','"+operatestr[1]+"')",0);
				}
		}
	  }
	}
//==============================================================
//ajax页面调用js有提示
//=======================================================
function ajaxProcessscript(url,id){
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aascript,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
function aascript(str,id){
	
	var jsonlad=str;

	jsonlad=jsonlad.split("{}");
	document.getElementById(id).innerHTML=jsonlad[0];

	if (jsonlad.length>1)
	  {
		for(var k=1;k<jsonlad.length;k++){

		jsstr=jsonlad[k].split(";");
				for(var i=0;i<jsstr.length-1;i++)
				{
					
				operatestr=jsstr[i].split("||");
				var linkstr=operatestr[1]
				if (confirm(operatestr[0]))
				{
					window.location.href=''+linkstr+'';
				}
				else
				{
				return false;
				}	
		}
	  }
	}
	}
//==============================================================
//ajax页面调用js有提示不跳转
//=======================================================
function ajaxProcessscriptnolink(url,id){
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aascriptnolink,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
function aascriptnolink(str,id){

	var jsonlad=str;

	jsonlad=jsonlad.split("{}");
	document.getElementById(id).innerHTML=jsonlad[0];

	if (jsonlad.length>1)//有提示
	  {
		for(var k=1;k<jsonlad.length;k++){

		jsstr=jsonlad[k].split(";");
				for(var i=0;i<jsstr.length-1;i++)
				{
					
				//operatestr=jsstr[i].split("||");
				alert(jsstr[i]);

		}
	  }
	}
	}
//==============================================================

//ajax页面调用js只执行js代码
//=======================================================
function ajaxProcessscriptonlyjs(url,id){
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aascriptonlyjs,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
function aascriptonlyjs(str,id){

	var jsonlad=str;

	jsonlad=jsonlad.split("{}");
	document.getElementById(id).innerHTML=jsonlad[0];

	if (jsonlad.length>1)//
	  {
		for(var k=1;k<jsonlad.length;k++){

		jsstr=jsonlad[k].split(";");
				for(var i=0;i<jsstr.length-1;i++)
				{
				setTimeout(jsstr[i],0); 
		}
	  }
	}
	}
//==============================================================

//==============================================================
//ajax页面调用js没有提示
//=======================================================
function ajaxProcessscriptnotip(url,id){
	var httpRequest=new HttpRequest();
	with(httpRequest){
	init();
	doSetCallBack(aascripttip,id);
	doSendResuest(url,"GET",httpRequest);
	}
	}
function aascripttip(str,id){
	
	var jsonlad=str;

	jsonlad=jsonlad.split("{}");
	document.getElementById(id).innerHTML=jsonlad[0];
	if (jsonlad.length>1)
	  {
		for(var k=1;k<jsonlad.length;k++){

		jsstr=jsonlad[k].split(";");
				for(var i=0;i<jsstr.length-1;i++)
				{
					
				operatestr=jsstr[i].split("||");
				var linkstr=operatestr[0]
				window.location.href=''+linkstr+'';

		}
	  }
	}
	}
//==============================================================
//---------------图片缩放－－－onload=proDownImage(this,95,95);－－－－－－－－－－－－－－－－
function proDownImage(ImgD,wid,hei){
	var proMaxHeight =hei ;
	var proMaxWidth = wid;
      var image=new Image();
      image.src=ImgD.src;
      if(image.width>0 && image.height>0){
      var rate = (proMaxWidth/image.width < proMaxHeight/image.height)?proMaxWidth/image.width:proMaxHeight/image.height;
    if(rate <= 1){   
     ImgD.width = image.width*rate;
     ImgD.height =image.height*rate;
    }
    else {
			ImgD.width = image.width;
			ImgD.height =image.height;
         }
      }
}

function chk_hits(typeid,ggid)
{	
		var url="/tongji/tongjigghits.asp";
		var canshu="typeid="+escape(typeid)+"&ggid="+escape(ggid)+"&random="+Math.random();
		var xmlHttpAD = getHTTPObjectAD();
		xmlHttpAD.open('POST', url, true) ; 
		xmlHttpAD.setRequestHeader("Content-Type","application/x-www-form-urlencoded") ; 
		xmlHttpAD.onreadystatechange = function(){if (xmlHttpAD.readyState == 4 && xmlHttpAD.status == 200){
		
		};
		}
		xmlHttpAD.send(canshu);
		
}
		
		
		
	function getHTTPObjectAD()
	{	
		var xmlhttprequest=false ; 
		try 
		{
			xmlhttprequest = new XMLHttpRequest();
		} 
		catch (trymicrosoft) 
		{
			try
			{
				xmlhttprequest = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (othermicrosoft)
			{
				try 
				{
					xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (failed)
				{
					xmlhttprequest = false;
				}
			}
		}
		return xmlhttprequest;
	}
	
//快速评价部分/设置推荐商家商品js-------------------------------------------
	//document.documentElement.clientHeight+'px'
//  onload的时候声明对象
var objcom = new Object;

//function oload(){
//obj = document.getElementById('topFill');
//obj.style.display = 'none';
//}
function clcom(topFill,topFillreccom,topFillnews){
//document.body.style.overflow = 'hidden';
//document.body.style.height = document.documentElement.clientHeight + 'px';
//if(topFillreccom)
if(topFillreccom!=''){
	if (document.getElementById(topFillreccom)!=null)
	{
	document.getElementById(topFillreccom).style.display = 'none';
	}
	}
if(topFillnews!=''){
	if (document.getElementById(topFillnews)!=null)
	{
	document.getElementById(topFillnews).style.display = 'none';
	}
	}	
objcom = document.getElementById(topFill);
objcom.style.display = 'block';

//obj.style.height = document.documentElement.clientHeight + 'px';
}
function bclcom(topFill){

objcom = document.getElementById(topFill);
//document.body.style.overflow = '';
objcom.style.display = 'none';
}
function oresizecom(topFill){
objcom = document.getElementById(topFill);
if(objcom.style.display != 'block'){
  
}else{
  clcom(topFill);
}
}
//+++++++解决ie6 js不能提交问题+++++++
function doSubmit()
{
	dp2.submit();
}

function isnocom(str,topFill,formname,formchild,tripstr){

	if (str == 'yesselect')
	{
		var obj_selec=document.getElementById(formname);
		//	var sel = document.formname.getElementsByTagName("select");
		var sel = obj_selec.getElementsByTagName("select");
		for (i=0;i<sel.length;i++)
		{
			if (sel[i].value==0) {
				alert(tripstr);
				sel[i].focus();
				return false;
			}
		}

	//	obj_selec.submit()
		 setTimeout("doSubmit('"+formname+"')",0);

	}
	else if (str=='yescheck')
		{	
			var obj_check=document.getElementById(formname);

			var flag = false;
			if(obj_check != null){
				
				var msglen=obj_check.radioid.length;
				//var msglen=obj_check.getElementsByTagName('audit_result').length;
				for(i=0;i<msglen;i++){
				  if(obj_check.radioid[i].checked==true){
					flag = true;
					//obj_check.submit()
					 setTimeout("doSubmit('"+formname+"')",0);
				  }
				}
			}
			if (flag == false)
			{
				alert(tripstr)
				return false;
			}		
					
		}
	else if(str=='yestextarea'){
		//拆分提示判断要检测的表单元素
		var arraystr1
		var arraystr2
		var arraystr3
		arraystr1= tripstr.split('||');
		
		arraystr2 =arraystr1[0].split('_');
		arraystr3 =arraystr1[1].split('_');
			
		var obj_check=document.getElementById(formname);
		
		for(i=0;i<obj_check.elements.length;i++)
		{
			if(obj_check.elements[i].name==arraystr2[0])
			{
					if(obj_check.elements[i].value=='')
					{alert(arraystr2[1]);
					obj_check.elements[i].focus();
					return false;
					}
			}
	//		else if(obj_check.elements[i].name==arraystr3[0])
//			{	alert(document.getElementById('Editor').innerHTML);
//				alert(obj_check.elements[i].value);
//					if(obj_check.elements[i].value=='')
//					{alert(arraystr3[1]);
//					obj_check.elements[i].focus();
//					return false;
//					}
//			}
		}
	
		//obj_check.submit()	
		}
	else
	{
	  bclcom(topFill);
	}
}
//============================
function tripinfo(text,doajax,doid){
	if (confirm(text))
	{
		ajaxProcess(doajax,doid);
		return true;
	}
	else
	{
		return false;
	}
}
////快速评价部分js结束＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝
//----------------------巧点合作商家查看详细商品说明用
var obj1 = new Object;
var obj2 = new Object;

//function oload(){

//obj1 = document.getElementById('topFill');
//obj1.style.display = 'none';
	//setCookie("div_precookie","") ;  
//}
function cl(topFill,doid,doajax,doajaxid){
//	alert(topFill);
//document.body.style.overflow = 'hidden';
//document.body.style.height = document.documentElement.clientHeight + 'px';

if (doajax!='')
{
	ajaxProcess(doajax,doajaxid);
}
var arr=getCookie("div_precookie"+doid);

obj1 = document.getElementById(topFill);
if (arr!='' && arr!=null )

{
	if(arr==topFill)
		{	
			if(obj1.style.display=='none')
			{
				obj1.style.display = 'block';
				}
			else
			{
				obj1.style.display = 'none';
				}
		}
	else
	{
		obj2 = document.getElementById(arr);
	
		if (obj2!=null)
		{
			obj2.style.display = 'none';
		}
		obj1.style.display = 'block';
	}
}
else
{
	obj1.style.display = 'block';
	}


document.cookie = "div_precookie"+doid+"=" + escape(topFill);


//obj1.style.height = document.documentElement.clientHeight + 'px';
}
function bcl(topFill){
	
obj1 = document.getElementById(topFill);
//document.body.style.overflow = '';
obj1.style.display = 'none';
}
function oresize(topFill){
obj1 = document.getElementById(topFill);
if(obj1.style.display != 'block'){
  
}else{
  cl(topFill);
}
}
function isno(str,topFill){
if (str == 'yes'){
var sel = document.dp2.getElementsByTagName("select");
	//alert(sel.length);
	for (i=0;i<sel.length;i++){
		if (sel[i].value==0) {
			alert("请选择本次评价的所有选项！");
			sel[i].focus();
			return false;
		}
	}

}else {
  bcl(topFill);
}
}
function   setCookie(name,value)   
  { 
         var   Days   =   1;   //此   cookie   将被保存   30   天   
         var   exp     =   new   Date();         //new   Date("December   31,   9998");   
         exp.setTime(exp.getTime()   +   Days*24*60*60*1000);   
          document.cookie   =   name   +   "="+   escape   (value);
  } 

function getCookie(name) {
	
var bikky = document.cookie;
    name += "=";
    var i = 0; 
    while (i < bikky.length) {
      var offset = i + name.length;
      if (bikky.substring(i, offset) == name) { 
        var endstr = bikky.indexOf(";", offset); 
        if (endstr == -1) endstr = bikky.length;
          return unescape(bikky.substring(offset, endstr)); 
        }
        i = bikky.indexOf(" ", i) + 1; 
        if (i == 0) break; 
      }
    return null; 
}

function Copy_09(theField,tipstr) {
var tempval=document.getElementById(theField);
tempval.focus();
tempval.select();
therange=tempval.createTextRange();
therange.execCommand("Copy");
alert(tipstr);
}

//＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝测试div遮挡select标签＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝
     function show_div(div1){
		
          var div1 = document.getElementById(div1);
		   
          div1.style.top = getTop(div1.parentNode) + div1.parentNode.clientHeight + "px";
          div1.style.left = getLeft(div1.parentNode);
		  
          div1.style.visibility = 'visible'; 
          //创建一个无内容的iframe来挡住select框
          var menuShim = document.getElementById(div1.id + "_shim");
         if (menuShim) {
             menuShim.style.display = "block";
         } else {
             menuShim = document.createElement("iframe");
             menuShim.id = div1.id + "_shim";
             menuShim.frameBorder = "no";
             menuShim.scrolling = "no";
			 
            // menuShim.width = div1.clientWidth;
             //menuShim.height = div1.clientHeight;
             menuShim.width = "470px";
             menuShim.height = "200px";			 
             menuShim.style.position = "absolute";
             menuShim.style.left = getLeft(div1);
             menuShim.style.top = getTop(div1);
             document.body.appendChild(menuShim);
         }
     } 

     function hide_div(div1){ 
         var curObj = document.getElementById(div1);
         curObj.style.visibility='hidden'
         var menuShim = document.getElementById(curObj.id + "_shim");
         if (menuShim !== null) {
             menuShim.style.display = "none";
         }
     } 
  
     function getLeft(obj) {
         var thisValue = 0;
         if (obj) {
             thisValue = obj.offsetLeft + getLeft(obj.offsetParent);
         }
         return thisValue;
     }
  
     function getTop(obj) {
         var thisValue = 0;
         if (obj) {
             thisValue = obj.offsetTop + getTop(obj.offsetParent);
         }
         return thisValue;
     }
//======limitestr=====================================================
//函数 limitestr＝＝用于textarea限制输入字符数
function limitestr(id,nums)
{
 var str_m=document.getElementById(id).value;
 if(str_m.length>nums) 
 {
 document.getElementById(id).value=str_m.substr(0,nums)
 }
}
function picindexcom(para){
	for(var i=1;i<=document.getElementById("pichidden").value;i++)
	{
	
		if(i==para){
		document.getElementById("prepic"+i).className="smallpic selectpic";
		document.getElementById('proimg').getElementsByTagName("img")(0).src=document.getElementById("small"+i).src;
		}
		else
		document.getElementById("prepic"+i).className="smallpic noselectpic";
	}
}