// Client JS for DAS Application

// *********************************************************************
//  Popup Page Functions
// *********************************************************************
function popupPage(pageURL, width, height)
{
	var windowFeatures = "plain,scrollbars,resizable=no,height=" + height + ",width=" + width + "";
	popWin = window.open(pageURL,"winPopup", windowFeatures);
	popWin.focus();
}

function popupPageNoScroll(pageURL, width, height)
{
	var windowFeatures = "plain,resizable=no,left=400,top=200,height=" + height + ",width=" + width + "";
	popWin = window.open(pageURL,"winPopup", windowFeatures);
	popWin.focus();
}

function CloseWindow(){
	window.close();
}
// *********************************************************************
//  Print Page Functions
// *********************************************************************
function PrintIt(){ 

	if (window.print) {
		window.print() ;  
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    
		WebBrowser1.outerHTML = "";  
	}
}

// *********************************************************************
//  UI Element Display Functions
// *********************************************************************

	// Get  the browser type
	if(document.getElementById) { // IE 5 and up, NS 6 and up
		var upLevel = true;
		}
	else if(document.layers) { // Netscape 4
		var ns4 = true;
		}
	else if(document.all) { // IE 4
		var ie4 = true;
		}

	// Gets a page element
	function getObject(ID) {
		if(upLevel) {
			var obj = document.getElementById(ID);
			}
		else if(obj) {
			var obj = eval('document.' + ID);
			}
		else if(obj) {
			var obj = eval('document.all.' + ID);
			}
		return obj;
	}	

	// Hide a page element
	function hideObject(ID) {
		var obj = getObject(ID);	
		if (ns4) {
			obj.visibility = "hide";
			}
		if (ie4 || upLevel) {
			obj.style.visibility = "hidden";
			}
	}	
	
	// Hide a page element
	function removeObject(ID) {
		var obj = getObject(ID);	
		if (ns4) {
			obj.display = "none";
			}
		if (ie4 || upLevel) {
			obj.style.display = "none";
			}
	}
	
	// Restores a page element
	function restoreObject(ID) {
		var obj = getObject(ID);			
		if (ns4) {
			obj.display = "block";
			}
		if (ie4 || upLevel) {
			obj.style.display = "block";
			}
	}
	
	// Show a hidden page element
	function showObject(ID) {
		var obj = getObject(ID);
		if (ns4) {
			obj.visibility = "show";
			}
		if (ie4 || upLevel) {
			obj.style.visibility = "visible";
			}	
	}
	
	function showFull(obj)
	{
		//var obj = getObject(ID);
		if (ns4) {
			obj.overflow = "scroll";
			}
		if (ie4 || upLevel) {
			obj.style.overflow = "scroll";
			}	
	}
	
	function hideFull(obj)
	{
		//var obj = getObject(ID);
		if (ns4) {
			obj.overflow = "hidden";
			}
		if (ie4 || upLevel) {
			obj.style.overflow = "hidden";
			}	
	}	
	
	fmtMoney = function( number, floatPoint, decimalSep, thousandsSep ) 
	{
		floatPoint = Math.abs( floatPoint+1 ? floatPoint : 2 );
		decimalSep = decimalSep || ',';
		thousandsSep = thousandsSep || '.';
		( number+'' ).match( /(\d+)(?:\.(\d+)|)/ );
		with( RegExp ) {
 			var frac = floatPoint ? decimalSep + Number( '.'+ $2 ).toFixed( floatPoint ).substr( 2 ) : '';
			return ( ( x = $1.length % 3 ) ? $1.substr( 0, x )+thousandsSep :'' ) + $1.substr( x ).replace( /(\d{3})(?=\d)/g, '$1'+thousandsSep ) + frac;
		}
	}
	
	var numb = '0123456789';
	var lwr = 'abcdefghijklmnopqrstuvwxyz';
	var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	 
	function isValid(parm,val) 
	{
		if (parm == "") return false;
		for (i=0; i<parm.length; i++)
		{
			if (val.indexOf(parm.charAt(i),0) == -1) return false;
		}
		return true;
	}
	 
	function isNum(parm) {return isValid(parm,numb);}
	function isLower(parm) {return isValid(parm,lwr);}
	function isUpper(parm) {return isValid(parm,upr);}
	function isAlpha(parm) {return isValid(parm,lwr+upr);}
	function isAlphaNum(parm) {return isValid(parm,lwr+upr+numb);}