function show(obj){$(obj).show();}
function hide(obj){$(obj).hide();}
//打开新窗口
function openWindowsByEosin(urlOpen,mod,width,height,top,left)
{window.open(urlOpen,mod,"Scrollbars=yes; Width="+width+"px; Height="+height+"px; Top="+top+"px; Left="+left+"px");}
//公司注册检测
function comreg()
{
	if ($("#comname").val()==""){alert("公司名称不能为空！");$("#comname").focus();return false;}
	if ($("#linkman").val()==""){alert("联系人不能为空！");$("#linkman").focus();return false;}
	if ($("#tel").val()==""){alert("联系电话不能为空！");$("#tel").focus();return false;}
	if ($("#addr").val()==""){alert("联系地址不能为空！");$("#addr").focus();return false;}
    return true;
}
//用户注册检测
function reg()        
{   
	if ($("#username").val() == ""){alert("登陆名不能为空！");$("#username").focus();return (false);}
	
	if ($("#usernames").text()=="用户己存在请重新填写"){alert("用户己经存在请重新填写");$("#username").focus();return false;}
	
	if ($("#usernames").text()=="用户名中含有不安全字符"){alert("用户名中含有不安全字符");$("#username").focus();return false;}
	
	if ($("#usernames").text()=="用户格式不正确"){alert("用户格式不正确");$("#username").focus();return false;}
	
	if ($("#pass").val() == ""){alert("密码不能为空！");$("#pass").focus();return (false);}
	
	if ($("#pass1").val() == ""){alert("确认密码不能为空！");$("#pass1").focus();return (false);}
	
	if ($("#pass1").val()!=$("#pass").val()){alert("确认密码与输入的密码不同！");$("#pass1").focus();return (false);}
	
	if ($("#question").val() == ""){alert("请选择您的密码问题！");$("#question").focus();return (false);}
	
	if ($("#answer").val() == ""){alert("请输入您的问题答案！");$("#answer").focus();return (false);}

	//if ($(":radio:checked").val()=="1"&&$("input[name=agent][@checked]").val()=="1"&&$("#cid").val()=="0"){alert("请选择所属公司！");$("#selectButton").focus();return (false)}

	
	if ($("#linkman").val() == ""){alert("请输入您的姓名！");$("#linkman").focus();return (false);} 
		
	if ($("#city").val() == ""){alert("请填写您所在城市名称！");$("#city").focus();return (false);} 
       
    if ($("#area").val() == ""){alert("请填写您所在区/县！");$("#area").focus();return (false);}  
	
	if ($("#tel").val() == ""){alert("请输入您的联系方式！");$("#tel").focus();return (false);}    
	
	if ($("#email").val() == ""){alert("请输入您的电子邮件地址！");$("#email").focus();return (false);}    
	  
	if ($("#emails").text()=="邮箱格式不正确！"){alert("邮箱格式不正确！");$("#email").focus();return false;}
	
	if ($("#emails").text()=="邮箱己存在请重新填写"){alert("邮箱己存在请重新填写！");$("#email").focus();return false;}
	
	return true;
}


//当用户点击输入框时改变样式
function input(obj){$(obj).addClass("redkuang");}
//正确输入样式
function inputright(obj){$(obj).removeClass("redkuang");}
//是否用户名允许的字符 字母数字开头，允许3-16字节，允许字母数字下划线中线
function checkUsername(obj)
{
	var val = $(obj).val();
    var reg = /^[a-zA-Z0-9_]{4,16}/i;
	if (!reg.test(val)){
		$(obj+"s").html("<font color='red'>用户格式不正确</font>");
		input(obj);
		return false
	}
   else{userchk(obj,"/userCenter/userchk.asp");}
}
//密码判断
function checkPass(obj)
{
	var val = $(obj).val();
	var reg = /^\s*[.A-Za-z0-9_-]{6,18}\s*$/; 
	if (!reg.test(val)){
		$(obj+"s").html("<font color='red'>英文字母、数字，6-18位，不区分大小写</font>");
		input(obj);
		return false;
	}
	else{
        $(obj+"s").html("密码符合要求！");
		inputright(obj)
		return true
	}
}

