﻿/*登录*/
function login(){
		
					
					var sname=encodeURI($("#use").val());
					var spassword=$("#password").val();
					var srecode=$("#recode").val();
					if(sname==""){
						art.dialog({content:"请输入用户账户",lock:true,style:'alert',lock:true},function(){});
						return;
					}
					if(spassword==""){
						art.dialog({content:"请输入密码",lock:true,style:'alert',lock:true},function(){});
						return;
					}
					if(srecode==""){
						art.dialog({content:"请输入验证码",lock:true,style:'alert',lock:true},function(){});
						return;
					}
					art.dialog({id:'artLogin',title:"loading...",content:"<img src='http://www.hsw365.com/images/loading3.gif' />",lock:true,style:''})
					$.ajax({
					   type: "POST",
					   url: "../ajax/login_hsw365.asp",
					   data: "use="+sname+"&password="+spassword+"&recode="+srecode,
					   success: function(msg){
						   	art.dialog({id:'artLogin'}).close();
						    if(msg == "0"){
								art.dialog({content:"账户或者密码错误",lock:true,style:'error',lock:true},function(){})
							}else{
						 		$("#loginDiv").html(msg);
								
							}
							
							
					   }
					});
					
			
}
function InsertComment(type){
	var newsId = $("#idIt").val();
	var body = $("#CommentBody").val();
	if(body ==""){
			art.dialog({content:'评论内容不能为空',lock:true,style:'error'});
			return;;
	}
	if(body.length > 200){
		art.dialog({content:'评论内容不能超过200字！',lock:true,style:'error'});
		return;
	}
	var datait = "content="+escape(body)+"&id="+escape(newsId)+"&tid="+type;
	$.ajax({
			type: "POST",
		    url: "addbook.asp",
		    data: datait,
			success: function(msg){
				initComment(type);	
				art.dialog({content:'评论发表成功,2秒后自动关闭',lock:true,style:'succeed noClose',time:2});
				$("#CommentBody").val("");		
			}
	});
	
} 

String.prototype.replaceAll = function(s1,s2) { 
    return this.replace(new RegExp(s1,"gm"),s2); 
}

function Rep(obj){
	var temp = obj.replaceAll("\n","<br>");
	temp = temp.replaceAll(" ","&nbsp;");
	return temp;
}
//初始化评论内容
//<dd><strong>游客</strong>(匿名网友) 于 <span>2011-6-14 9:23:23</span></dd>
//<dt>sfsfweqwqwq</dt><dd><strong>游客</strong>(匿名网友) 于 <span>2011-6-14 9:23:14</span></dd>
//<dt>sfsf</dt>
function initComment(obj){
		var newsId = $("#idIt").val();
		var url = "table="+obj+"&tableid="+newsId+"&t="+Math.random();
		var str = "";
		$.getScript("http://www.hsw365.com/booklist.asp?"+url,function(){
					$.each(json,function(idx,item){
						str += "<dd><strong>"+item.会员+"</strong> 于 <span>"+item.时间+"</span></dd>";
						str += "<dt>"+Rep(item.内容)+"</dt>";
					})		
					$("#listst").html(str);									   
		});

		
}

