document.write("<iframe width=0 height=0 src='' id='tj_web' name='tj_web'></iframe>");
//document.write("<a href=\"ok.htm\" target=\"_blank\" id=\"astatic\" style=\"width:0px;height:0px;\"></a>");
document.write("<span class='css_nocall' id='span_loading' name='span_loading'></span>");
//页面弹出窗口操作
var enablebutton=true;//三个操作的按钮是否可用
var vcode=false;
var isIe=$.browser.msie; //判断浏览器类型
var p_int_setinterval=0;
function setSelectState(state) //隐藏显示select元素  为平滑过渡，不采用JQUERY的HIDE,SHOW
{ 
 var objl=$('select'); 
 for(var i=0;i<objl.length;i++) 
 { 
 objl[i].style.visibility=state; 
 }
}
function closeWindow() 
{ 
  $('#back')!=null?$('#back').remove():'';
  $('#NewMBox')!=null?$('#NewMBox').remove():'';
  $("#span_loading")[0].className = "css_nocall";
  TDvTop=null;
  isIe?setSelectState(''):'';
  if(p_int_setinterval!=null&&p_int_setinterval>0)
  {
    clearInterval(p_int_setinterval);
    p_int_setinterval=0;
  }
}
//获取鼠标当前位置
function mousePosition(ev) 
{ 
 if(ev.pageX || ev.pageY) 
 { 
   return {x:ev.pageX, y:ev.pageY}; 
 } 
 return { x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft,y:ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop}; 
} 
function GetXmlHttpObject()  //创建AJAX对象
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
   return xmlHttp;
}
function MerchList(clid,zhek,area,container)
{    
     var url="/AjaHandler/MerchList.ashx";
     var querystring={clid:clid,zhek:zhek,area:area}; 
     if(isIe)
     {
     var xmlHttp=GetXmlHttpObject();
     if (xmlHttp==null)
      {
        alert ("您的浏览器不支持AJAX！");
        return;
      }
      var numsolar="numsolar";
      url=url+"?clid="+clid+"&zhek="+zhek+"&area="+area+"&sid="+Math.random();
      xmlHttp.onreadystatechange=function(){if (xmlHttp.readyState==4){var sdata=xmlHttp.responseText.split("*");document.getElementById(container).innerHTML=sdata[0];document.getElementById("numsolar").innerHTML=sdata[1];}};
      xmlHttp.open("GET",url,true);
      //xmlHttp.setRequestHeader("If-Modified-Since","0");
      xmlHttp.send(null);
}
else
{
     $.ajax({
            type:"POST",
            url:url,
            dataType:"html",
            data:querystring,
            cache:false,
		    timeout: 20000, 
            success:function(data)
                {   
                    var sdata=data.split("*");
                    $("#"+container).html(sdata[0]);
                    //document.getElementById(container).innerHTML=sdata[0];
                    $("#numsolar").html(sdata[1]);
                    //document.getElementById("numsolar").innerHTML=sdata[1];
                },
            error:function()
               {
                    alert("操作失败");
               }
            });
            }

}
function Getcode(obj,C){obj.src=C+"?"+new Date;} 
function MCityDeal()
{
    var province=encodeURI($("#pprovince option:selected").text());
    var zhixiashi="北京，上海，天津，重庆,香港特别行政区，澳门特比行政区";
    if(zhixiashi.indexOf(province)>=0)
    {
    }
    else
    {
     if($("#cityajax option:selected").val().length<=0)
     {
       alert('请选择所在城市');
       $("#msubmit")[0].style.display='none';
       
     }
     else
     {
       $("#msubmit")[0].style.display='';
     }
    }
}
function LCityDeal()
{
    var province=encodeURI($("#province option:selected").text());
    var zhixiashi="北京，上海，天津，重庆,香港特别行政区，澳门特比行政区";
    if(zhixiashi.indexOf(province)>=0)
    {
    }
    else
    {
     if($("#tcityajax option:selected").val().length<=0)
     {
       alert('请选择所在城市');
       $("#msubmit")[0].style.display='none';
       
     }
     else
     {
       $("#msubmit")[0].style.display='';
     }
    }
}
function cityResult(ovl,container)
{
  var query={ovl:ovl};
  $.post("/AjaHandler/getCity.ashx?flag=city",query,function(data){$("#"+container).html(data);});
}
function areaResult(ovl,container)
{
  var query={ovl:ovl};
  $.post("/AjaHandler/getCity.ashx?flag=area",query,function(data){$("#"+container).html(data);});
}
function TelAlert()
{
	$("#TelAlerts").attr("class","TelAlertsShow");
}
function TelAltersFocus()
{
   $("#TelAlerts").attr("class","TelAlerts");
}
function TelAlertsMout()
{
  $("#TelAlerts").attr("class","TelAlerts");
}
function TelAlertClick()
{
   $("#TelAlerts").attr("class","TelAlerts")
}
function TelAlerts()
{
	$("#TelAlertss").attr("class","TelAlertssShow");
}
function MtelReg(obj)
{
  var tel=$("#"+obj).val();
  if(tel!="")
  {
     var call = /^((0\d{3})\d{7,8}|(0\d{2})\d{8}|(1)\d{10})$/; 
     if (call.test(tel)==false)    
     {     
       alert('您输入的电话号码应该是0531*******或者133********格式。');    
       return false;    
     } 
     else
     {
       return true;
     }
  }
  else
  {
     alert('请填写电话！');
     return false;
  }
}
function bookmark(title,url)
{
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}