//邮箱判断
function checkEmail(obj)
{
	var val = $(obj).val();
	if ((val.indexOf('@',0)==-1)||(val.indexOf('.',0)==-1)||(val.length<6)){
		$(obj+"s").html("<font color='red'>邮箱格式不正确！</font>");
		input(obj);
		return false
	}
	else{emailchk(obj,"/userCenter/emailchk.asp");}
}

//查询用户是否存在
function userchk(obj,url)
{   
	$(obj+"s").html("正在查询用户是否存在...");
    val = $(obj).val();
	$.get(url+"?aa="+Math.random()+"&username="+val,function(data){		
        var getstr=unescape(data)
		if (getstr=="恭喜你，此会员可以注册"){inputright(obj);$(obj+"s").html(getstr);}
		else{$(obj+"s").html(getstr);return false;}
	});

}

//查询邮箱是否存在
function emailchk(obj,url)
{   
	$(obj+"s").html("正在查询邮箱是否存在...");
    val = $(obj).val();
	$.get(url+"?aa="+Math.random()+"&email="+val,function(data){		
        var getstr=unescape(data)
		if (getstr=="此邮箱可以注册"){inputright(obj);$(obj+"s").html(getstr);}
		else{$(obj+"s").html(getstr);return false;}
	});

}

//登陆
function login()
{
  if ($("#username").val()==""){alert("请输入会员名！");$("#username").focus();return false;}
  if ($("#pass").val()==""){alert("请输入您的密码！");$("#pass").focus();return false;}
  if ($("#validcode").val()==""){alert("请输入验证码！");$("#validcode").focus();return false;}
}

//设置select的选择项
function selecttext(obj,text)
{   
	var count=$(obj+" option").length;
	for(var i=0;i<count;i++)  
    {
		if($(obj).get(0).options[i].text == text){$(obj).get(0).options[i].selected = true; break;}  
	 }	
}
//设置select的选择项
function selectvalue(obj,val)
{   
	var count=$(obj+" option").length;
	for(var i=0;i<count;i++)  
    {
		if($(obj).get(0).options[i].value == val){$(obj).get(0).options[i].selected = true; break;}  
	 }	
}

//会员修改
function modifyuser()
{
	//if ($("usertype").val()=="1"&&$("input[name=agent][@checked]").val()=="1"&&$("#cid").val()=="0"){alert("请选择所属公司！");$("#selectButton").focus();return (false)}
	
	if ($("#linkman").val() == ""){alert("请输入您的姓名！");$("#linkman").focus();return (false);} 
		
	if ($("#city").val() == ""){alert("请填写您所在城市名称！");$("#city").focus();return (false);} 
       
    if ($("#area").val() == ""){alert("请填写您所在区/县！");$("#area").focus();return (false);}  
	
	if ($("#tel").val() == ""){alert("请输入您的联系方式！");$("#tel").focus();return (false);}    
	
	if ($("#email").val() == ""){alert("请输入您的电子邮件地址！");$("#email").focus();return (false);}    
	
	return true;
}

//显示片区
function getpqlist(obj,val1,val2)
{   
	var count=$(obj+" option").length;
	$(obj+" option").slice(1,count).remove();
	$(obj).attr("disabled","disabled");
	$.get("/inc/getpqlist.asp?areaid="+val1,function(data){$(obj).removeAttr("disabled");$(obj).append(unescape(data));if(val2!=""){selectvalue(obj,val2)};})
}