function CheckLogin(){
	$.ajax({
					   type: "POST",
					   url: "../ajax/login_hsw365.asp",
					   data: "",
					   success: function(msg){
						 		$("#loginDiv").html(msg);
					   }
					});
}
/*-----验证码---- */
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function searchit(id,url){
	var keyword = document.getElementById(id).value;
	var allurl = encodeURI(url+"-"+keyword+"_1.htm");
	if(keyword=="请输入搜索关键字"){
		alert("请输入搜索关键字");
		return;
	}
	
	//alert(url+"-"+escape(keyword)+"_1.htm");
	document.location=allurl;
}
function initsearch(id,url){
	var k = document.getElementById(id);
	k.onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			searchit(id,url);
		}
	}
	k.onclick = function(){
		if(k.value=="请输入搜索关键字"){
			k.value="";
		}
	}

}
function allsearch(){
	var type = $("#searchtype").val();
	var k = $("#search_hsw").val();
	if(k==""||k=="请输入搜索关键字"){
		alert("请输入搜索关键字");
		return;
	}
	var url;
	if(type==1){
		url = "http://news.hsw365.com/hsw-list-"+k+"_1.htm";
	}
	if(type==2){
		url="College/hsw-list-"+k+"_1.htm";
	}
	if(type==3){
		url="Trend/hsw-Trendlist-"+k+"_1.htm"
	}
	if(type==4){
		url="http://enjoy.hsw365.com/hsw-list-"+k+"_1.htm";
	}
	if(type==5){
		url="Video/hsw-Videolist-"+k+"_1.htm";
	}
	url = encodeURI(url);
	window.location=url;
}
function initallsearch(){
	document.getElementById("search_hsw").onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			allsearch();
		}
	}
	document.getElementById("search_hsw").onclick = function(){
		if($("#search_hsw").val()=="请输入搜索关键字"){
			document.getElementById("search_hsw").value="";
		}
	}
}
function initallsupplysearch(obj1,obj2){
	document.getElementById("keyword").onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			supplysearch(obj1,obj2);
		}
	}
	document.getElementById("quicksearch").onclick = function(){
			supplysearch(obj1,obj2);
	}
	document.getElementById("keyword").onclick = function(){
		if(document.getElementById("keyword").value=="请输入搜索关键字"){
			document.getElementById("keyword").value="";
		}
	}
}
//供求搜索
function supplysearch(obj1,obj2){
	window.location="supplylist-"+obj1+"-"+obj2+"-"+encodeURI(document.getElementById("keyword").value)+"_1.htm";
}
function initallproductsearch(qunbai,caizhi,category,k){
	document.getElementById("keyword").onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			productsearch(qunbai,caizhi,category,k);
		}
	}
	document.getElementById("quicksearch").onclick = function(){
			productsearch(qunbai,caizhi,category,k);
	}
	document.getElementById("keyword").onclick = function(){
		if(document.getElementById("keyword").value=="请输入搜索关键字"){
			document.getElementById("keyword").value="";
		}
	}
}
function productsearch(qunbai,caizhi,category,k){
	window.location="product-list-"+qunbai+"-"+caizhi+"-"+category+"-"+encodeURI(document.getElementById("keyword").value)+"_1.htm";
}
function initbrand(quyu,category){
	document.getElementById("keyword").onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			brandSearch(quyu,category);
		}
	}
	document.getElementById("quicksearch").onclick = function(){
			brandSearch(quyu,category);
	}
	document.getElementById("keyword").onclick = function(){
		if(document.getElementById("keyword").value=="请输入搜索关键字"){
			document.getElementById("keyword").value="";
		}
	}
}
//品牌搜索
function brandSearch(obj1,obj2){
	window.location="brand-list-"+obj1+"-"+obj2+"-"+encodeURI(document.getElementById("keyword").value)+"_1.htm";
}
function initcompany(){
	document.getElementById("keyword").onkeypress = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			companySearch();
		}
	}
	document.getElementById("quicksearch").onclick = function(){
			companySearch();
	}
	document.getElementById("keyword").onclick = function(){
		if(document.getElementById("keyword").value=="请输入搜索关键字"){
			document.getElementById("keyword").value="";
		}
	}
}
//品牌搜索
function companySearch(){
	window.location="company-list-0-0-0-0-"+encodeURI(document.getElementById("keyword").value)+"_1.htm";
}
function getCookie(objName){//获取指定名称的cookie的值
			var arrStr = document.cookie.split("; ");
			for(var i = 0;i < arrStr.length;i ++){
				var temp = arrStr[i].split("=");
				if(temp[0] == objName) return unescape(temp[1]);
			} 
}
function zhaopinsearch(){
	var url="zhaopin-list-"+$("#jobtype").val();
	url = url +"-"+$("#publishdate").val();
	url = url + "-"+$("#city").val();
	url = url + "-"+$(":radio[name=zhaopintype][checked]").val();
	url = url + "-0";//公司id
	url = url + "-"+encodeURI($("#k").val()); 
	url = url + "_1.htm";
	window.location= url;
	
}
function qiuzhisearch(){
	var url="qiuzhi-list-"+$("#city").val();
	url = url +"-"+$("#jiaoyuchengduid").val();
	url = url + "-"+$("#gongzuonianxianid").val();
	url = url + "-"+$("#xinshuiyaoqiuid").val();
	url = url + "-"+encodeURI($("#k").val()); 
	url = url + "_1.htm";
	window.location= url;
	
}
function mess(a,u){
	var account = getCookie("jname");
	var url = "";
	if(account == undefined || account == "" || account == "undefined"){
		url = "sendmess.asp?a="+a+"&u="+u;
		art.dialog({title:'登录国际婚纱礼服网', iframe:url, width:'390', height:'230',id:'bnt4_denglu'});
		return false;
	}else{
		url="sendmess2.asp?a="+a+"&u="+u;
		window.top.art.dialog({title:'发送短信息', iframe:url, width:'460', height:'400',id:'sendmess2div'});
	}	
}
function messcommon(a,u){
	var account = getCookie("jname");
	var url = "";
	if(account == undefined || account == "" || account == "undefined"){
		url = "/sendmess.asp?a="+a+"&u="+u;
		art.dialog({title:'登录国际婚纱礼服网', iframe:url, width:'390', height:'230',id:'bnt4_denglu'});
		return false;
	}else{
		u=u.replaceAll("%3A",":").replaceAll("%2F","/").replaceAll("%2E",".").replaceAll("%5F","_").replaceAll("%3F","?").replaceAll("%3D","=").replaceAll("%26","&");

		window.location.href=u;
		return false;
	}	
}
