// JavaScript Document
function ResumeError() {
return true;
}
window.onerror = ResumeError;


window.defaultStatus="欢迎访问本站"; 

	function Body()
	{
		parent.document.body.innerHTML=document.body.innerHTML;
	}

//=============================================================================
//Function : 		
//Parameter:
//Return value:		
//=============================================================================
	function AD_Add()
	{
		var Result=window.showModalDialog("Ad_Edit.asp",window,"dialogWidth:750px;dialogHeight:520px;toolbar=no;location=no;directories=no;status=no;menubar=NO;scrollbars=no;resizable=no;help=0; status:0");
		if(Result!=null)
		{
			window.document.body.innerHTML=Result;
		}
	}


	function StaticEvent(theForm,theValue)
	{
		var temp=parseInt(theValue);
		if(temp==1)
		{
			document.getElementById("CurtainAd").style.display="";
			theForm.elements["AdPosition"].disabled=false;
			theForm.elements["PageXmargin"].disabled=false;
			theForm.elements["PageYmargin"].disabled=false;
		}
		else
		{
			document.getElementById("CurtainAd").style.display="none";
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
		}
	}
	
	
	function DynamicEvent(theForm,theValue)
	{
		var temp=parseInt(theValue);
		if(temp==1)
		{
			document.getElementById("CurtainAd").style.display="";
			document.getElementById("DynamicTr").style.display=""
			theForm.elements["AdPosition"].disabled=false;
			theForm.elements["PageXmargin"].disabled=false;
			theForm.elements["PageYmargin"].disabled=false;
			theForm.elements["MoveType"].disabled=true;
			theForm.elements["MoveSpeed"].disabled=false;
			
		}
		else if(temp==0)
		{
			document.getElementById("CurtainAd").style.display="none";
			document.getElementById("DynamicTr").style.display="";
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
			theForm.elements["MoveType"].disabled=false;
			theForm.elements["MoveSpeed"].disabled=false;
		}
		else if(temp==3)
		{
			document.getElementById("CurtainAd").style.display="none";
			document.getElementById("DynamicTr").style.display="";
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
			theForm.elements["MoveType"].disabled=false;
			theForm.elements["MoveSpeed"].disabled=false;
		}		
		else if(temp==2)
		{
			document.getElementById("CurtainAd").style.display="none";
			document.getElementById("DynamicTr").style.display="none";
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
			theForm.elements["MoveType"].disabled=true;
			theForm.elements["MoveSpeed"].disabled=true;
		}
		
	}
//=============================================================================
//Function : 		
//Parameter:
//Return value:		
//=============================================================================
	function ad_submit(){
		form1.content.value=form1.doc_html.value;
	}



//=============================================================================
//Function : 		
//Parameter:
//Return value:		
//=============================================================================
	function IsDisplay(theForm,obj){
		if(obj==1){
			document.getElementById("CurtainAd").style.display="none";
			document.getElementById("DynamicTr").style.display="none";
			document.getElementById("StaticStyleBox").style.display="block";
			document.getElementById("DynamicStyleBox").style.display="none";
			theForm.elements["StaticStyle"].disabled=false;
			theForm.elements["StaticStyle"].options[0].selected=true;
			theForm.elements["DynamicStyle"].disabled=true;
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
			theForm.elements["MoveType"].disabled=true;
			theForm.elements["MoveSpeed"].disabled=true;
		}
		else if(obj==2){
			document.getElementById("StaticStyleBox").style.display="none";
			document.getElementById("DynamicStyleBox").style.display="block";
			document.getElementById("DynamicTr").style.display="";
			document.getElementById("CurtainAd").style.display="none";
			theForm.elements["DynamicStyle"].options[0].selected=true;
			theForm.elements["StaticStyle"].disabled=true;
			theForm.elements["MoveSpeed"].disabled=false;
			theForm.elements["MoveType"].disabled=false;
			theForm.elements["DynamicStyle"].disabled=false;
			theForm.elements["AdPosition"].disabled=true;
			theForm.elements["PageXmargin"].disabled=true;
			theForm.elements["PageYmargin"].disabled=true;
		}
	}

//页面边距验证
	function PageMargin(theForm)
	{
		var temp="",tempNum;
		theForm.elements["PageXmargin"].value;
		try{
				temp=theForm.elements["PageXmargin"].value;
				if(!isNumber(temp))
				{
					Alert(8);
					theForm.elements["PageXmargin"].focus();
					theForm.elements["PageXmargin"].select();
					return false;
				}
				tempNum=parseInt(temp);
			}catch(Exception){
					Alert(8);
					theForm.elements["PageXmargin"].focus();
					theForm.elements["PageXmargin"].select();
					return false;
		}
		theForm.elements["PageYmargin"].value;
		try{
				temp=theForm.elements["PageYmargin"].value;
				if(!isNumber(temp))
				{
					Alert(9);
					theForm.elements["PageYmargin"].focus();
					theForm.elements["PageYmargin"].select();
					return false;
				}
				tempNum=parseInt(temp);
			}catch(Exception){
					Alert(9);
					theForm.elements["PageYmargin"].focus();
					theForm.elements["PageYmargin"].select();
					return false;
		}
		return true;		
	}
	
