// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var prox;
var proy;
var proxc;
var proyc;
var isIe = (document.all) ? true : false;
var online = new Array();

function closeed(id) {/*--关闭--*/
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = document.getElementById(id);
    if (o.style.display == "block") {
        proyc = setInterval(function() {
            closey(o)
        }, 10);
    }
    closeWindow();
}

function init_message(id){
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = document.getElementById(id);
    if (o.style.display == "block") {
        proyc = setInterval(function() {
            closey(o)
        }, 10);
    }
    $('message').innerHTML = "<img src='/images/loading.gif' />正在保存,请耐心等待..... ";
    closeWindow();
}

function show_search(id, width_s, height_s, heigher){
    closeWindow();
    var sWidth,sHeight;
    sWidth = window.screen.availWidth;
    //屏幕可用工作区高度： window.screen.availHeight;
    //屏幕可用工作区宽度： window.screen.availWidth;
    //网页正文全文宽：     document.body.scrollWidth;
    //网页正文全文高：     document.body.scrollHeight;
    if(window.screen.availHeight > document.body.scrollHeight){  //当高度少于一屏
        sHeight = window.screen.availHeight+2000;
    }else{//当高度大于一屏
        if(heigher == true){
            sHeight = document.body.scrollHeight+4000;
        }else{
            sHeight = document.body.scrollHeight;
        }

    }
    var back = document.createElement("div");
    back.setAttribute("id","back");
    back.style.position = "absolute";
    back.style.top = "0";
    back.style.left = "0";
    back.style.background = "#777";
    back.style.filter = "Alpha(opacity=30);";
    back.style.opacity = "0.3";
    back.style.width = sWidth + "px";
    back.style.height = sHeight + "px";
    back.style.zIndex = "100";
    document.body.appendChild(back);
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = document.getElementById(id);
    var st = document.documentElement.scrollTop;//滚动条距顶部的距离
    var sl = document.documentElement.scrollLeft;//滚动条距左边的距离
    var ch = document.documentElement.clientHeight;//屏幕的高度
    var cw = document.documentElement.clientWidth;//屏幕的宽度
    var objT = Number(st)+(Number(ch)-Number(height_s))/2;
    var objL = Number(sl)+(Number(cw)-Number(width_s))/2;
    o.style.left = objL + "px";  //拼接上 单位"px"
    if(heigher == true){
        o.style.top = 100 + "px";
    }else{
        o.style.top = objT + "px";
    }

    o.style.display = "block";
    o.style.width = "1px";
    o.style.height = "1px";
    prox = setInterval(function() {
        openx(o, width_s, height_s)
    }, 100);
}

//关闭窗口
function closeWindow() {
    if (document.getElementById('back') != null) {
        document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
    }
}

function openx(o, x, y_s) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx < x) {
        o.style.width = (cx + Math.ceil((x - cx) / 5)) + "px";
    }
    else {
        clearInterval(prox);
        proy = setInterval(function() {
            openy(o, y_s)
        }, 10);
    }
}
function openy(o, y) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy < y) {
        o.style.height = (cy + Math.ceil((y - cy) / 5)) + "px";
    }
    else {
        clearInterval(proy);
    }
}

function closey(o) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy > 0) {
        o.style.height = (cy - Math.ceil(cy / 5)) + "px";
    }
    else {
        clearInterval(proyc);
        proxc = setInterval(function() {
            closex(o)
        }, 10);
    }
}
function closex(o) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx > 0) {
        o.style.width = (cx - Math.ceil(cx / 5)) + "px";
    }
    else {
        clearInterval(proxc);
        o.style.display = "none";
    }
}


function settime(obj){
    if(obj.value.length==9||obj.value.length==10){
        obj.value=obj.value+' 00:00:00'
    }else if(obj.value.length==16||obj.value.length==15){
        obj.value=obj.value+':00'
    }
}



