﻿var fileid = "";
var n=-1;
$(document).ready(function(){
	$('.moor').mouseover(function(){
		$('.-d').css('display','none');
		$('.moor').css("background-image","url(../../Pubstyle/images/jiaoyu0.jpg)");
		$('#'+this.id).css("background-image","url(../../Pubstyle/images/jiaoyu.jpg)");
		$('#'+this.id+'-d').css('display','block');
	  }
	);
	$('.moor01').mouseover(function(){
		$('.-e').css('display','none');
		$('.moor01').css("background-image","url(../../Pubstyle/images/zuixin.jpg)");
		$('#'+this.id).css("background-image","url(../../Pubstyle/images/jingpin.jpg)");
		$('#'+this.id+'-e').css('display','block');
	  }
	);
	$('.moor02').mouseover(function(){
		$('.-f').css('display','none');
		$('.moor02').css("background-color","#FFF");
		$('#'+this.id).css("background-color","#E8E7E7");
		$('#'+this.id+'-f').css('display','block');
	  }
	);
		setInterval("showAuto()", 3000);
});
function showAuto()
	{	++n;
		if(n>3) n=0;
		$(".qiehuan_top div").eq(n).trigger('mouseover');
	}
function headtonews(aid){
	var a_id = aid;
	window.location.href='../index.php/Cont?a_id='+aid;
}
function mousover(id){
		$('#'+id+'list').css('background','#FFFDF6');
}
function mousout(id){
		$('#'+id+'list').css('background','none');
}
function headtolist(id){
		var channel_id = id;
		
		if(channel_id =='zufang'){
			window.location.href='../index.php/House?cid='+channel_id;
		}else if(channel_id == 'zhaopin'){
			window.location.href='../index.php/Rment?cid='+channel_id;
		}else{
			window.location.href='../index.php/News?cid='+channel_id;
		}
}
function subkeyword(){
	var key = $('#keyword').val();
	var url = 'House/selkey';
	$.ajax({
    url: url,
    data: 'keys='+key,
    type: 'POST',
    dataType: 'html',
    timeout: 3000,
    error: function(){
        alert('网络超时');
    },
    success: function(msg){
		alert(msg);
		//window.location.href="../index.php/Manage";
    }
});
}
//弹出层star
function show(tag){
 var light=document.getElementById(tag);
 //var fade=document.getElementById('fade');
 light.style.display='block';
 //fade.style.display='block';
 }
