function change(current,mouseDownObj,showObj,currentStyle){
	$(mouseDownObj).eq(current).addClass(currentStyle).siblings().removeClass(currentStyle); 
	$(showObj).eq(current).css({display:''}).siblings().css({display:'none'}); 
}

var comments = {
		check:function(){
				
				var contents = $("#contents").val();
				var checkCode= $("#checkCode").val();
				
				if(!contents||contents=='文明上网，理性发言'){ alert('请填写评论内容'); $("#contents").focus(); return false;}
				else if(!checkCode){ alert('请填写验证码'); $("#checkCode").focus(); return false;}
				else{
					var id       = $("#id").val();
					var formhash = $("#formhash").val();
					var act      = $("#act").val();
					var ctype    = $("#ctype").val();
					$.ajax({
					   type: "POST",
					   url: "save.php",
					   data: "id="+id+"&ctype="+ctype+"&contents="+contents+"&checkCode="+checkCode+"&act="+act+"&formhash="+formhash,
					   success: function(e){
						 if(e=='checkcodeWrong') alert('验证码输入错误');
						 else if(e=='ok'){ alert('评论成功'); window.location.href=window.location.href;}
						 else alert(e);
					   }
					});	
				}
				return false;
			},
		reply:function(obj){
				
				var value = $(obj).html();
				value = value.replace(/(<br>|回复：)/ig,'');
				$("#contents").val('回复：'+value);
				$("#contents").focus();
			}
	};
	
function check_website(){
	var site = $("#site").val();
	if(!site){ alert('网站名称不能为空'); return false;}
	else{
		var inputNum = site.replace(/[^\x00-\xff]/g, "**").length;
		if(inputNum>16){ alert('网站名称不能超过8个汉字'); return false;}
	}
	
	var url = $("#url").val();
	if(!url){ alert('网站地址不能为空'); return false;}
	else{
		if(!url.match(/http:\/\/.+/)){
			alert('请输入正确的网站地址');
			return false;
		}
	}
	
	var cid = $("#cid").val();

	if(cid==0){ alert('请选择收录分类'); return false;}
	
	var province = $("#province").val();
	var city     = $("#city").val();
	if(city==0 || province==0){ alert('请选择所属地区'); return false;}
	
	var linkMeUrl = $("#linkMeUrl").val();
	if(!linkMeUrl){ alert('链接本站地址不能为空'); return false;}
	else{
		if(!linkMeUrl.match(/http:\/\/.+/)){
			alert('请输入正确的链接本站地址');
			return false;
		}
	}
}

function check_exhibition(){
	var ename = $("#ename").val();
	if(!ename){ alert('展会名称不能为空'); return false;}
	
	var eshortName = $("#eshortName").val();
	if(!eshortName){ alert('展会简称不能为空'); return false;}
	
	var province = $("#province").val();
	var city     = $("#city").val();
	if(city==0 || province==0){ alert('请选择举办城市'); return false;}
	
	var startDate = $("#startDate").val();
	var endDate  = $("#endDate").val();
	if(!startDate || !endDate){ alert('请选择展会起始和结束时间'); return false;}
	
	var venues = $("#venues").val();
	if(!venues){ alert('展会场馆不能为空'); return false;}
	
	var zwPrice = $("#zwPrice").val();
	if(!zwPrice){ alert('展位价格不能为空'); return false;}
	
	var organizers = $("#organizers").val();
	if(!organizers){ alert('主办单位不能为空'); return false;}
	
	var sponsor = $("#sponsor").val();
	if(!sponsor){ alert('承办单位不能为空'); return false;}
	
	var contectInfo = $("#contectInfo").val();
	if(!contectInfo){ alert('联系信息不能为空'); return false;}
	
	var content = $("#content").val();
	if(!content){ alert('展会简介不能为空'); return false;}

}

