﻿//*************************************************************************************************************************************
function GoMessageBox(nMessage) {      	
    if(IsIEVersion7()) {
	    GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=1&msg=" + nMessage, 23, 6, null);
	}
	else {
        GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=1&msg=" + nMessage, 23.4, 8.8, null);   
	}
}
//*************************************************************************************************************************************
function GoQuestionBox(nQuestion) {
    var Return_Value;
       	
    if(IsIEVersion7()) {
        Return_Value = GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=2&msg=" + nQuestion, 23, 6, null);   
    }
    else {
        Return_Value = GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=2&msg=" + nQuestion, 23.4, 8.8, null);
    }
		
    return Return_Value;
}
//*************************************************************************************************************************************
function GoCalendar(RequestedDate) {
    var Return_Value;
    
    if(IsIEVersion7()) {
        Return_Value = GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemCalendar.aspx?Date=" + RequestedDate, 20.2, 21.9, null);
    }
    else {
        Return_Value = GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemCalendar.aspx?Date=" + RequestedDate, 20.6, 24.7, null);
    }
            
    return Return_Value;
}
//*************************************************************************************************************************************
function __GoErrorMessage() {
    if(IsIEVersion7()) {
        GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=0", 23, 9, null);
    }
    else {
        GoModalWindow(__Virtual_Path + "WebUtils/GlobalPages/SystemMessages.aspx?type=0", 23.4, 11.8, null);
    }
}
//*************************************************************************************************************************************
function GoModalWindow(sWindowPath, nWindowWidth, nWindowHeight, sWindowParams) {
    var Return_Value;

    if(sWindowParams == null) {
	    sWindowParams = "resizable: no;"
	    sWindowParams += "center: yes;"
	    sWindowParams += "status: yes;";
	    sWindowParams += "help: no;";
	    sWindowParams += "edge: raised;";
	    sWindowParams += "scroll: no;";
    }
            
    sWindowParams += "dialogWidth: " + nWindowWidth + ";";
    sWindowParams += "dialogHeight: " + nWindowHeight + ";";

	Return_Value = window.showModalDialog(sWindowPath, "DialogWindow", sWindowParams);
	
	Return_Value = (Return_Value != undefined) ? Return_Value : "";
	
	return Return_Value;
}
//*************************************************************************************************************************************
function GoWindow(sWindowPath, nWindowWidth, nWindowHeight, sWindowParams) {
    var objWin;
    
    if(sWindowParams == null) {
	    sWindowParams = "toolbar = no,";
	    sWindowParams += "directories = no,";
	    sWindowParams += "status = yes,";
	    sWindowParams += "menubar = no,";
	    sWindowParams += "scrollbars = no,";
	    sWindowParams += "resizable = no,";
	    sWindowParams += "copyhistory = no,";
	    sWindowParams += "location = no,";
	    sWindowParams += "top = 50,";
	    sWindowParams += "left = 50,";
    }
        
    sWindowParams += "width = " + nWindowWidth + ",";
    sWindowParams += "height = " + nWindowHeight + ";"
    
    objWin = window.open(sWindowPath, "NonDialogWindow", sWindowParams);
    
    return objWin;
}
//*************************************************************************************************************************************
function SetControlDisplay(sControlName, bDisplay) {
    var sDisplay = (bDisplay) ? "block" : "none";
    
    document.getElementById(sControlName).style.display = sDisplay;
}
//*************************************************************************************************************************************
function SetControlVisibility(sControlName, bVisible) {
    var sVisible = (bVisible) ? "visible" : "hidden";
    
    document.getElementById(sControlName).style.visibility = sVisible;
}
//*************************************************************************************************************************************
function GetControlValue(sControlName) {   
    return document.getElementById(sControlName).value;
}
//*************************************************************************************************************************************
function SetControlValue(sControlName, Value) {    
    document.getElementById(sControlName).value = Value;
}
//*************************************************************************************************************************************
function SetControlInnerHtml(sControlName, Value) {   
    document.getElementById(sControlName).innerHTML = Value;
}
//*************************************************************************************************************************************
function SetControlInnerText(sControlName, Value) {   
    document.getElementById(sControlName).innerText = Value;
}
//*************************************************************************************************************************************
function SetControlEnabled(sControlName, bEnabled) {   
    document.getElementById(sControlName).disabled = bEnabled;
}
//*************************************************************************************************************************************
function Trim(strToTrim) {
	return strToTrim.replace(/^\s*|\s*$/g, "");
}
//*************************************************************************************************************************************
function LTrim(strToLTrim) {
	return strToLTrim.replace(/^\s*/, "")
}
//*************************************************************************************************************************************
function RTrim(strToRTrim) {
	return strToRTrim.replace(/\s*$/, "");
}
//*************************************************************************************************************************************
function StringBuilder(Value) {
    this.ArrStrings = new Array("");
    
    this.Append(Value);
}

StringBuilder.prototype.Append = function(Value) {
    if(Value) {
        this.ArrStrings.push(Value);
    }
}

StringBuilder.prototype.Clear = function() {
    this.ArrStrings.length = 1;
}

StringBuilder.prototype.ToString = function() {
    return this.ArrStrings.join("");
}
//*************************************************************************************************************************************
function ClearCombo(objCombo) {	
	for (var i = objCombo.options.length - 1 ; i >= 0 ; i--) {
		objCombo.options.remove(i);
	}
}
//*************************************************************************************************************************************
function AddComboOption(objCombo, Key, Value, bSelected) {
	var objOption = document.createElement("Option");
	
	if(bSelected) {
        objOption.setAttribute("selected", "selected");
    }
        
	objCombo.options.add(objOption);
	
	objOption.value = Key;
	objOption.innerText = Value;
}
//*************************************************************************************************************************************
function GetExplorerVersion() {
    var retVal = -1;
  
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    
        if(re.exec(ua) != null) {
            retVal = parseFloat(RegExp.$1);
        }
    }
  
    return retVal;
}

function IsIEVersion7() {
    var version = GetExplorerVersion();
    var IsIE7 = false;

    if (version >= 7) {
        IsIE7 = true;
    }
    
    return IsIE7
}
//*************************************************************************************************************************************

