
function submitSearch(){
        
    var s = document.forms[0].s.value;
    var t = document.forms[0].t.value;
    
    //求职
    if(t == "9"){
    
        var c = document.forms[0].c.value;
        var jq = document.forms[0].jq.value;
        window.navigate("/search?a=fs&q=" + jq + "&s=" + s + "&t=" + t + "&c=" + c);    
    
    //酒店
    }else if(t == "10"){
    
        var cityForHotel = document.forms[0].cityForHotel.value;
        var hotelName = document.forms[0].hotelName.value;
        var checkInDate = document.forms[0].checkInDate.value;
        var checkOutDate = document.forms[0].checkOutDate.value;
    
        if(checkInputForHotel()){
            window.navigate("/search?a=fs&q=" + q + "&s=" + s + "&t=" + t + "&c=" + cityForHotel + "&hn=" + hotelName + "&cid=" + checkInDate + "&cod=" + checkOutDate);
        }
    
    //交友
    }else if(t == "11"){
    
        var fp = document.forms[0].fp.value;
        var fc = document.forms[0].fc.value;
        var a1 = document.forms[0].a1.value;
        var a2 = document.forms[0].a2.value;
        var gender = "";
        
        if(document.forms[0].gender[0].checked == true){
            gender = document.forms[0].gender[0].value;
        }else{
            gender = document.forms[0].gender[1].value;
        }
        
        window.navigate("/search?a=fs&s=" + s + "&t=" + t + "&c=" + fc + "&fp=" + fp + "&a1=" + a1 + "&a2=" + a2 + "&g=" + gender); 
    
    //地图
    }else if(t == "21"){
    
        var mc = document.forms[0].mc.value;
        var mq = document.forms[0].mq.value;
        window.navigate("/search?a=fs&q=" + mq + "&s=" + s + "&t=" + t + "&c=" + mc); 
        
    //其它  
    }else{
    
        var q = document.forms[0].q.value;
        if(q == ""){
            q = "走光";
        }            

        window.navigate("/search?a=fs&q=" + q + "&s=" + s + "&t=" + t);
    }
    
    return;
}

function checkInputForHotel(){
    
    var fH = document.forms[0];
    
	if(fH.cityForHotel.value.length==0){
		alert("请输入城市!");
		fH.cityForHotel.focus();
		return false;
	}
	if (fH.checkInDate.value.length==0){
		alert("请输入入住时间!");
		fH.checkInDate.focus();
		return false;
	}
	if(!isDateString(fH.checkInDate.value)){
		alert("入住时间不符合格式规范或无效的日期!");
		fH.checkInDate.focus();
		return false;
	}
	if (fH.checkOutDate.value.length==0){
		alert("请输入离店时间!");
		fH.checkOutDate.focus();
		return false;
	}	
	if(!isDateString(fH.checkOutDate.value)){
		alert("离店时间不符合格式规范或无效的日期!");
		fH.checkOutDate.focus();
		return false;
	}
	if (stringToDate(fH.checkOutDate.value,true) <= stringToDate(fH.checkInDate.value,true)){
		alert("离店时间不能早于或等于入住时间" + fH.checkInDate.value+"!");
		fH.checkOutDate.focus();
		return false;
	}
	return true;
}

function setCheckInDate(d){
	document.getElementById("hdate1").value=d;
	if(document.getElementById("hdate2").value.length==0)
	{
		showCalendar('dimg2',false,'hdate2','hdate1');
	}
}

function stringToDate(sDate, bIgnore){	
    var bValidDate, year, month, day
	var iaDate = new Array(3)
	
	if (bIgnore) bValidDate = true
	else bValidDate = isDateString(sDate)
	
	if (bValidDate)
	{  iaDate = sDate.toString().split("-")
		year = parseFloat(iaDate[0])
		month = parseFloat(iaDate[1]) - 1
		day=parseFloat(iaDate[2])
		return (new Date(year,month,day))
	}
	else return (new Date(1900,1,1))
}

function isDateString(sDate){	
    var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31]
	var iaDate = new Array(3)
	var year, month, day

	if (arguments.length != 1) return false
	iaDate = sDate.toString().split("-")
	if (iaDate.length != 3) return false
	if (iaDate[1].length > 2 || iaDate[2].length > 2) return false
	if (isNaN(iaDate[0])||isNaN(iaDate[1])||isNaN(iaDate[2])) return false

	year = parseFloat(iaDate[0])
	month = parseFloat(iaDate[1])
	day=parseFloat(iaDate[2])

	if (year < 1900 || year > 2100) return false
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
	if (month < 1 || month > 12) return false
	if (day < 1 || day > iaMonthDays[month - 1]) return false
	return true
}

/*
 * 记录图片广告点击
 */
function beautyAdClick(landPageTime,beautyAdName){
    beautyAdClick = new Image();
    beautyAdClick.src = 'http://www.58search.com/pages/beautyAdClickLog.jsp?landPage=' + document.location + '&landPageTime=' + landPageTime + '&beautyAdName=' + beautyAdName;
}