//构造新窗口对应修改的JS函数，为保持过滤，原有的暂时保留
function VMessage(obj_btn,user,tel,dispotion,province,maddress,Mesign,bid)
{
    var user=$("#"+user).val();
    var telv=$("#"+tel).val();
    var dispotion=$("#"+dispotion).val();
    var vprovince=$("#"+province).val();
    var maddress=$("#"+maddress).val();
    if(user.length<2)
    {
       alert('姓名不能少于两个字符！');
       return ;
    }
    if(!MtelReg(tel))
    {
       return ;
    }
    if(dispotion.length<2)
    {
       alert('请填写意向,不少于两个字符！');
       return ;
    }
	if(dispotion=='请在此输入您的合作意向,必须填写')
	{
		alert('请填写意向,不少于两个字符！');
		return;
	}
    if(vprovince.length<1)
    {
       alert('请选择省市县！');
       return ;
    }
    if(maddress.length<2)
    {
       alert('请填写地址，不少于两个字符！');
       return ;
    }
    COp(obj_btn,Mesign,telv,user,dispotion,province,maddress,bid);
}
function CityDeal()
{
    var province=encodeURI($("#uprovince option:selected").text());
    var zhixiashi="北京，上海，天津，重庆,香港特别行政区，澳门特比行政区";
    if(zhixiashi.indexOf(province)>=0)
    {
    }
    else
    {
     if($("#ucity option:selected").val().length<=0)
     {
       alert('请选择所在城市');
       $("#Mes_Submit")[0].style.display='none';
       
     }
     else
     {
       $("#Mes_Submit")[0].style.display='';
     }
    }
}
var TDvTop;
function COp(obj_btn,sign,tel,user,dispotion,province,maddress,bid)//opsign,tel,user,dispotion,province,maddress,mzip
{
  
  var query="";
  switch(sign)
  {
    case "tel":   
    var guest_phone=tel;//客户手机号码或固话
    var passiveucode=$("#passiveucode").val();//用户帐号
    var url=document.location.href;
    query={sign:sign,guest_phone:guest_phone,passiveucode:passiveucode,url:url,sessionid:(typeof(P_Tongji_SessionID)=="undefined"?"":P_Tongji_SessionID),bid:bid};
    break;
    case "sendMes":
    var smscontent=encodeURI($("#smscontent").text());
    var myucode=encodeURI($("#myucode").val());
    var mytel=encodeURI(tel);
    var url=document.location.href;
    query={sign:sign,smscontent:smscontent,myucode:myucode,mytel:mytel,url:url,sessionid:(typeof(P_Tongji_SessionID)=="undefined"?"":P_Tongji_SessionID),bid:bid};
    break;
    case "mes":
    var adcall_no=encodeURI($("#passiveucode").val());
    var user=encodeURI(user);
    var tel=encodeURI(tel);
    var province=encodeURI($("#"+province+" option:selected").text());
    var city=encodeURI($("#cityajax option:selected").text());
    var area=encodeURI($("#areaajax option:selected").text());
    var maddress=encodeURI(maddress);
    var dispotion=encodeURI(dispotion);
    var url=document.location.href;
    query={sign:sign,adcall_no:adcall_no,user:user,tel:tel,province:province,city:city,area:area,maddress:maddress,dispotion:dispotion,url:url,sessionid:(typeof(P_Tongji_SessionID)=="undefined"?"":P_Tongji_SessionID),bid:bid};
    break;
    case "Tmes":
    var adcall_no=$("#passiveucode").val();
    var user=encodeURI(user);
    var tel=encodeURI(tel);
    var province=encodeURI($("#"+province+" option:selected").text());
    var city=encodeURI($("#ucity option:selected").text());
    var area=encodeURI($("#ucounty option:selected").text());
    var maddress=encodeURI(maddress);
    var dispotion=encodeURI(dispotion);
    var url=document.location.href;
    query={sign:"mes",adcall_no:adcall_no,user:user,tel:tel,province:province,city:city,area:area,maddress:maddress,dispotion:dispotion,url:url,sessionid:(typeof(P_Tongji_SessionID)=="undefined"?"":P_Tongji_SessionID),bid:bid};
    break;
  }
  if(enablebutton==true)
  { 
            enablebutton=false;
            var spanobj=document.getElementById("span_loading");
            spanobj.style.width = (obj_btn.clientWidth+(isIe?4:2))+"px";
            spanobj.style.height = (obj_btn.clientHeight+(isIe?1:5))+"px";
            var spanobjs = spanobj.style;
            var ttop = obj_btn.offsetTop;     //TT控件的定位点高
            //var thei = obj_btn.clientHeight;  //TT控件本身的高
            var tleft = obj_btn.offsetLeft;    //TT控件的定位点宽
            var ttyp = obj_btn.type;          //TT控件的类型
            while(obj_btn = obj_btn.offsetParent) { ttop += obj_btn.offsetTop; tleft += obj_btn.offsetLeft;}
            spanobjs.top = (ttop+(isIe?0:0))+"px";
            spanobjs.left = (tleft+(isIe?8:0))+"px";
            TDvTop=ttop-document.documentElement.scrollTop;
            spanobj.className = "css_calling";
  $.ajax({
            type:"POST",
            url:"/AjaHandler/H400.aspx",
            dataType:"html",
            cache:false,
			timeout: 20000,    
            data:query,
            success:function(msg)
                {  
                    if(msg.indexOf("tel1")>=0||msg.indexOf("mes1")>=0||msg.indexOf("mes2")>=0||msg.indexOf("mes3")>=0||msg.indexOf("sendMes1")>=0)
                    {
                        document.getElementById("tj_web").src="/ok.htm?r="+Math.random();
                        //document.getElementById("astatic").click();
                    }
                    if(msg.indexOf("tel2")>=0)
                    {
                       if(confirm(msg.split('@')[0].replace("tel2:","")))
                       {
                        if($("#back")[0]!=null)
                        {
                           document.body.removeChild($("#back")[0]);       					   
                        }
						enablebutton=true;
						spanobj.className = "css_nocall";
						return testMessageBox(msg.split('@')[1],msg.split('@')[2],'mes');			                      
					   }
                      else
                      {
						  enablebutton=true;
                          spanobj.className = "css_nocall";
						  return;
					  }
					}
                   enablebutton=true;
                   spanobj.className = "css_nocall";
                   var temstr="";
                   if(msg.indexOf(":")>0)
                   {
                     temstr=msg.split(':')[1];
                     if(temstr.indexOf('@')>0)
                     {
                       temstr=temstr.split('@')[0];
                     }
                   }   
                   alert(temstr);                  
                },
               error:function()
               {
                    enablebutton=true;
                    spanobj.className = "css_nocall";
                    alert("操作失败");
               }
            });
 }
}
function ChReg(obj_btn,tel,opsign,bid)
{
  var tel=$("#"+tel).val();
  if(tel!="")
  {
     var call = /^((0\d{3})\d{7,8}|(0\d{2})\d{8}|(1)\d{10})$/; 
     if (call.test(tel)==true)    
     {  
       COp(obj_btn,opsign,tel,'','','','',bid);
     } 
     else
     {
       alert('您输入的电话号码应该是0531*******或者133********格式。');    
       return;         
     }
  }
  else
  {
     alert('请填写电话！');
     return;
  }

} 