function hide(tag){
 var light=document.getElementById(tag);
 //var fade=document.getElementById('fade');
 light.style.display='none';
 //fade.style.display='none';
 window.location.reload();
}
function hidef(tag){
 var light=document.getElementById(tag);
 //var fade=document.getElementById('fade');
 light.style.display='none';
 //fade.style.display='none';
 window.location.reload();
}
//end
function submitaddrent(){
	var title = $("#title").val().replace(/^\s+|\s+$/g,"");
	var dates = $("#dates").val().replace(/^\s+|\s+$/g,"");
	var area = $("#area").val().replace(/^\s+|\s+$/g,"");
	var address = $("#address").val().replace(/^\s+|\s+$/g,"");
	var livetime = $("#dates").val();
	var tmtype = $("#tmtype").val();
	var rent_style = $("input[name='rent_style']:checked").val();
	var house_style = $("input[name='house_style']:checked").val();
	var price = $("#price").val();
	var phone = $("#phone").val().replace(/\s+/g,"");
	var qq = $("#qq").val().replace(/\s+/g,"");
	var email = $("#email").val();
	var password = $("#password").val().replace(/^\s+|\s+$/g,"");
	var content = $("#content").val();
	var filename = '';
	var filedata = new Array();
	var nfiledata = new Array();
	 $("#fileQueue .fileName").each(function(){
				  if($("#fileQueue .fileName").length>1){
					filename += jQuery(this).html()+'##';
		filedata = filename.split('##');
		for(var i=0;i<filedata.length-1;i++){
			var reg = /([^\b]+)\(/g;
			reg.exec(filedata[i]);   
			nfiledata[i] = RegExp.$1.replace(/\s+/g,""); 
		}
				  }else if($("#fileQueue .fileName").length=1)
				  {
					filename+=$("#fileQueue .fileName").html();
					
					var reg = /([^\b]+)\(/g;
					reg.exec(filename);   
					nfiledata = RegExp.$1.replace(/\s+/g,"");
				  }else{
					alert("上传失败，请按要求添加附件!");
					return false;
				  }
	  })
	var obj = nfiledata;
	for(var j=0;j<nfiledata.length;j++){
		if(/.*[\u4e00-\u9fa5]+.*$/.test(nfiledata[j])) 
		{ 
			alert("文件名格式错误，请使用英文字符!"); 
			return false; 
		}
	}
	if(price.length>5){
		alert("价格格式错误");
		return false;
	}
	if(/[^\d]/.test(price) && price != ''){
		alert("价格必须是数字!");
		return false;
	}
	if(title.length > 14){
		alert('标题必须在14个汉字以内');
		return false;
	}
	if(isNaN(phone) && phone.length!=10 && phone!==''){
		alert('电话号码格式错误');
		return false;
	}
	if(isNaN(qq) && qq!==''){
		alert('qq号码格式错误');
		return false;
	}
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.test(email) && email!==''){
		alert('email格式错误!');
	  return false; 
	}
	if(title==''||title==null||area==''||area==null||livetime==''||livetime==null||password==''||password==null||content==''||content==null){
		alert("必填选项需要填写完整!");
		return false;
	}else if( (phone==''||phone==null) && (qq==''||qq==null) && (email==''||email==null)){
		alert("至少填写一种联系方式!");
		return false;
	}
	url='House/add_new_rent';
	$.ajax({
		url: url,
		data: 'title='+title+'&dates='+dates+'&area='+area+'&address='+address+'&livetime='+livetime+'&tmtype='+tmtype+'&rent_style='+rent_style+'&house_style='+house_style+'&price='+price+'&phone='+phone+'&qq='+qq+'&email='+email+'&password='+password+'&content='+content+'&nfiledata='+nfiledata,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
	$('#uploadify').uploadifyUpload();
			var lastid = msg;
			if(nfiledata !='' && nfiledata != null){
				url='House/add_new_img';
				$.ajax({
				url: url,
				data: 'lastid='+lastid+'&nfiledata='+nfiledata,
				type: 'POST',
				dataType: 'html',
				timeout: 3000,
				error: function(){
					alert('网络超时');
				},
				success: function(msg){
					return;
				}			
				})
			}else{
				window.location.reload();
			}
		}
	});
}
function submitaddrent1(){
	var title = $("#title").val().replace(/^\s+|\s+$/g,"");
	var dates = $("#dates").val().replace(/^\s+|\s+$/g,"");
	var area = $("#area").val().replace(/^\s+|\s+$/g,"");
	var address = $("#address").val().replace(/^\s+|\s+$/g,"");
	var livetime = $("#dates").val();
	var tmtype = $("#tmtype").val();
	var rent_style = $("input[name='rent_style']:checked").val();
	var house_style = $("input[name='house_style']:checked").val();
	var price = $("#price").val();
	var phone = $("#phone").val().replace(/\s+/g,"");
	var qq = $("#qq").val().replace(/\s+/g,"");
	var email = $("#email").val();
	var password = $("#password").val().replace(/^\s+|\s+$/g,"");
	var content = $("#content").val();
	var filename = '';
	var filedata = new Array();
	var nfiledata = new Array();
	 $("#fileQueue .fileName").each(function(){
				  if($("#fileQueue .fileName").length>1){
					filename += jQuery(this).html()+'##';
		filedata = filename.split('##');
		for(var i=0;i<filedata.length-1;i++){
			var reg = /([^\b]+)\(/g;
			reg.exec(filedata[i]);   
			nfiledata[i] = RegExp.$1.replace(/\s+/g,""); 
		}
				  }else if($("#fileQueue .fileName").length=1)
				  {
					filename+=$("#fileQueue .fileName").html();
					
					var reg = /([^\b]+)\(/g;
					reg.exec(filename);   
					nfiledata = RegExp.$1.replace(/\s+/g,"");
				  }else{
					alert("上传失败，请按要求添加附件!");
					return false;
				  }
	  })
	var obj = nfiledata;
	for(var j=0;j<nfiledata.length;j++){
		if(/.*[\u4e00-\u9fa5]+.*$/.test(nfiledata[j])) 
		{ 
			alert("文件名格式错误，请使用英文字符!"); 
			return false; 
		}
	}
	if(price.length>5){
		alert("价格格式错误");
		return false;
	}
	if(/[^\d]/.test(price) && price != ''){
		alert("价格必须是数字!");
		return false;
	}
	if(title.length > 14){
		alert('标题必须在14个汉字以内');
		return false;
	}
	if(isNaN(phone) && phone.length!=10 && phone!==''){
		alert('电话号码格式错误');
		return false;
	}
	if(isNaN(qq) && qq!==''){
		alert('qq号码格式错误');
		return false;
	}
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.test(email) && email!==''){
		alert('email格式错误!');
	  return false; 
	}
	if(title==''||title==null||area==''||area==null||livetime==''||livetime==null||password==''||password==null||content==''||content==null){
		alert("必填选项需要填写完整!");
		return false;
	}else if( (phone==''||phone==null) && (qq==''||qq==null) && (email==''||email==null)){
		alert("至少填写一种联系方式!");
		return false;
	}
	$('#uploadify').uploadifyUpload();
	url='../House/add_new_rent';
	$.ajax({
		url: url,
		data: 'title='+title+'&dates='+dates+'&area='+area+'&address='+address+'&livetime='+livetime+'&tmtype='+tmtype+'&rent_style='+rent_style+'&house_style='+house_style+'&price='+price+'&phone='+phone+'&qq='+qq+'&email='+email+'&password='+password+'&content='+content+'&nfiledata='+nfiledata,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			var lastid = msg;
			if(nfiledata !='' && nfiledata != null){
				url='House/add_new_img';
				$.ajax({
				url: url,
				data: 'lastid='+lastid+'&nfiledata='+nfiledata,
				type: 'POST',
				dataType: 'html',
				timeout: 3000,
				error: function(){
					alert('网络超时');
				},
				success: function(msg){
					return;
				}			
				})
			}else{
				window.location.reload();
			}
		}
	});
}
function submitaddjobs(){
	var title = $("#title").val();
	var area = $("#area").val();
	var job_style = $("input[name='jobstyle']:checked").val();
	var sex = $("input[name='sex']:checked").val();
	var price = $("#price").val();
	var tmtype = $("#tmtype").val();
	var phone = $("#phone").val();
	var qq = $("#qq").val();
	var email = $("#email").val();
	var password = $("#password").val();
	var content = $("#content").val();
	/*if(title==''||title==null||area==''||area==null||password==''||password==null||content==''||content==null){
		alert("必填选项需要填写完整!");
		return false;
	}else if( (phone==''||phone==null) && (qq==''||qq==null) && (email==''||email==null)){
			alert("至少填写一种联系方式!");
		return false;
	}
	if(price.length>5){
		alert("价格格式错误");
		return false;
	}
	if (/[^\d]/.test(price) && price != ''){
		alert("价格必须是数字!");
		return false;
	}
	if(title.length > 14){
		alert('标题必须在14个汉字以内');
		return false;
	}
	if(isNaN(phone) || phone.length!=10 && phone!==''){
		alert('电话号码格式错误');
		return false;
	}
	if(isNaN(qq) && qq!==''){
		alert('qq号码格式错误');
		return false;
	}
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.test(email) && email!==''){
		alert('email格式错误!');
	  return false; 
	}*/
	url='Jobs/add_new_rent';
	$.ajax({
		url: url,
		data: 'title='+title+'&area='+area+'&job_style='+job_style+'&sex='+sex+'&price='+price+'&tmtype='+tmtype+'&phone='+phone+'&qq='+qq+'&email='+email+'&password='+password+'&content='+content,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			alert('发布成功!');
			//window.location.href='../index.php/Jobs?cid=zhaopin';
		}
	});
}
function submitaddjobs1(){
	var title = $("#title").val();
	var area = $("#area").val();
	var job_style = $("input[name='jobstyle']:checked").val();
	var sex = $("input[name='sex']:checked").val();
	var price = $("#price").val();
	var tmtype = $("#tmtype").val();
	var phone = $("#phone").val();
	var qq = $("#qq").val();
	var email = $("#email").val();
	var password = $("#password").val();
	var content = $("#content").val();
	
	if(title==''||title==null||area==''||area==null||password==''||password==null||content==''||content==null){
		alert("必填选项需要填写完整!");
		return false;
	}else if( (phone==''||phone==null) && (qq==''||qq==null) && (email==''||email==null)){
			alert("至少填写一种联系方式!");
		return false;
	}
	if(price.length>5){
		alert("价格格式错误");
		return false;
	}
	if(/[^\d]/.test(price) && price != ''){
		alert("价格必须是数字!");
		return false;
	}
	if(title.length > 14){
		alert('标题必须在14个汉字以内');
		return false;
	}
	if(isNaN(phone) || phone.length!=10 && phone!==''){
		alert('电话号码格式错误');
		return false;
	}
	if(isNaN(qq) && qq!==''){
		alert('qq号码格式错误');
		return false;
	}
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.test(email) && email!==''){
		alert('email格式错误!');
	  return false; 
	}
	url='../Jobs/add_new_rent';
	$.ajax({
		url: url,
		data: 'title='+title+'&area='+area+'&job_style='+job_style+'&sex='+sex+'&price='+price+'&tmtype='+tmtype+'&phone='+phone+'&qq='+qq+'&email='+email+'&password='+password+'&content='+content,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			alert('发布成功!');
			window.location.href='../index.php/Jobs?cid=zhaopin';
		}
	});
}
function editjobs(){
	var title = $("#title").val();
	var aid = $("#aid").val();
	var area = $("#area").val();
	var job_style = $("input[name='jobstyle']:checked").val();
	var sex = $("input[name='sex']:checked").val();
	var price = $("#price").val();
	var tmtype = $("#tmtype").val();
	var phone = $("#phone").val();
	var qq = $("#qq").val();
	var email = $("#email").val();
	var password = $("#password").val();
	var content = $("#content").val();
	if(title==''||title==null||area==''||area==null||password==''||password==null||content==''||content==null){
		alert("必填选项需要填写完整!");
		return false;
	}else if( (phone==''||phone==null) && (qq==''||qq==null) && (email==''||email==null)){
			alert("至少填写一种联系方式!");
		return false;
	}
	if(price.length>5){
		alert("价格格式错误");
		return false;
	}
	if(/[^\d]/.test(price) && price != ''){
		alert("价格必须是数字!");
		return false;
	}
	if(title.length > 14){
		alert('标题必须在14个汉字以内');
		return false;
	}
	if(isNaN(phone) || phone.length!=10 && phone!==''){
		alert('电话号码格式错误');
		return false;
	}
	if(isNaN(qq) && qq!==''){
		alert('qq号码格式错误');
		return false;
	}
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.test(email) && email!==''){
		alert('email格式错误!');
	  return false; 
	}
	url='../Jobs/update_new';
	$.ajax({
		url: url,
		data: 'title='+title+'&area='+area+'&aid='+aid+'&job_style='+job_style+'&sex='+sex+'&price='+price+'&tmtype='+tmtype+'&phone='+phone+'&qq='+qq+'&email='+email+'&password='+password+'&content='+content,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
		if(msg == 1){
			alert('修改成功!');
			window.location.href='../index.php/Jobs?cid=zhaopin';
		}
		else if(msg == 0){
			alert('修改失败!');
			return false;
		}else{
			alert('修改失败!');
		}
		}
	});
}
function subarea(area){
	url='Jobs/selectjobs';
	$.ajax({
		url: url,
		data: 'area='+area,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			$(".right_box").html(msg);
		}
	});
}
function subtype(area,ty){
	url='../Jobs/selectjobs';
	$.ajax({
		url: url,
		data: 'area='+area+'&ty='+ty,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			$(".c_box_left").html(msg);
		}
	});
}
function substyle(area){
	url='../Jobs/selectjobs';
	$.ajax({
		url: url,
		data: 'area='+area,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			$(".right_box").html(msg);
		}
	});
}
function updatejobs(id){
	window.location.href='../Jobs/Release?aid='+id;
}
function subpwd(){
	alert($("#pwd").val());
}
function showpage(num,type){
	url='Jobs/showpage';
	$.ajax({
		url: url,
		data: 'num='+num+'&type='+type,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){
			$(".right_box").html(msg);
		}
	});
}
function shownew(num,type,cid){
	url='News/showpage';
	$.ajax({
		url: url,
		data: 'num='+num+'&type='+type+'&cid='+cid,
		type: 'POST',
		dataType: 'html',
		timeout: 3000,
		error: function(){
			alert('网络超时');
		},
		success: function(msg){//alert(msg);return;
			$(".cbody").html(msg);
		}
	});
}
