﻿function chghelp(id) {
    var obj = document.getElementById(id);
    if (obj.style.display == "") {
        obj.style.display = "none";
    }
    else {
        obj.style.display = "";
    }
}
        
function show(id) {
document.getElementById(id).style.display = 'block';
}
function hide(id) {
document.getElementById(id).style.display = 'none';
}
function changediv(id, content) {
document.getElementById(id).innerHTML = content;
}

function HotelSearchSubit() {
var returnresult=false;
var category;
var   obj   =   eval("jipiaoform.radio");        
for (j = 0; j < obj.length; j++) {
    if (obj[j].checked) {
        category = obj[j].value;
    }
}

    if (category == 'oneway') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                        returnresult= true;
                    }
                    else {
                        alert('“出发城市”不能与“目的城市”重名');
                    }
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“目的城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }

    if (category == 'airreturn') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (isDate(document.forms["jipiaoform"].ctl00_ContentPlaceholderIndex_CnSecondCityDate.value)) {
                        if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                            returnresult= true;
                        }
                        else {
                            alert('“出发城市”不能与“目的城市”重名');
                        }
                    }
                    else {
                        alert('请选择“返程日期”，或者输入返程日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                    }   
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“目的城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }

    if (category == 'muti') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (document.forms["jipiaoform"].CnThreeCity.value != '中文/拼音') {
                        if (isDate(document.forms["jipiaoform"].CnSecondCityDate.value)) {
                            if (document.forms["jipiaoform"].CnThreeCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                                if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                                    returnresult= true;
                                }
                                else {
                                    alert('“出发城市”不能与“中转城市”重名');
                                }
                            }
                            else {
                                alert('“中转城市”不能与“目的城市”重名');
                            }
                        }
                        else {
                            alert('请选择“中转日期”，或者输入中转日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                        }
                    }
                    else {
                        alert('请输入选择“目的城市”名称，再搜索'); ;
                    }   
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“中转城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }
    return returnresult;

}


//验证给定的日期是否合法   ,参数格式要求：yyyy-mm-dd 可以根据情况更改正则表达式
function isDate(oStartDate) {
    //对日期格式进行验证 要求为2000-2099年  格式为 yyyy-mm-dd 并且可以正常转换成正确的日期
    var pat_hd = /^20\d{2}-((0[1-9]{1})|(1[0-2]{1}))-((0[1-9]{1})|([1-2]{1}[0-9]{1})|(3[0-1]{1}))$/;

    try {
        if (!pat_hd.test(oStartDate)) { throw "日期非法！"; }
        var arr_hd = oStartDate.split("-");
        var dateTmp;
        dateTmp = new Date(arr_hd[0], parseFloat(arr_hd[1]) - 1, parseFloat(arr_hd[2]));
        if (dateTmp.getFullYear() != parseFloat(arr_hd[0]) || dateTmp.getMonth() != parseFloat(arr_hd[1]) - 1 || dateTmp.getDate() != parseFloat(arr_hd[2])) {
            throw "日期非法！";
        }
    }
    catch (ex) {
        if (ex.description)
        { return false; }
        else
        { return false; }
    }
    return true;
}

function JipiaoSearchSubit() {
var returnresult=false;
var category;
var   obj   =   eval("jipiaoform.radio");        
for (j = 0; j < obj.length; j++) {
    if (obj[j].checked) {
        category = obj[j].value;
    }
}

    if (category == 'oneway') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                        returnresult= true;
                    }
                    else {
                        alert('“出发城市”不能与“目的城市”重名');
                    }
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“目的城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }

    if (category == 'airreturn') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (isDate(document.forms["jipiaoform"].ctl00_ContentPlaceholderIndex_CnSecondCityDate.value)) {
                        if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                            returnresult= true;
                        }
                        else {
                            alert('“出发城市”不能与“目的城市”重名');
                        }
                    }
                    else {
                        alert('请选择“返程日期”，或者输入返程日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                    }   
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“目的城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }

    if (category == 'muti') {
        if (document.forms["jipiaoform"].CnFirstCity.value != '中文/拼音') {
            if (document.forms["jipiaoform"].CnSecondCity.value != '中文/拼音') {
                if (isDate(document.forms["jipiaoform"].CnFirstCityDate.value)) {
                    if (document.forms["jipiaoform"].CnThreeCity.value != '中文/拼音') {
                        if (isDate(document.forms["jipiaoform"].CnSecondCityDate.value)) {
                            if (document.forms["jipiaoform"].CnThreeCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                                if (document.forms["jipiaoform"].CnFirstCity.value != document.forms["jipiaoform"].CnSecondCity.value) {
                                    returnresult= true;
                                }
                                else {
                                    alert('“出发城市”不能与“中转城市”重名');
                                }
                            }
                            else {
                                alert('“中转城市”不能与“目的城市”重名');
                            }
                        }
                        else {
                            alert('请选择“中转日期”，或者输入中转日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                        }
                    }
                    else {
                        alert('请输入选择“目的城市”名称，再搜索'); ;
                    }   
                }
                else {
                    alert('请选择“出发日期”，或者输入出发日期 参数格式要求：yyyy-mm-dd  如2009-12-08');
                }
            }
            else {
                alert('请输入选择“中转城市”名称，再搜索');
            }
        }
        else {
            alert('请输入选择“出发城市”名称，再搜索');
        }
    }
    return returnresult;

}


function nav(thisObj,Num){
if(thisObj.className == "at")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
  if (i == Num)
  {
   thisObj.className = "at"; 
      document.getElementById(tabObj+"_c_"+i).style.display = "block";
      try{
      document.getElementById(tabObj+"_m_"+i).style.display = "block";}
      catch(e){}
  }else{
   tabList[i].className = "not"; 
   document.getElementById(tabObj+"_c_"+i).style.display = "none";
      try{
   document.getElementById(tabObj+"_m_"+i).style.display = "none";}
      catch(e){}
  }
} 
}