﻿function $(strO){
    return document.getElementById(strO);
}


function ow(URL, windowType){
   if ( windowType == 1 ){
        window.open(URL, 'defaultWindow', 'width=500 height=500 ');
   }

   if ( windowType == 2 ){
        window.open(URL, 'defaultWindow', 'width=580 height=600 ');
   }

}

function closeDialogWindow(closeType){

    switch (closeType){
        case 1:
            //document.getElementById('tbl_swNavigationBar').style.display='none';
            location.href = "about:blank";
            window.parent.dialogWindow.hide();
            break;
        
        case 2:
           window.parent.location.reload();
            window.parent.dialogWindow.hide();
            break;
    }
}
function closeAdvancedWindow(){
    location.href = "about:blank";
    window.parent.advanceWindow.hide();
}

function acceptOnlyNumbers(e, decimal) {
    var key;
    var keychar;

    if (window.event){
       key = window.event.keyCode;
    }
    else if (e) {
       key = e.which;
    }
    else {
       return true;
    }
    
    keychar = String.fromCharCode(key);
        
    if(keychar == ".")
       return true;
    
    if(keychar == "-")
       return true;

    if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27)) {
       return true;
    }
    else if ((("0123456789").indexOf(keychar) > -1)) {
       return true;
    }
    else if (decimal && (keychar == ".")) { 
      return true;
    }
   
    else{
       return false;
    }
}



/* #Region: Action Buttons Div Class
 * This code is specific to 
 * Action button in small window
*/    
    function ActionButtonsDiv (){};
    ActionButtonsDiv.prototype.Activate = function() {
        document.getElementById("DIV_ActionButtons").style.display = 'block';
        document.getElementById('SWContentHolder').style.height = (window.parent.dialogIframe.height-105 ) + "px";
        document.getElementById("SWContentHolder").style.borderBottomWidth = "4px";
        
    }

    ActionButtonsDiv.prototype.Deactivate = function() {
	    document.getElementById("DIV_ActionButtons").style.display = 'none';
	    document.getElementById("SWContentHolder").style.borderWidth = "0px";
    }
    var iActionButtonsDiv = new ActionButtonsDiv();

/* #End Region: Action Buttons Div Class */    

/* #Region: iMatics Utilities // static class
*/    
	function imUtilities(){};

	imUtilities.CleanBlankTextFromForm = function(){
		var frm = document.forms[0];
		for (var i=0;i<frm.elements.length;i++){
			if (frm.elements[i].type == "text" || frm.elements[i].type == "textarea"){
				if(frm.elements[i].value=="-"){
					frm.elements[i].value="";
				}
			}
		}

	}
/* #End Region: iMatics Utilities
*/   

/* #Region: Title Case 
*/    

function TitleCase(obj1){
    var a = obj1.value;
    var b = a.substring(0,1)
    var c = b.toUpperCase()
    var len = a.length
    var d = a.substring(1,len)
    var e = c+d
    
    
    var htext = Trim(a);
    htext = htext.toLowerCase();

    htext = htext.substr(0, 1).toUpperCase() + htext.substring(1, htext.length);
    for(var i=1; i<htext.length; i++)
    {
    if(htext.substr(i, 1) == " ")
    {
    while(htext.substr(i, 1) == " ")
    i++;

    if(i + 1 < htext.length)
    htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase() + htext.substring(i + 1, htext.length);
    else
    htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase();
    }
    }
    obj1.value = htext;
}
    
function Trim(strIn){
    strOut = strIn;
    strOut = strOut.replace(/^ */g, "");
    strOut = strOut.replace(/ *$/g, "");
    return strOut;
}

/* #End Region: iMatics Utilities
*/   

