//这里是友价房产系统全局JS，
//不受模板影响，
//就是任何模板都可以或可能调用的一些通用样式，写在这里

//手机版判断
function is_mobile() {
    var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i;
  var u = navigator.userAgent;
  if (null == u) {
   return true;
  }
  var result = regex_match.exec(u);

  if (null == result) {
   return false
  } else {
   return true
  }
}

//头部登录验证
function userCheckses(){
$.get(document.getElementById("webhttp").innerHTML+"template/sesCheck.php",{},function(result){
 if(result=="none"){
  document.getElementById("notlogin").style.display="";
  document.getElementById("yeslogin").style.display="none";
  return false;
 }else{
  document.getElementById("yeslogin").style.display="";
  document.getElementById("notlogin").style.display="none";
  fh=result;
  if(result=="yk"){document.getElementById("tuzx").style.display="none";fh="游客";}
  document.getElementById("yesuid").innerHTML=fh;
  return false;
 }
});
}

//相加
function addNum(num1,num2){ //避免出现小数点多位的情况
var sq1,sq2,m;
try{sq1=num1.toString().split(".")[1].length;} catch(e){sq1=0;}
try{sq2=num2.toString().split(".")[1].length;} catch(e){sq2=0;}
m=Math.pow(10,Math.max(sq1,sq2));
return ( num1 * m + num2 * m ) / m;
}

//相乘
function accMul(arg1,arg2){
 var m=0,s1=arg1.toString(),s2=arg2.toString();
 try{m+=s1.split(".")[1].length}catch(e){}
 try{m+=s2.split(".")[1].length}catch(e){}
 return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
}

//区域调用
function areacha(){
document.getElementById("fareas").style.display="";
window.frames["fareas"].location.href="../config/areas.php?id="+document.getElementById("area1").value;	
}

//提交
function tjwait(){
document.getElementById("tjbtn").style.display="none";
document.getElementById("tjing").style.display="";	
}

//邮箱判断
function isEmail(str){//判断邮箱
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
return reg.test(str);
}

//手机判断
function isMot(str){
 var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/; 
 return myreg.test(str);
}

//弹出微信二维码
function glotangweixin(x){
layer.open({
  type: 1,
  title: "微信扫描联系",
  closeBtn: 1,
  shadeClose: true,
  area: ['210px', '245px'],
  content: '<img src="'+x+'" width=200 height=200 />'
});

}

//回到顶部
function gotoTop(acceleration,stime){acceleration=acceleration||0.1;stime=stime||10;var x1=0;var y1=0;var x2=0;var y2=0;var x3=0;var y3=0;if(document.documentElement){x1=document.documentElement.scrollLeft||0;y1=document.documentElement.scrollTop||0;}
if(document.body){x2=document.body.scrollLeft||0;y2=document.body.scrollTop||0;}
var x3=window.scrollX||0;var y3=window.scrollY||0;var x=Math.max(x1,Math.max(x2,x3));var y=Math.max(y1,Math.max(y2,y3));var speeding=1+ acceleration;window.scrollTo(Math.floor(x/speeding),Math.floor(y/speeding));if(x>0||y>0){var run="gotoTop("+ acceleration+", "+ stime+")";window.setTimeout(run,stime);}}

//对象DIS
function objdis(x,y){
 if(0==x){document.getElementById(y).style.display="none";}	
 else if(1==x){document.getElementById(y).style.display="";}	
}

//跳转
function gourl(x){
 location.href=x;
}

//分站
function fzqhover(){
document.getElementById("fzqh").style.display="";
}
function fzqhout(){
document.getElementById("fzqh").style.display="none";
}

//全选
function xuan(){
 c2=document.getElementsByName("C2");
 c=document.getElementsByName("C1");
 if(c2[0].checked){
 for(i=0;i<c.length;i++){
 c[i].checked="checked";
 }
 }else{
 for(i=0;i<c.length;i++){
 c[i].checked=false;
 }
 }
}
function xuan1(){
 c21=document.getElementsByName("C21");
 c11=document.getElementsByName("C11");
 if(c21[0].checked){
 for(i=0;i<c11.length;i++){
 c11[i].checked="checked";
 }
 }else{
 for(i=0;i<c11.length;i++){
 c11[i].checked=false;
 }
 }
}

function textinto(x,y){
document.getElementById(x).value=y;	
}

//经纪人评价弹窗
function tcjjrpj(x,y){
$.get(document.getElementById("webhttp").innerHTML+"template/sesCheck.php",{},function(result){
 if(result=="none"){
  tclogin();
 }else{
  layer.open({
  type: 2,
  area: ['700px', '325px'],
  title:["经纪人评价","text-align:left"],
  skin: 'layui-layer-rim', //加上边框
  content:[document.getElementById("webhttp").innerHTML+'template/jjrpj.php?id='+x+'&tz='+y, 'no'] 
  });
 }
});
}

function gloobjdis(x,y){
document.getElementById(x).style.display=y;
}

function gloobjhtml(x,y){
document.getElementById(x).innerHTML=y;
}


//弹出会员登录窗口
function tclogin(){
layer.open({
  type: 2,
  area: ['650px', '415px'],
  title:["快捷登录","text-align:left"],
  skin: 'layui-layer-rim', //加上边框
  content:[document.getElementById("webhttp").innerHTML+'template/openw.php', 'no'] 
});
}

//公用报名
function glogetxx(x,y,z){
layer.open({
  type: 2,
  area: ['436px', '325px'],
  title:false,
  skin: 'layui-layer-rim', //加上边框
  shadeClose :true,
  content:[document.getElementById("webhttp").innerHTML+'template/glogetxx.php?admin='+x+"&var1="+y+"&var2="+z, 'no'] 
});
}

function setIndexCookie() {
$.get(document.getElementById("webhttp").innerHTML+"template/indexcookie.php",{admin:2},function(result){
});
};

function getIndexCookie () {
$.get(document.getElementById("webhttp").innerHTML+"template/indexcookie.php",{admin:1},function(result){
 if(result=="no"){
  layer.open({
    type:1,
    title: false,
    closeBtn: 1,
    area: ['900px','465px'],
    shadeClose: false,
    content: $('.indexYJTS')
  });
  setIndexCookie();
 }
});
}