function changejg()
{   
	var text=$("#infotypeid").find("option:selected").text();

	if(text=="出租"||text=="合租"||text=="求租"){$("#cs").hide();$("#zy").hide();$("#cz").show()}
	
	else if(text=="出售"||text=="求购"){$("#cz").hide();$("#zy").hide();$("#cs").show();}
	
	else if(text=="租售"){$("#zy").hide();$("#cz").show();$("#cs").show();}
	
	else if(text=="转让"){$("#cz").hide();$("#cs").hide();$("#zy").show();}
	
	//else{$("#cs").hide();$("#zy").hide();$("#cz").show()}
	
}

function callupload(begin,count,url){for (i=begin;i<=count;i++){upload("upload"+i,i,url);}}

/////上传图片
function upload(obj,i,url){
    var obj = $('#button'+i), interval;
	new AjaxUpload(obj,{
		action: url, 
		name: 'file1',
		onSubmit : function(file, ext){		
			obj.val('上传中…');
			this.disable();
			interval = window.setInterval(function(){
				var val = obj.val();
				if (val.length < 6){
					obj.val(val + '.');					
				} else {
					obj.val('上传中');				
				}
			}, 200);
		},
		onComplete: function(file, response){
		    obj.val('上传图片');
			var responsetext=response.split("|")
				eval(responsetext[1])		
			window.clearInterval(interval);
			this.enable();
			if (responsetext[0]!=""){
			   $("#images"+i).val(responsetext[0]);
			   if (responsetext[0].indexOf(".swf")!=-1){
					$("#img"+i).replaceWith("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='163' height='56'><param name='movie' value='"+responsetext[0]+"' /><param name='quality' value='high' /> <param name='wmode' value='opaque' /><embed src='"+responsetext[0]+"' quality='high' wmode='opaque' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='163' height='56'></embed></object>");
				}
				else{$("#img"+i).attr("src",responsetext[0]);
				}
			}					
		}
	});
}

//发布检测
function publiczs()
{		
	var text=$("#infotypeid").find("option:selected").text();
	if ($("#housetypeid").val()=="0"){alert("请选择信息类型");$("#housetypeid").focus();return false;}
	
	if ($("#infotypeid").val()=="0"){alert("请选择意向");$("#infotypeid").focus();return false;}
	
	if ($("#areaid").val()=="0"){alert("请选择区域");$("#areaid").focus();return false;}
	
	if ($("#pqid").val()=="0"){alert("请选择片区");$("#pqid").focus();return false;}
	
	var flag=0;$(":checkbox:jianzhu").each(function(){if($(this).attr("checked")==true){flag++;}})
	
	if (flag==0){alert("请选择建筑结构");$("#jianzhu").focus();return false;}
	
    if((text=="出租"||text=="合租"||text=="求租"||text=="租售")&&$("#czjg").val()==""){alert("请输入租金");$("#czjg").focus();return false;}
	
	if((text=="出售"||text=="求购"||text=="租售")&&$("#csjg").val()==""){alert("请输入售价");$("#csjg").focus();return false;}
	
	if(text=="转让"&&$("#zyjg").val()==""){alert("请输入转让价");$("#zyjg").focus();return false;}
	
	if ($("#title").val()==""){alert("请输入信息标题");$("#title").focus();return false;}
	
	if ($("#jpnote").val()==""){alert("请输入精辟内容词语");$("#jpnote").focus();return false;}
	
	if ($("#content").val()==""){alert("请输入信息内容");$("#content").focus();return false;}
}
//检测数字
function IsNum(obj){ if (isNaN($(obj).val())){alert("此处只能输入数字");$(obj).val("");$(obj).focus()}}
//设置单选
function radiovalue(obj,val){$(":radio:"+obj).each(function(){if (val.indexOf($(this).val())!=-1){$(this).attr("checked","checked");}})}
//设置多选
function checkvalue(obj,val){$(":checkbox:"+obj).each(function(){if (val.indexOf($(this).val())!=-1){$(this).attr("checked","checked");}})}

//显示小类
function getclass(obj,val1,val2)
{   
	var count=$(obj+" option").length;
	$(obj+" option").slice(1,count).remove();
	$(obj).attr("disabled","disabled");
	$.get("/inc/getclass.asp?parentid="+val1,function(data){$(obj).removeAttr("disabled");$(obj).append(unescape(data));if(val2!=""){selectvalue(obj,val2)};})
}