var searchUrlAlter = {
		'check' : function(){
				var checkKwd = $("#checkKwd").val();

				var searchweb = $("#searchweb").val();
				if(searchweb == '16888') searchUrlAlter._16888(checkKwd);
				else if(searchweb == 'autohome') searchUrlAlter.autohome(checkKwd);
				else if(searchweb == 'bitauto') searchUrlAlter.bitauto(checkKwd);
				else if(searchweb == 'pcauto') searchUrlAlter.pcauto(checkKwd);
				else if(searchweb == '51auto') searchUrlAlter._51auto(checkKwd);
				else if(searchweb == 'ucar') searchUrlAlter.ucar(checkKwd);
				return false;
			},
		'tabs' : function(){
				var tabs = $(".tabs li");
				tabs.click(function(){
					var index = tabs.index(this);
					tabs.eq(index).addClass("on").siblings("li").removeClass("on");
					$("#searchType").val(index);
					if(index==6){
						$(".notTwo").css({display:'none'});	
						$(".twoHands").css({display:'block'});
						
						for(var x in webChange){
							if(webChange.eq(x).attr('checked')){
								if(x>0||x<4){
									webChange.eq(0).attr({checked:true});
									$("#searchweb").val(webChange.eq(0).val());	
									break;	
								}	
							}
						}
						
					}
					else{
						$(".notTwo").css({display:'block'});	
						$(".twoHands").css({display:'none'});
						
						for(var x in webChange){
							if(webChange.eq(x).attr('checked')){
								if(x>3){
									webChange.eq(0).attr({checked:true});
									$("#searchweb").val(webChange.eq(0).val());	
									break;	
								}	
							}
						}
						
					}
				});
				
				var webChange = $(".webChange");
				webChange.click(function(){
					var index = webChange.index(this);
					$("#searchweb").val(webChange.eq(index).val());		 
				});
			},
		'_16888' : function(checkKwd){
				var searchType = $("#searchType").val();
				var k          = $("#search-kw").val();
				if((k=='在这里输入你要搜索的内容，点击直达直接进入相应网站对应频道'||!k)&&checkKwd=='true'){ alert('请输入需要搜索的内容'); return false;}
				if(checkKwd=='false') k = '';
				k = encodeURI(k);
				if(searchType==0) window.open('http://www.16888.com/seachprice.php?q='+k);
				else if(searchType==1) window.open('http://auto.16888.com/searchcar.html');
				else if(searchType==2) window.open('http://www.16888.com/searchnews.php?q='+k);
				else if(searchType==3) window.open('http://www.16888.com/seachimg.php?q='+k);
				else if(searchType==4) window.open('http://dealer.16888.com/search.php?q='+k);
				else if(searchType==5){
					var searchform = $("#searchform");
					searchform.attr({action:'http://bbs.16888.com/search.php?mod=forum'});
					$("#search-kw").attr({name:'srchtxt'});
					searchform.submit();
				}
				else if(searchType==6) alert('车主之家没有此栏目');
				//alert(searchType);
			},
		'autohome' : function(checkKwd){
				var searchType = $("#searchType").val();
				var k          = $("#search-kw").val();
				if((k=='在这里输入你要搜索的内容，点击直达直接进入相应网站对应频道'||!k)&&checkKwd=='true'){ alert('请输入需要搜索的内容'); return false;}
				if(checkKwd=='false') k = '';
				k = escape(k);
				if(searchType==0) window.open('http://car.autohome.com.cn//CarPriceNew/ashx/Search.ashx?q='+k);
				else if(searchType==1) window.open('http://sou.autohome.com.cn/zonghe?q='+k);
				else if(searchType==2) window.open('http://sou.autohome.com.cn/zonghe?q='+k);
				else if(searchType==3) window.open('http://car.autohome.com.cn//CarPic/pic_search.ashx/Search.ashx?q='+k);
				else if(searchType==4) window.open('http://dealer.autohome.com.cn/pr6_c670.html');
				else if(searchType==5){
					window.open('http://sou.autohome.com.cn/luntan?q='+k);
					
				}
				else if(searchType==6) window.open('http://www.che168.com/guangdong/list------------------os-p.html?w='+k);
			},
		'bitauto' : function(checkKwd){
				var searchType = $("#searchType").val();
				var k          = $("#search-kw").val();
				if((k=='在这里输入你要搜索的内容，点击直达直接进入相应网站对应频道'||!k)&&checkKwd=='true'){ alert('请输入需要搜索的内容'); return false;}
				if(checkKwd=='false') k = '';
				k = encodeURI(k);
				if(searchType==0) window.open('http://price.bitauto.com/keyword.aspx?keyword='+k+'&cityCode=0');
				else if(searchType==1) window.open('http://www.cheyisou.com/chexing/'+k);
				else if(searchType==2) window.open('http://www.cheyisou.com/qiche/'+k+'/?para=en|utf8');
				else if(searchType==3) window.open('http://www.cheyisou.com/tupian/'+k);
				else if(searchType==4) window.open('http://www.cheyisou.com/jingxiaoshang/'+k);
				else if(searchType==5){
					window.open('http://www.cheyisou.com/luntan/'+k);
					
				}
				else if(searchType==6) window.open('http://www.ucar.cn/buycar/CarList.aspx');
			},
		'pcauto' : function(checkKwd){
				var searchType = $("#searchType").val();
				var k          = $("#search-kw").val();
				if((k=='在这里输入你要搜索的内容，点击直达直接进入相应网站对应频道'||!k)&&checkKwd=='true'){ alert('请输入需要搜索的内容'); return false;}
				if(checkKwd=='false') k = '';
				k = escape(k);
				if(searchType==0) window.open('http://ks.pcauto.com.cn/auto_price.jsp?q='+k+'&version=3');
				else if(searchType==1) window.open('http://ks.pcauto.com.cn/auto_price.jsp?q='+k+'&version=3');
				else if(searchType==2) window.open('http://ks.pcauto.com.cn/auto_cms.jsp?q='+k);
				else if(searchType==3) window.open('http://ks.pcauto.com.cn/auto_photo.jsp?q='+k);
				else if(searchType==4) window.open('http://ks.pcauto.com.cn/auto_dealer.jsp?q='+k);
				else if(searchType==5){
					window.open('http://ks.pcauto.com.cn/auto_bbs.jsp?q='+k);
					
				}
				else if(searchType==6) window.open('http://2car.51auto.com/control/CarsList');
			},
		'_51auto' : function(checkKwd){
				var searchType = $("#searchType").val();
				var k          = $("#search-kw").val();
				if((k=='在这里输入你要搜索的内容，点击直达直接进入相应网站对应频道'||!k)&&checkKwd=='true'){ alert('请输入需要搜索的内容'); return false;}
				if(checkKwd=='false') k = '';
				if(searchType==6&&k) window.open('http://search.51auto.com/q='+k);
				else window.open('http://www.51auto.com/2cars/');
			},
		'ucar' : function(checkKwd){
				var searchType = $("#searchType").val();
				if(searchType==6) window.open('http://www.ucar.cn/');
			}
	};
	
$(function(){
	searchUrlAlter.tabs();
});
