﻿
/*后退*/
 function btnCancel_onclick() 
{
	window.history.back(-1);
}
/*刷新验证码*/
    function RefreshVerifyCode() 
    {
    var ccImg = document.getElementById("Img_VerifyCode");
    var ccImgSrc = "";
    if (ccImg)
    {
	    nowTime = new Date();
	    ccImgSrc = "VerifyCode.aspx?r=" + nowTime.getTime();
	    ccImg.src = ccImgSrc;
    }
    }

function DrawImage(ImgD,maxWidth,maxHeight,minWidth,minHeight)
{
     var flag=false;
     var  image=new  Image();
     image.src=ImgD.src;
     if(image.width>0  &&  image.height>0)
       {
         flag=true;       
               if(image.width>=maxWidth||image.height>=maxHeight)
               {
               if(image.width/image.height >=  maxWidth/maxHeight){
                 if(image.width>maxWidth){
                 ImgD.width=maxWidth;
                 ImgD.height=(image.height*maxWidth)/image.width;
                 }
                              
                 }
               else{
                 if(image.height>maxHeight){
                 ImgD.height=maxHeight;
                 ImgD.width=(image.width*maxHeight)/image.height;
                 }
               
                 
                 }
              }else if(image.width<=minWidth||image.height<=minHeight)
               {
               if(image.width/image.height >=  minWidth/minHeight){
                 if(image.width<minWidth){
                 ImgD.width=minWidth;
                 ImgD.height=(image.height*minWidth)/image.width;
                 }
                            
                 }
               else{
                 if(image.height<minHeight){
                 ImgD.height=minHeight;
                 ImgD.width=(image.width*minHeight)/image.height;
                 }
                             
                 }
              }else{
                ImgD.height=image.height;
                ImgD.width=image.width;
               
              }
       }       
}
function choosediv(aa)
{ 
    switch(aa)
    {
        case 0:document.getElementById("choose_left").className="Property_Content_div_right_title_current";
               document.getElementById("choose_center").className="Property_Content_div_right_title_center"; 
               document.getElementById("choose_right").className="Property_Content_div_right_title_right";
               document.getElementById("Property_Information").style.display="block";
               document.getElementById("Property_zbpt").style.display="none";
               document.getElementById("Property_xqzp").style.display="none";
               break;
        case 1:document.getElementById("choose_left").className="Property_Content_div_right_title_left";
               document.getElementById("choose_center").className="Property_Content_div_right_title_current2"; 
               document.getElementById("choose_right").className="Property_Content_div_right_title_right";
               document.getElementById("Property_Information").style.display="none";
               document.getElementById("Property_zbpt").style.display="block";
               document.getElementById("Property_xqzp").style.display="none";
               break;
        case 2:document.getElementById("choose_left").className="Property_Content_div_right_title_left";
               document.getElementById("choose_center").className="Property_Content_div_right_title_center"; 
               document.getElementById("choose_right").className="Property_Content_div_right_title_current";
               document.getElementById("Property_Information").style.display="none";
               document.getElementById("Property_zbpt").style.display="none";
               document.getElementById("Property_xqzp").style.display="block";
               break;
        default:document.getElementById("choose_left").className="Property_Content_div_right_title_current";
               document.getElementById("choose_center").className="Property_Content_div_right_title_center"; 
               document.getElementById("choose_right").className="Property_Content_div_right_title_right";
               document.getElementById("Property_Information").style.display="block";
               document.getElementById("Property_zbpt").style.display="none";
               document.getElementById("Property_xqzp").style.display="none";
               break;
    }
    
}

function checkphone(tel)  //验证号码， 手机，座机，小灵通
{
        var my=false;
        var reg0=/^(0212[56789]{1}\d{6})$/;
        var reg1=/^(0108[013679]{1}\d{6})$/;
        var reg2=/^(0106[019]{1}\d{6})$/;
        var reg3=/^(1[35]\d{9})$/;
        var reg4=/^\d{3,4}-\d{8}$/; 
        var reg5=/^\d{11,12}$/; 
        var reg6=/^\d{8}$/; 

      
        if(reg0.test(tel))my=true;
        if(reg1.test(tel))my=true;
        if(reg2.test(tel))my=true;
        if(reg3.test(tel))my=true;
        if(reg4.test(tel))my=true;
        if(reg5.test(tel))my=true;
        if(reg6.test(tel))my=true;
       
        return my;
}
function checknumber(number)
{
    var my=false;
    var reg0=/^\d+$/;
   
  
    if(reg0.test(number))my=true;
    return my;
}

function OnKeyDownClick(buttonname,e)
{
    if(e.keyCode==13)
    {  
        document.getElementById(buttonname).click();
        return false;
    }
}

function DataLength(fData,type)   //判断输入字符串长度 type : 0 只能为中文  type : 1 普通判断长度
{
    var intLength=0;
    switch(type)
    {
        case 0:for (var i=0;i<fData.length;i++)         //判断只能为中文，不为中文返回-1
                {
                    if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255))
                    {
                       intLength+=1;
                    }   
		            else
		            {
		               return -1;           
		            }
                }                
                return intLength;
        case 1: for (var i=0;i<fData.length;i++)       //判断输入字符串长度，中文为2个字节
                {
                    if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255))
                    {
                       intLength+=2;
                    }   
		            else
		            {
		               intLength+=1;              
		            }
                }
                return intLength;                
    }
}

function addBookmark(title,url) 
{
    if (window.sidebar) { 
       window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) {
       window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
      return true;
    }
}

function ShowOrderDiv(divname)
{
    document.getElementById(divname).style.display="";
}

function CloseOrderDiv(divname)
{
    document.getElementById(divname).style.display="none";
}
function ShowPicture(img,houseid,ptype)
{
    var daps  = document.getElementById("abc").style;
   
    var thei=img.offsetHeight;
    var w=img.offsetWidth;
    var tleft=img.offsetLeft+40;
    var ttop=img.offsetTop;	  
    
    while (img = img.offsetParent){ttop+=img.offsetTop; tleft+=img.offsetLeft;}	  
    daps.top  =  ttop+thei+6+"px"; //层的 Y 坐标
    daps.left = tleft + 1+"px";  //层的 X 坐标
    daps.display = "";  //层显示
    document.getElementById("abc").innerHTML="<iframe src=\"/AdHouse/HousePictureView.aspx?id=" + houseid + "&ptype=" + ptype + "\" width=\"370\" height=\"280\" scrolling=\"no\" frameborder=\"0\" ></iframe>";       
}

function ClosePrePic(divname){
	document.getElementById(divname).style.display = "none";
}

document.onclick = function()
{  
     if(document.getElementById('AgencyBoxTitle')!=null)
        document.getElementById('AgencyBoxTitle').style.display='none';  
}   
function showcxt(cid,iscxt,cxt)
{
    if(document.getElementById(cid).checked==true)   
    {    
        
        window.location.href=iscxt;        
    }
    else
    {
        window.location.href=cxt;
    }
}
