﻿function openDialog(url, height, width)
{
	var ran = Math.random();
	var sURL;
	if(url.indexOf("?")<0)
		sURL = url + "?ran=" + ran.toString();
	else
		sURL = url + "&ran=" + ran.toString();
	var returnString;	
	var obj = window.self;
	returnString = window.showModalDialog(sURL, obj,'dialogHeight:'+height+'px;dialogWidth:'+width+'px;edge:Raised;center:Yes;help:No;resizable:No;status:No;scroll:No');
	return returnString;
}

//打开窗口
function openWindow(url, windowName, height, width, IsCenter)
{
	if (IsCenter) 
	{
		if ((parseInt(navigator.appVersion) >= 4 )) 
		{ 
			xposition = (screen.width - width) / 2; 
			yposition = (screen.height - height) / 2; 
		}
	} 
	else
	{
		xposition=0; 
		yposition=0; 
	}
	
	sFeatures = "width=" + width + "," 
				+ "height=" + height + "," 
				+ "location=0," 
				+ "menubar=0," 
				+ "resizable=1," 
				+ "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,windowName,sFeatures); 
}
	
function getQueryString(name) 
{ 
    // 如果链接没有参数，或者链接中不存在我们要获取的参数，直接返回空 
    if(location.href.indexOf("?")==-1 || location.href.indexOf(name+'=')==-1) 
    { 
        return ''; 
    } 
 
    // 获取链接中参数部分 
    var queryString = location.href.substring(location.href.indexOf("?")+1); 
 
    // 分离参数对 ?key=value&key2=value2 
    var parameters = queryString.split("&"); 
 
    var pos, paraName, paraValue; 
    for(var i=0; i<parameters.length; i++) 
    { 
        // 获取等号位置 
        pos = parameters[i].indexOf('='); 
        if(pos == -1) { continue; } 
 
        // 获取name 和 value 
        paraName = parameters[i].substring(0, pos); 
        paraValue = parameters[i].substring(pos + 1); 
 
        // 如果查询的name等于当前name，就返回当前值，同时，将链接中的+号还原成空格 
        if(paraName == name) 
        { 
            return unescape(paraValue.replace(/\+/g, " ")); 
        } 
    } 
    return ''; 
}

var HttpConnection = function(url, userName, password) {
    this.url = url;
    if (userName)
        this.userName = userName;
    else {
        try {
            this.userName = new LCCLogonInfo().account;
        }
        catch (e) {}
    }
    
    if (password)
        this.password = password;
    else {
        try {
            this.password = decrypt(new LCCLogonInfo().adKey);
        }
        catch (e) {}
    }
}

function crtRqt(){
        if(window.ActiveXObject)
            return new ActiveXObject("Microsoft.XMLHTTP");
        else
            return new XMLHttpRequest();
}

HttpConnection.prototype.asyncGet = function(callback) {
    var xmlhttp = crtRqt();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            callback(xmlhttp.responseText);
        }
    }
    xmlhttp.open("GET", encodeURI(this.url), true, this.userName, this.password);
    xmlhttp.send();
}   

function $(sElmId){
    return document.getElementById(sElmId);
}

function g(sElmId){
    return document.getElementById(sElmId);
}

function TextBoxKeyPress()
        {
            if (event.keyCode == 13)
            {
                Search();
            }
        }