//滚动速度验证
	function Scroll(theForm)
	{
		var temp,tempNum;
		try{
				temp=theForm.elements["MoveSpeed"].value;
				if(!isNumber(temp))
				{
					Alert(7);
					theForm.elements["MoveSpeed"].focus();
					theForm.elements["MoveSpeed"].select();
					return false;
				}
				tempNum=parseInt(temp);
				if(tempNum<1)
				{
					Alert(7);
					theForm.elements["MoveSpeed"].focus();
					theForm.elements["MoveSpeed"].select();
					return false;
				}
			}catch(Exception){
					Alert(7);
					theForm.elements["MoveSpeed"].focus();
					theForm.elements["MoveSpeed"].select();
					return false;
		}
		return true;
	}
//=============================================================================
//Function : 		
//Parameter:
//Return value:		
//=============================================================================
	function AddValidation(theForm)
	{
		var temp=theForm.elements["Title"].value;
		var tempNum;
		if(!isNull(temp))
		{
			Alert(2);
			theForm.elements["Title"].focus();
			theForm.elements["Title"].select();
			return false;
		}
		temp=theForm.elements["Width"].value;
		if(!isNumber(temp))
		{
			Alert(3);
			theForm.elements["Width"].focus();
			theForm.elements["Width"].select();
			return false;
		}
		temp=theForm.elements["Height"].value;
		if(!isNumber(temp))
		{
			Alert(4);
			theForm.elements["Height"].focus();
			theForm.elements["Height"].select();
			return false;
		}
		tempNum=parseInt(getCheckedValue(theForm,"AdType"));
		tempNumb=parseInt(theForm.elements["StaticStyle"].value);
  		//如果是静态窗帘广告
		if(tempNum==1&&tempNumb==1)
		{
			if(!PageMargin(theForm))
				return false;
		}
		tempNumb=parseInt(theForm.elements["DynamicStyle"].value);
		//如果是动态普通广告
		if(tempNum==2&&tempNumb==0)
		{
			if(!Scroll(theForm))
				return false;
		}
		//如果是动态窗帘广告
		if(tempNum==2&&tempNumb==1)
		{
			if(!PageMargin(theForm))
				return false;
				
			if(!Scroll(theForm))
				return false;
		}

		temp=etxt.GetContent();;
		if(!isNull(temp))
		{
			Alert(5);
			return false;
		}
		theForm.elements["adContent"].value=temp;
		return true;
	}	
	
//=============================================================================
//Function : Delete Ad		
//Parameter:ID is ad index number
//Return value:		
//=============================================================================
	function Delete(ID,BOOL)
	{
		if(BOOL=="Yes")
		{
			if(!Confirm(73))
			{
				if(Confirm(77))
				{
					Temp_Frame.location="Dispose_hiwebad.asp?ID="+ID+"&Ad_Type=2&Window=2";
				}
			}
		}
		else
		{
			if(Confirm(11))
			{
				Temp_Frame.location="Dispose_hiwebad.asp?ID="+ID+"&Ad_Type=2&Window=2";
			}
		}
	}
	
//=============================================================================
//Function : Modify Ad		
//Parameter:ID is ad index number
//Return value:		
//=============================================================================
	function Modify(ID)
	{
		var Ra=new Date();
		var str=Ra.getYear()+Ra.getMonth()+Ra.getDate()+Ra.getHours()+Ra.getMinutes()+Ra.getSeconds();
		var Result=window.showModalDialog("Ad_Modify.asp?ID="+ID+"&Ra="+str,window,"dialogWidth:750px;dialogHeight:520px;toolbar=no;location=no;directories=no;status=no;menubar=NO;scrollbars=no;resizable=no;help=0; status:0");
		if(Result!=null)
		{
			window.document.body.innerHTML=Result;
		}
	}
	
//=============================================================================
//Function : Builder Ad		
//Parameter:ID is ad index number
//Return value:		
//=============================================================================
	function Builder(ID)
	{
		Temp_Frame.location="Dispose_hiwebad.asp?ID="+ID+"&Ad_Type=3&Window=2";
	}


function resizeimg(ImgD,iwidth,iheight) { 
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0){ 
        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; 
                } 
               ImgD.alt=image.width+"×"+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; 
                     } 
                ImgD.alt=image.width+"×"+image.height; 
            } 
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针 
　　　　　//ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
　　　　　　ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开"; 
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放 
　　　　　 { 
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100; 
　　　　　　　　　　zoom += event.wheelDelta / 12; 
　　　　　　　　　　if (zoom> 0)　this.style.zoom = zoom + "%"; 
　　　　　　　　　　return false; 
　　　　　 } 
　　　  } else { //如果不是IE 
　　　　　　　     ImgD.title = "点击图片可在新窗口打开"; 
　　　　　　   } 
    } 
}
