﻿
//屏幕设置
$(document).ready(function() {
if (WidthScreen() == true) {
         $("#btnIndex").attr("href", "/InfoSys/Info/Default.aspx");
    }
    else {
        $("#btnIndex").attr("href", "/Web/Default.aspx"); 
    }

    if ($("body.English").length > 0) {
        $("#btnIndex").css({ "background": "url(/Theme/Default/CssImage/Button/Index_en.gif) no-repeat 0px 0px" });
        $("#btnReturn").css({ "background": "url(/Theme/Default/CssImage/Button/Return_en.gif) no-repeat 0px 0px" });
    }
    else {
        $("#btnIndex").css({ "background": "url(/Theme/Default/CssImage/Button/Index.gif) no-repeat 0px 0px" });
        $("#btnReturn").css({ "background": "url(/Theme/Default/CssImage/Button/Return.gif) no-repeat 0px 0px" });
    }
});

//取屏大小
function WidthScreen() {
    var screenwidth = window.screen.width;
    var screenHeight = window.screen.height;
    if (screenwidth >= 1366) {
        return true;
    }
    else {
        return false;
    }
}

//取得天气
function GetWeather(objWeatherImage, objWeather, objTemperature) {
    
    s1 = "2006-12-18"
    s2 = "2007-1-5"
    var nowday = new Date();
    var openday = new Date("11-13-2010");
    iDays = parseInt(Math.abs(openday - nowday) / 1000 / 60 / 60 / 24)



//    jQuery("body.Chinese " + objWeather).html('广州-多云');
//    jQuery("body.English " + objWeather).html('Temp');
    //jQuery(objTemperature).html('12℃~18℃');
    if (WidthScreen() == true) {
        $(objWeatherImage).css({ "background-image": "url(/Theme/default/CssImage/weather.gif)" });
        $(objWeatherImage).css({ "background-position": "0px -90px" });
        //jQuery("body.Chinese " + objWeather).html('距离第16届亚运会开幕还有' + iDays + '天');
        //jQuery("body.English " + objWeather).html('Countdown to the Asian Games:' + iDays);
jQuery("body.Chinese " + objWeather).html('');
        jQuery("body.English " + objWeather).html('');
    } else {
    $(objWeatherImage).css({ "background-image": "url(/Theme/Screen17/CssImage/weather.gif)" });
    $(objWeatherImage).css({ "background-position": "0px -70px" });
    //jQuery("body.Chinese " + objWeather).html('距离第16届亚');
    //jQuery("body.English " + objWeather).html('Countdown to the ');
    //jQuery("body.Chinese " + objTemperature).html('运会开幕' + iDays + '天');
    //jQuery("body.English " + objTemperature).html('Asian Games:' + iDays);
    jQuery("body.Chinese " + objWeather).html(' ');
    jQuery("body.English " + objWeather).html(' ');
    jQuery("body.Chinese " + objTemperature).html(' ');
    jQuery("body.English " + objTemperature).html(' ');
    }
}
//计算天数差的函数，通用 
function DateDiff(sDate1, sDate2) {    //sDate1和sDate2是 2006-12-18格式 
    var aDate, oDate1, oDate2, iDays
    aDate = sDate1.split("-")
    oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])    //转换为 12-18-2006格式 
    aDate = sDate2.split("-")
    oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
    iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24)    //把相差的毫秒数转换为天数 
    return iDays
}    

//取当前时间
function GetTime(objDate, objTime, edition) {
    var year, month, day, hours, minutes, seconds;
    var intYear, intMonth, intDay, intHours, intMinutes, intSeconds;
    var today;
    today = new Date();
    intYear = today.getYear();
    intMonth = today.getMonth() + 1;
    intDay = today.getDate();
    intHours = today.getHours();
    intMinutes = today.getMinutes();
    intSeconds = today.getSeconds();

    if (intYear < 1900) {
        intYear += 1900;
    }
    if (intMonth < 10) {
        intMonth = "0" + intMonth;
    }
    if (intDay < 10) {
        intDay = "0" + intDay;
    }
    //获取系统时间的分数
    if (intMinutes < 10) {
        minutes = "0" + intMinutes;
    }
    else
        minutes = intMinutes;
    //获取系统时间的秒数
    if (intSeconds < 10)
        seconds = "0" + intSeconds;
    else
        seconds = intSeconds;

    jQuery("body.Chinese " + objDate).html(intYear + '年' + intMonth + '月' + intDay + '日');
    jQuery("body.English " + objDate).html(intYear + '-' + intMonth + '-' + intDay + '');
    jQuery(objTime).html(intHours + ':' + minutes + ':' + seconds);

    //每隔1秒钟执行一次tick函数
    window.setTimeout('GetTime("' + objDate + '", "' + objTime + '")', 1000);
}


//ajax调用
function WebService(url, pars, callback) {
    $.ajax({
        data: pars,
        url: url,
        type: "POST",
        contentType: "application/json;utf-8",
        dataType: 'json',
        cache: false,
        timeout: 30 * 1000,
        success: function(json) {
            callback(json.d);
        },
        error: function(xml, status) {
            if (status == 'error') {
                try {
                    var json = eval('(' + xml.responseText + ')');
                    alert(json.Message + '\n' + json.StackTrace);
                } catch (e) { }
            } else {
                alert(status);
            }
        },
        beforeSend: function(xml) {
            if (!pars) xml.setRequestHeader("Content-Type", "application/json;utf-8")
            $("#loading").show();
        }
                ,
        complete: function() {
            $("#loading").hide();
        }
    });
}