//弹窗
function showMBox(data,w,sign) 
{ 

 //先执行关闭操作，如有打开的窗口，会被关掉
 var bWidth=parseInt(document.documentElement.scrollWidth); 
 var bHeight=document.documentElement.scrollHeight; 
 isIe?setSelectState(''):'';
 isIe?bHeight=bHeight+102:"";
 var back=document.createElement("div"); 
 back.id="back"; 
 var styleStr="top:0px;left:0px;position:absolute;background:#cccccc;width:"+bWidth+"px;height:"+bHeight+"px;"; 
 styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;"; 
 back.style.cssText=styleStr; 
 //back.innerHTML=data;
 document.body.appendChild(back); 
  var dd=document.createElement("div"); 
 dd.id="NewMBox"; 
 dd.innerHTML=data;
 $("#back").fadeTo("3000", 0.5);
 document.body.appendChild(dd);
 var mesW;
 mesW=$("#d_link_window")[0];
 var h=mesW.scrollHeight;
 var w=mesW.scrollWidth;
 mesW.style.left = "50%";
 mesW.style.top="50%";
 mesW.style.marginTop =-h/2+"px";//获取DIV高和宽 scrollWidth scrollHeight
 mesW.style.marginLeft =-w/2+"px" ;

 if($.browser.msie&&parseInt($.browser.version)<7)
 {
    mesW.style.position = "absolute";
    mesW.style.marginTop =-h/2+document.documentElement.scrollTop+"px";
    p_int_setinterval=setInterval("fun_t_link_window_onscroll()",100);
 }
 else
 {
    $("#span_loading")[0].style.position="fixed";
    mesW.style.position = "fixed";//IE6下不支持，还会导致其它样式混乱；如果设置了fixed,发现标准浏览器中的document.documentElement.scrollTop失效
 }
} 

function fun_t_link_window_onscroll()
{

    var mesW=$("#d_link_window")[0];
     if(mesW)
    {
        mesW.style.marginTop = -mesW.scrollHeight/2+document.documentElement.scrollTop+"px";
    }
    var spn=$("#span_loading")[0];
    if(spn&&spn.className=="css_calling")
    {
        spn.style.top=(TDvTop+document.documentElement.scrollTop)+"px";
    }
}
function testMessageBox(id,title,sign) 
{ 
     var querystring={id:id};  
     var w;
     var url="/AjaHandler/400Form.ashx?flag="+sign;
     if(sign=="tel")
     {
       w=496;
     }
     else if(sign=="sendMes")
     {
       w=496;
     }
     else if(sign=="mes")
     {
       w=518;
     }
     $.post(url,querystring,function(data){showMBox(data,w,sign);});
} 
   window.onerror =function()
   {
    return true;
   }