//发布配套
function publicpt()
{
	var text=$("#infotype").find("option:selected").text();
	if ($("#parentid").val()=="0"){alert("请选择大类");$("#parentid").focus();return false;}
	
	if ($("#classid").val()=="0"){alert("请选择小类");$("#classid").focus();return false;}
	
	if ($("#areaid").val()=="0"){alert("请选择区域");$("#areaid").focus();return false;}
	
	if ($("#pqid").val()=="0"){alert("请选择片区");$("#pqid").focus();return false;}
	
    if((text=="出租"||text=="合租"||text=="求租"||text=="租售")&&$("#czjg").val()==""){alert("请输入租金");$("#czjg").focus();return false;}
	
	if ($("#title").val()==""){alert("请输入信息标题");$("#title").focus();return false;}
	
	if ($("#jpnote").val()==""){alert("请输入精辟内容词语");$("#jpnote").focus();return false;}
	
	if ($("#content").val()==""){alert("请输入信息内容");$("#content").focus();return false;}
}

function GetUrl(housetypeid)
{   
    var Url="/zushou/"
	if(housetypeid==1){Url="/ck/"}
	else if(housetypeid==2){Url="/ck/"}
	else if(housetypeid==3){Url="/gyy/"}
	else if(housetypeid==4){Url="/gyyd/"}
	else if(housetypeid==5){Url="peitao/"}
	return Url
}
function sou()
{
	var housetypeid=$("#housetypeid").val();
	var infotypeid=$("#infotypeid").val();
	var areaid=$("#areaid").val();
	var pqid=$("#pqid").val();
	var mianji=$("#mianji").val();
	var key=$("#key").val();
	if(housetypeid==""){alert("请选择信息类型");$("#housetypeid").focus();return false;}
	if(infotypeid==""){alert("请选择意向");$("#infotypeid").focus();return false;}
	if (key==""){key="0";}
	url=GetUrl(housetypeid)+"list-"+housetypeid+"-"+infotypeid+"-"+areaid+"-"+pqid+"-"+mianji+"-0-0-"+escape(key)+"-0-1.html"
	window.location.href=encodeURI(url);
}

function soupt()
{
	var parentid=$("#parentid").val();
	var classid=$("#classid").val();
	var key=$("#key").val();
	if (key==""){key="0";}
	url="/peitao/"+"list-"+parentid+"-"+classid+"-0-0-0-0-0-"+escape(key)+"-0-1.html"
	window.location.href=encodeURI(url);
}

function sounews()
{
	var classid=$("#classid").val();
	var key=$("#key").val();
	if (key==""){key="0";}
	url="/zhinan/"+"list-"+classid+"-"+escape(key)+"-1.html"
	window.location.href=encodeURI(url);
}

function shownav(k)
{
   for(var i=0;i<10;i++){$("#subnav_"+i).hide();$("#title_"+i).removeClass("hover");}
   $("#title_"+k).addClass("hover");
   $("#subnav_"+k).show();
}


function heartBeat(){ 
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
 diffY = document.documentElement.scrollTop;
else if (document.body)
 diffY = document.body.scrollTop;
else{}
percent=.1*(diffY-lastScrollY); 
if(percent>0)percent=Math.ceil(percent); 
else percent=Math.floor(percent); 
document.getElementById("leftDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px";
document.getElementById("rightDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px";
lastScrollY=lastScrollY+percent; 
}

function copyToClipBoard(){var clipBoardContent="";clipBoardContent+=document.title;clipBoardContent+=""; clipBoardContent+=this.location.href;window.clipboardData.setData("Text",clipBoardContent);alert("复制成功!");}

function jubao(infoid){$.get("/inc/report.asp?id="+infoid,function(){alert("您已成功举报该信息！");})}
