﻿//当前浏览器版本
//var uavi = navigator.userAgent.toLowerCase(), checkbrowser = function (r) {
//    return r.test(uavi);
//},
//    isOpera = checkbrowser(/opera/),
//    isIE = !isOpera && checkbrowser(/msie/),
//    isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest,
//    isIE7 = isIE && checkbrowser(/msie 7/),
//    isIE8 = isIE && checkbrowser(/msie 8/);
    
//显示正在载入数据层
function ShowLoading() {
    $("html").css("overflow-x", "hidden");
    $('#iframeLoading').show();
    $('#divLoading').show();
    $('#divInnerLoading').show();
}

//隐藏正在载入数据层
function HideLoading() {
    $('#divInnerLoading').hide();
    $('#divLoading').hide();
    $('#iframeLoading').hide();
    if ($('#divTransparentBg').css('display') == 'none')
        $("html").css("overflow-x", "auto");
}

//现实透明背景
function ShowTransparentBg() {
    $("html").css("overflow-x", "hidden");
    $('#iframeTransparent').show();
    $('#divTransparentBg').show();
}

//隐藏透明背景
function HideTransparentBg() {
    $('#divTransparentBg').hide();
    $('#iframeTransparent').hide();
    $("html").css("overflow-x", "auto");
}

//接收Url
function QueryString(fieldName) {
    var urlString = document.location.search;
    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 null;
        }
    }
    else {
        return null;
    }
}

//重设图片大小
function ResizeImage(img, width, height, mark) {
//    img.style.marginLeft = 0;
//    img.style.marginTop = 0;
    var image = new Image();
    image.src = img.src;
    var iw = image.width;
    var ih = image.height;
    var iratio = width > 0 ? iw / width : 1;
    var ih_artio = height > 0 ? ih / height : 1;
    var tempW = width;
    var tempH = ih / iratio;
    if (mark == 1) //长、宽都要满足(显示部分)
    {
        if (tempH < height) {
            ih = height;
            iw = iw / ih_artio;
        }
        else {
            iw = tempW;
            ih = tempH;
        }
    }
    else if (mark == 2) //满足高度
    {
        ih = height;
        iw = iw / ih_artio;
    }
    else if (mark == 3) //长、宽都要满足(显示完整)
    {
        if (tempH > height && height > 0) {
            ih = height;
            iw = iw / ih_artio;
        }
        else {
            iw = tempW;
            ih = tempH;
        }

        if (height > ih && height > 0)
            img.style.marginTop = (height - ih) / 2 + "px";

        if (width > iw && width > 0)
            img.style.marginLeft = (width - iw) / 2 + "px";
    }
    else //满足宽度
    {
        iw = tempW;
        ih = tempH;
        if (height > ih && mark == 0)
            img.style.marginTop = (height - ih) / 2 + "px";
    }
    img.width = iw;
    img.height = ih;
}

$(document).bind("contextmenu", function (e) {
    //取消默认的右键菜单 
    return false;
});