﻿/// <reference path="jquery-1.2.6-vsdoc.js" />

function AlertBox() { 
    
}

//判短字节数，若小于则返回真
function ToVertySize(value, size) {
    if (value == '') {
        return true;
    }
    // 预期计数：中文2字节，英文1字节
    var a = 0;
    // 循环计数
    var i = 0;

    for (i = 0; i < value.length; i++) {
        if (value.charCodeAt(i) > 255) {
            // 按照预期计数增加2
            a += 2;
        }
        else {
            a++;
        }
        // 如果增加计数后长度大于限定长度，就直接返回临时字符串
        if (a > size) {
            return false;
        }
    }
    return true;
}

//获取地址栏参数值
function QueryString(fieldName) {
    QueryString(fieldName, "?");
}

function QueryString(fieldName, querySplit) {
    var stUrl = document.location.href;
    var urlString = stUrl.substring(stUrl.lastIndexOf(querySplit), stUrl.length);
    if (urlString != null) {
        var typeQu = fieldName + "=";
        var urlEnd = urlString.indexOf(typeQu);
        if (urlEnd != -1) {
            var paramsUrl = urlString.substring(urlEnd + typeQu.length);
            var isEnd = paramsUrl.indexOf('&');
            if (isEnd != -1) {
                return paramsUrl.substring(0, isEnd);
            }
            else {
                return paramsUrl;
            }
        }
        else {
            return '';
        }
    }
    else {
        return '';
    }
}

//转化时间格式
function DateToStr(datetime) {

    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1; //js从0开始取 
    var date = datetime.getDate();
    var hour = datetime.getHours();
    var minutes = datetime.getMinutes();
    var second = datetime.getSeconds();

    if (month < 10) {
        month = "0" + month;
    }
    if (date < 10) {
        date = "0" + date;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    if (second < 10) {
        second = "0" + second;
    }

    var time = year + "-" + month + "-" + date + " " + hour + ":" + minutes + ":" + second; //2009-06-12 17:18:05

    return time;
}

function SetCookie(c_name, value, expiredays) {
    var exdate = new Date()
    exdate.setDate(exdate.getDate() + expiredays)
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
}

function GetCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(";", c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}

// 获取编辑器中HTML内容
function getEditorHTMLContents(EditorName) {
    var oEditor = FCKeditorAPI.GetInstance(EditorName);
    return (oEditor.GetXHTML(true));
}

// 设置编辑器中内容
function SetEditorContents(EditorName, ContentStr) {
    var oEditor = FCKeditorAPI.GetInstance(EditorName);
    oEditor.SetHTML(ContentStr);
}

// 插入内容到编辑器中
function InsertEditorContents(EditorName, ContentStr) {
    var oEditor = FCKeditorAPI.GetInstance(EditorName);
    oEditor.InsertHtml(ContentStr);
}


