﻿//
//1 . setTab(childname, childshow, childhide, cursel, n, columnname, colshow, colhide) 
// childname内容的id，childshow内容显示样式，childhide内容不可见样式，cursel当前数字，n总数字
// columnname栏目的id, colshow栏目显示的样式, colhide栏目隐藏的样式
//
//2、NowTime(conid)显示当前时间 格式“19:53:35 ”，参数conid,是指把时间赋值给标签的id
//
//3、DateWeek()显示日期和星期 格式“ 2010年1月9日 星期六 ”
//
//4、ReSet(ControlIdStr)清空控件的内容，参数ControlIdStr为控件的id字符串，可以多个id，用逗号连接
//
//5、getFileSize(filePath) 得到文件的大小，参数filePath为文件路径。
//
//6、IsNull(ControlIdStr) 判断控件是否为空，是返回false，否返回TRUE ，参数是控件id字符串，用逗号连接
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

function GetUrl() {
    var b;
    b = window.document.location.pathname.substring(1, document.location.pathname.lastIndexOf('-'));
    if (b == '/'|| b == '') {
        b = window.document.location.pathname.substring(1, document.location.pathname.lastIndexOf(".aspx"));
        if (b == '/')
            b = "home";
    }    
    b = b.toLowerCase(); 
    if (document.getElementById(b)) {
        document.getElementById(b).setAttribute("src", "/images/" + b + "100.gif");
    }
}
       
    window.onload = function() { GetUrl(); }

    // JavaScript Document
    function TabADSMenu(tabname, tabadnum, number) {
        //number栏目数量
        //alert(tabname+"-"+tabadnum);
        for (var i = 0; i < number; i++) {
            if (i == tabadnum)
                document.getElementById(tabname + "_" + i).style.display = "block";
            else
                document.getElementById(tabname + "_" + i).style.display = "none";
        }
        for (var j = 0; j < number; j++) {
            document.getElementById("a_" + tabname + "_" + j).className = "block";
        }
        document.getElementById("a_" + tabname + "_" + tabadnum).className = "tasadsOn";
        //	alert(document.getElementById("o_"+tabadid_num+tabadnum).className);
        //document.getElementById("content_"+tabadid_num+tabadnum).style.display="block";
    }



    // childname内容的id，childshow内容显示样式，childhide内容不可见样式，cursel当前数字，n总数字
    // columnname栏目的id, colshow栏目显示的样式, colhide栏目隐藏的样式
    function setTab(childname, childshow, childhide, cursel, n, columnname, colshow, colhide) {
        for (i = 1; i <= n; i++) {
            var childmenu = document.getElementById(childname + i);
            var childcon = document.getElementById(childname + i);
            var columnmenu = document.getElementById(columnname + i);
            var columncon = document.getElementById(columnname + i);
            if (childcon) {
                childmenu.className = i == cursel ? childshow : childhide;
                childcon.style.display = i == cursel ? "block" : childhide;
            }
            if (columncon) {
                columnmenu.className = i == cursel ? colshow : colhide;
            }
        }
    }

    // 输出 排序号并到一定数字改变数字的样式
    // num 当前数字 , changnum 到达这个数字时改变数字的样式, control 输出控件, minclassname 未改变数字前的样式, bigclassname改变数字后的样式
    function OutNum(num, minclassname, bigclassname, changnum, control) {
        if (num < changnum)
            document.write('<' + control + ' class="' + minclassname + '" >' + num + '</' + control + '>');
        else
            document.write('<' + control + ' class="' + bigclassname + '"  >' + num + '</' + control + '>');
    }

    function showhide(idchild, childshow, childhide, i, idcol, colshow, colhide) {

        var childmenu = document.getElementById(idcol + i);
        var childcon = document.getElementById(idchild + i);
        var hide = document.getElementById("Hidden" + i);
        if (childcon) {
            if (childcon.className == childshow) {
                childcon.className = childhide;
                childmenu.className = colhide;

            }
            else {
                childcon.className = childshow;
                childmenu.className = colshow;

            }

        }
    }

    // childname内容的id，childshow内容显示样式，childhide内容不可见样式，cursel当前数字，n总数字
    // columnname栏目的id, colshow栏目显示的样式, colhide栏目隐藏的样式
    function setssTab(childname, childshow, childhide, cursel, n, txtid, message, url) {
        for (i = 1; i <= n; i++) {
            var childmenu = document.getElementById(childname + i);
            var childcon = document.getElementById(childname + i);
            var columnmenu = document.getElementById(txtid);
            var columncon = document.getElementById(txtid);
            if (childcon) {
                childmenu.className = i == cursel ? childshow : childhide;
                //  childcon.style.display = i == cursel ? "block" : childhide;
                document.getElementById("formsearch").action = url;
            }
            if (columncon) {
                columnmenu.value = message;
            }
        }
    }

    function IsNull(ControlIdStr) {
        if (ControlIdStr=="" || ControlIdStr=="[object]")
        return false;     
              
            var arr = new Array();
            arr = ControlIdStr.split(",");
//        alert(arr.length+"请填写完整ddd信息！");
//            if (arr.length == 0)  {   
//              if(document.getElementById(ControlIdStr)){
//               
//                 if(document.getElementById(ControlIdStr).value == "")
//                 {
//                     alert("请填写完dddaaaa整信息！");
//                     document.getElementById(ControlIdStr).focus();
//                      return false;
//                 }
//                 else      
//                 {  alert("请填写完h整信息！");  }}}
//            else
                for (var i = 0; i < arr.length; i++) 
                if (document.getElementById(arr[i]))
                  if(document.getElementById(arr[i]).value == "")
                  {
                     alert("请填写完整信息！");
                     document.getElementById(arr[i]).focus();
                      return false;
                  }
                    return true;
  }
                
               
 
 

    function ShowTab(conid, conclass, i, colid, colclass) {
        var contentid = document.getElementById(conid + i);
        var columid = document.getElementById(colid + i);


        if (contentid)
            contentid.className = conclass;
        if (columid)
            columid.className = colclass;

    }


    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 addCookie(objName, objValue, objHours) {//添加cookie

        var str = objName + "=" + escape(objValue);

        if (objHours > 0) {   //为0时不设定过期时间，浏览器关闭时cookie自动消失
            var date = new Date();
            var ms = objHours * 3600 * 1000;
            date.setTime(date.getTime() + ms);
            str += "; expires=" + date.toGMTString();


        }
        document.cookie = str;


    }


    function GetCookieClass(childname, childshow, childhide, n, columnname, colshow, colhide, cookieid) {
        var cursel = "11";
        cursel = n;

        if (cursel) {

            for (i = 1; i <= 9; i++) {

                var childmenu = document.getElementById(childname + i);
                var childcon = document.getElementById(childname + i);
                var columnmenu = document.getElementById(columnname + i);
                var columncon = document.getElementById(columnname + i);
                if (childcon) {
                    //  alert(cursel + "-" + childcon);

                    childcon.className = i == cursel ? childshow : childhide;
                    childcon.style.display = i == cursel ? "block" : childhide;
                }
                if (columncon) {
                    // alert(cursel + "-" + columncon);

                    columnmenu.className = i == cursel ? colshow : colhide;
                }


            }
        }
        else {

            addCookie('Master', 1, 0);
        }
    }


    function ChClassID(fid, cid) {


        controlValue[controlValue.selectedIndex].innerText

        var f = document.getElementById(fid);
        var c = document.getElementById(cid);

        if (f[f.selectedIndex].value == 1 || f[f.selectedIndex].value == 2 || f[f.selectedIndex].value == 3) {
            c.Visible = true;

        }
        else {
            c.Visible = false;
        }
    }


    function car_check(OutDate,StartDate) {
        var myday = new Date();
        if (stringToDate(document.getElementById(OutDate).value, true) < stringToDate(document.getElementById(StartDate).value, true)) {

            alert("结束租用时间不能早于开始租用时间!");
            document.getElementById("OutDate").focus(); return false;
        }
        
        if (document.getElementById("StartDate").value.length == 0) {
            alert("请选择开始租用时间!");
            document.getElementById("StartDate").focus(); return false;
        }

        if (document.getElementById("OutDate").value.length == 0) {
            alert("请选择结束租用时间!");
            document.getElementById("OutDate").focus(); return false;
        }



        if (!isDateString(document.getElementById("StartDate").value)) {
            alert("开始租用时间不符合格式规范或为无效的日期!");
            document.getElementById("StartDate").focus();
            return false;
        }

        if (stringToDate(document.getElementById("StartDate").value, true) <= myday) {
            alert("开始租用时间不能早于或等于今天!");
            document.getElementById("StartDate").focus(); return false;
        }
        if (document.getElementById("OutDate").value.length == 0) {
            alert("请选择结束租用时间!");
            document.getElementById("OutDate").focus(); return false;
        }

        if (!isDateString(document.getElementById("OutDate").value)) {
            alert("结束租用时间不符合格式规范或为无效的日期!");
            document.getElementById("OutDate").focus();
            return false;
        }


    

        /*
        if (document.carform.texi_type.value.length==0)
        {alert("请选择开始租用方式!");
        document.carform.texi_type.focus();return false;}
	
if (document.carform.useaddres.value.length==0)
        {alert("请选择接车地点!");
        document.carform.useaddres.focus();return false;}	
        */
    }

    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 countprice(Price, UnitNum, All) {

        var allprice = document.getElementById(Price).value * document.getElementById(UnitNum).value;
        document.getElementById(All).value = allprice;
        //  document.getElementById('span_Moneys').innerHTML = "￥" + allprice + "元";

    }



    function Search(txtStr, Url) {

        if (IsNull(txtStr)) {

            var keyword = escape(document.getElementById(txtStr).value);
            Url = Url + "?" + txtStr + "=" + keyword;
            window.open(Url);
        }

    }
    function ReSet(ControlIdStr) {

        if (ControlIdStr) {
            var arr = new Array();
            arr = ControlIdStr.split(",");

            if (arr.length == 0)

                document.getElementById(ControlIdStr).value = "";
            else
                for (var i = 0; i < arr.length; i++) {

                if (document.getElementById(arr[i]))
                    document.getElementById(arr[i]).value = "";
            }
        }
    }
    function ReSetServer(ControlIdStr, head) {

        if (ControlIdStr) {
            var arr = new Array();
            arr = ControlIdStr.split(",");

            if (arr.length == 0)

                document.getElementById(head + ControlIdStr).value = "";
            else
                for (var i = 0; i < arr.length; i++) {

                if (document.getElementById(head + arr[i]))
                    document.getElementById(head + arr[i]).value = "";
            }
        }
    }
    function SearchHotel(Url, txtStr) {

        if (Url.toString() != "") {
            var DistrictID = "";
            var Star = "";
            var Price = "";
            var keyword = "";

            var fieldnameStr = "?1=1";  //定义字段名称变量
            var keywordStr = "";    //定义关键字变量
            var filter = "";    //定义分隔符变量


            DistrictID = document.getElementById("selDistrictID").value;
            Star = document.getElementById("selStar").value;
            Price = document.getElementById("selPrice").value;
            keyword = document.getElementById(txtStr).value;

            if (DistrictID.length != 0)  //如果所在区域不为空
            {
                fieldnameStr = fieldnameStr + "&DistrictID=" + escape(DistrictID);

            }
            if (Star.length != 0)  //如果所在区域不为空
            {
                fieldnameStr = fieldnameStr + "&Star=" + escape(Star);

            }

            if (Price.length != 0)  //如果所在区域不为空
            {
                fieldnameStr = fieldnameStr + "&Average=" + escape(Price);

            }
            if (keyword.length != 0)  //如果所在区域不为空
            {
                fieldnameStr = fieldnameStr + "&" + txtStr + "=" + escape(keyword);

            }

            Url = Url + fieldnameStr;
            window.open(Url);
        }

    }
    function TourOrder(lineid, url) {
        var myday = new Date();
        if (stringToDate(document.getElementById("StartDate").value, true) <= myday) {
            alert("开始租用时间不能早于或等于今天!");
            document.getElementById("StartDate").focus();
            return false;
        }
        var num = document.getElementById("CF_Nums").value;
        if (num == "" || num == 0) {
            alert("旅游人数不能为空！");
            return false;
        }
        var time = document.getElementById("StartDate").value;
        if (time == "") {
            alert("出行日期不能为空！");
            return false;
        }
        if (lineid || url) {
            url = url + "?PeopleNum=" + num + "&StartDate=" + escape(time) + "&LineID=" + lineid;
            window.open(url);
        }
        else {
            alert("线路ID获取失败，请重试！");
            return false;
        }


    }
 function DateWeek()
        {
       tmpDate = new Date();
       date = tmpDate.getDate();
    month= tmpDate.getMonth() + 1;
    year= tmpDate.getYear();
    document.write(year);
    document.write("年");
    document.write(month);
    document.write("月");
    document.write(date);
    document.write("日 ");
    
    myArray=new Array(6);
    myArray[0]="星期日"
    myArray[1]="星期一"
    myArray[2]="星期二"
    myArray[3]="星期三"
    myArray[4]="星期四"
    myArray[5]="星期五"
    myArray[6]="星期六"
    weekday=tmpDate.getDay();
    if (weekday==0 | weekday==6)
    {
    document.write(myArray[weekday]);
    }
    else
    {document.write(myArray[weekday]);
    };
    }
function NowTime(conid)
{

var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
 
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock=hours+":"+minutes+":"+seconds
if(document.layers){document.layers.conid.document.write(myclock)
document.layers.conid.document.close()
}else if(document.all)
document.getElementById(conid).innerHTML=myclock
setTimeout("NowTime('"+conid+"')",1000)
}


function getFileSize(filePath)    
{    
   var image=new Image();    
   image.dynsrc=filePath;    
   alert(image.fileSize);    
} 












function s()
{
alert("aa");
}

