﻿


function Common_OpenUrl(url, modeIndex) {
   
    var pathUrl = Common_getRootPath() + "/Web/" + url;
    var pathUrl = Common_getRootPath() + "/" + url;
    if (modeIndex == 1)
        window.location.href = pathUrl;
    else if (modeIndex == 2) {
        window.open(pathUrl);
    }
    else {
        window.open(url);
    }
}


/*-----------------------------------------------------------
author:  shuh
create date:2011-2-16
description:打开一个窗体

param url:连接地址
param winName:唯一的名称
param width:宽度
param height:高度
------------------------------------------------------------*/
function Common_openwindow(url, winName, width, height) {
    xposition = 0; yposition = 0;
    if ((parseInt(navigator.appVersion) >= 4)) {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    theproperty = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=0,"
    + "scrollbars=1,"
    + "status=0,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + "," //仅适用于Netscape
    + "screeny=" + yposition + "," //仅适用于Netscape
    + "left=" + xposition + "," //IE
    + "top=" + yposition; //IE 
    window.open(url, winName, theproperty);
}



/*-----------------------------------------------------------
author:  shuh
create date:2011-2-16
description:获得网站根目录
------------------------------------------------------------*/
function Common_getRootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
    return prePath;
}

/*-----------------------------------------------------------
author:  shuh
create date:2011-2-16
description:除法
------------------------------------------------------------*/
function Common_accDiv(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
    try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""))
        r2 = Number(arg2.toString().replace(".", ""))
        return (r1 / r2) * pow(10, t2 - t1);
    }
}


/*-----------------------------------------------------------
author:  shuh
create date:2011-2-16
description:乘法
------------------------------------------------------------*/
function Common_accMul(arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try { m += s1.split(".")[1].length } catch (e) { }
    try { m += s2.split(".")[1].length } catch (e) { }
    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}

/*-----------------------------------------------------------
author:  shuh
create date:2011-2-16
description:四舍五入 保留几位小数
Dight--处理的数,

How--可保留的位数

------------------------------------------------------------*/
function Common_ForDight(Dight, How) {
    var c = Math.pow(10, How);
    return Math.round(Dight * c) / c;
}

//产品选中特效
function ProductOver(product) {
    $($(product).children()[1]).css("border", "1px solid #cccccc");
    $($(product).children()[1]).css("backgroundColor", "#f7fbfc");
    $($($(product).children()[1]).children()[0]).css("color", "#ff0000");

//    product.childNodes[1].style.border = "1px solid #cccccc";
//    product.childNodes[1].style.backgroundColor = "#f7fbfc";
//    product.childNodes[1].firstChild.style.color = "#ff0000";
}
function ProductOut(product) {
    $($(product).children()[1]).css("border", "1px solid #ffffff");
    $($(product).children()[1]).css("backgroundColor", "#ffffff");
    $($($(product).children()[1]).children()[0]).css("color", "#000000");

//    product.childNodes[1].style.border = "1px solid #ffffff";
//    product.childNodes[1].style.backgroundColor = "#ffffff";
//    product.childNodes[1].firstChild.style.color = "#000000";
}
