﻿var selectcount = 0;

function CheckAll()
{
    var a = document.getElementsByTagName("input");

    for (var i = 0; i < a.length; i++)
        if ((a[i].type == "checkbox") && (!(a[i].disabled))) {
            var bSelect = a[i].checked;
            break;
        }

    if (bSelect) {
        selectcount = 0;
        for (var i = 0; i < a.length; i++)
            if ((a[i].type == "checkbox") && (!(a[i].disabled))) {
                a[i].checked = false;
            }
    }
    else {
        selectcount = 0;
        for (var i = 0; i < a.length; i++)
            if ((a[i].type == "checkbox") && (!(a[i].disabled))) {
                a[i].checked = true;
                ++selectcount;
            }
    }

    event.srcElement.value = (bSelect == true) ? "全 选" : "取 消"; 
}

function SetFullWindow()
{
    window.moveTo(0, 0);

    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        }
    }
}


function pop(url, width, height)
{
    var winwidth = (window.screen.availWidth - width)/2;

    var winheight = (window.screen.availHeight - height)/2;

    if (width == undefined && height == undefined) var news = window.open(url,
                                                                          "",
                                                                          "top=50,left=100,menubar=yes,toolbar=yes,location=no,directories=no, status=yes,scrollbars=yes,resizable=yes, width=800,height=500");
    else var news = window.open(url,
                                "",
                                "top=" + winheight
                                       + ",left="
                                       + winwidth
                                       + ",menubar=yes,toolbar=yes,location=auto,directories=auto, status=auto,scrollbars=auto,resizable=yes, width="
                                       + width
                                       + ",height="
                                       + height
                                       + "");

    news.focus();
}

function pop2(url)
{
    var news = window.open(url,
                           "",
                           "top=100,left=300,status=no,toolbar=no,menubar=no,location=no,channelmode=no,directories=no,scrollbars=yes,resizable=no, width=400,height=350");

    news.focus();
}

function OpenPage(url)
{
    var news=window.open(url,
                '',
                'scrollbars=yes, resizable=yes, status=no, toolbar=no, left=0, top=0, width= '
                    + (window.screen.width - 10) + ', height=' + (window.screen.height - 80) + '');
    news.focus();
    return false;
}

//sujunyong 添加 2010.11.11 19:30 跟OpenPage（）功能相同，去掉：return false
function OpenPage1(url)
{
   var news= window.open(url,
                '',
                'scrollbars=yes, resizable=yes, status=no, toolbar=no, left=0, top=0, width= '
                    + (window.screen.width - 10) + ', height=' + (window.screen.height - 80) + '');
   news.focus();
}

function clkCom()
{
    var a = document.getElementsByTagName("input");

    var self = event.srcElement;

    for (var i = 0; i < a.length; i++) {
        if ((a[i].type == "checkbox") && (a[i] != self)) {
            a[i].checked = false;
        }
    }
}

function checkcontent(source, arguments)
{
    //获取FCKEditor实例 
    var oEditor = FCKeditorAPI.GetInstance('FtbComment');

    //判断是否为空 
    if (oEditor.GetXHTML(true) == "") {
        oEditor.SetHTML("");
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }
}

function Pause(numberMillis)
{
    var now = new Date();

    var exitTime = now.getTime() + numberMillis;

    while (true) {
        now = new Date();
        if (now.getTime() > exitTime) {
            return;
        }
    }
}

function OnImageFileAdded(file)
{
    var myreg = /.jpg|.gif|.jpeg/i;

    if (file.fileName.match(myreg)) {
        var fileSize = -1;

        var image = new Image();
        image.src = file.filePath;

        if (file.input.files && file.input.files[0]) //firefox、mozilla
            {
            fileSize = file.input.files[0].fileSize; //所有上传类型都可获取文件大小，不仅仅是图片
        }
        else {
            Pause(500); //延迟500ms，等待图片载入完成才可获取图片大小，否则取值将为-1
            fileSize = image.fileSize;
        }
        if (fileSize != -1 && fileSize > 10486784) {
            alert('图片大小（' + fileSize + '字节）超出规定大小1M，请重新选择符合标准的图片！');
            return false;
        }
        else {
            var showImage = file.getElementById("showImage");

            showImage.style.display = "";
            showImage.src = image.src;
        }
    }
}

function OnImageFileAdding(file)
{
    var myreg = /.jpg|.gif|.jpeg/i;

    if (!file.fileName.match(myreg)) {
        alert('不正确的文件格式，只允许JPG,JPEG和GIF图片文件。');
        return false;
    }
}

function flashfocus(pics, links, texts)
{
    if (pics != "") {
        var focus_width = 405;  // 图片宽度

        var focus_height = 220; // 图片高度
        var text_height = 20;   // 显示的文字高度

        if (navigator.userAgent.indexOf("MSIE") != -1) {
            focus_height = 220;
            text_height = 20;
        }

        var swf_height = focus_height + text_height;
        var result = '';

        result += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
        result += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
        result += 'width="' + focus_width + '" ';
        result += 'height="' + swf_height + '">';
        result += '<param name="allowScriptAccess" value="always">';
        result += '<param name="movie" value="images/focus.swf">';
        result += '<param name="quality" value="high">';
        result += '<param name="bgcolor" value="#ffffff">';
        result += '<param name="menu" value="false">';
        result += '<param name=wmode value="transparent">';
        result += '<param name="FlashVars" ';
        result += 'value="pics=' + pics;
        result += '&links=' + links;
        result += '&texts=' + texts;
        result += '&borderwidth=' + focus_width;
        result += '&borderheight=' + focus_height;
        result += '&textheight=' + text_height + '">';
        result += '<embed src="images/focus.swf" ';
        result += 'wmode="opaque" ';
        result += 'FlashVars="pics=' + pics;
        result += '&links=' + links;
        result += '&texts=' + texts;
        result += '&borderwidth=' + focus_width;
        result += '&borderheight=' + focus_height;
        result += '&textheight=' + text_height + '" ';
        result += 'menu="false" ';
        result += 'bgcolor="#ffffff" ';
        result += 'quality="high" ';
        result += 'width="' + focus_width + '" ';
        result += 'height="' + focus_height + '" ';
        result += 'allowScriptAccess="sameDomain" ';
        result += 'type="application/x-shockwave-flash" ';
        result += 'pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        result += '</object>';

        document.getElementById("flash").innerHTML = result;
    }
}

