$(document).ready(function(){
	adimgshow();
	$("#yzrbt").hover(function () {
		$(this).removeClass("yzr01").addClass("yzr02");
	},function () {
		$(this).removeClass("yzr02").addClass("yzr01");
	});
	
	$("#showssBox_0 p").hover(function () {
		$(this).addClass("pbg");
	},function () {
		$(this).removeClass("pbg")
	});
	
	$(".dhbt,.s1").click(function () {
		for(var i=0;i<4;i++){
			$('.jyssbg').removeClass('jyssbged_'+i);
		}
		$('.showssBox').hide();
	});
	
	$('div.jyssbg').click(function(){
		var index=$(this).attr('index');
		if($(this).hasClass('jyssbged_'+index)){
			$(this).removeClass('jyssbged_'+index);
			$('#showssBox_'+index).hide();
		}else{
			$('#showssBox_0,#showssBox_1,#showssBox_2,#showssBox_3').hide();
			$('#showssBox_'+index).show();
			for(var i=0;i<4;i++){
				$('div.jyssbged_'+i).removeClass('jyssbged_'+i);
			}
			$(this).addClass('jyssbged_'+index);
			$(this).removeClass("jyssbgover");
		}
		return false;
	}).hover(function(){
		var index=$(this).attr('index');
		if(!$(this).hasClass('jyssbged_'+index)){
			$(this).addClass("jyssbgover");
		}
	},function(){
		$(this).removeClass("jyssbgover");
	});
	$('div.showssBox').click(function(e){
		e.stopPropagation();
	});
	$(document).click(function(){
		for(var i=0;i<4;i++){
			$('div.jyssbged_'+i).removeClass('jyssbged_'+i);
		}
		$('.showssBox').hide();
	});
	
	var setHeight=function(){
		var height1=$('#showssBox_1 select[name=heightbegin]').val();
		var height2=$('#showssBox_1 select[name=heightend]').val();
		var html='';
		if(height1==''&&height2==''){
			html='模特身高';
			$('#HeadSearchHeight').val(0);
			$('#HeadSearchHeight1').val(0);
		}else if(height1==''){
			html=height2+'以下';
			$('#HeadSearchHeight').val(0);
			$('#HeadSearchHeight1').val(height2);
		}else if(height2==''){
			html=height1+'以上';
			$('#HeadSearchHeight').val(height1);
			$('#HeadSearchHeight1').val(0);
		}else{
			if(height1>height2){
				html=height2+'-'+height1+'CM';
				$('#HeadSearchHeight').val(height2);
				$('#HeadSearchHeight1').val(height1);
			}else if(height1==height2){
				html=height1+'CM';
				$('#HeadSearchHeight').val(height1);
				$('#HeadSearchHeight1').val(height1);
			}else{
				html=height1+'-'+height2+'CM';
				$('#HeadSearchHeight').val(height1);
				$('#HeadSearchHeight1').val(height2);
			}
		}
		$('.jyssbg_1 span').html(html);
	};
	
	var setStyle=function(){
		var html='';
		
		var HeadstyleMax = document.getElementById("HeadstyleMax");
		var HeadstyleMin = document.getElementById("HeadstyleMin");

		if(HeadstyleMax.value==''&&HeadstyleMin.value==''){
			html='模特类别';
			$('#HeadSearchStyle').val('');
		}else if(HeadstyleMin.value==''){
			html=HeadstyleMax.value;
			$('#HeadSearchStyle').val(HeadstyleMax.value);
		}else{
			html=HeadstyleMin.value;
			$('#HeadSearchStyle').val(HeadstyleMin.value);
		}
		
		$('.jyssbg_3 span').html(html);
	};
	

	var setCity=function(){
		var html='';
		
		var provinces = document.getElementById("provinces");
		var citys = document.getElementById("header_citys");
		$('#HeadSearchProvince').val(provinces.value);
		$('#HeadSearchCity').val(citys.value);
		if(provinces.value==''&&citys.value==''){
			html='所在城市';
		}else if(citys.value==''){
			html=provinces.value;
		}else{
			html=provinces.value + ' ' + citys.value;
		}
		
		$('.jyssbg_2 span').html(html);
	};
	
	$('#showssBox_0 .s1').click(function(){
		$('.jyssbg_0 span').html($(this).html());
		$('.jyssbg_0 input').val($(this).attr('value'));
	});
	$('#showssBox_1 .dhbt').click(setHeight);
	$('#showssBox_2 .dhbt').click(setCity);
	$('#showssBox_3 .dhbt').click(setStyle);
	$('#yzrbt').click(function(){
		
	});

});


   function checkLogin(){
      var theform = document.getElementById("login");
      var name=theform.username.value;
      var password=theform.password.value;
    if(name=="模特卡号或邮箱"||name==""){
	     alert("请输入用户名！");
		 return false;
	  }else if(password==""){
	     alert("请输入密码！");
		 return false;
	  }else{
	     theform.submit(); 
	  }
      
   }

	function levemessage(mid){
		if(mid==null){
			alert('你还没登陆');
			document.location.href="/login.php";
		}else{
		var obj = document.getElementById("out");
		obj.style.display = "block";}
	}
	function submit(obj){
		var obj = document.getElementById("out");
		obj.style.display = "none";
	}
	function cancel(obj){
		var obj = document.getElementById("out");
		obj.style.display = "none";
	}

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  	try {
    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  	} catch (e2) {
    		xmlHttp = false;
  	}
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
  xmlHttp = new XMLHttpRequest();
}
function header_showcity(cityname){
	var city = document.getElementById("header_city");
	if(cityname==""){
		city.innerHTML="<select name=\"city\" id=\"header_citys\"><option value=\"0\">---不限---</option></select>";
	}else{
		var url = "/include/index/getcity.php?cityname=" +encodeURIComponent(cityname);
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = header_showcityOK;
		xmlHttp.send(null);	
	}
}
function header_showcityOK(){
	if (xmlHttp.readyState == 4) {
		try{
			var response = xmlHttp.responseText;
			var city = document.getElementById("header_city");
			city.innerHTML=response;
		}catch(exception){}
	}	
}


