﻿function OpenFixedWin(address, winname, height, width, scrollbars,resizeable) {
	var iHeight = height;
	var iWidth = width;
	var iLeft = (screen.width - iWidth)/2;
	var iTop = (screen.height- iHeight)/2;
	var iScrollbars = scrollbars;
	var iResizeable = resizeable;
	if(iScrollbars == null || iScrollbars=="") iScrollbars = "yes";
	var feature = "left="+iLeft+",top="+iTop+",fullscreen=0,width= " + iWidth + ",height=" + iHeight +",toolbar=no, menubar=no, scrollbars=" + iScrollbars + ", resizable=" + iResizeable+ ", location=no, status=yes";
	var win =window.open(address,winname,feature);	
	win.focus();
	win = null;
}

//绑定首页的内容切换事件
function BindHoverEvent(objName, suffix) {
    var obj = $(objName);
    if (obj) {
        obj.hover(
        function() { obj.each(function(i) { $(this).removeClass("select"); $("#" + $(this).attr("name") + suffix).hide(); }); $(this).addClass("select"); $("#" + $(this).attr("name") + suffix).show(); },
        function() { });
    }
}

function ShowModalDialogPage(url, width, height) {
    var x = parseInt(screen.width / 2.0) - (width / 2.0);
    var y = parseInt(screen.height / 2.0) - (height / 2.0);
    var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
    if (isMSIE) {
        retval = window.showModalDialog(url, window, "dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogLeft:" + x + "px; dialogTop:" + y + "px; status:no; directories:yes;scrollbars:no;Resizable=no; ");
    } else {
        var win = window.open(url, "Warehouse", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,modal=yes,dependance=yes,width=" + width + ",height=" + height + ",resizable=no");
        eval('try { win.resizeTo(width, height); } catch(e) { }');
        win.focus();
    }
}

function ShowModalDialogPageAndRefresh(url, width, height,commitButtonId) {
    var x = parseInt(screen.width / 2.0) - (width / 2.0);
    var y = parseInt(screen.height / 2.0) - (height / 2.0);
    var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
    
    if (url.indexOf("?") > -1)
        url += "&buttonId=" + commitButtonId;
    else
        url += "?buttonId=" + commitButtonId;
        
    if (isMSIE) {
        retval = window.showModalDialog(url, window, "dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogLeft:" + x + "px; dialogTop:" + y + "px; status:no; directories:yes;scrollbars:no;Resizable=no; ");
    } else {
        var win = window.open(url, "Warehouse", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,modal=yes,dependance=yes,width=" + width + ",height=" + height + ",resizable=no");
        eval('try { win.resizeTo(width, height); } catch(e) { }');
        win.focus();
    }
}

function TriggerParentButtonClick(buttonId) {
    var button;

    var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
    if (isMSIE) {
        button = window.dialogArguments.document.getElementById(buttonId);
    } else {
        button = window.opener.document.getElementById(buttonId);
    }
    
    if (button) {
        if (document.all) {
            button.click();
        }
        else {
            var evt = document.createEvent("MouseEvents");
            evt.initEvent("click", true, true);
            button.dispatchEvent(evt);
        }
    }
} 