function showstyle(cityname){
	var Headstyles = document.getElementById("Headstyles");
	if(cityname==""){
		Headstyles.innerHTML="<select name=\"HeadstyleMin\" id=\"HeadstyleMin\"><option value=\"\">--不限--</option></select>";
	}else{
			var url = "/include/index/getstyle.php?cityname=" +encodeURIComponent(cityname);
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = showstyleOK;
			xmlHttp.send(null);	
	}
}
function showstyleOK(){
	if (xmlHttp.readyState == 4) {
		try{
			var response = xmlHttp.responseText;
			var Headstyles = document.getElementById("Headstyles");
			Headstyles.innerHTML=response;
		}catch(exception){}
	}	
}

function qiehuanShowcity(cityname){
	var QiehuanCity = document.getElementById("QiehuanCity");
	if(cityname==""){
		QiehuanCity.innerHTML="<select name=\"QiehuanCity\" id=\"QiehuanCitys\"><option value=\"\">全部</option></select>";
	}else{
			var url = "/include/index/getQiehuanCity.php?cityname=" +encodeURIComponent(cityname);
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = qiehuanShowcityOK;
			xmlHttp.send(null);	
	}
}
function qiehuanShowcityOK(){
	if (xmlHttp.readyState == 4) {
		try{
			var response = xmlHttp.responseText;
			var QiehuanCity = document.getElementById("QiehuanCity");
			QiehuanCity.innerHTML=response;
		}catch(exception){}
	}	
}

function HeadSearchKeyFun(){
	var KeywordName = document.getElementById("KeywordName");
	if(KeywordName.value=='模特卡、名字'){
		document.KeySearch.action="/search/";
	}else{
		document.KeySearch.action="/search/---0-0-2--"+encodeURI(KeywordName.value)+"-30-1-1.html";
	}
	document.KeySearch.submit();
}	


function HeadSearchGaojiFun(){

	//document.GaojiSearchForm.action="/search/"+encodeURI($('#provinces').val())+"-"+encodeURI($('#thecity').val())+"-"+encodeURI($('#select_lb').val())+"-"+encodeURI($('#select_sg1').val())+"-"+$('#select_sg2').val()+"-"+encodeURI($('#select_nl1').val())+"-"+$('#select_nl2').val()+"-"+$('#select_xb').val()+"---30-1-1.html";
	document.GaojiSearchForm.action="/search/"+encodeURI($('#provinces').val())+"-"+encodeURI($('#citys').val())+"-"+encodeURI($('#select_lb').val())+"-"+encodeURI($('#select_sg1').val())+"-"+$('#select_sg2').val()+"-"+$('#select_xb').val()+"---30-1-1.html";
	document.GaojiSearchForm.submit();
}

function qieCityFucn(){
	$("#theCityP").show();
	$("#qiehuanDiv").hide();
	if(qieMyform.qiehuanPro.value==""){
		document.qieMyform.action="http://www.motexiu.cn/";
		//document.qieMyform.action="http://www.motexiu.cn/";
	}else if(qieMyform.QiehuanCity.value==""){
		document.qieMyform.action="http://www.motexiu.cn/"+qieMyform.qiehuanPro.value;
	}else{
		document.qieMyform.action="http://www.motexiu.cn/"+qieMyform.QiehuanCity.value;
	}
	
	document.qieMyform.submit();
}
function changeCity(){
   $("#theCityP").hide();
   $("#changeCity").hide();
   $("#qiehuanDiv").show();
}


function adimgshow(){
	setTimeout(switchimg,1500);
}
function switchimg(){
	$("#top1").toggle();
	$("#top2").toggle();
	adimgshow();
}
