
//--- \busi\Globals.js
function AdjustHeight()
{
/*
    if($("LeftNav") == null || $("CenterNav") == null || $("RightNav") == null)
    {
        return; 
    }
    
	var newHeight = document.body.offsetHeight - Globals.AppLayout.TopNavOffset;
	if(newHeight > 100)
	{
		//var tmp = $("MiddleBody").innerHTML; 
		
		//$("LeftNav").style.height = newHeight + "px";
		//$("CenterNav").style.height = (newHeight - Globals.AppLayout.CenterNavOffset) + "px";
		//$("RightNav").style.height = (newHeight - (Globals.AppLayout.CenterNavOffset - Globals.AppLayout.CrumbHeight)) + "px";		
	
		//Globals.UI.Navigation.LoadPage("", "", "", "", "", ""); 
		
		//$("LeftNav").style.height = newHeight + "px";
		//$("CenterNav").style.height = (newHeight - Globals.AppLayout.CenterNavOffset) + "px";
		//$("RightNav").style.height = (newHeight - (Globals.AppLayout.CenterNavOffset - Globals.AppLayout.CrumbHeight)) + "px";		
		
		//Globals.UI.Navigation.LoadPage("", "", tmp, "", "", ""); 
	}
*/
}

function Globals(){};

Globals.MouseX = 0; 
Globals.MouseY = 0; 

Globals.AppSettings = new function(){}; 
Globals.AppSettings.Debug = true; 
Globals.AppSettings.RelativePath = "";
Globals.AppLayout 	= null; 
Globals.MainMenu 	= null; 

Globals.PageTitle 	= null; 
Globals.PageBody 	= null; 

Globals.MoveX 		= null; 
Globals.Security 	= null; 

Globals._cssFiles 	= new Array(); 
Globals.AddCSS 		= function(fileName)
{
	Globals._cssFiles[Globals._cssFiles.length] = fileName; 
}

Globals.Init = function()
{
	var cookieData = ReadCookie("userdata");	
	if(cookieData != null)
	{
		Globals.UserData = cookieData.parseJSON(); 
	}
	
	if($("page_title") != null)
	{
		Globals.PageTitle = $("page_title").innerHTML; 
		Globals.PageBody = $("page_body").innerHTML; 
	}
	
    Globals.Security = Security; 
	if(Globals.AppLayout.SetupCSS != null)
	{
		Globals.AppLayout.SetupCSS(); 
	}
	
	Globals.AppLayout.Render(Globals.PostInit); 	
	
    Event.observe(document, 'mousemove', function(event)
    {
        Globals.MouseX = Event.pointerX(event);  
        Globals.MouseY = Event.pointerY(event);
        
        if(Globals.MoveX != null)
        {            
            var value = (Globals.MouseX - 5); 
            if(value < 2) value = 1; 
            
            $(Globals.MoveX).style.width = value + "px";        
        }
    });			
    
   
    if(Globals._cssFiles.length == 0)
    {
		Globals.AddCSS("./client/css/Global.css");     	
		Globals.AddCSS("./client/css/rte.css"); 				      
		Globals.AddCSS("./client/css/UIControls.css"); 				
		Globals.AddCSS("./client/css/grid.css"); 						
		Globals.AddCSS("./client/css/TabMenu.css"); 							
    }
	
	for(var i = 0; i < Globals._cssFiles.length; i++)
	{
		var headID = document.getElementsByTagName("head")[0];         
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = Globals._cssFiles[i];
		cssNode.media = 'screen';
		headID.appendChild(cssNode);   	
	}
	
	Globals.InitSecurity(); 	
}

Globals.PostInit = function()
{
	window.historyStorage.init();
	window.dhtmlHistory.create();
		
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(HandleHistory);
	var mainWin = dhtmlHistory.getCurrentLocation();

	if(Globals.InitConfig != null)
	{
		Globals.InitConfig(); 		
	}
	
	if(Globals.PageTitle != null) //This means it is a content page and needs to be parsed
	{
		
		if(PageOnLoad == null)
		{
			alert("Error: Content page does not have PageOnLoad function."); 
		}
		else
		{
			PageOnLoad(); //All content pages must have function that executes after loading
		}
	}
	else
	{
		if (mainWin && mainWin.length > 0) 
		{
			HandleHistory(mainWin, null);	
		}
		else
		{
			HomePage.Load(); 
		}
	}
	
	AdjustHeight();
};

Globals.SetupLoginForm = function()
{
	if(Globals.MainMenu != null)
	{
		Globals.MainMenu.Render(Globals.MainMenu.SelectedIndex); 
	}
};

Globals.InitSecurity = function()
{
	Globals.Security.Init(); 
};

Globals.ShowSpinner = function(id, text)
{
    $(id).innerHTML = '<table valign="middle" align="center" cellpadding="2px" style="padding-bottom:200px"><tr><td style="height:400px;"><img src="./imgs/spinner.gif" /><br /><br /><br /><br /><br /></td><td style="color:#666666">' + text + '</td></tr></table></div>'; 
};

document.onselectstart = function(event)
{
    return Globals.MoveX == null; 
};

document.onmouseup = function(event)
{
    Globals.MoveX = null; 
    return true; 
};

Globals.UrlEncode = function(value) 
{
	var t = escape(value);
	t = t.replace('+', "%2B");
	return t;
};

Globals.UrlDecode = function(value) 
{
	value = value.replace("%2B", '+');
	var t = unescape(value);
	return t;
};


Globals.HtmlEscape = function(textToEscape)
{
	var d = document.createElement('div'); 
	
	if(document.all)
	{
		d.innerText = textToEscape; 
	} 
	else
	{
		d.textContent = textToEscape;
	}
	
	var returnValue = d.innerHTML; 
	return returnValue; 
};

Globals.CreatedDisableWindow = false; 
Globals.DisableWindow = function()
{
	if(!Globals.CreatedDisableWindow)
	{
		document.body.innerHTML += 
		"<div id='disable_window_div' style='position:absolute;top:0px;left:0px;z-index:9;filter: alpha(opacity=50);opacity:50;-moz-opacity:50;background-color:black;width:5000;height:4000'></div>"; 
	}
	else
	{
	}
};

Globals.EnableWindow = function()
{
};

Globals.WriteMasterStatus = function(text)
{
	//return; 
	//$("MasterStatus").innerHTML = text; 
}

Globals.LoadLibraries = function()
{

}

Globals.IsPreIE7 = function()
{
    var nVer = navigator.appVersion;
    var nAgt = navigator.userAgent;
    var browserName  = '';
    var fullVersion  = 0; 
    var majorVersion = 0;

    if ((verOffset=nAgt.indexOf("MSIE"))!=-1) 
    {
        browserName  = "Microsoft Internet Explorer";
        fullVersion  = parseFloat(nAgt.substring(verOffset+5));
        majorVersion = parseInt(''+fullVersion);
        if(fullVersion < 7)
        {
            return true; 
        } 
    }

    return false
};

Globals.IsIE7 = function()
{
    var nVer = navigator.appVersion;
    var nAgt = navigator.userAgent;
    var browserName  = '';
    var fullVersion  = 0; 
    var majorVersion = 0;

    if ((verOffset=nAgt.indexOf("MSIE"))!=-1) 
    {
        browserName  = "Microsoft Internet Explorer";
        fullVersion  = parseFloat(nAgt.substring(verOffset+5));
        majorVersion = parseInt(''+fullVersion);
		return true; 
    }

    return false
};

Globals.UserData = null; 

//Resets data and puts it into a cookie that expires after 1 minute. This way if the 
//user is to log off of the system, they will not "remain" logged in unless they specify; 

Globals.RefreshData = function()
{
	//Globals.UserData should contain any information that needs to persist
	if(Globals.UserData != null)
	{
		EraseCookie("userdata"); 
		CreateCookie("userdata", Globals.UserData.toJSONString(), 10);
	}
}

Globals.IntervalId = -1; 

Globals.ClearUserData = function()
{
	Globals.UserData = null;
	if(Globals.IntervalId != -1)
	{
		clearInterval(Globals.IntervalId);
	}
	Globals.IntervalId = -1; 
	EraseCookie("userData"); 
};

Globals.RefreshUserData = function()
{
	Globals.ClearUserData(); 
	Globals.IntervalId = window.setInterval(Globals.RefreshData, 9000);
};

Globals.RefreshUserData(); 

function CreateCookie(name, value, seconds) 
{
	var date = new Date();
	date.setTime(date.getTime() + (seconds * 1000));
	var expires = "; expires=" + date.toGMTString();
	document.cookie = name + "=" + value + expires + "; path=/";
}

function ReadCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
}

function EraseCookie(name) 
{
	CreateCookie(name,"",-1);
}

function IsDefined(variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}


//--- \busi\Error.js

function Error(){};
Error.Severity = function(){}; 

Error.Severity.Assert 	= 1; 
Error.Severity.Crash 	= 2; 
Error.Severity.High 	= 3; 
Error.Severity.Medium 	= 4; 
Error.Severity.Low 		= 5; 

Error.Handle = function(desc, page, line)
{
	var errorTxt = ""  
	+'<br /><b>Error description:</b> \t'+desc
	+'<br /><b>Page address:</b>      \t'+page
	+'<br /><b>Line number:</b>       \t'+line + "<hr />"; 
	
	if(Globals.AppSettings.Debug)
	{
	    Error.CreateDebugWindow(); 
	}	
	
    $("debugwindow").innerHTML += errorTxt; 
	return true
};

//window.onerror = Error.Handle;

Error.DebugWriteLine = function(txt)
{
	Error.DebugWrite(txt + "<br />"); 
};

Error.DebugWrite = function (txt)
{
	if(Globals.AppSettings.Debug)
	{
	    Error.CreateDebugWindow(); 
        $("debugwindow").innerHTML += txt; 
    }
    else
    {
    	$("debugwindow").innerHTML += txt + "<br />";
    }
};

Error.CreateDebugWindow = function()
{
	if($("debugwindow") == null)
	{
		Globals.DisableWindow(); 
		document.body.innerHTML += 
		"<div id='debugwindow' style='background-image:url(imgs/error.jpg);background-repeat:no-repeat;background-position:bottom left;position:absolute;top:20px;left:20px;z-index:10;margin-left:20px;width:600px;height:600px; overflow:auto;padding:20px;background-color:#ffffff;border:solid 1px #333333;'><b>Debug Information</b><hr /><br ></div>";
	}		
};


Error.Log = function(errorObj, referrer, severity)
{
	switch(severity)
	{
		case Error.Severity.Assert:
		{
			Error.DumpToScreen(); 
			break; 
		}
		case Error.Severity.Crash:
		{
			break; 
		}
		case Error.Severity.High:
		{
			break; 
		}
		case Error.Severity.Medium:
		{
			break; 
		}
		case Error.Severity.Low:
		{
			break; 
		}
	}
}

Error.LogException = function(e)
{
    Error.Handle("Exception: " + e.name + "<br />" + e.description, "", ""); 
};

Error.LogAjaxException = function(t, e)
{
    Error.Handle("Ajax Error: " + e.name + "<br />" + e.description, "", ""); 
};

Error.LogAjaxFailure = function(t, e)
{
    Error.Handle("Ajax Error: " + e.name + "<br />" + e.description, "", ""); 
};

Error.LogError = function(errorTxt)
{
    document.write(errorTxt.Type + "<br />" + errorTxt.Message + "<br />" + errorTxt.StackTrace); 
};

Error.DumpToScreen = function()
{
	//window.document.body.innerText = window.document.body.outerHTML; 
	//alert(window.dump); 
	//document.body.innerText = dumpObj(text4, "test",".......",1); 
}


//--- \busi\DynamicLoadJS.js
var loadCount = 0; 
var LoadedJSLibraries = new Array(); 
		
function include_once(url)
{
    /*
    return; 
	url = Globals.AppSettings.RelativePath + url; 
	if(!AlreadyLoaded(url))
	{
		document.write(url + "<br />"); 
		var e = document.createElement("script");
		e.src = url;
		e.type="text/javascript";
		document.getElementsByTagName("head")[0].appendChild(e); 
		
		//Globals.WriteMasterStatus("Loading " + url + "..."); 

		loadCount++; 
    	try
    	{
    		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'POST', 
				parameters: '',
				requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
				onComplete: LoadingDone,
			});			    
		}
		catch(e)
		{
			alert(e.message); 
		}
		LoadedJSLibraries[LoadedJSLibraries.length] = url.toLowerCase(); 
		
	}
	*/
}

function LoadingDone(results)
{
    //alert(results.responseText); 
    //eval(results.responseText.);
    loadCount--; 
}

function AlreadyLoaded(url)
{
	for(var i = 0; i < LoadedJSLibraries.length; i++)
	{
		if(LoadedJSLibraries[i] == url.toLowerCase())
		{
			return true; 
		}
	}
	
	return false; 
}

/*
function logException(req, exception) {
	var params = "";
	if (req && req.responseText) {
		//params += "r=" + Global.urlEncode(req.responseText)
	}
	if (exception && exception.message) {
		//params += "e=" + Global.urlEncode(exception.message);
	}

	if (params && params.length > 0 && window.location.href.match(/localhost/)) {
		alert(params);
	}

	alert(exception.message); 
}
*/


//--- \busi\Mask.js
var $a; 

function ReturnEmptyIfNull(value)
{
	if(value == null) 
	{
		return ""; 
	}
	else
	{
		return value; 
	}
}

function CommonReg()
{
	//Static Common Regular expressions
	//this.PhoneReg = 	;
}

//Data class to transfer mask information
MaskData = function(mask)//,  regexPattern, onRegexNoMatch,  onRegexMatch,  onWrongKeyPressed)
{
	//Passed data
	this.mask 				= ReturnEmptyIfNull(mask); 
	//this.RegexPattern 		= ReturnEmptyIfNull(regexPattern);
	//this.OnRegexNoMatch 		= ReturnEmptyIfNull(onRegexNoMatch); 
	//this.OnRegexMatch 		= ReturnEmptyIfNull(onRegexMatch); 
	//this.OnWrongKeyPressed 	= ReturnEmptyIfNull(onWrongKeyPressed);
	
	// Constants for now
	this.maskDisplay 		= " ";
	this.maskAlpha 			= "a" 
	this.maskAlphaNumeric 	= "x" 
	this.maskNumeric 		= "n" 
	this.OnFocus 			= "javascript:GotFocus(this);" 
	this.OnClick 			= "javascript:OnClick(event, this);" 
	this.OnKeyDown 			= "javascript:KeyDown(event, this);" 
	this.OnKeyPress 		= "javascript:KeyPress(event, this);" 
	this.OnBlur 			= "javascript:LostFocus(this);" 
	this.OnInput 			= "javascript:OnInput(event, this);" 
	this.OnCut 				= "javascript:OnCut(this);" 
	this.OnPaste 			= "javascript:OnPaste(this);" 
		
	this.GetParams = function()
	{
		var returnVal = " " + 
		"mask='" 			+ this.mask 			+ "' " + 
		"RegexPattern=''" + //" 		+ this.RegexPattern 		+ "' " + 
		"OnRegexNoMatch=''" + // 	+ this.OnRegexNoMatch 	+ "' " + 
		"OnRegexMatch=''" + //" 	+ this.OnRegexMatch 		+ "' " + 
		"OnWrongKeyPressed=''" + //"	+ this.OnWrongKeyPressed 	+ "' " +  
		"maskDisplay='" 		+ this.maskDisplay 		+ "' " +  
		"maskAlpha='" 		+ this.maskAlpha 			+ "' " +  
		"maskAlphaNumeric='" 	+ this.maskAlphaNumeric 	+ "' " +  
		"maskNumeric='" 		+ this.maskNumeric 		+ "' " +  
		"OnFocus='" 		+ this.OnFocus 			+ "' " +  
		"OnBlur='" 		+ this.OnBlur 			+ "' " +  
		"OnClick='" 			+ this.OnClick 			+ "' " +  
		"OnKeyDown='" 		+ this.OnKeyDown 		+ "' " +  
		"OnKeyPress='" 		+ this.OnKeyPress 		+ "' " +  
		"OnInput='" 		+ this.OnInput 			+ "' " +  
		"OnCut='" 			+ this.OnCut 			+ "' " +  
		"OnPaste='" 		+ this.OnPaste 			+ "' " +  
		"";
		
		return returnVal; 
	};
};

//Static function to handle the event
function GotFocus(textField)
{
	var mask = textField.getAttribute("mask");
	
	if(mask != null && mask.length > 0)
	{
		var r = GetSelectionStart(textField);
		var validPos = GetValidPos(textField, r);
						
		if(validPos != -1)
		{
			if(textField.value == null || textField.value.length==0)
			{
				textField.value = GetDisplayMask(textField, true);
			}
		}
		
		PutCaretPos(textField, validPos);		
	}
	else
	{
		textField.blur();	
	}
}

function LostFocus(textField)
{
	return true;
	var mask = textField.getAttribute("mask");
	
	if(mask != null && textField.value == GetDisplayMask(textField,true))
	{
		textField.value = "";
	}
	else
	{
		if(textField.value != null && textField.value.length > 0)
		{
			var regexPattern 	= textField.getAttribute("RegexPattern");
			var onRegExMatch 	= textField.getAttribute("OnRegexMatch");
			var onRegExNoMatch 	= textField.getAttribute("OnRegexNoMatch");
					
			if(regexPattern != null && regexPattern.length > 0)
			{
				var re = new RegExp(regexPattern);
				if(textField.value.match(re))
				{				
					if(onRegExMatch != null && onRegExMatch.length > 0)
					{
						eval(onRegExMatch);
					}
				}
				else
				{
					if(onRegExNoMatch != null&&onRegExNoMatch.length > 0)
					{
						eval(onRegExNoMatch);
					}
				}
			}
		}
	}
};

function GetDisplayMask(textField, $D)
{
	var mask = textField.getAttribute("mask");
	if($D == true)
	{
		var f	= "";
		var $f 	= textField.getAttribute("maskAlpha");
		var $g 	= textField.getAttribute("maskNumeric");
		var $h 	= textField.getAttribute("maskAlphaNumeric");
		var $i 	= textField.getAttribute("maskDisplay");
		var m 	= mask.split("");
		
		for(mi = 0; mi < m.length; mi++)
		{
			if(m[mi] == $f || m[mi] == $g || m[mi] == $h)
			{
				f += $i;
			}
			else
			{
				f += m[mi];
			}
		}
		
		return f;

	}
	else
	{
		return mask;
	}

}

function PutCaretPos(textField, returnPosition, textValue)
{
	if(returnPosition <= 0)
	{
		returnPosition = 0;
	}

	if(returnPosition >= textField.value.length-1)
	{
		returnPosition = textField.value.length-1
	}

	returnPosition = GetValidPos(textField,returnPosition,textValue);

	if(returnPosition != -1)
	{
		if(textField.createTextRange)
		{
			var textRangeObj = textField.createTextRange();

			textRangeObj.moveStart("character", returnPosition);
			textRangeObj.moveEnd('character', (returnPosition + 1) - (textField.value.length));
			textRangeObj.select();
		}
		else if(textField.setSelectionRange)
		{
			textField.focus();
			textField.setSelectionRange(returnPosition,returnPosition+1);
		}

	}
	else
	{
		textField.blur();
	}
}

function GetSelectionStart(textField)
{
	if(textField.createTextRange)
	{
		$C = document.selection.createRange().duplicate();
		$C.moveEnd("character",textField.value.length);
		
		var position = textField.value.lastIndexOf($C.text);
		
		if($C.text=="") position = textField.value.length;
		
		return position;

	}
	else
	{
		return textField.selectionStart;
	}

}

function GetSelectionEnd(textField)
{
	if(textField.createTextRange)
	{
		$C = document.selection.createRange().duplicate();
		$C.moveStart("character", -textField.value.length);
		$j = $C.text.length;
		return $j;
	}
	else
	{
		return textField.selectionEnd;
	}
}

function GetValidPos(textField, returnPosition, textValue)
{
	if(textValue == null)
	{
		textValue = false;
	}

	if(PosIsValid(textField,returnPosition))
	{
		return returnPosition;
	}
	else
	{
		var mask = textField.getAttribute("mask");

		if(textValue)
		{
			while(returnPosition >= 0)
			{
				if(PosIsValid(textField, returnPosition))
				{
					return returnPosition;
				}

				returnPosition--;
			}

			while(returnPosition < mask.length-1)
			{
				if(PosIsValid(textField,returnPosition))
				{
					return returnPosition;
				}		

				returnPosition++;
			}

		}
		else
		{

			while(returnPosition < mask.length-1)
			{
				if(PosIsValid(textField,returnPosition))
				{
					return returnPosition;
				}
				returnPosition++;
			}

			while(returnPosition >= 0)
			{
				if(PosIsValid(textField,returnPosition))
				{
					return returnPosition;

				}
				returnPosition--;
			}
		}

		return -1;
	}	
}	

function PosIsValid(textField, position)
{
	var mask = textField.getAttribute("mask");
	var m = mask.split("");
	
	if(m.length > position)
	{
		if(m[position] != null)
		{
			var maskAlpha 			= textField.getAttribute("maskAlpha");
			var maskNumeric 		= textField.getAttribute("maskNumeric");
			var maskAlphaNumeric	= textField.getAttribute("maskAlphaNumeric");
			
			if	(
						m[position] == maskAlpha
					|| 	m[position] == maskNumeric
					|| 	m[position] == maskAlphaNumeric
			 	)
			{
				return true;
			}
			else
			{
				return false;
			}

		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}

function KeyDown(event, textField)
{
	var mask = textField.getAttribute("mask");
	
	if(mask != null && mask.length > 0)
	{
		var k = GetKeyCode(event);
		if(k == 8 || (k >= 33 && k <= 40) || k == 46)
		{
			switch(k)
			{
				case 8:
					KeyBackspace(textField);
					break;
				case 33:
					PushPosBegin(textField);
					break;
				case 34:
					PushPosEnd(textField);
					break;
				case 35:
					PushPosEnd(textField);
					break;
				case 36:
					PushPosBegin(textField);
					break;
				case 37:
					PushPosLeft(textField);
					break;
				case 38:
					PushPosLeft(textField);
					break;
				case 39:
					PushPosRight(textField);
					break;
				case 40:
					PushPosRight(textField);
					break;
				case 46:
					KeyDelete(textField);
					break;
			};
			
			StopEvent(event);
		}
	}
};

function DebugWrite(stringToLog)
{
	$("debug").innerHTML += stringToLog + "<br />";
}

function KeyPress(event, textField)
{
	var mask = textField.getAttribute("mask");
	if(mask != null && mask.length > 0)
	{
		var kc = GetKeyCode(event);
		var ss = GetSelectionStart(textField);
		
		if(kc != 9)
		{
			if(KeyIsValid(textField, ss, kc))
			{
				var ks = String.fromCharCode(kc);
				UpdateChar(textField,ss,ks);
				PutCaretPos(textField,ss+1);
			}
			else
			{
				var $q=textField.getAttribute("OnWrongKeyPressed");
				if($q!=null&&$q.length>0)
				{
					eval($q);
				}
			};
			
			StopEvent(event);
		}
	}
};

function UpdateChar(textField,$j,ks)
{
	var x = textField.value;
	
	var $t = x.substring(0,$j);
	var $u = x.substring($j+1,x.length);
	
	textField.value = $t + ks +$u;
}

function KeyIsValid(textField, locaction, keyToTest)
{
	var m = textField.getAttribute("mask").split("");

	if(m.length > locaction)
	{
		var testChar 			= m[locaction];
		var maskAlpha 			= textField.getAttribute("maskAlpha");
		var maskNumeric 		= textField.getAttribute("maskNumeric");
		var maskAlphaNumeric	= textField.getAttribute("maskAlphaNumeric");	
		
		if(testChar == maskAlpha)
		{
			if((keyToTest >= 65 && keyToTest <= 90) || (keyToTest >= 97 && keyToTest <= 122))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else if(testChar == maskNumeric)
		{
			if(keyToTest >= 48 && keyToTest <= 57)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else if(testChar == maskAlphaNumeric)
		{
			if((keyToTest >= 48 && keyToTest <= 57) || (keyToTest >= 65 && keyToTest <= 90) || (keyToTest >= 97 && keyToTest <= 122))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}

function GetKeyCode(event)
{
	return(event.keyCode ? event.keyCode:event.which ? event.which:event.charCode);
};


function PushPosLeft($b)
{
	var k=GetSelectionStart($b);
	
	if((k-1)>=0)
	{
		PutCaretPos($b,(k-1),true);
	}
};

function PushPosRight($b)
{
	var k=GetSelectionStart($b);
	if((k+1)<$b.value.length)
	{
		PutCaretPos($b,(k+1));
	}
};

function PushPosBegin($b)
{
	PutCaretPos($b,0);
};

function PushPosEnd($b)
{
	PutCaretPos($b,$b.getAttribute("mask").length);
};

function KeyDelete($b)
{
	var $k = GetSelectionStart($b);
	var $l = GetSelectionEnd($b);
	if($k == 0 && $l == $b.value.length)
	{
		$b.value="";
		GotFocus($b);
	}
	else
	{
		var $i = $b.getAttribute("maskDisplay");
		UpdateChar($b,$k,$i);
		PutCaretPos($b,$k+1);
	}
};

function KeyBackspace($b)
{
	var $k=GetSelectionStart($b);
	var $l=GetSelectionEnd($b);
	if($k==0&&$l==$b.value.length)
	{
		$b.value="";
		GotFocus($b);
	}
	else
	{
		var $i = $b.getAttribute("maskDisplay");
		UpdateChar($b,$k,$i);
		$j = GetValidPos($b,$k-1,true);
		PutCaretPos($b,$j);
	}
};

function StopEvent(event)
{
	if(document.all)
	{
		event.returnValue = false;
	}
	else if(event.preventDefault)
	{
		event.preventDefault();
	}
};

function StopEventPropagation(event)
{
	event.cancelBubble = true;
	
	if(event.stopPropagation)
	{
		event.stopPropagation();
	}
};

function OnClick(event, fieldValue)
{
	var mask = fieldValue.getAttribute("mask");
	if(mask != null && mask.length > 0)
	{
		var selectionStart = GetSelectionStart(fieldValue);
		PutCaretPos(fieldValue, selectionStart);
	};
	
	StopEventPropagation(event);
};

function OnPaste(textField)
{
	var $d = window.clipboardData.getData("Text");
	var $j = PlaceInMask(textField, $d);
	$a = textField;
	
	window.setTimeout("ValidatePos("+ $j +")", 10);
	StopEvent(event);
};

function ValidatePos($j,$b)
{
	if($b==null)
	{
		$b=$a;
	};
	
	PutCaretPos($b,$j);
};

function OnCut(textField)
{
	var $k = GetSelectionStart(textField);
	var $l = GetSelectionEnd(textField);
	
	if($k + $l == textField.value.length)
	{
		window.clipboardData.setData("Text",textField.value);
		textField.value="";
		GotFocus(textField);
	}
	else
	{
		var $i = textField.getAttribute("maskDisplay");
		
		window.clipboardData.setData("Text",textField.value.substring($k,($k+1)));
		UpdateChar(textField,$k,$i);
		PutCaretPos(textField,$k);
	};
	
	StopEvent(event);
};

function OnInput(event,textField)
{
	ValidateContent(textField);
	PutCaretPos(textField, GetSelectionStart(textField));
};

function PlaceInMask(textField, $d)
{
	var $c = "";
	
	if($d.length>0)
	{
		var mask	= textField.getAttribute("mask");
		var $f		= textField.getAttribute("maskAlpha");
		var $g		= textField.getAttribute("maskNumeric");
		var $h		= textField.getAttribute("maskAlphaNumeric");
		var $i		= textField.getAttribute("maskDisplay");
		var $m		= GetSelectionStart(textField);
		
		$c += textField.value.substring(0,$m);
	
		for(i=$m; i<mask.length;i++)
		{
			if(mask.substring(i,(i+1))==$f)
			{
				while($d.length>0&&(!(($d.substring(0,1).charCodeAt(0)>=65&&$d.substring(0,1).charCodeAt(0)<=90)||($d.substring(0,1).charCodeAt(0)>=97&&$d.substring(0,1).charCodeAt(0)<=122))))
				{
					$d=$d.substring(1);

				};
				
				if($d.length>0)
				{
					$c+=$d.substring(0,1);
					$d=$d.substring(1);

				}
				else
				{
					break;
				}

			}
			else if(mask.substring(i, (i+1)) == $g)
			{
				while($d.length>0&&(!($d.substring(0,1).charCodeAt(0) >= 48 && $d.substring(0,1).charCodeAt(0) <= 57)))
				{
					$d=$d.substring(1);
				};
				
				if($d.length>0)
				{
					$c+=$d.substring(0,1);
					$d=$d.substring(1);
				}
				else
				{
					break;
				}

			}
			else if(mask.substring(i,(i+1))==$h)
			{
				while($d.length>0 && (!(($d.substring(0,1).charCodeAt(0) >= 65 && $d.substring(0,1).charCodeAt(0) <= 90) || ($d.substring(0,1).charCodeAt(0)>=97&&$d.substring(0,1).charCodeAt(0)<=122)||($d.substring(0,1).charCodeAt(0)>=48&&$d.substring(0,1).charCodeAt(0)<=57))))
				{
					$d=$d.substring(1);
				};
				
				if($d.length>0)
				{
					$c+=$d.substring(0,1);
					$d=$d.substring(1);
				}
				else
				{
					break;
				}
			}
			else
			{
				$c+=mask.substring(i,(i+1));
			}
		};
		
		$c += textField.value.substring(i,mask.length);
	};
	
	textField.value=$c;
	return i;
};


//--- \busi\Image.js
function Image(){};

Image.GetDrawImageHtml = function(imageStrm, width, height, mouseover)
{
	var html = "<table cellspacing='0' cellpadding='0' style='height:" + height + "px;' " + mouseover + ">";
	if(mouseover == null) mouseover = ""; 
	
	for(var y = 0; y < height; y++)
	{
		html += "<tr>";
		for(var x = 0; x < width; x++)
		{
			var tmp = (y * height) + x;
			html += "<td style='background-color:#" + imageStrm[(y * height) + x] + ";' width='1px' height='1px'></td>";
		}
		html += "</tr>";
	}

	html += "</table>";

	return html;
}

Image.GetStretchXImageHtml = function(imageStrm, stretch, height)
{
	var html = "<table cellspacing='0' cellpadding='0' style='width:100%;'>";

	for(var y = 0; y < height; y++)
	{
		html += "<tr>";
		html += "<td style='background-color:#" + imageStrm[y] + ";height=1px'></td>";
		html += "</tr>";
	}

	html += "</table>";

	return html;
}

Image.FlipImageStreamHorizontal = function(streamOriginal, width)
{
	var stream = new Array();
	for(var i = 0; i < streamOriginal.length; i++)
	{
		stream[i] = streamOriginal[i];
	}

	for(var y = 0; y < (stream.length / width); y++)
	{
		var tmpArray = new Array();

		for(var x = (width - 1); x > -1; x--)
		{
			tmpArray[tmpArray.length] = (stream[(y * width) + x]);
		}

		for(var tmp = 0; tmp < width; tmp++)
		{
			stream[(y * width) + tmp] = tmpArray[tmp];
		}
	}

	return stream;
}


//--- \busi\security\security.js
function Security(){};

Security.ServerData = null; 
Security.Parameters = null; 
Security.Key 		= null; 

Security.Init = function()
{
	setMaxDigits(131);
	Security.ServerData = new ServerData.SenderObject("serverdata", null, Globals.Location.ASHX.Security);             
	Security.ServerData.SendData(Security.PostInit); 					 	
}; 

Security.PostInit = function(results)
{
	Security.Parameters = Security.ServerData.ReturnObject.Data; 	
	Security.Key = new RSAKeyPair(Security.Parameters.RSA_E, "", Security.Parameters.RSA_M);    
};

Security.RSAEncrypt = function(string)
{
	if(Security.Key == null)
	{
		Error.LogError("Security.Key is null. RSA data not yet returned from server."); 
	}
	
	var curdate = new Date(); 
	
	var timestamp = (curdate.getMonth() +1) + "/" + curdate.getDate() + "/" + curdate.getYear(); 
	return encryptedString(Security.Key, base64encode(string + "|" + timestamp)); 
};

Security.Sha1HashRSAEncrypt = function(string)
{
	//92429d82a41e930486c6de5ebda9602d55c39986
	return Security.RSAEncrypt(Sha1Hash(string)); 
	//return Security.RSAEncrypt(string); 
}

Security.GetRandomNumber = function()
{
	var now = new Date();
	var seed = now.getSeconds();
	return Math.random(seed);
};

Security.GetGlobalServerParams = function()
{
	if(Security.Initialized())
	{
		return "&_______k=" + encodeURIComponent(Security.RSAEncrypt("tmp")); 
	}
	
	return ""; 
};

Security.Initialized = function()
{
	return Security.Key != null; 
};


//--- \busi\security\sha1.js
function Sha1Hash(msg)
{
    // constants [4.2.1]
    var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
 
    // PREPROCESSING 
 
    msg += String.fromCharCode(0x80); // add trailing '1' bit to string [5.1.1]
 
    // convert string msg into 512-bit/16-integer blocks arrays of ints [5.2.1]
    var l = Math.ceil(msg.length/4) + 2;  // long enough to contain msg plus 2-word length
    var N = Math.ceil(l/16);              // in N 16-int blocks
    var M = new Array(N);
    for (var i=0; i<N; i++) {
        M[i] = new Array(16);
        for (var j=0; j<16; j++) {  // encode 4 chars per integer, big-endian encoding
            M[i][j] = (msg.charCodeAt(i*64+j*4)<<24) | (msg.charCodeAt(i*64+j*4+1)<<16) | 
                      (msg.charCodeAt(i*64+j*4+2)<<8) | (msg.charCodeAt(i*64+j*4+3));
        }
    }
    // add length (in bits) into final pair of 32-bit integers (big-endian) [5.1.1]
    M[N-1][14] = ((msg.length-1) >>> 30) * 8;
    M[N-1][15] = ((msg.length-1)*8) & 0xffffffff;
 
    // set initial hash value [5.3.1]
    var H0 = 0x67452301;
    var H1 = 0xefcdab89;
    var H2 = 0x98badcfe;
    var H3 = 0x10325476;
    var H4 = 0xc3d2e1f0;
 
    // HASH COMPUTATION [6.1.2]
 
    var W = new Array(80); var a, b, c, d, e;
    for (var i=0; i<N; i++) {
 
        // 1 - prepare message schedule 'W'
        for (var t=0;  t<16; t++) W[t] = M[i][t];
        for (var t=16; t<80; t++) W[t] = ROTL(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1);
 
        // 2 - initialise five working variables a, b, c, d, e with previous hash value
        a = H0; b = H1; c = H2; d = H3; e = H4;
 
        // 3 - main loop
        for (var t=0; t<80; t++) {
            var s = Math.floor(t/20); // seq for blocks of 'f' functions and 'K' constants
            var T = (ROTL(a,5) + sha1F(s,b,c,d) + e + K[s] + W[t]) & 0xffffffff;
            e = d;
            d = c;
            c = ROTL(b, 30);
            b = a;
            a = T;
        }
 
        // 4 - compute the new intermediate hash value
        H0 = (H0+a) & 0xffffffff;  // note 'addition modulo 2^32'
        H1 = (H1+b) & 0xffffffff; 
        H2 = (H2+c) & 0xffffffff; 
        H3 = (H3+d) & 0xffffffff; 
        H4 = (H4+e) & 0xffffffff;
    }
 
    return H0.toHexStr() + H1.toHexStr() + H2.toHexStr() + H3.toHexStr() + H4.toHexStr();
}
 
//
// function 'f' [4.1.1]
//
function sha1F(s, x, y, z) 
{
    switch (s) {
    case 0: return (x & y) ^ (~x & z);
    case 1: return x ^ y ^ z;
    case 2: return (x & y) ^ (x & z) ^ (y & z);
    case 3: return x ^ y ^ z;
    }
}
 
//
// rotate left (circular left shift) value x by n positions [3.2.5]
//
function ROTL(x, n)
{
    return (x<<n) | (x>>>(32-n));
}
 
//
// extend Number class with a tailored hex-string method 
//   (note toString(16) is implementation-dependant, and 
//   in IE returns signed numbers when used on full words)
//
Number.prototype.toHexStr = function()
{
    var s="", v;
    for (var i=7; i>=0; i--) { v = (this>>>(i*4)) & 0xf; s += v.toString(16); }
    return s;
}


//--- \busi\security\crypto\Barrett.js
// BarrettMu, a class for performing Barrett modular reduction computations in
// JavaScript.
//
// Requires BigInt.js.
//
// Copyright 2004-2005 David Shapiro.
//
// You may use, re-use, abuse, copy, and modify this code to your liking, but
// please keep this header.
//
// Thanks!
// 
// Dave Shapiro
// dave@ohdave.com 

function BarrettMu(m)
{
	this.modulus = biCopy(m);
	this.k = biHighIndex(this.modulus) + 1;
	var b2k = new BigInt();
	b2k.digits[2 * this.k] = 1; // b2k = b^(2k)
	this.mu = biDivide(b2k, this.modulus);
	this.bkplus1 = new BigInt();
	this.bkplus1.digits[this.k + 1] = 1; // bkplus1 = b^(k+1)
	this.modulo = BarrettMu_modulo;
	this.multiplyMod = BarrettMu_multiplyMod;
	this.powMod = BarrettMu_powMod;
}

function BarrettMu_modulo(x)
{
	var q1 = biDivideByRadixPower(x, this.k - 1);
	var q2 = biMultiply(q1, this.mu);
	var q3 = biDivideByRadixPower(q2, this.k + 1);
	var r1 = biModuloByRadixPower(x, this.k + 1);
	var r2term = biMultiply(q3, this.modulus);
	var r2 = biModuloByRadixPower(r2term, this.k + 1);
	var r = biSubtract(r1, r2);
	if (r.isNeg) {
		r = biAdd(r, this.bkplus1);
	}
	var rgtem = biCompare(r, this.modulus) >= 0;
	while (rgtem) {
		r = biSubtract(r, this.modulus);
		rgtem = biCompare(r, this.modulus) >= 0;
	}
	return r;
}

function BarrettMu_multiplyMod(x, y)
{
	/*
	x = this.modulo(x);
	y = this.modulo(y);
	*/
	var xy = biMultiply(x, y);
	return this.modulo(xy);
}

function BarrettMu_powMod(x, y)
{
	var result = new BigInt();
	result.digits[0] = 1;
	var a = x;
	var k = y;
	while (true) {
		if ((k.digits[0] & 1) != 0) result = this.multiplyMod(result, a);
		k = biShiftRight(k, 1);
		if (k.digits[0] == 0 && biHighIndex(k) == 0) break;
		a = this.multiplyMod(a, a);
	}
	return result;
}




//--- \busi\security\crypto\BigInt.js
// BigInt, a suite of routines for performing multiple-precision arithmetic in
// JavaScript.
//
// Copyright 1998-2005 David Shapiro.
//
// You may use, re-use, abuse,
// copy, and modify this code to your liking, but please keep this header.
// Thanks!
//
// Dave Shapiro
// dave@ohdave.com

// IMPORTANT THING: Be sure to set maxDigits according to your precision
// needs. Use the setMaxDigits() function to do this. See comments below.
//
// Tweaked by Ian Bunning
// Alterations:
// Fix bug in function biFromHex(s) to allow
// parsing of strings of length != 0 (mod 4)

// Changes made by Dave Shapiro as of 12/30/2004:
//
// The BigInt() constructor doesn't take a string anymore. If you want to
// create a BigInt from a string, use biFromDecimal() for base-10
// representations, biFromHex() for base-16 representations, or
// biFromString() for base-2-to-36 representations.
//
// biFromArray() has been removed. Use biCopy() instead, passing a BigInt
// instead of an array.
//
// The BigInt() constructor now only constructs a zeroed-out array.
// Alternatively, if you pass <true>, it won't construct any array. See the
// biCopy() method for an example of this.
//
// Be sure to set maxDigits depending on your precision needs. The default
// zeroed-out array ZERO_ARRAY is constructed inside the setMaxDigits()
// function. So use this function to set the variable. DON'T JUST SET THE
// VALUE. USE THE FUNCTION.
//
// ZERO_ARRAY exists to hopefully speed up construction of BigInts(). By
// precalculating the zero array, we can just use slice(0) to make copies of
// it. Presumably this calls faster native code, as opposed to setting the
// elements one at a time. I have not done any timing tests to verify this
// claim.

// Max number = 10^16 - 2 = 9999999999999998;
//               2^53     = 9007199254740992;

var biRadixBase = 2;
var biRadixBits = 16;
var bitsPerDigit = biRadixBits;
var biRadix = 1 << 16; // = 2^16 = 65536
var biHalfRadix = biRadix >>> 1;
var biRadixSquared = biRadix * biRadix;
var maxDigitVal = biRadix - 1;
var maxInteger = 9999999999999998; 

// maxDigits:
// Change this to accommodate your largest number size. Use setMaxDigits()
// to change it!
//
// In general, if you're working with numbers of size N bits, you'll need 2*N
// bits of storage. Each digit holds 16 bits. So, a 1024-bit key will need
//
// 1024 * 2 / 16 = 128 digits of storage.
//

var maxDigits;
var ZERO_ARRAY;
var bigZero, bigOne;

function setMaxDigits(value)
{
	maxDigits = value;
	ZERO_ARRAY = new Array(maxDigits);
	for (var iza = 0; iza < ZERO_ARRAY.length; iza++) ZERO_ARRAY[iza] = 0;
	bigZero = new BigInt();
	bigOne = new BigInt();
	bigOne.digits[0] = 1;
}

setMaxDigits(20);

// The maximum number of digits in base 10 you can convert to an
// integer without JavaScript throwing up on you.
var dpl10 = 15;
// lr10 = 10 ^ dpl10
var lr10 = biFromNumber(1000000000000000);

function BigInt(flag)
{
	if (typeof flag == "boolean" && flag == true) {
		this.digits = null;
	}
	else {
		this.digits = ZERO_ARRAY.slice(0);
	}
	this.isNeg = false;
}

function biFromDecimal(s)
{
	var isNeg = s.charAt(0) == '-';
	var i = isNeg ? 1 : 0;
	var result;
	// Skip leading zeros.
	while (i < s.length && s.charAt(i) == '0') ++i;
	if (i == s.length) {
		result = new BigInt();
	}
	else {
		var digitCount = s.length - i;
		var fgl = digitCount % dpl10;
		if (fgl == 0) fgl = dpl10;
		result = biFromNumber(Number(s.substr(i, fgl)));
		i += fgl;
		while (i < s.length) {
			result = biAdd(biMultiply(result, lr10),
			               biFromNumber(Number(s.substr(i, dpl10))));
			i += dpl10;
		}
		result.isNeg = isNeg;
	}
	return result;
}

function biCopy(bi)
{
	var result = new BigInt(true);
	result.digits = bi.digits.slice(0);
	result.isNeg = bi.isNeg;
	return result;
}

function biFromNumber(i)
{
	var result = new BigInt();
	result.isNeg = i < 0;
	i = Math.abs(i);
	var j = 0;
	while (i > 0) {
		result.digits[j++] = i & maxDigitVal;
		i = Math.floor(i / biRadix);
	}
	return result;
}

function reverseStr(s)
{
	var result = "";
	for (var i = s.length - 1; i > -1; --i) {
		result += s.charAt(i);
	}
	return result;
}

var hexatrigesimalToChar = new Array(
 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
 'u', 'v', 'w', 'x', 'y', 'z'
);

function biToString(x, radix)
	// 2 <= radix <= 36
{
	var b = new BigInt();
	b.digits[0] = radix;
	var qr = biDivideModulo(x, b);
	var result = hexatrigesimalToChar[qr[1].digits[0]];
	while (biCompare(qr[0], bigZero) == 1) {
		qr = biDivideModulo(qr[0], b);
		digit = qr[1].digits[0];
		result += hexatrigesimalToChar[qr[1].digits[0]];
	}
	return (x.isNeg ? "-" : "") + reverseStr(result);
}

function biToDecimal(x)
{
	var b = new BigInt();
	b.digits[0] = 10;
	var qr = biDivideModulo(x, b);
	var result = String(qr[1].digits[0]);
	while (biCompare(qr[0], bigZero) == 1) {
		qr = biDivideModulo(qr[0], b);
		result += String(qr[1].digits[0]);
	}
	return (x.isNeg ? "-" : "") + reverseStr(result);
}

var hexToChar = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                          'a', 'b', 'c', 'd', 'e', 'f');

function digitToHex(n)
{
	var mask = 0xf;
	var result = "";
	for (i = 0; i < 4; ++i) {
		result += hexToChar[n & mask];
		n >>>= 4;
	}
	return reverseStr(result);
}

function biToHex(x)
{
	var result = "";
	var n = biHighIndex(x);
	for (var i = biHighIndex(x); i > -1; --i) {
		result += digitToHex(x.digits[i]);
	}
	return result;
}

function charToHex(c)
{
	var ZERO = 48;
	var NINE = ZERO + 9;
	var littleA = 97;
	var littleZ = littleA + 25;
	var bigA = 65;
	var bigZ = 65 + 25;
	var result;

	if (c >= ZERO && c <= NINE) {
		result = c - ZERO;
	} else if (c >= bigA && c <= bigZ) {
		result = 10 + c - bigA;
	} else if (c >= littleA && c <= littleZ) {
		result = 10 + c - littleA;
	} else {
		result = 0;
	}
	return result;
}

function hexToDigit(s)
{
	var result = 0;
	var sl = Math.min(s.length, 4);
	for (var i = 0; i < sl; ++i) {
		result <<= 4;
		result |= charToHex(s.charCodeAt(i))
	}
	return result;
}

function biFromHex(s)
{
	var result = new BigInt();
	var sl = s.length;
	for (var i = sl, j = 0; i > 0; i -= 4, ++j) {
		result.digits[j] = hexToDigit(s.substr(Math.max(i - 4, 0), Math.min(i, 4)));
	}
	return result;
}

function biFromString(s, radix)
{
	var isNeg = s.charAt(0) == '-';
	var istop = isNeg ? 1 : 0;
	var result = new BigInt();
	var place = new BigInt();
	place.digits[0] = 1; // radix^0
	for (var i = s.length - 1; i >= istop; i--) {
		var c = s.charCodeAt(i);
		var digit = charToHex(c);
		var biDigit = biMultiplyDigit(place, digit);
		result = biAdd(result, biDigit);
		place = biMultiplyDigit(place, radix);
	}
	result.isNeg = isNeg;
	return result;
}

function biDump(b)
{
	return (b.isNeg ? "-" : "") + b.digits.join(" ");
}

function biAdd(x, y)
{
	var result;

	if (x.isNeg != y.isNeg) {
		y.isNeg = !y.isNeg;
		result = biSubtract(x, y);
		y.isNeg = !y.isNeg;
	}
	else {
		result = new BigInt();
		var c = 0;
		var n;
		for (var i = 0; i < x.digits.length; ++i) {
			n = x.digits[i] + y.digits[i] + c;
			result.digits[i] = n % biRadix;
			c = Number(n >= biRadix);
		}
		result.isNeg = x.isNeg;
	}
	return result;
}

function biSubtract(x, y)
{
	var result;
	if (x.isNeg != y.isNeg) {
		y.isNeg = !y.isNeg;
		result = biAdd(x, y);
		y.isNeg = !y.isNeg;
	} else {
		result = new BigInt();
		var n, c;
		c = 0;
		for (var i = 0; i < x.digits.length; ++i) {
			n = x.digits[i] - y.digits[i] + c;
			result.digits[i] = n % biRadix;
			// Stupid non-conforming modulus operation.
			if (result.digits[i] < 0) result.digits[i] += biRadix;
			c = 0 - Number(n < 0);
		}
		// Fix up the negative sign, if any.
		if (c == -1) {
			c = 0;
			for (var i = 0; i < x.digits.length; ++i) {
				n = 0 - result.digits[i] + c;
				result.digits[i] = n % biRadix;
				// Stupid non-conforming modulus operation.
				if (result.digits[i] < 0) result.digits[i] += biRadix;
				c = 0 - Number(n < 0);
			}
			// Result is opposite sign of arguments.
			result.isNeg = !x.isNeg;
		} else {
			// Result is same sign.
			result.isNeg = x.isNeg;
		}
	}
	return result;
}

function biHighIndex(x)
{
	var result = x.digits.length - 1;
	while (result > 0 && x.digits[result] == 0) --result;
	return result;
}

function biNumBits(x)
{
	var n = biHighIndex(x);
	var d = x.digits[n];
	var m = (n + 1) * bitsPerDigit;
	var result;
	for (result = m; result > m - bitsPerDigit; --result) {
		if ((d & 0x8000) != 0) break;
		d <<= 1;
	}
	return result;
}

function biMultiply(x, y)
{
	var result = new BigInt();
	var c;
	var n = biHighIndex(x);
	var t = biHighIndex(y);
	var u, uv, k;

	for (var i = 0; i <= t; ++i) {
		c = 0;
		k = i;
		for (j = 0; j <= n; ++j, ++k) {
			uv = result.digits[k] + x.digits[j] * y.digits[i] + c;
			result.digits[k] = uv & maxDigitVal;
			c = uv >>> biRadixBits;
			//c = Math.floor(uv / biRadix);
		}
		result.digits[i + n + 1] = c;
	}
	// Someone give me a logical xor, please.
	result.isNeg = x.isNeg != y.isNeg;
	return result;
}

function biMultiplyDigit(x, y)
{
	var n, c, uv;

	result = new BigInt();
	n = biHighIndex(x);
	c = 0;
	for (var j = 0; j <= n; ++j) {
		uv = result.digits[j] + x.digits[j] * y + c;
		result.digits[j] = uv & maxDigitVal;
		c = uv >>> biRadixBits;
		//c = Math.floor(uv / biRadix);
	}
	result.digits[1 + n] = c;
	return result;
}

function arrayCopy(src, srcStart, dest, destStart, n)
{
	var m = Math.min(srcStart + n, src.length);
	for (var i = srcStart, j = destStart; i < m; ++i, ++j) {
		dest[j] = src[i];
	}
}

var highBitMasks = new Array(0x0000, 0x8000, 0xC000, 0xE000, 0xF000, 0xF800,
                             0xFC00, 0xFE00, 0xFF00, 0xFF80, 0xFFC0, 0xFFE0,
                             0xFFF0, 0xFFF8, 0xFFFC, 0xFFFE, 0xFFFF);

function biShiftLeft(x, n)
{
	var digitCount = Math.floor(n / bitsPerDigit);
	var result = new BigInt();
	arrayCopy(x.digits, 0, result.digits, digitCount,
	          result.digits.length - digitCount);
	var bits = n % bitsPerDigit;
	var rightBits = bitsPerDigit - bits;
	for (var i = result.digits.length - 1, i1 = i - 1; i > 0; --i, --i1) {
		result.digits[i] = ((result.digits[i] << bits) & maxDigitVal) |
		                   ((result.digits[i1] & highBitMasks[bits]) >>>
		                    (rightBits));
	}
	result.digits[0] = ((result.digits[i] << bits) & maxDigitVal);
	result.isNeg = x.isNeg;
	return result;
}

var lowBitMasks = new Array(0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F,
                            0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,
                            0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF);

function biShiftRight(x, n)
{
	var digitCount = Math.floor(n / bitsPerDigit);
	var result = new BigInt();
	arrayCopy(x.digits, digitCount, result.digits, 0,
	          x.digits.length - digitCount);
	var bits = n % bitsPerDigit;
	var leftBits = bitsPerDigit - bits;
	for (var i = 0, i1 = i + 1; i < result.digits.length - 1; ++i, ++i1) {
		result.digits[i] = (result.digits[i] >>> bits) |
		                   ((result.digits[i1] & lowBitMasks[bits]) << leftBits);
	}
	result.digits[result.digits.length - 1] >>>= bits;
	result.isNeg = x.isNeg;
	return result;
}

function biMultiplyByRadixPower(x, n)
{
	var result = new BigInt();
	arrayCopy(x.digits, 0, result.digits, n, result.digits.length - n);
	return result;
}

function biDivideByRadixPower(x, n)
{
	var result = new BigInt();
	arrayCopy(x.digits, n, result.digits, 0, result.digits.length - n);
	return result;
}

function biModuloByRadixPower(x, n)
{
	var result = new BigInt();
	arrayCopy(x.digits, 0, result.digits, 0, n);
	return result;
}

function biCompare(x, y)
{
	if (x.isNeg != y.isNeg) {
		return 1 - 2 * Number(x.isNeg);
	}
	for (var i = x.digits.length - 1; i >= 0; --i) {
		if (x.digits[i] != y.digits[i]) {
			if (x.isNeg) {
				return 1 - 2 * Number(x.digits[i] > y.digits[i]);
			} else {
				return 1 - 2 * Number(x.digits[i] < y.digits[i]);
			}
		}
	}
	return 0;
}

function biDivideModulo(x, y)
{
	var nb = biNumBits(x);
	var tb = biNumBits(y);
	var origYIsNeg = y.isNeg;
	var q, r;
	if (nb < tb) {
		// |x| < |y|
		if (x.isNeg) {
			q = biCopy(bigOne);
			q.isNeg = !y.isNeg;
			x.isNeg = false;
			y.isNeg = false;
			r = biSubtract(y, x);
			// Restore signs, 'cause they're references.
			x.isNeg = true;
			y.isNeg = origYIsNeg;
		} else {
			q = new BigInt();
			r = biCopy(x);
		}
		return new Array(q, r);
	}

	q = new BigInt();
	r = x;

	// Normalize Y.
	var t = Math.ceil(tb / bitsPerDigit) - 1;
	var lambda = 0;
	while (y.digits[t] < biHalfRadix) {
		y = biShiftLeft(y, 1);
		++lambda;
		++tb;
		t = Math.ceil(tb / bitsPerDigit) - 1;
	}
	// Shift r over to keep the quotient constant. We'll shift the
	// remainder back at the end.
	r = biShiftLeft(r, lambda);
	nb += lambda; // Update the bit count for x.
	var n = Math.ceil(nb / bitsPerDigit) - 1;

	var b = biMultiplyByRadixPower(y, n - t);
	while (biCompare(r, b) != -1) {
		++q.digits[n - t];
		r = biSubtract(r, b);
	}
	for (var i = n; i > t; --i) {
    var ri = (i >= r.digits.length) ? 0 : r.digits[i];
    var ri1 = (i - 1 >= r.digits.length) ? 0 : r.digits[i - 1];
    var ri2 = (i - 2 >= r.digits.length) ? 0 : r.digits[i - 2];
    var yt = (t >= y.digits.length) ? 0 : y.digits[t];
    var yt1 = (t - 1 >= y.digits.length) ? 0 : y.digits[t - 1];
		if (ri == yt) {
			q.digits[i - t - 1] = maxDigitVal;
		} else {
			q.digits[i - t - 1] = Math.floor((ri * biRadix + ri1) / yt);
		}

		var c1 = q.digits[i - t - 1] * ((yt * biRadix) + yt1);
		var c2 = (ri * biRadixSquared) + ((ri1 * biRadix) + ri2);
		while (c1 > c2) {
			--q.digits[i - t - 1];
			c1 = q.digits[i - t - 1] * ((yt * biRadix) | yt1);
			c2 = (ri * biRadix * biRadix) + ((ri1 * biRadix) + ri2);
		}

		b = biMultiplyByRadixPower(y, i - t - 1);
		r = biSubtract(r, biMultiplyDigit(b, q.digits[i - t - 1]));
		if (r.isNeg) {
			r = biAdd(r, b);
			--q.digits[i - t - 1];
		}
	}
	r = biShiftRight(r, lambda);
	// Fiddle with the signs and stuff to make sure that 0 <= r < y.
	q.isNeg = x.isNeg != origYIsNeg;
	if (x.isNeg) {
		if (origYIsNeg) {
			q = biAdd(q, bigOne);
		} else {
			q = biSubtract(q, bigOne);
		}
		y = biShiftRight(y, lambda);
		r = biSubtract(y, r);
	}
	// Check for the unbelievably stupid degenerate case of r == -0.
	if (r.digits[0] == 0 && biHighIndex(r) == 0) r.isNeg = false;

	return new Array(q, r);
}

function biDivide(x, y)
{
	return biDivideModulo(x, y)[0];
}

function biModulo(x, y)
{
	return biDivideModulo(x, y)[1];
}

function biMultiplyMod(x, y, m)
{
	return biModulo(biMultiply(x, y), m);
}

function biPow(x, y)
{
	var result = bigOne;
	var a = x;
	while (true) {
		if ((y & 1) != 0) result = biMultiply(result, a);
		y >>= 1;
		if (y == 0) break;
		a = biMultiply(a, a);
	}
	return result;
}

function biPowMod(x, y, m)
{
	var result = bigOne;
	var a = x;
	var k = y;
	while (true) {
		if ((k.digits[0] & 1) != 0) result = biMultiplyMod(result, a, m);
		k = biShiftRight(k, 1);
		if (k.digits[0] == 0 && biHighIndex(k) == 0) break;
		a = biMultiplyMod(a, a, m);
	}
	return result;
}




//--- \busi\security\crypto\RSA.js
// RSA, a suite of routines for performing RSA public-key computations in
// JavaScript.
//
// Requires BigInt.js and Barrett.js.
//
// Copyright 1998-2005 David Shapiro.
//
// You may use, re-use, abuse, copy, and modify this code to your liking, but
// please keep this header.
//
// Thanks!
// 
// Dave Shapiro
// dave@ohdave.com 

function RSAKeyPair(encryptionExponent, decryptionExponent, modulus)
{
	this.e = biFromHex(encryptionExponent);
	this.d = biFromHex(decryptionExponent);
	this.m = biFromHex(modulus);
	
	// We can do two bytes per digit, so
	// chunkSize = 2 * (number of digits in modulus - 1).
	// Since biHighIndex returns the high index, not the number of digits, 1 has
	// already been subtracted.
	//this.chunkSize = 2 * biHighIndex(this.m);
	
	////////////////////////////////// TYF
    	this.digitSize = 2 * biHighIndex(this.m) + 2;
	this.chunkSize = this.digitSize - 11; // maximum, anything lower is fine
	////////////////////////////////// TYF

	this.radix = 16;
	this.barrett = new BarrettMu(this.m);
}

function twoDigit(n)
{
	return (n < 10 ? "0" : "") + String(n);
}

function encryptedString(key, s)
// Altered by Rob Saunders (rob@robsaunders.net). New routine pads the
// string after it has been converted to an array. This fixes an
// incompatibility with Flash MX's ActionScript.
// Altered by Tang Yu Feng for interoperability with Microsoft's
// RSACryptoServiceProvider implementation.
{
	////////////////////////////////// TYF
	if (key.chunkSize > key.digitSize - 11)
	{
	    return "Error";
	}
	////////////////////////////////// TYF


	var a = new Array();
	var sl = s.length;
	
	var i = 0;
	while (i < sl) {
		a[i] = s.charCodeAt(i);
		i++;
	}

	//while (a.length % key.chunkSize != 0) {
	//	a[i++] = 0;
	//}

	var al = a.length;
	var result = "";
	var j, k, block;
	for (i = 0; i < al; i += key.chunkSize) {
		block = new BigInt();
		j = 0;
		
		//for (k = i; k < i + key.chunkSize; ++j) {
		//	block.digits[j] = a[k++];
		//	block.digits[j] += a[k++] << 8;
		//}
		
		////////////////////////////////// TYF
		// Add PKCS#1 v1.5 padding
		// 0x00 || 0x02 || PseudoRandomNonZeroBytes || 0x00 || Message
		// Variable a before padding must be of at most digitSize-11
		// That is for 3 marker bytes plus at least 8 random non-zero bytes
		var x;
		var msgLength = (i+key.chunkSize)>al ? al%key.chunkSize : key.chunkSize;
		
		// Variable b with 0x00 || 0x02 at the highest index.
		var b = new Array();
		for (x=0; x<msgLength; x++)
		{
		    b[x] = a[i+msgLength-1-x];
		}
		b[msgLength] = 0; // marker
		var paddedSize = Math.max(8, key.digitSize - 3 - msgLength);
	
		for (x=0; x<paddedSize; x++) {
		    b[msgLength+1+x] = Math.floor(Math.random()*254) + 1; // [1,255]
		}
		// It can be asserted that msgLength+paddedSize == key.digitSize-3
		b[key.digitSize-2] = 2; // marker
		b[key.digitSize-1] = 0; // marker
		
		for (k = 0; k < key.digitSize; ++j) 
		{
		    block.digits[j] = b[k++];
		    block.digits[j] += b[k++] << 8;
		}
		////////////////////////////////// TYF

		var crypt = key.barrett.powMod(block, key.e);
		var text = key.radix == 16 ? biToHex(crypt) : biToString(crypt, key.radix);
		result += text + " ";
	}
	return result.substring(0, result.length - 1); // Remove last space.
}

function decryptedString(key, s)
{
	var blocks = s.split(" ");
	var result = "";
	var i, j, block;
	for (i = 0; i < blocks.length; ++i) {
		var bi;
		if (key.radix == 16) {
			bi = biFromHex(blocks[i]);
		}
		else {
			bi = biFromString(blocks[i], key.radix);
		}
		block = key.barrett.powMod(bi, key.d);
		for (j = 0; j <= biHighIndex(block); ++j) {
			result += String.fromCharCode(block.digits[j] & 255,
			                              block.digits[j] >> 8);
		}
	}
	// Remove trailing null, if any.
	if (result.charCodeAt(result.length - 1) == 0) {
		result = result.substring(0, result.length - 1);
	}
	return result;
}

function base64encode(str) 
{	
	var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var base64DecodeChars = new Array(
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
	52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
	-1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
	15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
	-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
	41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
	var out, i, len;
	var c1, c2, c3;

	len = str.length;
	i = 0;
	out = "";
	while(i < len) {
	c1 = str.charCodeAt(i++) & 0xff;
	if(i == len)
	{
		out += base64EncodeChars.charAt(c1 >> 2);
		out += base64EncodeChars.charAt((c1 & 0x3) << 4);
		out += "==";
		break;
	}
	c2 = str.charCodeAt(i++);
	if(i == len)
	{
		out += base64EncodeChars.charAt(c1 >> 2);
		out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
		out += base64EncodeChars.charAt((c2 & 0xF) << 2);
		out += "=";
		break;
	}
	c3 = str.charCodeAt(i++);
	out += base64EncodeChars.charAt(c1 >> 2);
	out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
	out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
	out += base64EncodeChars.charAt(c3 & 0x3F);
	}
	return out;
}


//--- \busi\security\userroles.js
//Server will also check each of these rights to prevent user from setting them client side
UserRoles = new Object();

UserRoles.HasRights = function(passedIndex)
{
	if(Globals.UserData == null)
	{
		return false; 
	}
	
	var rights = Globals.UserData.Doc.parseJSON().Rights.parseJSON();     				
	if(rights == null)
	{
		return false; 
	}
		
	if(passedIndex > rights.length)
	{
		return false; 
	}
	
	if(rights[passedIndex] == 1)
	{
		return true; 
	}
	
	return false; 
};



//--- \busi\DataBridgeObject.js
function DataBridgeObject(internalName, displayName, dataType)
{
	this.DisplayName = displayName;
	this.Name = internalName;
	this.DataType = dataType; 
	this.DataTypeHigh;
	this.JavascriptValidationFunction = "";
	this.ValidationErrorText = "";
	this.WriteValidationError = true;
	this.Key = false;
	this.GridVisible = true;
	this.Editable = true;
	this.MaxLength = 45;
	this.Style = "";
	this.Required = false; 
}

function DataBridge(dataBridgeName)
{
	this.DataObjects = new Array(); 
	this.DataObjectsHigh = new Array();
	this.DataObjectsOrder = new Array();
	this.DisplayName = dataBridgeName; 
	this.TableName = dataBridgeName; 
	this.IdAliasIndex = -1; 
	this.DataHandler = ""; 
	
	this.Add = function(objectToAdd)
	{
		this.DataObjects[this.DataObjects.length] = objectToAdd; 
	};
}


//--- \data\Server.Data.js
var ServerData = function(){}; 

ServerData.SenderObject = function(command, dataObject, commandURL, params)
{
    var _this = this; 
    this.Command = command; 
    this.DataObject = dataObject; 
    this.CommandURL = commandURL;
    this.ReturnFunction = null; 
    this.Params = params; 

    this.SendData = function(returnFunction)
    {    	
        this.ReturnFunction = returnFunction; 
        this.ReturnObject   = null; 
    	
        var tmpObj = new Object(); 
        tmpObj.Command = this.Command; 
        tmpObj.DataObject = this.DataObject;        
		tmpObj.UserData = Globals.UserData; 
        
        var params = "xferobj=" + encodeURIComponent(tmpObj.toJSONString()) + "&" + this.Params + "&" + Security.GetGlobalServerParams();                
				
        var myAjax = new Ajax.Request(
	            this.CommandURL, 
	            {
		            method: "post", 
		            parameters: params,
		            requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
		            onComplete: function(req){_this.ParseReturn(req);}/*,
		            onException: Error.LogAjaxException,
		            onFailure: Error.LogAjaxFailure*/
	            });
        
        return myAjax;  
    };
    
    this.ParseReturn = function(req)
    {
        this.ReturnObject = req.responseText.parseJSON();
        if(!this.ReturnObject)
        {
            Error.Handle(" Return Error for req.responseTExt.parseJSON()", "Data/Server.Data.js:ParseReturn", this.CommandURL); 
            Error.Handle("Server Dump:", req.responseText, this.CommandURL); 
        }
        else
        {        
            if(this.ReturnObject.Errors)
            {
                for(var i = 0; i < this.ReturnObject.ErrorList.length; i++)
                {
                    Error.Handle(" Error from server: <br />" + this.ReturnObject.ErrorList[i].Type + 
                    "<br />" + this.ReturnObject.ErrorList[i].Message + "<br /><br />" + this.ReturnObject.ErrorList[i].StackTrace, "Data/Server.Data.js:ParseReturn", this.CommandURL); 
                }
            }
            
            if(this.ReturnObject.DataBridge != null)
            {
            	//Cache previous databridge objects.
            	ServerData.DataBridgeObjects.Add(this.ReturnObject.DataBridge);             
				
				//Go through, find all columns that are dates, convert them to out
				//Date format (MM/DD/YYYY)
            	if(this.ReturnObject.DataRows != null)
            	{            	

					var dateColumns = new Array(); 

					var indexOffset = 0; 
					for(var i = 0; i < this.ReturnObject.DataBridge.DataObjects.length; i++)
					{
						//Passwords, although part of the data bridge definition, are not transmitted
						if(this.ReturnObject.DataBridge.DataObjects[i].DataType == "Password" || this.ReturnObject.DataBridge.DataObjects[i].DataType == "DoublePassword")
						{
							indexOffset--; 
						}

						if(this.ReturnObject.DataBridge.DataObjects[i].DataType == "Date")
						{
							dateColumns[dateColumns.length] = i + indexOffset; 
						}
					}

					for(var i = 0; i < this.ReturnObject.DataRows.length; i++)
					{
						for(var j = 0; j < dateColumns.length; j++)
						{
							this.ReturnObject.DataRows[i][dateColumns[j]] = this.ConvertDate(this.ReturnObject.DataRows[i][dateColumns[j]]); 
						}
					}    
				}
            }
        } 
        this.ReturnFunction(this.ReturnObject.Data); 
    };
    
    this.ConvertDate = function(date)
    {
		var formattedDate = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear(); 
    	return formattedDate; 
    };
};

ServerData.DataBridgeObjects = function(){}; 
ServerData.DataBridgeObjects._objects = new Array(); 
	
ServerData.DataBridgeObjects.Add = function(objectToAdd)
{
	if(ServerData.DataBridgeObjects.Get(objectToAdd.TableName) == null)
	{
		ServerData.DataBridgeObjects._objects[ServerData.DataBridgeObjects._objects.length] = objectToAdd; 
	}
	else
	{
		//Replace old object with one retrived from the server to keep them in sync
		for(var i = 0; i < ServerData.DataBridgeObjects._objects.length; i++)
		{
			if(objectToAdd.TableName == ServerData.DataBridgeObjects._objects[i].TableName)
			{
				ServerData.DataBridgeObjects._objects[i] = objectToAdd; 
			}
		}
	}
};
	
ServerData.DataBridgeObjects.Get = function(dataName)
{
	for(var i = 0; i < ServerData.DataBridgeObjects._objects.length; i++)
	{
		if(dataName == ServerData.DataBridgeObjects._objects[i].TableName)
		{
			return ServerData.DataBridgeObjects._objects[i]; 
		}
	}

	return null; 
};



//--- \data\Structs.Data.js
KeyValue = function(key, value)
{
	this.Key = key; 
	this.Value = value; 
}


//--- \nav\Navigation.js
Globals.UI = function(){}; 
Globals.UI.Navigation = function(){};
Globals.UI.Navigation.HideRight = function()
{
    $("RightNav").style.display = "none";
};
Globals.UI.Navigation.ShowRight = function()
{
    $("RightNav").style.display = "block";
};
Globals.UI.Navigation.HideLeft = function()
{
    $("LeftNav").style.display = "none";
    $("LeftNavSep").style.display = "none";    
    $("LeftNavBack").style.display = "none";    
};
Globals.UI.Navigation.ShowLeft = function()
{
    $("LeftNav").style.display = "block";
    $("LeftNavSep").style.display = "block";
    $("LeftNavBack").style.display = "block";    
};
Globals.UI.Navigation.HideMiddleStatus = function()
{
    $("BottomFooter").style.display = "none";
}
Globals.UI.Navigation.ShowMiddleStatus = function()
{
    $("BottomFooter").style.display = "block";
}

Globals.UI.Navigation.HideCrumb = function()
{
    $("NavCrumb").style.display = "none";
}
Globals.UI.Navigation.ShowCrumb = function()
{
    $("NavCrumb").style.display = "block";
}

Globals.UI.Navigation.HideTitle = function()
{
    $("PageTitle").style.display = "none";
}
Globals.UI.Navigation.ShowTitle = function()
{
    $("PageTitle").style.display = "block";
}

Globals.UI.Navigation.HideSubTitle = function()
{
    $(Globals.UI.Navigation.SubNavTitleId).style.display = "none";
    $("SubNavMenu").style.display = "none";
}
Globals.UI.Navigation.ShowSubTitle = function()
{
    $(Globals.UI.Navigation.SubNavTitleId).style.display = "block";
    $("SubNavMenu").style.display = "";
}

Globals.UI.Navigation.Reset = function()
{
    $(Globals.UI.Navigation.SubNavTitleId).className = "SubNavTitle"; 
    $("SubNavMenu").innerHTML = ""; 
   	$("SubNavTitle").innerHTML = "";
    $("MiddleBody").innerHTML = ""; 
    $("LeftNav").innerHTML = "";
	Globals.UI.Navigation.ShowMiddleStatus(); 
	Globals.UI.Navigation.ShowLeft(); 
	Globals.UI.Navigation.ShowMiddleStatus(); 
	Globals.UI.Navigation.ShowCrumb(); 
	Globals.UI.Navigation.ShowTitle(); 
	Globals.UI.Navigation.ShowSubTitle(); 
};

var crumbs = new Array(); 
Globals.UI.Navigation.ResetCrumbTrail = function()
{
    $("NavCrumb").innerHTML = "";
	crumbs = new Array(); 
}
Globals.UI.Navigation.AddToCrumbTrail = function(key, value)
{
	crumbs[crumbs.length] = new KeyValue(key, value);
	Globals.UI.Navigation.RenderCrumbTrail(); 
}
Globals.UI.Navigation.RenderCrumbTrail = function()
{
	var val = ""; 
	for(var i = 0; i < crumbs.length; i++)
	{
    	val += '<a href="' + crumbs[i].Value + '">' + crumbs[i].Key + '</a><span class="CrumbSep">\\</span>';	
	}
	
	$("NavCrumb").innerHTML = val; 
}

Globals.UI.Navigation.SetSubTitleBackground = function(img)
{
	$(Globals.UI.Navigation.SubNavTitleId).style.backgroundImage = "url('" + img + "')";
};

Globals.UI.Navigation.LoadPage = function(title, subtitle, bodymiddle, bodyright, footer, leftmenu)
{		
	if(footer == null) footer = ""; 
	//$("SubNavMenu").innerHTML = ""; 
	//Re initialize everything in case rights have changed due to login etc.
	if(Globals.InitConfig != null)
	{
		Globals.InitConfig(); 		
	}
	
	$("PageTitle").innerHTML = title; 
	
	if(subtitle == null) subtitle = ""; 
	
	if(subtitle == "")
	{
		Globals.UI.Navigation.HideSubTitle(); 	
	}
	else
	{
		Globals.UI.Navigation.ShowSubTitle(); 	
		$(Globals.UI.Navigation.SubNavTitleId).innerHTML = subtitle; 	
	}
	
	$("BottomFooter").innerHTML = footer; 	

	if(bodymiddle != null) 
	{
		$(Globals.UI.Navigation.MiddleBodyId).innerHTML = bodymiddle; 
	}	
	if(bodyright != null && bodyright != "")
	{
		Globals.UI.Navigation.ShowRight(); 
		$("RightNav").innerHTML = bodyright; 
	}	
	else
	{
		Globals.UI.Navigation.HideRight(); 
		$("RightNav").innerHTML = ""; 
	}
	
	if(leftmenu != null && leftmenu != "")
	{
		leftmenu.Render(); 
	}
	else if(leftmenu != null) //If menu is null, keep the existing content
	{
		$("LeftNav").innerHTML = ""; 
	}	
	
	Globals.SetupLoginForm(); 	
};

Globals.UI.Navigation.SetBodyMiddle = function(bodymiddle)
{
	$(Globals.UI.Navigation.MiddleBodyId).innerHTML = bodymiddle; 
};

Globals.UI.Navigation.MiddleBodyId = "MiddleBody"; 
Globals.UI.Navigation.SubNavTitleId = "SubNavTitle"; 
Globals.UI.Navigation.BottomFooterId = "BottomFooter"; 

Globals.ShowSpinner = function(id, text, minHeight)
{
    if($(id))
    {
        $(id).innerHTML = '<br /><br /><table align="center" cellpadding="2px"><tr><td><img src="./imgs/spinner.gif" /></td><td style="color:#666666">' + text + '</td></tr></table></div>'; 
    }
};

Globals.UI.Text = function(){}; 
Globals.UI.Text.GetTitle = function(main, sub)
{
    return '<div style="padding-left:5px;padding-right:100px; padding-top:15px;">' + 
            '<h2 style="font-family:tahoma; ' + 
            'letter-spacing:-1px;border-bottom:solid 3px #efefef;' + 
            'width:80%">' + main + ' <span style="letter-spacing:1px;' + 
            'font-size:14px;font-weight:100">'
             + sub + '</span></h2> ';
};


//--- \ui\IControl.js
var DataBridgeControl = new Object(); 

//******************************************************************************
// Controls class
//******************************************************************************
function IDataControl(recordId, container, prms, dataSet, getValueF, setValueF, renderF, validateF)
{
	if(container == null)
	{
		//return; 
		//alert("Assert Error: Container for " + recordId + " is null."); 
	}
	
	this._recordId					= recordId; 
	this._dataSet					= dataSet; 
	this._container					= container; 
	this._renderF					= renderF; 
	this._validateF					= validateF; 
	this._prms						= prms; 
	this._disableF					= null;
	this._enableF					= null; 
	this._focusF					= null; 
	this._selectF					= null; 
	this._getJSONStringF			= null; 
	this._getURIFormat              = null; 
	this._onEnterF					= null; 
	
	this.Required					= false; 
	this.ValidateOnBlur 			= true; 
	this.ValidationError 			= false; 
	this.ValidationRegExpression 	= null; 
	this.ValidationErrorTxt			= null; 
	this.ValidationErrorWriteOut	= false; 
	this.Label						= null; 
	this.DisplayLabel				= true; 
	this.GetRecordId				= function() { return this._recordId; }; 
	this.GetDataSet					= function() { return this._dataSet; }; 
			
	this.GetValue					= getValueF; 
	this.SetValue					= setValueF; 
	
	this.Render	= function(defaultValue) 
	{
		if(defaultValue == null) defaultValue = ""; 
		
		var htmlValue = this._renderF(defaultValue); 

		if(htmlValue != null) //Renders on it's own
		{
			if(this.ValidateOnBlur)
			{
				htmlValue = htmlValue.replace("OnBlur='", "OnBlur='" + this.GetSelfReferenceString() + ".Validate();\n"); 				 
				htmlValue = htmlValue.replace("Onblur='", "OnBlur='" + this.GetSelfReferenceString() + ".Validate();\n"); 				 
				htmlValue = htmlValue.replace("onblur='", "OnBlur='" + this.GetSelfReferenceString() + ".Validate();\n"); 				 
			}
			
			if(this._onEnterF)
			{
				htmlValue = htmlValue.replace("KeyPressPlaceHolder='", "onKeyPress='" + this.GetSelfReferenceString() + ".checkOnEnter(event);\n"); 				 			
			}

			var htmlText = ""; 
			if(this.DisplayLabel && this.Label != null && this.Label != "")
			{
				var requiredTxt = "<span class='error'>*</span> <b>";
				if(!this.Required)
				{
					requiredTxt = ""; 
				}
				
				htmlText = requiredTxt + this.Label + "</b><br />";
			}

			htmlText += "" + 
			"<span id='"+ this.GetFeedbackSpanId() + "_span1'>" + 
			"<span id='"+ this.GetFeedbackSpanId() + "'>" + htmlValue + 
			"</span>" + 
			"<span class='error' id='"+ this.GetFeedbackSpanId() + "_errorText'></span>" 
		
			if(this._container)
			{
			    $(this._container).innerHTML = htmlText;
			}
		}
	};
	
	this.checkOnEnter = function(e)
	{
		var characterCode; 

		if(e && e.which)//if which property of event object is supported (NN4)
		{ 
			e = e; 
			characterCode = e.which;  //character code is contained in NN4's which property
		}
		else
		{
			e = event; 
			characterCode = e.keyCode;  //character code is contained in IE's keyCode property
		}

		if(characterCode == 13)
		{
			this._onEnterF(); 
			return false;  
		}
		else
		{
			return true; 
		}		
	};
	
	this.toJSONString = function()
	{
		return this.GetJSONString(); 
	};
	
	this.GetURIFormat = function()
	{		
		if(this._getURIFormat == null)
		{
	        return this._recordId + "=" + Globals.UrlEncode(this.GetValue()); 
	    }
	    else
	    {
	        return this._getURIFormat(); 
	    }
	};
	
	this.GetJSONString = function()
	{		
		if(this._getJSONStringF == null)
		{
			var tmp = new Object(); 
			tmp.Name = this._recordId;
			tmp.Value = this.GetValue();
			
			return tmp.toJSONString(); 
		}
		else
		{
			return this._getJSONStringF(); 
		}
	};
	
	this.SetValidationRegExpression = function(value)
	{
		this.ValidationRegExpression = value; 
	};
	
	this.Disable = function()
	{
		if(this._disableF == null)
		{
			if($(this._recordId) == null) return; 
			$(this._recordId).disabled = true; 
		}
		else
		{
			this._disableF(); 
		}
	};
	
	this.Enable	= function()
	{
		if(this._enableF == null)
		{
			if($(this._recordId) == null) return; 
			$(this._recordId).disabled = false; 
		}
		else
		{
			this._enableF(); 
		}
	};
	
	this.Focus	= function()
	{
		if(this._focusF == null)
		{
			if($(this._recordId) == null) return; 
			$(this._recordId).focus(); 
		}
		else
		{
			this._focusF(); 
		}
	};
	
	this.Select	= function()
	{
		if(this._selectF == null)
		{
			if($(this._recordId) == null) return; 
			$(this._recordId).select(); 
		}
		else
		{
			this._selectF(); 
		}
	};	
	
	this.Validate = function()
	{		
		if(this._validateF != null)
		{
			if(!this._validateF())
			{				
				this.SetInvalid(); 				
				return false; 
			}
		}
		else //No validation passed in, resort to default validation
		{
			//If regular expression has been passed, validate with value set.
			if(this.ValidationRegExpression != null)
			{
				if(!this.ValidationRegExpression.test(this.GetValue()))
				{
					if(this.GetValue() != "" || this.Required)
					{
						this.SetInvalid();					
						return false; 
					}
				}
			}
		}		
				
		//Fall through case
		this.SetValid(); 
		return true; 		
	};
	
	this.SetValid = function()
	{
		if(this.ValidationError == true)
		{	
			var oldValue = this.GetValue(); 
			
			this.ValidationError = false; 
			
			$(this.GetFeedbackSpanId()).style.cssText = ""; 
			$(this.GetFeedbackSpanId() + "_errorText").innerHTML = ""; 
			$(this.GetFeedbackSpanId() + "_span1").title = ""; 
		}
		
	};
	
	this.SetInvalid = function()
	{
		if(this.ValidationError == true)
		{
			//Already in error state, no need to reset to invalid state
			return; 
		}
	
	    if($(this.GetFeedbackSpanId() + "_span1") == null) return; //Renders on it's own
		var oldValue = this.GetValue(); 
		this.ValidationError = true; 
		
		var title = ""; 
		var errorTxt = "<span>&nbsp;<b>!</b>&nbsp;&nbsp;</span>";
		
		if(this.ValidationErrorTxt != null)
		{
			if(this.ValidationErrorWriteOut)
			{
				errorTxt = "<span>&nbsp;<b>!</b>&nbsp;&nbsp;" + this.ValidationErrorTxt + "</span>";				
			}
			else
			{
				title = this.ValidationErrorTxt; 
			}
		}
		
		$(this.GetFeedbackSpanId() + "_span1").title = title; 
		$(this.GetFeedbackSpanId() + "_errorText").innerHTML = errorTxt; 
		$(this.GetFeedbackSpanId()).style.cssText = "border:solid 2px #E9D1C8"; 
	};
		
	this.GetFeedbackSpanId = function()
	{
		return this.GetRecordId() + "_feedback"; 
	};
	
	
	this.GetSelfReferenceString = function()
	{
		return "DataBridgeControl.Control" + this.GetRecordId(); 
	};
	
	//Create the ability to self reference
	eval("DataBridgeControl.Control" + this.GetRecordId() + " = this;"); 
}




//--- \ui\Drawing.js
function Drawing(){};

Drawing.MakeIntoGradientOverlay = function(container)
{
	//alert(container.outerHTML); 
}

Drawing.TransformToPhotoFrame = function(picObj)
{
	var fillColor = "#white"; 
	
	picObj.innerHTML = "<span style='padding:3px;'>" + 
	"<table cellpadding='0' cellspacing='0'>" + 
		"<tr>" + 
			"<td>" + 
			"</td>" + 
		"</tr>" + 
		"<tr>" + 
			"<td>" + 
				//"<div style='border:solid 1px #ececec;background-color:#efefef;padding-top:10px;padding-left:7px; padding-right:7px;padding-bottom:20px;'>" + 
					"<div>" + 
						picObj.innerHTML + 
					"</div>" + 
				//"</div>" + 
			"</td>" + 
		"</tr>" + 
		"<tr>" + 
			"<td>" + 
				//57 X 4
				"<table cellspacing='0' cellpadding='0'>" + 
					"<tr>" + 
						"<td width='57px' height= '4px'>" + 
							Drawing.GetSquareCornerShadow(false, true,"#000000", fillColor) + 
						"</td>" + 
						"<td style='width:100%'>" + 
							"<table height='100%' width='100%' cellspacing='0' cellpadding='0'>" + 
								"<tr><td height='1px'>" + Drawing.GetLine("#000000", "23") + "</td></tr>" + 
								"<tr><td height='1px'>" + Drawing.GetLine("#000000", "13") + "</td></tr>" + 
								"<tr><td height='1px'>" + Drawing.GetLine("#000000", "3") + "</td></tr>" + 
								"<tr><td height='1px'>" + Drawing.GetLine("#000000", "0") + "</td></tr>" + 
							"<td></td></tr></table>" + 
						"</td>" + 
						"<td width='57px;' height= '4px'>" + 
							Drawing.GetSquareCornerShadow(false, false,"#000000", fillColor) + 
						"</td>" + 
					"</tr>" + 
				"</table" + 
			"</td>" + 
		"</tr>" + 
	"</table></span>";	
}

Drawing.GetOpacityText = function(opacity)
{
	var mozOpacity = opacity * .01;
	return "filter: alpha(opacity=" + opacity + ");opacity: " + mozOpacity + ";-moz-opacity:" + mozOpacity + ";";
}
Drawing.TransformToFloatingContainer = function(div, fillColor, transparency, style)
{
	var divOldContents = div.innerHTML;
	var shadowColor = "#000000"; 
	
	var level1 = transparency - 80;
	var level2 = transparency - 65;
	var level3 = transparency - 60;
	var level4 = transparency - 40;
	
	div.outerHTML = "<div style='" + style + "'>" + 
	"<table cellpadding='0' cellspacing='0'>" + 
		"<tr>" + 
			"<td style='width:10px; height:10px'>" + 
				Drawing.GetCornerShadow(true, true,shadowColor, fillColor) + 
			"</td>" + 
			"<td>" + 
				"<table height='100%' width='100%' cellspacing='0' cellpadding='0'>" + 
					"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level1) + "</td></tr>" + 
					"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level2) + "</td></tr>" + 
					"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level3) + "</td></tr>" + 
					"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level4) + "</td></tr>" + 
					"<tr style='background-color:" + fillColor + ";height:6px;'><td></td></tr>" + 
					"</table>" + 
			"</td>" + 
			"<td width='10px'>" + 
				Drawing.GetCornerShadow(true, false,shadowColor, fillColor) + 
			"</td>" + 
		"</tr>" + 
		"<tr style='height:100%;'>" + 
			"<td width='10px'>" + 
				"<table height='100%' width='100%' cellspacing='0' cellpadding='0'><tr>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level1) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level2) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level3) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level4) + "</td>" + 
					"<td style='background-color:" + fillColor + ";width:5px'></td>" + 
				"</tr></table>" + 
			"</td>" + 
			"<td>" + 
				"<div style='" + style + ";background-color:" + fillColor + "'>" + 
					divOldContents + 
				"</div>" + 
			"</td>" + 
			"<td>" + 
				"<table height='100%' width='100%' cellspacing='0' cellpadding='0'><tr>" + 
					"<td style='background-color:" + fillColor + ";width:5px'></td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level4) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level3) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level2) + "</td>" + 
					"<td width='1px'>" + Drawing.GetLine(shadowColor, level1) + "</td>" + 
				"</tr></table>" + 
			"</td>" + 
		"</tr>" + 
		"<tr>" + 
			"<td width='10px;height:10px;'>" + 
				Drawing.GetCornerShadow(false, true,shadowColor, fillColor) + 
			"</td>" + 
			"<td>" + 
				"<table height='100%' width='100%' cellspacing='0' cellpadding='0'>" + 
				"<tr style='background-color:" + fillColor + ";height:6px;'><td></td></tr>" + 
				"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level4) + "</td></tr>" + 
				"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level3) + "</td></tr>" + 
				"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level2) + "</td></tr>" + 
				"<tr><td height='1px'>" + Drawing.GetLine(shadowColor, level1) + "</td></tr>" + 
				"<td></td></tr></table>" + 
			"</td>" + 
			"<td width='10px'>" + 
				Drawing.GetCornerShadow(false, false,shadowColor, fillColor) + 
			"</td>" + 
		"</tr>" + 
	"</table></div>";
}

Drawing.GetLine = function(color, opacity)
{
	return "<table cellspacing='0' cellpadding='0' style='height:100%;width:100%;background-color:" + color + ";" + Drawing.GetOpacityText(opacity) + "'><tr><td></td></tr></table>";
}

Drawing.FlipHorizontal = function(x, arraySize)
{
	return (arraySize - 1) - x;
}

Drawing.GetCornerShadow = function(top, left, baseColor, fillColor)
{
	var table = new MultiDimensionalArray(10,10); 
	
	var threeX 	= 3; 
	var fourX 	= 4; 
	var fiveX 	= 5; 
	var sixX 	= 6; 
	var sevenX 	= 7; 
	var eightX 	= 8; 
	var nineX 	= 9; 
	
	if(!left)
	{
		threeX 	= Drawing.FlipHorizontal(3, 10); 
		fourX 	= Drawing.FlipHorizontal(4, 10); 
		fiveX 	= Drawing.FlipHorizontal(5, 10); 
		sixX 		= Drawing.FlipHorizontal(6, 10); 
		sevenX 	= Drawing.FlipHorizontal(7, 10); 
		eightX 	= Drawing.FlipHorizontal(8, 10); 
		nineX 	= Drawing.FlipHorizontal(9, 10); 
	}
	
	var zeroY 	= 0; 
	var oneY 	= 1; 
	var twoY 	= 2; 
	var threeY 	= 3; 
	var fourY 	= 4; 
	var fiveY 	= 5; 
	var sixY 	= 6; 
	var sevenY 	= 7; 
	var eightY 	= 8; 
	var nineY 	= 9; 
	
	if(top)
	{
		zeroY 	= Drawing.FlipHorizontal(0, 10); 
		oneY 	= Drawing.FlipHorizontal(1, 10); 
		twoY 	= Drawing.FlipHorizontal(2, 10); 	
		threeY 	= Drawing.FlipHorizontal(3, 10); 
		fourY 	= Drawing.FlipHorizontal(4, 10); 
		fiveY 	= Drawing.FlipHorizontal(5, 10); 
		sixY 		= Drawing.FlipHorizontal(6, 10); 
		sevenY 	= Drawing.FlipHorizontal(7, 10); 
		eightY 	= Drawing.FlipHorizontal(8, 10); 
		nineY 	= Drawing.FlipHorizontal(9, 10); 
	}
	
	//Black
	table[zeroY][fourX] = {opacity:"80",color:baseColor};
	table[oneY][fourX] = {opacity:"60",color:baseColor};
	table[twoY][fiveX] = {opacity:"65",color:baseColor};
	table[threeY][fiveX] = {opacity:"90",color:baseColor};
	table[fourY][sixX] = {opacity:"60",color:baseColor};
	table[fiveY][sevenX] = {opacity:"80",color:baseColor};
	table[fiveY][eightX] = {opacity:"60",color:baseColor};
	table[sixY][nineX] = {opacity:"60",color:baseColor};
	
	//Grey
	table[zeroY][threeX] = {opacity:"10",color:baseColor};
	table[oneY][threeX] = {opacity:"10",color:baseColor};
	table[twoY][fourX] = {opacity:"10",color:baseColor};
	table[threeY][fourX] = {opacity:"10",color:baseColor};
	table[fourY][fiveX] = {opacity:"10",color:baseColor};
	table[fiveY][sixX] = {opacity:"10",color:baseColor};
	table[sixY][sevenX] = {opacity:"10",color:baseColor};
	table[sixY][eightX] = {opacity:"20",color:baseColor};

	table[zeroY][fiveX] = {opacity:"2",color:baseColor};
	table[oneY][fiveX] = {opacity:"7",color:baseColor};
	table[twoY][sixX] = {opacity:"3",color:baseColor};
	table[threeY][sixX] = {opacity:"20",color:baseColor};
	table[fourY][sevenX] = {opacity:"50",color:baseColor};
	table[fiveY][nineX] = {opacity:"30",color:baseColor};

	
	//10 X 10
	
	var returnVal = "<table cellspacing='0' cellpadding='0' style='width:10px;height:10px;'>";
	
	for(var y = 0; y < 10; y++)
	{
		returnVal += "<tr>";
		
		var theRestAreWhite = true; 
		if(!left)
		{
			theRestAreWhite = false; 
		}
		
		for(var x = 0; x < 10; x++)
		{			
			if(!top && !left && y > 5)
			{
				theRestAreWhite = true; 
			}		
			
			if(top && !left && y < 4)
			{
				theRestAreWhite = true; 
			}					
			
			if(table[y][x] == "")
			{
				if(theRestAreWhite)
				{				
					returnVal += "<td style='width:1px;height:1px;'></td>";	
				}
				else
				{
					returnVal += "<td style='background-color:" + fillColor + ";width:1px;height:1px;'></td>";		
				}
			}
			else
			{
				var fill = "<table cellpadding='0' cellspacing='0' style='" + Drawing.GetOpacityText(table[y][x].opacity) + "width:1px; height:1px;background-color:" + table[y][x].color + ";'><tr><td></td></tr></table>";
				theRestAreWhite = false; 
				
				if(!left)
				{
					theRestAreWhite = true; 
				}
				
				returnVal += "<td style='width:1px;height:1px;'>" + fill + "</td>";		
			}
			
		}	
		
		returnVal += "</tr>";		
	}
	
	returnVal += "</table>";
	return returnVal; 
	//return "<div style='background-color:green'>corner</div>";
}


Drawing.GetSquareCornerShadow = function(top, left, baseColor, fillColor)
{
	var table = new MultiDimensionalArray(4,58); 
	
	var oneX = 1; 
	var twoX = 2; 
	var threeX = 3; 
	var fourX = 4; 
	var fiveX = 5; 
	
	if(!left)
	{
		oneX = Drawing.FlipHorizontal(1, 58); 
		twoX = Drawing.FlipHorizontal(2, 58); 
		threeX = Drawing.FlipHorizontal(3, 58); 
		fourX = Drawing.FlipHorizontal(4, 58); 
		fiveX = Drawing.FlipHorizontal(5, 58); 
	}
	
	//Black
	table[0][oneX] = {opacity:"2",color:baseColor};
	table[1][oneX] = {opacity:"2",color:baseColor};
	table[2][oneX] = {opacity:"2",color:baseColor};
	table[3][oneX] = {opacity:"2",color:baseColor};

	table[0][twoX] = {opacity:"10",color:baseColor};
	table[1][twoX] = {opacity:"10",color:baseColor};
	table[2][twoX] = {opacity:"4",color:baseColor};
	table[3][twoX] = {opacity:"3",color:baseColor};
	
	table[0][threeX] = {opacity:"30",color:baseColor};
	table[1][threeX] = {opacity:"20",color:baseColor};
	table[2][threeX] = {opacity:"15",color:baseColor};
	table[3][threeX] = {opacity:"3",color:baseColor};

	table[0][fourX] = {opacity:"45",color:baseColor};
	table[1][fourX] = {opacity:"35",color:baseColor};
	table[2][fourX] = {opacity:"15",color:baseColor};
	table[3][fourX] = {opacity:"5",color:baseColor};

	table[0][fiveX] = {opacity:"50",color:baseColor};
	table[1][fiveX] = {opacity:"40",color:baseColor};
	table[2][fiveX] = {opacity:"20",color:baseColor};
	table[3][fiveX] = {opacity:"5",color:baseColor};

	var factor = 1; 
	var col1 = 50;
	var col2 = 40; 
	var col3 = 20; 
	var col4 = 5; 
	
	for(var i = 6; i < 58; i++)	
	{	
		var xPoint = i; 
		if(!left)
		{
			xPoint = Drawing.FlipHorizontal(i, 58);
		}
		
		if(i % 2 == 0)
		{
			factor++; 
			
			col1 = 50 - factor; 
			col2 = 40 - factor; 
			col3 = 20 - factor; 
			col4 = 5 - factor; 
			
			if(col3 < 3) col3 = 3; 
			if(col4 < 0) col4 = 0; 
		}
		
		table[0][xPoint] = {opacity:col1,color:baseColor};
		table[1][xPoint] = {opacity:col2,color:baseColor};
		table[2][xPoint] = {opacity:col3,color:baseColor};
		table[3][xPoint] = {opacity:col4,color:baseColor};
	}
	
	//document.write(col1 + " " + col2 + " " + col3 + " " + col4); 
	
	var returnVal = "<table cellspacing='0' cellpadding='0' width='58px' height='4px'>";
	
	for(var y = 0; y < 4; y++)
	{
		returnVal += "<tr>";
					
		for(var x = 0; x < 58; x++)
		{								
			if(table[y][x] == "")
			{
				returnVal += "<td width='1px' height='1px'></td>";	
			}
			else
			{
				var fill = "<table cellpadding='0' cellspacing='0' width='1px' height='1px' style='" + Drawing.GetOpacityText(table[y][x].opacity) + ";background-color:" + table[y][x].color + ";'><tr><td></td></tr></table>";				
				returnVal += "<td width='1px' height='1px'>" + fill + "</td>";		
			}
			
		}	
		
		returnVal += "</tr>";		
	}
	
	returnVal += "</table>";
	return returnVal; 
}

function MultiDimensionalArray(iRows,iCols) 
{ 
	var i; 
	var j; 
   var a = new Array(iRows); 
   for (i=0; i < iRows; i++) 
   { 
       a[i] = new Array(iCols); 
       for (j=0; j < iCols; j++) 
       { 
           a[i][j] = ""; 
       } 
   } 
   return(a); 
}

Drawing.SetTopShade = function(color, height, ontop, startingOpacity, container)
{
	var span = document.createElement("span");
	var heightFactor = 100 / height; 
	var zIndex = "-1";
	
	if(ontop)
	{
		zIndex = "10";
	}
	
	var html = '' + 
	'<table style="top:0px;position:absolute; z-index:' + zIndex + ';width:100%;" cellpadding="0" cellspacing="0">' +  
	'<tr>' + 
		'<td>'; 
	
	if(container != null)
	{
		html = '' + 
		'<table style="top:' + container.offsetTop  + 'px;left:' + container.offsetLeft + 'px;position:absolute; z-index:' + zIndex + ';width:300px;" cellpadding="0" cellspacing="0">' +  
		'<tr>' + 
			'<td>'; 
	}
	
	var opacity = startingOpacity; 
	var rowHeight = "1";
	for(var i = 0; i < height; i++)
	{
		
		//if(i % 2 == 0)
		//{
			opacity -= (startingOpacity / height);// = opacity - i; 
		//}
		
		//rowHeight = "1";
		//if(opacity < 30)
		//{
			//rowHeight = "4";
		//}
		//else if(opacity < 20)
		//{
			//rowHeight = "6";
		//}
		//else if(opacity < 10)
		//{
			//rowHeight = "7";
		//}
		
			
		html += '	<table style="' + Drawing.GetOpacityText(opacity) + ';width:100%;height:' + rowHeight + 'px; background-color:' + color + ';" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; 
	}
	
	html +=	'</td>' + 
	'</tr>' + 
	'</table>';
	
	span.innerHTML = html; 
	document.body.appendChild(span);
}


//--- \ui\UIControls.js
//******************************************************************************
// Controls class
//******************************************************************************
function UIControls(){}

//******************************************************************************
// UIControls 
//******************************************************************************
/*
include_once("ui/State.Control.js"); 
include_once("ui/Text.Control.js"); 
include_once("ui/TextArea.Control.js"); 
include_once("ui/ZipCode.Control.js"); 
include_once("ui/Phone.Control.js"); 
include_once("ui/Email.Control.js"); 
include_once("ui/MaskedText.Control.js"); 
include_once("ui/DatePicker.Control.js"); 
include_once("ui/DayView.Control.js"); 
include_once("ui/RadioGroup.Control.js"); 
include_once("ui/CheckBox.Control.js"); 
include_once("ui/ComboBox.Control.js"); 
*/

UIControls.GetControlFromDataBridgeObj = function(dataBridgeControl, container, viewOnly, val)
{
	var thisControl = ""; 
	if(viewOnly == null) viewOnly = false; 

	if(viewOnly)
	{
		thisControl = "<b>" + dataBridgeControl.DisplayName + ": </b> " + val;
		switch(dataBridgeControl.DataType)
		{
			case "DoublePassword":
			case "Password":
			{
				return ""; 
				break; 
			}			
		}
	}
	else
	{
		thisControl = UIControls.GetControlFromDataBridgeObjAux(dataBridgeControl, container); 
	}
	
	return thisControl; 	
};

UIControls.GetControlFromDataBridgeObjAux = function(dataBridgeControl, container)
{
	var thisControl = null; 
	
	if(dataBridgeControl.Editable  && dataBridgeControl.DataTypeHigh == null)
	{
		switch(dataBridgeControl.DataType)
		{
			case "NestedDataBridgeObject":
			{
				return null; 
				break; 
			}
			case "Date":
			{
				thisControl = new UIControls.DatePicker(dataBridgeControl.Name, container); 
				break; 
			}
			case "Checkbox":
			{
				var thisControl = new UIControls.CheckBox(dataBridgeControl.Name, container); 
				break; 
			}
			case "Email":
			{
				var thisControl = new UIControls.EmailControl(dataBridgeControl.Name, container); 
				break; 
			}
			case "PhoneNumber":
			{
				var thisControl = new UIControls.PhoneControl(dataBridgeControl.Name, container); 
				break; 
			}			
			case "ZipCode":
			{
				var thisControl = new UIControls.ZipCodeControl(dataBridgeControl.Name, container); 
				break; 
			}
			case "State":
			{
				var thisControl = new UIControls.StateControl(dataBridgeControl.Name, container); 
				break; 
			}			
			case "ID":
			case "ShortText":
			{
				var thisControl = new UIControls.TextControl(dataBridgeControl.Name, container, null, dataBridgeControl.MaxLength, dataBridgeControl.Style); 
				break; 
			}
			case "Password":
			{
				var thisControl = new UIControls.PasswordControl(dataBridgeControl.Name, container, null, null, dataBridgeControl.MaxLength, dataBridgeControl.Style); 
				break; 
			}			
			case "DoublePassword":
			{
				var thisControl = new UIControls.PasswordControl(dataBridgeControl.Name, container, true, null, dataBridgeControl.MaxLength, dataBridgeControl.Style); 
				break; 
			}			
			case "LongText":
			{
				var thisControl = new UIControls.TextArea(dataBridgeControl.Name, container); 
				break; 
			}			
			case "RichText":
			{
				var thisControl = new UIControls.RichTextEdit(dataBridgeControl.Name, container, "300", "600"); 
				break; 
			}					
			case "Label":
			{
				var thisControl = new UIControls.Label(dataBridgeControl.Name, container, dataBridgeControl.DisplayName); 
				break; 
			}
			case "DisplayValue":
			{
				var thisControl = new UIControls.DisplayValue(dataBridgeControl.Name, container, dataBridgeControl.DisplayName); 
				break; 
			}
			case "Image":
			{
				var thisControl = new UIControls.ImageUpload(dataBridgeControl.Name, container, dataBridgeControl.DisplayName); 
				break; 
			}			
			case "File":
			{
				var thisControl = new UIControls.FileUpload(dataBridgeControl.Name, container, dataBridgeControl.DisplayName); 
				break; 
			}			
			case "ComboBox":
			{
				var thisControl = new UIControls.ComboBox(dataBridgeControl.Name, container); 
				for(var i = 0; i < dataBridgeControl.ObjectList.toArray().length; i++)
				{
					thisControl.AddOption(dataBridgeControl.ObjectList[i].Value, dataBridgeControl.ObjectList[i].Key); 
				}
				
				break; 
			}			
		}
		
		if(thisControl != null)
		{
			//All of this information should come from the server.
			thisControl.Label = dataBridgeControl.DisplayName; 		
			thisControl.Required = dataBridgeControl.Required; 		

			if(dataBridgeControl.JavascriptValidationFunction != null && dataBridgeControl.JavascriptValidationFunction != "")
			{
				eval("thisControl._validateF = " + dataBridgeControl.JavascriptValidationFunction);
				thisControl.ValidationErrorTxt = dataBridgeControl.ValidationErrorText; 
				thisControl.ValidationErrorWriteOut = dataBridgeControl.WriteValidationError;				
			}
		}
	}	
	
	return thisControl;
};


//--- \ui\UIControls.High.js
/**************************************************************
//HTML Masked text control
/**************************************************************/
function UIControls_High(){};
/*include_once("ui/Address.Control.js"); */

function GetLabel(string)
{
	var textObj = document.createElement("span");
	textObj.innerHTML = string; 

	return textObj; 
}

UIControls_High.GetControlFromDataBridgeObj = function(dataBridgeControl, container, viewOnly, editArray, startIndex)
{
	var thisControl = null; 
	if(dataBridgeControl.Editable)
	{
		switch(dataBridgeControl.DataTypeHigh)
		{
			case "Contact":
			{
				if(viewOnly)
				{	
					thisControl = ""; 					
					thisControl += "<b>Phone:</b> " + editArray[startIndex];
					thisControl += "<br /><b>Email:</b> " + editArray[++startIndex];
					thisControl += "<br /><b>Address1:</b> " + editArray[++startIndex];
					thisControl += "<br /><b>Address2:</b> " + editArray[++startIndex];
					thisControl += "<br /><b>City:</b> " + editArray[++startIndex];
					thisControl += "<br /><b>State:</b> " + editArray[++startIndex];
					thisControl += "<br /><b>Zip:</b> " + editArray[++startIndex];
					//this.GetDataSet().Email.SetValue(array[startValue + 1]);
					//this.GetDataSet().Address.SetValueFromDataRow(array, startValue + 2); 				
				}
				else
				{
					thisControl = new UIControls_High.Contact(dataBridgeControl.DataTypeHigh, container);
				}
				break; 
			}
		}
		
		//All of this information should come from the server.
		thisControl.Label = dataBridgeControl.DisplayName; 		
	}
	
	return thisControl; 	
};


//--- \ui\controls.js
//******************************************************************************
// Controls class
//******************************************************************************
function Controls()
{
}

//******************************************************************************
// Properties
//******************************************************************************

//******************************************************************************
// Controls 
//******************************************************************************
Controls.text = function(id, maxLength, prms)
{
	if (maxLength == null || maxLength == -1 || maxLength == "-1")
	{
		maxLength = 50; // Just some default
	}
	
	return "<input type='text' id='" + id + "' maxlength='" + maxLength + "' " + Controls.addParams(prms) + " KeyPressPlaceHolder='' />";
}

Controls.file = function(id, style)
{
	return "<input type='file' id='" + id + "' name='" + name + "' style='" + style + "'/>";
}

Controls.password = function(id, maxLength, prms)
{
	if (maxLength == null)
	{
		maxLength = 50; // Just some default
	}
	
	return "<input type='password' id='" + id + "' maxlength='" + maxLength + "' " + Controls.addParams(prms) + " KeyPressPlaceHolder=''/>";
}

Controls.textarea = function(id, rows, cols, prms, maxLength)
{
	if (rows == null)
	{
		rows = 10; // Just some default
	}
	
	if (cols == null)
	{
		cols = 50; // Just some default
	}
	
	if (maxLength == null)
	{
		maxLength = ""; // Just some default
	}
	else 
	{
		maxLength = "onkeypress='return (this.value.length < " + maxLength + ");' ";
	}
	
	return "<textarea " + maxLength + "id='" + id + "' rows='" + rows + "' cols='" + cols + "' " + Controls.addParams(prms) + " ></textarea>";
}

Controls.hidden = function(id)
{
	return "<input type='hidden' id='" + id + "' />";
}

Controls.label = function(forId, text, prms, id)
{
	if (id != null)
	{
		return "<label  onmouseover=\"this.style.cursor='pointer';\" id='" + id + "' for='" + forId + "' " + Controls.addParams(prms) + ">" + text + "<label>";
	}

	return "<label  onmouseover=\"this.style.cursor='pointer';\" for='" + forId + "' " + Controls.addParams(prms) + ">" + text + "<label>";
}

Controls.button = function(id, text, prms)
{
	return "<input type='button' id='" + id + "' value='" + text + "' " + Controls.addParams(prms) + " />";
}

Controls.radio = function(id, group, text, value, prms)
{
	return "<input type='radio' id='" + id + "' name='" + group + "' " + Controls.addParams(prms) + " value='" + value + "' />" + Controls.label(id, text, null, "label_" + id);
}

Controls.check = function(id, group, text, prms)
{
	return "<input type='checkbox' id='" + id + "' name='" + group + "' " + Controls.addParams(prms) + " />" + Controls.label(id, text, null, "label_" + id);
}

Controls.imageButton = function(id, text, onImage, offImage, prms)
{
	var mouseOver = "onmouseover='Controls.toggleImg(\"" + id + "\")'";
	var mouseOut = "onmouseout='Controls.toggleImg(\"" + id + "\")'";
	var mouse = mouseOver + " " + mouseOut;
	var top = "<table><tr><td align='center'>"
		+ "<img id='imgBtn" + id + "' style='cursor:pointer' " + this.addParams(prms) + " src='/flooring/img/" + offImage + "' otherImg='/flooring/img/" + onImage + "' border='0' " + mouse + " />"
		+ "</td></tr>";
	
	if (text != null && text.length > 0)
	{
		top = top + "<tr><td align='center'><a href='#' " + this.addParams(prms) + " " + mouse + " >" 
			+ Controls.label("", text) + "</a></td></tr>"
	}
	
	return top + "</table>";
}

Controls.imageViewer = function(id, width, height, src, prms)
{
	return "<img id='" + id + "' src='" + src + "' width=" + width + "px" + " height=" + height + "px" + this.addParams(prms) + " src=''/>"
}

Controls.dropDown = function(id, options, prms)
{
	var s = "<select id='" + id + "' " + this.addParams(prms) + " >";
	
	if (options != null)
	{
		for (i = 0; i < options.length; i++)
		{
			s = s + options[i];
		}	
	}
	
	s = s + "</select>";
	
	return s;
}

Controls.option = function(text, value, isSelected)
{
	var s = "<option value='";
	if (value == null)
	{
		s = s + text;
	}
	else 
	{
		s = s + value;
	}
	
	s = s + "' ";
	
	if (isSelected)
	{
		s = s + "SELECTED ";
	}
	s = s + ">" + text + "</option>";
	
	return s;
}

Controls.date = function(id,prms)
{
	var months = new Array();
	months[months.length] = this.option("");
	months[months.length] = this.option("Jan");
	months[months.length] = this.option("Feb");
	months[months.length] = this.option("Mar");
	months[months.length] = this.option("Apr");
	months[months.length] = this.option("May");
	months[months.length] = this.option("Jun");
	months[months.length] = this.option("Jul");
	months[months.length] = this.option("Aug");
	months[months.length] = this.option("Sep");
	months[months.length] = this.option("Oct");
	months[months.length] = this.option("Nov");
	months[months.length] = this.option("Dec");
	
	var i = 0;
	var days = new Array();
	days[days.length] = this.option("");
	for (i = 1; i <= 31; i++)
	{
		days[days.length] = this.option(i, i);
	}
	
	var years = new Array();
	years[years.length] = this.option("");
	for (i = new Date().getYear(); i >= 1900; i--)
	{
		years[years.length] = this.option(i);
	}

	var myPrms = {};
	if (prms !== null)
	{
		myPrms = prms;
	}
	myPrms.onchange = "Controls.dateChanged(\"" + id + "\")";

	var s = "<div id='" + id + "' >"
		+ this.dropDown(id + "_m", months, myPrms)
		+ this.dropDown(id + "_d", days, myPrms)
		+ this.dropDown(id + "_y", years, myPrms)
		+ "</div>";
	return s;
}

Controls.state = function(id, prms, minWidth)
{
	if(minWidth == null || minWidth != true)
	{
		prms = Controls.setDefaultWidth(prms);
	}
	var s = "<select id='" + id + "' " + this.addParams(prms) + ">";
	s = s + Controls.option("");
	s = s + "<optgroup label='US'>";
	s = s + Controls.option("AK");
	s = s + Controls.option("AL");
	s = s + Controls.option("AR");
	s = s + Controls.option("AZ");
	s = s + Controls.option("CA");
	s = s + Controls.option("CO");
	s = s + Controls.option("CT");
	s = s + Controls.option("DC");
	s = s + Controls.option("DE");
	s = s + Controls.option("FL");
	s = s + Controls.option("GA");
	s = s + Controls.option("HI");
	s = s + Controls.option("IA");
	s = s + Controls.option("ID");
	s = s + Controls.option("IL");
	s = s + Controls.option("IN");
	s = s + Controls.option("KS");
	s = s + Controls.option("KY");
	s = s + Controls.option("LA");
	s = s + Controls.option("MA");
	s = s + Controls.option("MD");
	s = s + Controls.option("ME");
	s = s + Controls.option("MI");
	s = s + Controls.option("MN");
	s = s + Controls.option("MO");
	s = s + Controls.option("MS");
	s = s + Controls.option("MT");
	s = s + Controls.option("NC");
	s = s + Controls.option("ND");
	s = s + Controls.option("NE");
	s = s + Controls.option("NH");
	s = s + Controls.option("NJ");
	s = s + Controls.option("NM");
	s = s + Controls.option("NV");
	s = s + Controls.option("NY");
	s = s + Controls.option("OH");
	s = s + Controls.option("OK");
	s = s + Controls.option("OR");
	s = s + Controls.option("PA");
	s = s + Controls.option("PR");
	s = s + Controls.option("RI");
	s = s + Controls.option("SC");
	s = s + Controls.option("SD");
	s = s + Controls.option("TN");
	s = s + Controls.option("TX");
	s = s + Controls.option("UT");
	s = s + Controls.option("VA");
	s = s + Controls.option("VI");
	s = s + Controls.option("VT");
	s = s + Controls.option("WA");
	s = s + Controls.option("WI");
	s = s + Controls.option("WV");
	s = s + Controls.option("WY");
	s = s + "</optgroup><optgroup label='Canada'>";
	s = s + Controls.option("AB");
	s = s + Controls.option("BC");
	s = s + Controls.option("MB");
	s = s + Controls.option("NB");
	s = s + Controls.option("NF");
	s = s + Controls.option("NS");
	s = s + Controls.option("NT");
	s = s + Controls.option("NU");
	s = s + Controls.option("ON");
	s = s + Controls.option("PE");
	s = s + Controls.option("QC");
	s = s + Controls.option("SK");
	s = s + Controls.option("YT");
	s = s + "</optgroup>";
	
	return s;
}

Controls.smartField = function(id, options, prms)
{
	var btn = Controls.button(id, "Find", prms);
	prms = Controls.setDefaultWidth(prms);	
	var fld = Controls.dropDown(id, options, prms);
	
	return fld + btn;
}

Controls.link = function(id, text, script)
{
	if (script)
	{
		return "<a id='" + id + "' href=\"javascript: " + script +"\" >" + text + "</a>";
	}
		return "<a id='" + id + "' href='#' >" + text + "</a>";
}

Controls.space = function()
{
	return "&nbsp;&nbsp;";
}


Controls.card = function(title)
{
	if(arguments.length < 2)
	{
		var card = new Table(2,1);
		//card.row(0).className = "title";
		card.cell(0,0).className = "title";
		card.cell(0,0).innerHTML = title;
		//card.row(1).className = "content";
		card.cell(1,0).className = "content";
	}
	else 
	{
		var card = new Table(3,1);
		card.cell(0,0).className = "title";
		card.cell(0,0).innerHTML = title;
		card.cell(1,0).className = "content";
		card.cell(2,0).className = "cardfooter";
		for(var n = 1; n < arguments.length; n++)
		{
			card.cell(2,0).innerHTML += arguments[n];
		}
	}
	card.table.className = "card";
		
	return card;
};

//******************************************************************************
// Utility Methods
//******************************************************************************
Controls.toggleImg = function(id)
{
	var img = $("imgBtn" + id);
	var temp = img.src;
	img.src = img.getAttribute("otherImg");	
	img.setAttribute("otherImg",temp);
}

Controls.addParams = function(prms)
{
	var addedMask = false;
	var s = "";
	if (prms != null)
	{
		if (prms.onclick)
		{
			s = s + " onclick='" + prms.onclick + "' ";
		}
		if (prms.onchange)
		{
			s = s + " onchange='" + prms.onchange + "' ";
		}
		if (prms.onkeyup)
		{
			s = s + " onkeyup='" + prms.onkeyup + "' ";
		}
		if (prms.style)
		{
			s = s + " style='" + prms.style + "' ";
		}
		if (prms.tabIndex)
		{
			s = s + " tabIndex='" + prms.tabIndex + "' ";
		}
		if (prms.mask)
		{
			s = s + " onkeydown='return " + prms.mask + "(event);' ";
			addedMask = true;
		}
	}
	
	if (!addedMask)
	{
		// Lets add a default mask to all fields...
		//s = s + " onkeydown='return Mask.FreeText(event);' ";
	}
	
	s = s + " OnBlur=''";
	return s;
}

Controls.setTabIndex = function(index,prms)
{
	if (prms == null)
	{
		prms = {"tabIndex": index};
	}
	else 
	{	
		prms.tabIndex = index;
	}
	
	return prms;	
}

Controls.setDefaultWidth = function(prms)
{
	if (prms == null)
	{
		prms = {"style": "width: 122px;"};
	}
	else if (prms.style == null)
	{
		prms.style = "width: 122px;";
	}
	else 
	{
		prms.style = prms.style + "; width: 122px;";
	}
	
	return prms;	
}

Controls.loadDropDown = function(id, options, selected)
{
	var dd = $(id);
	dd.innerHTML = "";

	for (i = 0; i < options.length; i++)
	{
		var opt = document.createElement("option");
		if (options[i].value == null)
		{
			opt.value = options[i];
			opt.innerHTML = options[i];
		}
		else 
		{
			opt.value = options[i].value;
			opt.innerHTML = options[i].text;
		}
		if (opt.value == selected)
		{
			opt.selected = true;
		}
		dd.appendChild(opt);
	}
}

Controls.setFocus = function(id, prms)
{
	if (prms == null)
	{
		prms = {"onclick": "$(\"" + id + "\").focus()"};
	}
	else if (prms.onclick == null)
	{
		prms.onclick = "$(\"" + id + "\").focus()";
	}
	else 
	{
		prms.onclick = prms.onclick + "; $(\"" + id + "\").focus()";
	}
	return prms;
}

Controls.enable = function(id, enable, prms)
{
	if (prms == null)
	{
		prms = {"onclick": "$(\"" + id + "\").disabled = " + !enable + ""};
	}
	else if (prms.onclick == null)
	{
		prms.onclick = "$(\"" + id + "\").disabled = " + !enable + "";
	}
	else 
	{
		prms.onclick = prms.onclick + "$(\"" + id + "\").disabled = " + enable + "";
	}
	return prms;
}

Controls.enableDisable = function(id1, id2, prms)
{
	if (prms == null)
	{
		prms = {"onclick": "$(\"" + id1 + "\").disabled = false; $(\"" + id2 + "\").disabled = true;"};
	}
	else if (prms.onclick == null)
	{
		prms.onclick = "$(\"" + id1 + "\").disabled = false; $(\"" + id2 + "\").disabled = true;";
	}
	else 
	{
		prms.onclick = prms.onclick + "; $(\"" + id1 + "\").disabled = false; $(\"" + id2 + "\").disabled = true;";
	}
	return prms;
}

Controls.enableDate = function(id, enable)
{
	$(id + "_m").disabled = !enable;
	$(id + "_d").disabled = !enable;
	$(id + "_y").disabled = !enable;
}

Controls.setDate = function(id, dStr)
{
	if (dStr == "1/1/1901" || dStr == "1/1/0001")
	{
		return;
	}

	var date = new Date(dStr);
	var m = date.getMonth();
	var d = date.getDate();
	var y = date.getFullYear();
	
	var dummy = new Date("1/1/2006");
	if (dummy.getDate() == 0)
	{
		d++;
	}
	
	$(id + "_m").selectedIndex = m+1;
	$(id + "_d").value = d;
	Controls.selectOption(id + "_y", y.toString());
	
	Controls.dateChanged(id);
}

Controls.getDate = function(id)
{
	try {
		var m = $(id + "_m").selectedIndex;
		var d = $(id + "_d").selectedIndex;
		var y = $F(id + "_y");
		
		if (m == 0 || d == 0 || y == "")
		{
			return "1/1/1901";
		}
		
		return m + "/" + d + "/" + y;
	}
	catch (e)
	{
	}
	
	return "";
}

Controls.dateChanged = function(id)
{
	var m = $(id + "_m").selectedIndex;
	var d = $(id + "_d").value;
	
	if (m == 0)
	{
		$(id+"_d").selectedIndex = 0;
		$(id+"_y").selectedIndex = 0;
		return;
	}
	
	var maxD = -1;
	switch (m)
	{
		case 2:
			var y = $F(id + "_y");
			var isLeapYear = (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0));
			if (isLeapYear)
			{
				maxD = 29;
			}
			else 
			{
				maxD = 28;
			}		
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			maxD = 30;
			break;
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			maxD = 31;
			break;
	}

	if (d > maxD)
	{
		d = 1;
	}
	
	$(id+"_d").length = 0;
	$(id+"_d")[0] = new Option("", "");
	var i;
	for (i = 1; i <= maxD; i++)
	{
		$(id+"_d")[$(id+"_d").length] = new Option(i,i);
	}
	$(id+"_d").value = d;

	if ($F(id+"_y") == "")
	{
		$(id+"_y").value = (new Date()).getFullYear();
	}
}

Controls.selectOption = function(id, valSelect)
{
	select = $(id);
	for (var n=0; n < select.options.length; n++)
	{
		if(select.options[n].value.toLowerCase() == valSelect.toLowerCase())
		{
			select.selectedIndex = n;
			return;
		}
	}
}

Controls.makeUpper = function(id)
{
	$(id).className = "uppercase";
	Event.observe(id, "blur", function() {$(id).value = $F(id).toUpperCase();}, false);
}

Controls.MenuItem = function(text, action, selected, selectedTabClass, unSelectedTabClass)
{
	if(selected)
	{
		return '' + 
		'<div class="SelectedTabContainer" onclick="' + action + ';">' + 
			'<table cellspacing="0" cellpadding="0">' + 
				'<tr>' + 
					'<td valign="top" class="TabMenuLeftSelected">' + 
						//'<img src="css/leftselected.png"/>' + 
					'</td>' + 
					'<td valign="top">' + 
						'<div class="' + selectedTabClass + '">' + text + '</div>' + 
					'</td>' + 
					'<td valign="top"  class="TabMenuRightSelected">' + 
						//'<img src="css/rightselected.png"/>' + 
					'</td>' + 
				'</tr>' + 
			'</table>' + 
		'</div>';	
	}
	else
	{
		return '' + 
		'<div class="' + unSelectedTabClass + '" onclick="' + action + ';">' + 
			text + 
		'</div>';
	}
};


//--- \ui\table.js
//******************************************************************************
// Table class
//******************************************************************************
Table = function (rows,cols) {
	this.init(rows,cols);
}

Table.prototype = {
	//**************************************************************************
	// Table properties
	//**************************************************************************
	table: null,

	//**************************************************************************
	// Table methods
	//**************************************************************************
	init: function(rows, cols) {
		this.table = document.createElement("table");
		var tbody = document.createElement("tbody");
		this.table.appendChild(tbody);
		
		for (r = 0; r < rows; r++) {
			var row = document.createElement("tr");
			tbody.appendChild(row);
			
			for (c = 0; c < cols; c++) {
				var cell = document.createElement("td");
				row.appendChild(cell);
			}		
		}
	},

	row: function(row) {
		return this.table.firstChild.childNodes[row];
	},
	
	cell: function(row, col) {
		return this.table.firstChild.childNodes[row].childNodes[col];
	}
}




//--- \ui\ColumnMenu.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.ColumnMenu = function(id, container, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	
	var getValueF = function() 
	{
		return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 	
		var returnVal = ""; 
		var menuItems = ""; 
		if(defaultValue == null)
		{
			defaultValue = 0; 
		}
		
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{			
			menuItems += UIControls.GetColumnMenuItem(this.GetDataSet().Options[i].Key, this.GetDataSet().Options[i].Value);  
		}

		return  '<div style="width:100%;">' + menuItems + '</div>'; 
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
	returnObj.AddItem = function(key, value)
	{
		if(value == null) value = key; 
		this.GetDataSet().Options[this.GetDataSet().Options.length] = new KeyValue(key, value); 
	};
	
	returnObj.SelectMenuItem = function(indexValue)
	{
		this.Render(indexValue); 
		eval(this.GetDataSet().Options[indexValue].Value); 
	};
	
	returnObj.SelectedTabClass 		= "SelectedTab"; 
	returnObj.UnSelectedTabClass 	= "UnselectedTab"; 	
	
	return returnObj; 
};

UIControls.GetColumnMenuItem = function(key, value)
{
	if(value == "|")
	{
		return '<div class="ColumnMenuDivider">' + key + '</div>';		 
	}
	else if(value != "")
	{
		return '<div style="padding:3px;padding-left:10px;">&raquo; <a href="' + value + '">' + key + '</a></div>';
	}
	else
	{
		return key;
	}
};


//--- \ui\TabMenu.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.TabMenu = function(id, container, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	
	var getValueF = function() 
	{
		return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 			
		var returnVal = ""; 
		var menuItems = ""; 
		if(defaultValue == null)
		{
			defaultValue = 0; 
		}
		
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{			
			menuItems += Controls.MenuItem(this.GetDataSet().Options[i].Key,
							this.GetSelfReferenceString() + ".SelectMenuItem(" + i + ")", 
							i==defaultValue, this.SelectedTabClass, this.UnSelectedTabClass);
		}

		var loginInner = ""; 
		if(Globals.UserData == null)
		{
			loginInner = "<a href='javascript:GoToPage(Page.UserLogin);'>Sign In</a>"; 
		}
		else
		{
			loginInner = "<b style='padding-right:5px;'></b> <a href='javascript:GoToPage(Page.User,\"account\");'>" + 
			Globals.UserData.FirstName + 
			"'s Account</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href='javascript:GoToPage(Page.UserLogin,\"logout\");'>Logout</a>"; 
		}

		var login = ""; 
		if(!$("login"))
		{		
			login = "<div id='login'>" + loginInner + "</div>"; 
		}
		else
		{
			$("login").innerHTML = loginInner; 
		}
		
		return  '<div class="UnselectedTab" style="width:5px;"></div>' + menuItems + login; 
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
	returnObj.SelectedIndex = -1; 
	
	returnObj.AddItem = function(key, value)
	{
		if(value == null) value = key; 
		this.GetDataSet().Options[this.GetDataSet().Options.length] = new KeyValue(key, value); 
	};
	
	returnObj.SelectMenuItem = function(indexValue, noload)
	{
		this.SelectedIndex = indexValue; 
		this.Render(indexValue); 
		if(!noload)
		{
		    eval(this.GetDataSet().Options[indexValue].Value); 
        }
	};
	
	returnObj.SelectedTabClass 		= "SelectedTab"; 
	returnObj.UnSelectedTabClass 	= "UnselectedTab"; 	
	
	return returnObj; 
}


//--- \ui\State.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.StateControl = function(id, container)
{	
	var getValueF = function() 
	{
		return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		this.Render(valueToSet); 
		//$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var states = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"); 
		var htmlValue = ""; 
			
		for(var i = 0; i < states.length; i++)
		{
			if(defaultValue == states[i])
			{
				htmlValue += "<option selected>" + states[i] + "</option>";
			}
			else
			{
				htmlValue += "<option>" + states[i] + "</option>";
			}
		}
		
		var returnVal = "<select id='" + this._recordId + "' >" + htmlValue + "</select>";		
		return returnVal;
	};

	return new IDataControl(id, container, null	, null, getValueF, setValueF, renderF);
}


//--- \ui\Text.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.Text = function(id, container, prms)
{	
	var getValueF = function() 
	{
		return 	$F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = Controls.text(this._recordId, 45, this._prms);					
		returnVal = returnVal.replace("/>", " value='" + defaultValue + "' class='borderStyle'/>"); 

		return returnVal; 
	};

	return new IDataControl(id, container, prms, null, getValueF, setValueF, renderF);
}

/**************************************************************
//HTML Masked text control
/**************************************************************/
UIControls.TextControl = function(id, container, prms, maxlength, style)
{		
	if(maxlength == null) maxlength = 45; 
	var dataSet = null; 
	
	var getValueF = function() 
	{
		return 	$F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = Controls.text(this._recordId, maxlength, this._prms);					
		returnVal = returnVal.replace("/>","OnBlur='' value='" + defaultValue + "' style='" + dataObject._style + "' class='borderStyle'/>"); 

		return returnVal; 
	};
		
	dataObject = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);		
	dataObject._style = style; 
	return dataObject; 
}



//--- \ui\Password.Control.js
/**************************************************************
//HTML Masked text control
/**************************************************************/
UIControls.PasswordControl = function(id, container, doubleEntry, prms, maxlength, style)
{		
	if(maxlength == null) maxlength = 45; 
	var dataSet = null; 
	
	var getValueF = function(encrypted) 
	{
		//Always give back and RSA encrypted SHA1 hash of the password so it is never transmitted in plain text
		if(encrypted)
		{
			return Security.Sha1HashRSAEncrypt($F(this._recordId)); 
		}
		else
		{
			return $F(this._recordId); 
		}
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
		if(this.DoubleEntry)
		{
			$(this._password2Id).value = valueToSet; 
		}		
	};
	
	var renderF = function(defaultValue) 
	{ 
		var validateTxt = "onkeyup='" + this.GetSelfReferenceString() + ".SetValidate();'"; 
		if(!this.DoubleEntry)
		{
			validateTxt = "onblur='" + this.GetSelfReferenceString() + ".Validate();'"; 
		}
		
		var pass1 = Controls.password(this._recordId, maxlength, this._prms);					
		pass1 = pass1.replace("/>",validateTxt + " value='" + defaultValue + "' style='" + dataObject._style + "' onfocus='this.select();' class='borderStyle'/>"); 
		
		var pass2 = Controls.password(this._recordId + "2", maxlength, this._prms);					
		pass2 = pass2.replace("/>",validateTxt + " value='" + defaultValue + "' style='" + dataObject._style + "' onfocus='this.select();' class='borderStyle'/>"); 

		
		var returnVal = pass1; 
		if(this.DoubleEntry)
		{
			if(this.Required)
			{
				returnVal += "<br /><span class='error'>* </span><b>Repeat " + this.Label + "</b><br />" + pass2;  
			}
			else
			{
				returnVal += "<br />Repeat " + this.Label + "<br />" + pass2;  			
			}
			
			this._password2Id = this._recordId + "2"; 
		}
		
		this._password1Id = this._recordId; 
		
		return returnVal; 
	};
		
	dataObject = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);		
	dataObject.AlreadyValidating = false; 
	
	dataObject._style = style; 
	dataObject.ValidationErrorTxt = "Passwords must match.";
	dataObject.ValidationErrorWriteOut = true; 
	dataObject._validateF = function()
	{
		this.AlreadyValidating = false; 
		if(this.DoubleEntry && $F(this._password1Id) != $F(this._password2Id))
		{
			this.ValidationErrorTxt = "Passwords must match.";
			//Need to trick it into rewriting the error message.
			this.ValidationError = false; 
			return false; 		
		}
		
		if(this.GetValue().length < 6)
		{
			this.ValidationErrorTxt = "Password requires at least six characters.";
			//Need to trick it into rewriting the error message.
			this.ValidationError = false; 
			return false; 
		}
		
		return true; 
	};	
	dataObject.SetValidate = function()
	{
		if(!this.AlreadyValidating)
		{
			var evalString = this.GetSelfReferenceString() + ".Validate()";
			this.AlreadyValidating = true; 
			window.setTimeout("eval(" + evalString + ")", 500);
		}
	};
	
	dataObject.DoubleEntry = doubleEntry; 
	dataObject._getURIFormat = function()
	{
		return this._recordId + "=" + Globals.UrlEncode(this.GetValue(true)); 
	};

	return dataObject; 
}



//--- \ui\TextArea.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.TextArea = function(id, container, prms)
{	
	var getValueF = function() 
	{
		return 	$F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		//textarea = function(id, rows, cols, prms, maxLength)
		var returnVal = Controls.textarea(this._recordId, 5, 60, this._prms);					
		returnVal = returnVal.replace("/>", " value='" + defaultValue + "'/>"); 

		return returnVal; 
	};

	return new IDataControl(id, container, prms, null, getValueF, setValueF, renderF);
}


//--- \ui\ZipCode.Control.js
/**************************************************************
//HTML ZipCode control
/**************************************************************/
UIControls.ZipCodeControl = function(id, container)
{		
	var maskObj = new MaskData("nnnnn-nnnn");
	var uiControl = new UIControls.MaskedText(id, container, maskObj, {style: "width:74px;"});
	uiControl.ValidationErrorTxt = "The Zip code is not in the proper format.";
	uiControl.SetValidationRegExpression(/(^\d{5}-    $)|(^\d{5}-$)|(^\d{5}-\d{4}$)/);

	uiControl._validateF = function()
	{
		if(!this.ValidationRegExpression.test(this.GetValue()))
		{
			if(this.GetValue() == "" && this.Required)
			{
				this.SetInvalid();					
				return false; 
			}				
		}
		
		return true; 
	};

	return uiControl; 
}



//--- \ui\Phone.Control.js
/**************************************************************
//HTML Phone control
/**************************************************************/
UIControls.PhoneControl = function(id, container)
{		
	var maskObj = new MaskData("(nnn)nnn-nnnn");	
	var uiControl = new UIControls.MaskedText(id, container, maskObj);
	
	uiControl.SetValidationRegExpression(/^\(\d{3}\)\d{3}-\d{4}$/);
	uiControl.ValidationErrorTxt = "Phone number is not in the proper format.";
	
	return uiControl; 
}



//--- \ui\Number.Control.js
/**************************************************************
//HTML Phone control
/**************************************************************/
UIControls.Number = function(id, container)
{		
	var maskObj = new MaskData("nnnnnnnnnn");	
	var uiControl = new UIControls.MaskedText(id, container, maskObj);
	
	uiControl.ValidationErrorTxt = "Must be a valid number.";	
	return uiControl; 
}



//--- \ui\Email.Control.js
/**************************************************************
//HTML Email control
/**************************************************************/
UIControls.EmailControl = function(id, container)
{		
	var uiControl = new UIControls.TextControl(id, container);
	
	uiControl.SetValidationRegExpression(/^\w+([\.-]?\w+)*@[A-Za-z0-9]+([\.-]?[A-Za-z0-9]+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/);
	uiControl.ValidationErrorTxt = "The Email is not in the proper format.";
	return uiControl; 
}



//--- \ui\MaskedText.Control.js
/**************************************************************
//HTML Masked text control
/**************************************************************/
UIControls.MaskedText = function(id, container, maskDataObj, prms)
{	
	var dataSet = function(){}; 
	dataSet.mask = "(nnn)nnn-nnnn";
	dataSet.maskDataObj = maskDataObj; 
	this._prms = prms; 
		
	var getValueF = function() 
	{
		return 	$F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = Controls.text(this._recordId, 45, this._prms);					
		returnVal = returnVal.replace("/>", this.GetDataSet().maskDataObj.GetParams() + " value='" + defaultValue + "' class='borderStyle'/>"); 

		return returnVal; 
	};
	
	dataObject = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
		
	return dataObject; 
}



//--- \ui\DatePicker.Control.js
var calPopupObj = null;

/**************************************************************
//HTML Date picker control
/**************************************************************/
UIControls.Calendars = function(){};
UIControls.DatePicker = function(id, container, date)
{		
	var calContainerId 		= id + "_container";	
	var calendarId 			= id + "_calendar";	
	var calTextContainerId 	= id + "_textContainer";	
	var calendarTextId 		= id + "_textCalendar";
	var calPopControlId		= id + "_calPopControl";
	var calLinkId			= id + "_calLinkId";
	var calTextId			= id + "_text"; 
	
	var popupControl		= document.createElement("div"); 
	var calPop 				= document.createElement("span");
	var calTextSpan 		= document.createElement("span");
	
	calPop.setAttribute("id", calContainerId);
	calTextSpan.setAttribute("id", calTextContainerId);
	
	popupControl.setAttribute("id", calPopControlId);
	
	popupControl.appendChild(calPop); 

	if($(calPopControlId) == null)
	{
		document.body.appendChild(popupControl); 
	}
	
	var calPic = "<a id=\"" + calLinkId + "\" href='javascript:void(null)' onclick='UIControls.Calendars." + 
	id + ".Show();'><div class=\"UIControl_CalendarImage\" onmouseover='this.style.cursor=\"pointer\";'></div></a>";	
	var vcalTextContainerIdHtml = "<span id='" + calTextContainerId + "'></span>";
	
	container.innerHTML = "" + 
		"<table cellspacing='0' cellpadding='3'><tr><td>" + 
		"<span id=\"" + id + "_feedback\">" + 
			"<span id=\"" + id + "_feedback_span1\">" + 
				"<div class='UIControl_CalendarBorder'>" + 
					"<table style='width:88px;' cellspacing='0' cellpadding='0'>" + 
						"<tr>" + 
							"<td width='75px;'>" + vcalTextContainerIdHtml + "<span style='padding-left:2px;width:100%;' id='" + calTextId + "'></span></td>" + 
							"<td style='padding-top:0px;padding-bottom:0px;width:1px;'>" + 
								calPic + 
							"</td>" + 
						"</tr>" + 
					"</table>" + 
				"</div>" + 
			"</span>" + 
		"</span>" + 
		"</td><td>" + 
		"<span style='color:#A75434;' id=\"" + id + "_feedback_errorText\"></span>" + 
		"</td></tr></table>" + 
		""; 	
	
	popupControl.className 	= "UIControl_CalendarPopup"; 
	
	var dataSet = function(){}; 
	if(calPopupObj == null)
	{
		calPopupObj = new YAHOO.widget.Calendar2up(calendarId, calContainerId, date);	
	}
		
	dataSet.calendar 	= calPopupObj; 
	dataSet.calText  	= calTextId;//null;//new UIControls.Text(calendarTextId, $(calTextContainerId), {"style":"background-color:#ffffff;border:solid 0px #ffffff; width: 70px;","enabled":"false"}); 
	dataSet.calTextId 	= calTextContainerId; 
	dataSet.calPopId	= calPopControlId; 
	dataSet.calLinkId	= calLinkId; 
	
	var getValueF = function() 
	{
		return $(this.GetDataSet().calText).innerHTML;//.GetValue(); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this.GetDataSet().calText).innerHTML = valueToSet;
		//this.GetDataSet().calText.SetValue(valueToSet); 
	};
	
	var renderF = function() 
	{ 				
		
		htmlText = this.Label + "<br />";

		this.GetDataSet().calendar.setChildFunction('onSelect', this.DateSelected ); 
		this.GetDataSet().calendar.render();
		this.GetDataSet().calendar.hide(); 
		//this.GetDataSet().calText.Render();				
		//this.GetDataSet().calText.Disable(); 
		
		var calPopControl = $(this.GetDataSet().calPopId); 				
		if(this.DisplayLabel && this.Label != null)
		{
			this._container.innerHTML = this.Label + "<br />" + this._container.innerHTML; 
		}
		
		return null; 
	};

	var returnObj = new IDataControl(id, container, null, dataSet, getValueF, setValueF, renderF);
	
	returnObj._disableF = function()
	{
		$(this.GetDataSet().calLinkId).className = "UIControl_CalendarImageDisabled"; 
		this._disabled = true; 
	};
	
	returnObj._enableF = function()
	{
		$(this.GetDataSet().calLinkId).className = "UIControl_CalendarImage"; 
		this._disabled = false; 
	};
	
	returnObj.Show = function()
	{
		if(!returnObj._disabled)
		{
			UIControls.Calendars.OpenCalObj = this;
			var cal = this.GetDataSet().calendar; 

			calPopupObj.outerContainer.style.display = 'block';			
			var pos = YAHOO.util.Dom.getXY($(this.GetDataSet().calTextId));
			YAHOO.util.Dom.setXY(calPopupObj.outerContainer, [pos[0] + 100,pos[1] + 10]);
		}
	}
	
	returnObj.DateSelected = function()	
	{
		var date = UIControls.Calendars.OpenCalObj.GetDataSet().calendar.getSelectedDates()[0]; 
		
		var formattedDate = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear(); 
		
		UIControls.Calendars.OpenCalObj.SetValue(formattedDate); 
		//UIControls.Calendars.OpenCalObj.GetDataSet().calText.SetValue(formattedDate); 
		UIControls.Calendars.OpenCalObj.GetDataSet().calendar.hide(); 
		UIControls.Calendars.OpenCalObj.Validate(); 
		UIControls.Calendars.OpenCalObj = null; 
	}
	
	returnObj._disabled = false; 
	
	eval("UIControls.Calendars." + id + " = returnObj;"); 

	return returnObj; 
}


//--- \ui\DayView.Control.js
// JScript File

var ClientDayView = new function()
{
    this._width                 = 350; 
    this._thisDay               = null; 
    this._scheduledResources    = new Array();
    this._currentAppointmentId  = null; 
    
    this.SetScheduledResources = SetScheduledResources__; 
    function SetScheduledResources__(scheduledResourcesDataTable, dateObj, selectedResources)
    {
        this._selectedResources = selectedResources; 
        this._thisDay = dateObj; 
        
        ClientDayView._scheduledResources = new Array();
        if(scheduledResourcesDataTable.ResourceList.Data == null) return; 

        var tmp = scheduledResourcesDataTable.ResourceList.Data.Rows; 
        for(var i = 0; i < tmp.length; i++)
        {
            if(Scheduled(dateObj, "day", tmp[i]))
            {
                ClientDayView._scheduledResources.push(tmp[i]); 
            }
        }        
    }
    
    this.CancelCurrentAppointment = CancelCurrentAppointment__; 
    function CancelCurrentAppointment__()
    {
        if(ClientDayView._currentAppointmentId != null)
        {
            var dataRow = ResourceDataTable.GetScheduledResourcesById(ClientDayView._currentAppointmentId); 
            var info = dataRow.Title + " - A00" + dataRow.Id; 
            if(confirm("Are you sure you want to cancel the appointment \"" + info + "\"?"))
            {
                ShowLoadingDialog("Canceling Appointment","Removing Appointment " + info + "..."); 
                ResourceDataTable.CancelScheduledResourcesById(ClientDayView._currentAppointmentId, ClientDayView.OnPostCancel); 
                ClientDayView._currentAppointmentId = null; 
            }         
        }
    }
    
    this.OnPostCancel = OnPostCancel__; 
    function OnPostCancel__()
    {
        LoadMonth(false);
        ResetScheduledResourceData();  
        SetDateRangeStartTime(); //Reset to add schedule form, not edit        
        //HideLoadingDialog();         
    }
    
    this.GetHTML = GetHTML__;     
    function GetHTML__()
    {
        var returnVal = "";         
        returnVal += GetAppointmentsHTML__();         
        returnVal += '<table cellpadding="0" cellspacing="0" border="0" style="width:' + ClientDayView._width + 'px; height:100%;">';
     
        for(var i = 0; i < 24; i++)
        {                  
            var hour = i; 
            var amPm = "AM";
            var onMouseClick1 = "SetSelectedDateTimeAux(" + hour + ",0);";
            var onMouseClick2 = "SetSelectedDateTimeAux(" + hour + ",30);";
                       
            if(hour == 0) 
            {
                hour = 12;             
            }
            
            if(hour > 12)
            {
                hour = hour - 12; 
            }
            
            if(i > 11)
            {
                amPm = "PM";
            }
            
            //Availability rules will be used here
            var bgColor = "FFF4BC";
            if(i > 7 && i < 17)
            {
                bgColor = "FFFFD5";
            }
                        
            returnVal += '<tr style="height: 20px;">';
            returnVal += '    <td width="40" rowspan="2" style="text-align: right;border-right: 1px solid #b4c2d6; border-bottom: 1px solid #b4c2d6; background-color: #d6e7fb; color:#495563; cursor: default;">';
            returnVal += '        <table cellspacing="0" cellpadding="0"><tr><td rowspan="2"><div style="padding-right: 2px;font-size: 16pt; ">' + hour + '</div></td><td style="border-bottom: 1px solid #b4c2d6; padding-bottom:2px; height:18px;font-size: 6pt"><span style="padding-right:2px">:00</span></td><tr style="height:17px;"><td style="padding-top:2px;font-size: 6pt"><span style="padding-right:2px">' + amPm + '</span></td></tr></table>';
            returnVal += '    </td>';
            returnVal += '    <td onmouseover="this.style.backgroundColor=\'#FFED95\';" onmouseout="this.style.backgroundColor=\'#' + bgColor + '\';" valign="bottom" style="background-color: #' + bgColor + '; cursor: pointer; cursor: hand;" onclick="' + onMouseClick1 + '">';
            returnVal += '        <div style="display: block; height: 1px; border-bottom: 1px solid #F3E4B1;">&nbsp;</div>';
            returnVal += '    </td>';
            returnVal += '</tr>';
            returnVal += '<tr style="height: 20px;">';
            returnVal += '    <td onmouseover="this.style.backgroundColor=\'#FFED95\';" onmouseout="this.style.backgroundColor=\'#' + bgColor + '\';"';
            returnVal += '        valign="bottom" style="background-color: #' + bgColor + '; cursor: pointer; cursor: hand;" onclick="' + onMouseClick2 + '">';
            returnVal += '            <div style="display: block; height: 1px; border-bottom: 1px solid #EAD098;">';
            returnVal += '            &nbsp;</div>';
            returnVal += '    </td>';
            returnVal += '</tr>';        
        }   
         
        returnVal += '</table>';
    
        return returnVal; 
    }
    
    function GetAppointmentsHTML__(thisDay)
    {
        return ""; 
        var returnVal = ""; 
        
        returnVal += '<div style="width: ' + ClientDayView._width + '; height: 0px;">';
        returnVal += '  <div style="position: relative; height: 0px; padding-top: 0px; margin-left: 42px; width: (100%); margin-right: 1px; border: 0px;">';
        
        var srGroups = new ScheduleGroupCollection(ClientDayView._scheduledResources, ClientDayView._selectedResources); 
        var list = srGroups.GetList(); 
        
        if(list.length == 0) return ""; 
        
        for(var i = 0; i < list.length; i++)
        {
            var timeItems = list[i].GetTimeItems(); 
            for(var iter2 = 0; iter2 < timeItems.length; iter2++)
            {
                if(IsSelected(timeItems[iter2], ClientDayView._selectedResources))
                {
                    var thisSr = timeItems[iter2]; 
                    returnVal += GetAppointmentDiv__(thisSr,list.length,i,thisSr.StartTime,thisSr.EndTime, ClientDayView._thisDay);                     
                }
            }
        }
               
        returnVal += '  </div>';
        returnVal += '</div>';
        
        return returnVal; 
    }
    
    function GetAppointmentDiv__(sr, columnNumber, columnPosition, startTime, endTime, thisDay)
    {
        var showDate = false; 
        if(!SameDay(startTime, endTime))//Spans multiple days, show date
        {
            showDate = true; 
        }
        
        var appointmentHeight = GetAppointmentHeight(startTime, endTime, thisDay); 
        
        var info = sr.Title + ' (' + FormatTimeFromDateObj(startTime, showDate) + ' - ' + FormatTimeFromDateObj(endTime, showDate) + ')';
        var returnVal = ""; 
            returnVal += '<div style="';
            returnVal += '                    -moz-user-select: none;';
            returnVal += '                    -khtml-user-select: none;'; 
            returnVal += '                    user-select: none; ';
            returnVal += '                    cursor: pointer;';
            returnVal += '                    cursor: hand; ';
            returnVal += '                    position: absolute; ';
            returnVal += '                    font-size: 8pt;';
            returnVal += '                    white-space: no-wrap;';
            returnVal += '                    left: ' + ((columnPosition * (100 / columnNumber)) + 2) + '%;'; 
            returnVal += '                    top: ' + GetAppointmentStartingPosition__(startTime, endTime, thisDay) + 'px;'; 
            returnVal += '                    width: ' + ((100 / columnNumber) - 2) + '%;'; 
            returnVal += '                    height: ' +  appointmentHeight + 'px;'; 
            returnVal += '                    background-color: gray;';
            returnVal += '            "';
            returnVal += '            onselectstart="return false;" onclick="event.cancelBubble=true;EditAppointment(\'' + sr.Id + '\');"';
            returnVal += '            onmouseover="this.firstChild.style.backgroundColor=\'#EFEFEF\';ClientDayView._currentAppointmentId=' + sr.Id + ';"';
            returnVal += '            onmouseout="this.firstChild.style.backgroundColor=\'white\';"';
            
            returnVal += '    >';
            returnVal += '  <div title="' + info + '" style="margin-top: 1px;';
            returnVal += '            display: block; height: ' + (appointmentHeight - 2)+ 'px; background-color: white; border-left: 1px solid black;';
            returnVal += '            border-right: 1px solid black; overflow: hidden;">';
            returnVal += '            <div style="float: left; width: 5px; height:100%; border-right: 1px solid black;">';
            
            var whiteHight = GetAppointmentBlueLinePaddingDivHeight(startTime, endTime, thisDay);             
            if(whiteHight != 0)
            {
                returnVal += '              <table cellspacing="0" cellpadding="0" style="width:100%; height:' + GetAppointmentBlueLineHeight(startTime, endTime, thisDay) + 'px; background-color:blue"><tr style="height:' + whiteHight + 'px; background-color:#fff"><td></td></tr><tr style="height:100%;"><td></td></tr></table>';
            }
            else
            {
                returnVal += '              <table cellspacing="0" cellpadding="0" style="width:100%; height:100%; background-color:blue"><tr><td></td></tr></table>';
            }
            
            returnVal += '            </div>';
            returnVal += '            <div style="float: left; width: 2px; height: 100%;">';
            returnVal += '            </div>';
            returnVal += '            <div style="padding: 2px;">' + info + '</div>';
            returnVal += '        </div>';
            returnVal += '    </div>    ';
            
            returnVal = ContextMenu.SetupMenu(returnVal,"appointment",["Cancel Appointment"],["ClientDayView.CancelCurrentAppointment();"])    
            
        return returnVal; 
    }
    
    var MINUTE_UNIT     = .666; 
    var HALF_HOUR_UNIT  = 20; 
    var HOUR_UNIT       = HALF_HOUR_UNIT * 2; 
    
    function GetAppointmentHeight(startTime, endTime, thisDay)
    {        
        returnVal = 0; 
        switch(GetAppointmentState(startTime, endTime, thisDay))
        {
            case "start_today":
            {
                returnVal = (24 - startTime.getHours()) * HOUR_UNIT;             
                break; 
            }
            case "end_today":
            {
                returnVal = endTime.getHours() * HOUR_UNIT; 
                break; 
            }
            case "all_day":
            {
                returnVal = 24 * HOUR_UNIT;             
                break; 
            }        
            case "sameday":
            {            
                var span = GetTimeSpanSameDay(startTime, endTime);        
                returnVal = HOUR_UNIT * span;             
                break; 
            }                        
        }
        
        if(endTime.getMinutes() > 30 && startTime.getMinutes() < 30)
        {
            returnVal += HOUR_UNIT; 
        }
        else if(endTime.getMinutes() > 30 && startTime.getMinutes() >= 30)
        {
            returnVal += HALF_HOUR_UNIT; 
        }
        else if(endTime.getMinutes() > 0 && startTime.getMinutes() <= 30)
        {
            returnVal += HALF_HOUR_UNIT; 
        }
        
        if(returnVal == 0)
        {
            returnVal = HALF_HOUR_UNIT; 
        }
        
        return returnVal;
    }
    
    function GetAppointmentBlueLineHeight(startTime, endTime, thisDay)
    {        
        returnVal = 0; 
        switch(GetAppointmentState(startTime, endTime, thisDay))
        {
            case "start_today":
            {
                returnVal = (24 - startTime.getHours()) * HOUR_UNIT;             
                break; 
            }
            case "end_today":
            {
                returnVal = endTime.getHours() * HOUR_UNIT; 
                break; 
            }
            case "all_day":
            {
                returnVal = 24 * HOUR_UNIT;             
                break; 
            }        
            case "sameday":
            {            
                var span = GetTimeSpanSameDay(startTime, endTime);        
                returnVal = HOUR_UNIT * span;             
                break; 
            }                        
        }
                
        
/*        if(endTime.getMinutes() > 30)
        {
            returnVal += parseInt(((endTime.getMinutes() - 30) * MINUTE_UNIT));    
        }
        else if(endTime.getMinutes() > 0)
        {
            returnVal += parseInt((endTime.getMinutes() * MINUTE_UNIT));    
        }
*/
        //if(endTime.getMinutes() > 30 && startTime.getMinutes() <= 30)
        //{
            //returnVal += parseInt(endTime.getMinutes() * MINUTE_UNIT); 
        //}
        //else if(endTime.getMinutes() > 30 && startTime.getMinutes() >= 30)
        //{
        //    returnVal += HALF_HOUR_UNIT + ; 
       // }
        if(endTime.getMinutes() > 0)
        {
            returnVal += parseInt(endTime.getMinutes() * MINUTE_UNIT); 
        }
                
        return returnVal;
    }
    
    function GetAppointmentBlueLinePaddingDivHeight(startTime, endTime, thisDay)
    {        
        returnVal = 0;              
                
        if(startTime.getMinutes() > 30)
        {
            returnVal += parseInt(((startTime.getMinutes() - 30) * MINUTE_UNIT));    
        }
        else if(startTime.getMinutes() == 30)
        {
            returnVal = 0; 
        }
        else if(startTime.getMinutes() > 0)
        {
            returnVal += parseInt((startTime.getMinutes() * MINUTE_UNIT));    
        }
        
        return returnVal;
    }    
        
    function GetAppointmentStartingPosition__(startTime, endTime, thisDay)
    {               
        var returnVal = 0; 
        switch(GetAppointmentState(startTime, endTime, thisDay))
        {
            case "sameday":
            case "start_today":
            {
                returnVal = HOUR_UNIT * startTime.getHours(); 
                break; 
            }
            case "end_today":
            case "all_day":
            {
                returnVal = 0; 
                break; 
            }        
        }           
        
        if(startTime.getMinutes() > 29)
        {
            returnVal += HALF_HOUR_UNIT; 
        }
        
        return returnVal; 
    }   
}


//--- \ui\RadioGroup.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.RadioGroup = function(id, container, prms)
{	
	__UIControls_RadioGroup_GroupIdCount++; 
	
	var dataSet = function(){}; 
	dataSet.Group = id + "_group" + __UIControls_RadioGroup_GroupIdCount; 
	dataSet.Options = new Array(); 
	
	var getValueF = function() 
	{
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{
			var thisRadio = $(this._recordId + "_" + i); 
			if(thisRadio.checked)
			{
				return thisRadio.value; 
			}
		}
	};
	
	var setValueF = function(valueToSet) 
	{ 
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{
			var thisRadio = $(this._recordId + "_" + i); 
			if(thisRadio.value == valueToSet)
			{
				thisRadio.checked = true;  
				return; 
			}
		}
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = ""; 
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{
			var tmp = Controls.radio(this._recordId + "_" + i, this.GetDataSet().Group, this.GetDataSet().Options[i].Key, this.GetDataSet().Options[i].Value, this._prms);					
			tmp = tmp.replace("/>", " value='" + defaultValue + "'/>"); 
			
			returnVal += tmp; 
		}

		return returnVal; 
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
	returnObj.AddOption = function(key, value)
	{
		if(value == null) value = key; 
		this.GetDataSet().Options[this.GetDataSet().Options.length] = new KeyValue(key, value); 
	};
	
	returnObj.Disable = function()
	{
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{
			var thisRadio = $(this._recordId + "_" + i); 
			thisRadio.disabled = true; 
		}
	};
	
	returnObj.Enable = function()
	{
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{
			var thisRadio = $(this._recordId + "_" + i); 
			thisRadio.disabled = false; 
		}
	};
	
	return returnObj; 
}

var __UIControls_RadioGroup_GroupIdCount = 0; 


//--- \ui\CheckBox.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.CheckBox = function(id, container, label, prms)
{		
	var getValueF = function() 
	{
		return $(this._recordId).checked; 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).checked = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = Controls.check(this._recordId, "", this.Label, this._prms);					
		returnVal = returnVal.replace("/>", " value='" + defaultValue + "'/>"); 

		return returnVal; 
	};

	var returnObj = new IDataControl(id, container, prms, null, getValueF, setValueF, renderF);	
	//returnObj.Label = label; 
	returnObj.DisplayLabel = false; 
	
	return returnObj; 
}


//--- \ui\ComboBox.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.ComboBox = function(id, container, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	
	var getValueF = function() 
	{
		return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = ""; 
		var options = new Array(); 
		for(var i = 0; i < this.GetDataSet().Options.length; i++)
		{			
			options[options.length] = Controls.option(this.GetDataSet().Options[i].Key, this.GetDataSet().Options[i].Value, defaultValue == this.GetDataSet().Options[i].Value);					
		}

		var returnVal = Controls.dropDown(this._recordId, options, this._prms);					
		returnVal = returnVal.replace("<select", "<select value='" + defaultValue + "' class='borderStyle'"); 
		
		return returnVal; 
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
	returnObj.AddOption = function(key, value)
	{
		if(value == null) value = key; 
		this.GetDataSet().Options[this.GetDataSet().Options.length] = new KeyValue(key, value); 
	};
	
	returnObj.GetDisplayValue = function()
	{
		return this.GetDataSet().Options[$(this._recordId).selectedIndex].Key;
	};
	
	return returnObj; 
}


//--- \ui\Grid.Control.js
/**************************************************************
//HTML Grid control
/**************************************************************/
UIControls.Grid = function(id, container, onrowclick, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	dataSet._onRowClick = onrowclick; 

	var getValueF = function() 
	{
	};
	
	var setValueF = function(valueToSet) 
	{ 
	};
	
	var renderF = function(defaultValue) 
	{ 	
		return CreateGridTable(this.ServerObject, this.GetSelfReferenceString(), defaultValue, this._recordId)
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);	
	returnObj.ServerObject 	= null; 
	
	returnObj.OnRowClick = function(id)
	{
		if(this.SelectedRowId)
		{
			$(this._recordId + "_row_" + this.SelectedRowId).style.backgroundColor = "#ffffff";		
		}
		
		this.SelectedRowId = id; 
		$(this._recordId + "_row_" + this.SelectedRowId).style.backgroundColor = "#cccccc";		
		
		if(this.GetDataSet()._onRowClick != null)
		{
			this.GetDataSet()._onRowClick(id); 
		}
	};
	
	returnObj.GetRowId = function(id)
	{
		return this._recordId + "_row_" + id; 
	};
	
	return returnObj; 
}


function CreateGridTable(serverObject, objReference, defaultValue, id)
{
	var rows = serverObject.DataRows; 
		
	//First column should always be unique identifier
	var returnString = "<table onmouseover='this.style.cursor=\"pointer\";' cellspacing='0' cellpadding='2' class='grid'><tr><td class='grid-heading'>&nbsp;</td>"; 		
	returnString += GetHeaderCells(serverObject.DataBridge); 
	
	returnString += "<td class='grid-heading2' width='100%'>&nbsp;</td></tr>";		
	
	var rowsLength = rows.length; 
	for(var i = 0; i < rowsLength; i++)	
	{	
		//Place unique id to be passed on row click
		returnString += "<tr id='" + id + "_row_" + i + "' onclick=\"" +  objReference + ".OnRowClick('" + i + "');\"><td class='grid-heading' style='padding-left:5px;padding-right:5px;'>" + (i + 1) + "</td>";
		var classVar = "grid-cell"; 
		if(defaultValue != -1 && defaultValue != "" && i == defaultValue)
		{
			classVar = "grid-cell-selected"; 
		}
		

		var dataObjectsLength = serverObject.DataBridge.DataObjects.length; 
		for(var j = 1; j < dataObjectsLength; j++)
		{				
			if(serverObject.DataBridge.DataObjects[j].DataType == "ComboBox")
			{
				returnString += GetDataCell(serverObject.DataBridge.DataObjects[j].ObjectList[rows[i][serverObject.DataBridge.DataObjects[j].ColumnIndex]].Value, serverObject.DataBridge.DataObjects[j], classVar);
				//alert(serverObject.DataBridge.DataObjects[j].ObjectList[rows[i][serverObject.DataBridge.DataObjects[j].ColumnIndex]].Value); 
				//alert(rows[i][serverObject.DataBridge.DataObjects[j].ColumnIndex]); 
				//passedValue = passedValue.truncate(100,"..."); 
				//valueTxt = "..."; 			
			}
			else
			{
				returnString += GetDataCell(rows[i][serverObject.DataBridge.DataObjects[j].ColumnIndex], serverObject.DataBridge.DataObjects[j], classVar);
			}
		}
		
		returnString += "<td class='" + classVar + "'>&nbsp;</td></tr>";		
	}
	
	returnString += "</table>";		
	return returnString; 
}

function GetDataCell(passedValue, dataBridgeObject, classVar)
{
	if(dataBridgeObject == null) return ""; 
	
	if(dataBridgeObject.GridVisible)
	{
		var valueTxt = passedValue; 
		if((dataBridgeObject.DataType == "LongText" || dataBridgeObject.DataType == "RichText") && passedValue != "")
		{
			passedValue = passedValue.truncate(100,"..."); 
			valueTxt = "..."; 
		}
		else if(dataBridgeObject.DataType == "NestedDataBridgeObject")
		{
			var returnCellTxt = ""; 			
			valueObj = passedValue.parseJSON();
			
			
			var dataObjectsLength = dataBridgeObject.DataBridgeObject.DataObjects.length; 
			for(var i = 0; i < dataObjectsLength; i++)
			{
				var thisValue = valueObj[dataBridgeObject.DataBridgeObject.DataObjects[i].Name]; 				
				if(thisValue == null) thisValue = ""; 				
				
				//Recursive call to get nested objects
				returnCellTxt += GetDataCell
					(
						thisValue, 
						dataBridgeObject.DataBridgeObject.DataObjects[i],
						classVar
					); 
			}
			
			return returnCellTxt; 
		}
		
		var returnVal =  "<td class='" + classVar + "' title='" + passedValue + "' NOWRAP>" + valueTxt + "&nbsp;</td>";	
		//var returnVal =  "<td class='" + classVar + "' title='" + passedValue.escapeHTML() + "' NOWRAP>" + valueTxt.escapeHTML() + "&nbsp;</td>";	
		return returnVal; 
	}
	
	return ""; 
}

function GetHeaderCells(dataBridgeObj)
{
	if(dataBridgeObj == null) return ""; 
	
	var returnString = ""; 
	for(var i = 0; i < dataBridgeObj.DataObjects.length; i++)
	{
		var classTxt = "class='grid-heading'"; 
		
		if(i == (dataBridgeObj.DataObjects.length - 1))
		{
			classTxt = "class='grid-heading'"; 
		}
		
		if(dataBridgeObj.DataObjects[i].GridVisible)
		{
			//Recursive call to get nested objects
			if(dataBridgeObj.DataObjects[i].DataType == "NestedDataBridgeObject")
			{
				returnString += GetHeaderCells(dataBridgeObj.DataObjects[i].DataBridgeObject); 
			}			
			else
			{			
				returnString += "<td " + classTxt + " NOWRAP>" + dataBridgeObj.DataObjects[i].DisplayName + "</td>";
			}
		}
	}
	
	return returnString; 
}


//--- \ui\DataList.Control.js
/**************************************************************
//HTML DataList control
/**************************************************************/
UIControls.DataList = function(id, container, onedit, onadd, ondelete, prms)
{	
	var dataSet = function(){}; 			
	dataSet._onadd 			= onadd; 
	dataSet._onedit 		= onedit; 
	dataSet._ondelete 		= ondelete; 
	
	var getValueF = function() 
	{
		//return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		//$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 	
		if(this.ServerObject == null)
		{
			return; 
		}
		
		var gridIdName = this._recordId + "gridDiv";
		
		$(this._container).innerHTML = "<table width='100%'><tr><td width='100%' valign='top'>" + 
		"<div class='datalist-grid' id='" +
		gridIdName + "'></div></td><td valign='top'>" + 
		this.GetToolButtons() + "</td></tr></table>";		
		var grid = new UIControls.Grid(this._recordId + "_grid",$(gridIdName), eval(this.GetSelfReferenceString() + ".RowSelected"));
		grid.ServerObject = this.ServerObject; 		
		grid.Render();	
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);		
	returnObj.SelectedRow = -1; 
	returnObj.ServerObject = null; 
	
	returnObj.RowSelected = function(id)
	{		
		_this.SelectedRow = id; 
		$(_this.GetSelfReferenceString() + "_delBTN").disabled = false; 
		$(_this.GetSelfReferenceString() + "_edtBTN").disabled = false; 
	};
	
	returnObj.OnEdit = function()
	{			
		//this.ServerObject.DataRows[_this.SelectedRow]
		if(this._autoForms)
		{
			var thisForm = new HtmlForm.Control(this._recordId + "FormEdit"); 
			thisForm.SetDataBridgeObject(this.ServerObject.DataBridge); 
			thisForm.Render(container, this._dataHandlerUrl, this._basePage, this.ServerObject.DataRows[_this.SelectedRow]); 		
		}	
		
		if(this.GetDataSet()._onedit != null)
		{
			this.GetDataSet()._onedit(this.GetSelectedRowIdAlias()); 
		}
	};
	
	returnObj.OnDelete = function()
	{
		if(confirm("Are you sure you want to permanently delete \"" + this.GetSelectedRowIdAlias() + "\"?"))
		{
			if(this._autoForms)
			{
				var thisForm = new HtmlForm.Control(this._recordId + "FormDelete"); 
				thisForm.SetDataBridgeObject(this.ServerObject.DataBridge); 
				thisForm.Delete(_this.GetSelectedRowId(), _this); 
			}					
			
			if(this.GetDataSet()._ondelete != null)
			{
				this.GetDataSet()._ondelete(_this.GetSelectedRowIdAlias()); 
			}
		}
	};
	
	returnObj.SetAutoForms = function(url, basePage)
	{
		this._basePage = basePage; 
		this._dataHandlerUrl = url; 
		this._autoForms = true; 
	}
	
	returnObj.OnAdd = function()
	{	
		if(this._autoForms)
		{
			var thisForm = new HtmlForm.Control(this._recordId + "FormAdd"); 
			thisForm.SetDataBridgeObject(this.ServerObject.DataBridge); 
			thisForm.Render(container, this._dataHandlerUrl, this._basePage); 		
		}		
		
		if(this.GetDataSet()._onadd != null)
		{
			this.GetDataSet()._onadd(_this.SelectedRow); 
		}		
	};	
	
	returnObj.GetToolButtons = function()
	{
		var thisObjectName = this.GetSelfReferenceString();
		var returnVal = ""; 
		
		returnVal += "<button id='" + thisObjectName + "_addBTN' onclick='" + thisObjectName + ".OnAdd();' style='width:100px;margin-bottom:3px;'>Add</button></br />"; 
		returnVal += "<button id='" + thisObjectName + "_edtBTN' onclick='" + thisObjectName + ".OnEdit();' style='width:100px;margin-bottom:3px;' disabled>Edit</button></br />"; 
		returnVal += "<button id='" + thisObjectName + "_delBTN' onclick='" + thisObjectName + ".OnDelete();' style='width:100px;margin-bottom:3px;' disabled>Delete</button></br />"; 

		return returnVal; 
	}
	
	returnObj.GetSelectedRowData = function()
	{
		return this.ServerObject.DataRows[_this.SelectedRow]; 
	};
	
	returnObj.GetSelectedRowIdAlias = function()
	{
	    var tmp = 0; 
		return this.GetSelectedRowData()[this.ServerObject.DataBridge.IdAliasIndex]; 
	};

	returnObj.GetSelectedRowId = function()
	{
		var index = 0; 
		for(var i = 0; i < this.ServerObject.DataBridge.DataObjects.length; i++)
		{
			if(this.ServerObject.DataBridge.DataObjects[i].Key)
			{
				index = this.ServerObject.DataBridge.DataObjects[i].ColumnIndex; 
				i = this.ServerObject.DataBridge.DataObjects.length; 
			}
		}
		
		return this.GetSelectedRowData()[index]; 
	};
	
	returnObj._autoForms = false; 	
	var _this = returnObj; 	
	return returnObj; 
}


//--- \ui\RichTextEdit.Control.js
/**************************************************************
//HTML Grid control
/**************************************************************/
UIControls.RichTextEdit = function(id, container, heightVal, widthVal, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	dataSet.Height = heightVal; 
	dataSet.Width = widthVal;
	UIControls.RichTextEdit.ImageBrowserForm = $("_imageBrowserForm"); 
	
	if(UIControls.RichTextEdit.ImageBrowserForm == null)
	{
		UIControls.RichTextEdit.ImageBrowserForm = document.createElement("div"); 
		UIControls.RichTextEdit.ImageBrowserForm.id = "_imageBrowserForm"; 
		UIControls.RichTextEdit.ImageBrowserForm.style.cssText = "" + 
		"position:absolute;z-index:10;display:none;width:200px;height:50px;background-color:#ffffff;border:solid 1px #cecece;"; 
		UIControls.RichTextEdit.ImageBrowserForm.innerHTML = "<div align='center' valign='middle' style='border:solid 1px #666666;height:100%;width:100%'>Choose an image: <span id='_picUploaderDiv'></span></div>";
        document.body.appendChild(UIControls.RichTextEdit.ImageBrowserForm); 

		UIControls.RichTextEdit.FileUpload = UIControls.ImageUpload("_picUploader", "_picUploaderDiv", "Picture"); 
		//new UIControls.FileUpload("_picUploader","_picUploaderDiv", prms, maxlength, style)
		UIControls.RichTextEdit.FileUpload.Render(); 
		UIControls.RichTextEdit.FileUpload.OnImageLoad = function()
		{
			rteCommand(UIControls.RichTextEdit.ImageBrowserForm.rte, 'InsertImage', UIControls.RichTextEdit.FileUpload.GetImageUrl());
			UIControls.RichTextEdit.ImageBrowserForm.HidePictureForm(); 
		};
		
		UIControls.RichTextEdit.ImageBrowserForm.ShowPictureForm = function()
		{			
			UIControls.RichTextEdit.ImageBrowserForm.style.left = Globals.MouseX + "px";
			UIControls.RichTextEdit.ImageBrowserForm.style.top = Globals.MouseY + "px";
			UIControls.RichTextEdit.ImageBrowserForm.style.display = "block"; 			
		};
		UIControls.RichTextEdit.ImageBrowserForm.HidePictureForm = function()
		{
			UIControls.RichTextEdit.ImageBrowserForm.style.display = "none"; 
			UIControls.RichTextEdit.FileUpload.Clear(); 
		};
	}
	
	var getValueF = function() 
	{
		return this.StripAbsoluteImagePaths(GetRichTextValue(this.GetIFrameId())); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		EnableDesignMode(this.GetIFrameId(), valueToSet, false);
	};
	
	var renderF = function(defaultValue) 
	{ 	
		InitRTE("scripts/custom/layout/css/imgs/richtext/", "", "");
		
		if(this.DisplayLabel)
		{
			$(this._container).innerHTML = this.Label + '<div id="' + this._recordId + '_body"></div>';
			WriteRichText(this.GetIFrameId(), this._recordId + "_body", defaultValue, this.GetDataSet().Width, this.GetDataSet().Height, true, false);
		}
		else
		{
			$(this._container).innerHTML = '<div id="' + this._recordId + '_body"></div>';
			WriteRichText(this.GetIFrameId(), this._recordId + "_body", defaultValue, this.GetDataSet().Width, this.GetDataSet().Height, true, false);		
		}
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);	
	returnObj.ServerObject 	= null; 	
	returnObj.GetIFrameId = function()
	{
		return this._recordId + "_iframe"; 
	};
	
	returnObj._disableF = function()
	{
		EnableDesignMode(this.GetIFrameId(), this.GetValue(), true);
		HideToggleHTML(this.GetIFrameId()); 
	};
	
	returnObj._enableF = function()
	{
		EnableDesignMode(this.GetIFrameId(), this.GetValue(), false);
		ShowToggleHTML(this.GetIFrameId()); 
	};
	
	returnObj.StripAbsoluteImagePaths = function(HTMLstring)
	{
		var url = window.location.toString();
		var urlParts = url.split('/');
		var baseURL = ""; 
		
		for(var i = 0; i < urlParts.length-1; i++)
		{
			baseURL += urlParts[i] + "/"; 
		}	
		
		var d = document.createElement('div'); 
		d.innerHTML = HTMLstring; 
		
		for(var i = 0; i < d.all.length; i++)
		{
		    var ele = d.all[i];
		    if(ele.tagName == "IMG")
		    {
		        if(ele.src.length >= baseURL.length)
		        {
		            if(ele.src.substring(0, baseURL.length).toLowerCase() == baseURL.toLowerCase())
		            {
		                ele.setAttribute("src", ele.src.substring(baseURL.length)); 
		            }
		         }
		    } 
		}		
		
		return d.innerHTML; 
	}
	
	return returnObj; 
}


//--- \ui\Label.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.Label = function(id, container, labelValue)
{		
	var getValueF = function() 
	{
		return $(this._recordId).innerHTML; 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).innerHTML = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = "<span id='" + this._recordId + "'>" + this.LabelValueTxt + "</span>"; 
		return returnVal; 
	};

	var returnObj = new IDataControl(id, container, null, null, getValueF, setValueF, renderF);	
	returnObj.LabelValueTxt = labelValue; 
	returnObj.DisplayLabel = false; 
	
	return returnObj; 
}


//--- \ui\DisplayValue.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.DisplayValue = function(id, container, labelValue)
{		
	var getValueF = function() 
	{
		return $(this._recordId).innerHTML; 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).innerHTML = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var returnVal = "<span id='" + this._recordId + "'>" + this.LabelValueTxt + "</span>"; 
		return returnVal; 
	};

	var returnObj = new IDataControl(id, container, null, null, getValueF, setValueF, renderF);	
	//returnObj.LabelValueTxt = labelValue; 
	//returnObj.DisplayLabel = true; 
	
	return returnObj; 
}


//--- \ui\FileUpload.Control.js
/**************************************************************
//HTML Masked text control
/**************************************************************/
UIControls.FileUpload = function(id, container, prms, maxlength, style)
{		
	if(maxlength == null) maxlength = 45; 
	var dataSet = null; 
	
	var getValueF = function() 
	{
	    if(!this.FileInfo) return null; 
		return this.FileInfo.toJSONString(); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
	    var tmp = 0; 
	    this.FileInfo = valueToSet.parseJSON(); 
		this.Render(); 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var styleTxt = ""; 		
		if(Globals.IsIE7())
		{
			styleTxt = "margin-left:-95px;border:solid 4px black;border-right:solid 3px black;border-left:solid 5px black;width:0px;position:relative;left:80px;filter:alpha(opacity=0);-moz-opacity:.0;opacity:.0;width:0px;";//"border:none;width:0px;color:#444444;background-color:#eeeeee;"; 
		}

		var returnVal = Controls.file(this._recordId, 
		styleTxt + 
		this._style);					
		
		returnVal = returnVal.replace("/>"," id='" + this._recordId + "_file' onchange='" + this.GetSelfReferenceString() + ".SendValue();' " + 
		"value='" + defaultValue + "' oncontextmenu='return false;' onkeydown='this.blur();'/>"); 
			
		var formId = this._recordId + "_form"; 
		
		returnVal += "<button style='width:60px;'>Browse...</button>";
		
		var usrString = ""; 
		if(Globals.UserData)
		{
			usrString = Globals.UserData.LoginEmail; 
		}
		
		var tmpVal = '' + 
		'<form name="' + formId + '"' + 
		' id="' + this._recordId + '_form" ' + 
		' action="' + Globals.Location.ASHX.File + '" method="post" enctype="multipart/form-data" style="margin-top:2px;">' + 
		'<input type="HIDDEN" name="UserId" id="UserId" value="' + usrString + '" />'; 		   
		
		if(this.FileInfo)
		{
    		returnVal = tmpVal + UIControls.FileUpload.GetFileDisplay(this.FileInfo, this._recordId) + " " + returnVal + " <button style='margin-left:10px;' onclick='" + 
    		this.GetSelfReferenceString() + ".FileInfo = null; " + 
    		this.GetSelfReferenceString() + ".Render();'>Remove File</button> ";
		}
		else
		{
			returnVal = tmpVal + returnVal; 
		    returnVal += '<span id="' + this._recordId + '_fileName" NOWRAP></span>';
		}
		
		return returnVal + '</form>'; 
	};
		
	dataObject = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);		
	dataObject._style = style; 
	var _this = dataObject; 
	
	dataObject.SendValue = function()
	{		
		if(this.GetControlValue() != null && this.GetControlValue() != "")
		{
			AIM.submit($(this._recordId + '_form'), {'onStart' : this.OnSendStart, 'onComplete' : this.OnSendComplete});
		}
	};
	
	dataObject.Browse = function()
	{
	    var inputField = $(this._recordId); 
		$(this._recordId).click(); 
	};
		
	dataObject.OnSendStart = function()
	{
		Globals.ShowSpinner(_this._recordId + '_fileName', " Loading File..."); 		
		return true; 
	};	

	dataObject.OnSendComplete = function(txt)
	{
		_this.SetValue(txt.stripTags()); 
	};	
		
		
	dataObject.GetControlValue = function()
	{
		return 	$(this._recordId).value; 
	};
	
	dataObject.GetFileIcon = function()
	{
	    if(!this.FileInfo) return ""; 
        return UIControls.FileUpload.GetFileIconAux(this.FileInfo.Extension); 	    
	};
	
	dataObject.FileInfo = null; 
	return dataObject; 
}

UIControls.FileUpload.GetFileDisplay = function(fileInfo, recordId)
{
	var fireFox = ""; 
	if(!Globals.IsIE7())
	{
		fireFox = "<br />";
	}

	return fireFox + '<span id="' + recordId + '_fileName" style="position:relative;left:0px;top:3px;padding-left:10px;" NOWRAP>' + UIControls.FileUpload.GetFileIconAux(fileInfo.Extension) + 
	' <a href="' + 
	fileInfo.RelativePath +  
	fileInfo.InternalName + 
	fileInfo.Extension + 
	'" target="_BLANK" style="position:relative;top:-3;">' + 
	fileInfo.Name + 
	fileInfo.Extension + 
	'</a></span>';
};

UIControls.FileUpload.GetFileIconAux = function(extension)
{
	switch(extension)
	{
		case ".jpg":
		{
			icoFile = "jpg.jpg";
			break; 
		}
		case ".doc":
		{
			icoFile = "doc.jpg";
			break; 
		}
		case ".xls":
		{
			icoFile = "xls.jpg";
			break; 
		}
		case ".pdf":
		{
			icoFile = "pdf.jpg";
			break; 
		}
		case ".txt":
		{
			icoFile = "txt.jpg";
			break; 
		}
		case ".zip":
		{
			icoFile = "zip.jpg";
			break; 
		}
		default:
		{
			icoFile = "file.jpg";
			break; 
		}
	}

	return "<img src='imgs/icons/" + icoFile + "' />";
};


//--- \ui\ImageUpload.Control.js
/**************************************************************
//HTML Masked text control
/**************************************************************/
UIControls.ImageUpload = function(id, container, prms, maxlength, style)
{		
	if(maxlength == null) maxlength = 45; 
	var dataSet = null; 
	
	var getValueF = function() 
	{
	    if(this.FileInfo == null)
	    {
	        return ""; 
	    }
	    else
	    {
	        return this.FileInfo.toJSONString(); 
        }
	};
	
	var setValueF = function(valueToSet) 
	{
	    this.FileInfo = valueToSet.parseJSON(); 
	    if(this.FileInfo != null)
	    {
			this.RenderSmallImage(); 
		}
	};
	
	var renderF = function(defaultValue) 
	{ 
		var styleTxt = ""; 		
		if(Globals.IsIE7())
		{
			styleTxt = "margin-left:-95px;border:solid 4px black;border-right:solid 3px black;border-left:solid 5px black;width:0px;position:relative;left:80px;filter:alpha(opacity=0);-moz-opacity:.0;opacity:.0;width:0px;";//"border:none;width:0px;color:#444444;background-color:#eeeeee;"; 
		}

		var returnVal = Controls.file(this._recordId, 
		styleTxt + 
		this._style);					
		
		returnVal = returnVal.replace("/>"," onchange='" + this.GetSelfReferenceString() + ".SendValue();' " + 
		"value='" + defaultValue + "' oncontextmenu='return false;' onkeydown='this.blur();' />"); 
		
		returnVal += "<button style='width:60px;'>Browse...</button>";
		
		var usrString = ""; 
		if(Globals.UserData)
		{
			usrString = Globals.UserData.LoginEmail; 
		}

		var formText = ""; 
		formText += '<form name="' + this._recordId + '_form" ' + 
		'id="' + this._recordId + '_form" ' + 
		' action="' + Globals.Location.ASHX.File + '" method="post" enctype="multipart/form-data" style="margin-top:2px;">' +  		
		'<input type="HIDDEN" name="UserId" id="UserId" value="' + usrString + '" />'; 		   
		
		formText = formText + returnVal; 			
		
		if(this.FileInfo)
		{
			formText += " <button style='margin-left:10px;' onclick='" + 
    		this.GetSelfReferenceString() + ".FileInfo = null; " + 
    		this.GetSelfReferenceString() + ".Render();'>Remove File</button> ";		
		}
		formText += '</form><span id="' + this._recordId + '_results" ></span>';
		
		return formText; 
	};
		
	dataObject = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);		
	dataObject._style = style; 
	var _this = dataObject; 
	
	dataObject.SendValue = function()
	{
		if(this.GetControlValue() != null && this.GetControlValue() != "")
		{
			AIM.submit($(this._recordId + '_form'), {'onStart' : this.OnSendStart, 'onComplete' : this.OnSendComplete});
		}
	};
	
	dataObject.OnSendStart = function()
	{
		Globals.ShowSpinner(_this._recordId + '_results', " Loading image..."); 		
		return true; 
	};	

	dataObject.OnSendComplete = function(txt)
	{
		_this.SetValue(txt.stripTags()); 
		if(_this.OnImageLoad != null)
		{
			_this.OnImageLoad(); 
		}
	};	
	
	dataObject.GetControlValue = function()
	{
		return 	$(this._recordId).value; 
	};
	
	dataObject.RenderLargeImage = function()
	{
		$(_this._recordId + '_results').innerHTML = "" +
		"<span style='margin-top:4px;'>" + 
		"<a href='javascript:" + _this.GetSelfReferenceString() + ".RenderSmallImage();'>" + 
			"<img border='0' src='imgs/smaller.png' />" +
		"</a> " + this.FileInfo.Name + this.FileInfo.Extension +  
		"</span><br />" + 
		"<img border='0' src='" + 
    		this.FileInfo.RelativePath +  
    		this.FileInfo.InternalName + 
    		this.FileInfo.Extension + 
		"' style='border:solid 1px #666666;' />" + 
		""; 
	};

	dataObject.RenderSmallImage = function()
	{
		$(_this._recordId + '_results').innerHTML = "" +
		"<span style='padding-top:4px;' valign='middle'>" + 
		    "<a href='javascript:" + _this.GetSelfReferenceString() + ".RenderLargeImage();'>" +  		
			    "<img border='0' src='imgs/larger.png' />" +
		    "</a> " +  this.FileInfo.Name + this.FileInfo.Extension +   
		"</span><br />" + 
		"<img border='0' src='" + 
    		this.FileInfo.RelativePath +  
    		"thumb_" + 
    		this.FileInfo.InternalName + 
    		this.FileInfo.Extension + 
		"'  style='border:solid 1px #666666;'/>" + 
		"";
	};
	
	dataObject.Clear = function()
	{
		$(_this._recordId + '_results').innerHTML = ""
	};
	
	dataObject.GetImageUrl = function()
	{
		return "" + 
    		this.FileInfo.RelativePath +  
    		this.FileInfo.InternalName + 
    		this.FileInfo.Extension + 
		""; 
	};
	
	dataObject.FileInfo = null; 
	dataObject.OnImageLoad = null; 
	
	return dataObject; 
}


AIM = 
{
    frame : function(c) {

        var n = 'f' + Math.floor(Math.random() * 99999);
        var d = document.createElement('DIV');
        d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
        document.body.appendChild(d);
		
        var i = document.getElementById(n);
        if (c && typeof(c.onComplete) == 'function') 
        {
            i.onComplete = c.onComplete;
        }

        return n;
    },

    form : function(f, name) {
        f.setAttribute('target', name);
    	f.submit(); 
    },

    submit : function(f, c) {
        AIM.form(f, AIM.frame(c));
        if (c && typeof(c.onStart) == 'function') {
            return c.onStart();
        } else {
            return true;
        }
        
    },

    loaded : function(id) {
        var i = document.getElementById(id);
        if (i.contentDocument) {
            var d = i.contentDocument;
        } else if (i.contentWindow) {
            var d = i.contentWindow.document;
        } else {
            var d = window.frames[id].document;
        }
        if (d.location.href == "about:blank") {
            return;
        }

        if (typeof(i.onComplete) == 'function') {
            i.onComplete(d.body.innerHTML);
        }
    }
}


//--- \ui\HtmlForm.Control.js
HtmlForm = function(){}; 
HtmlForm.Controls = new Array(); 

HtmlForm.Control = function(id)
{
	this.Editing = false; 
	this.ViewOnly = false;  
	this.AllowEdit = false;
	this.ServerObject = null
	this.ViewTemplate = null; 
	this.ValidateFunction = null; 
	this._saveTxt = "Save";
	this._editArray = null; 
	this._pageNumber = 0; 
	this._pageContainers = new Array(); 
	this._pageDataObjects = new Array(); 
	this._pageContainerIndex = 0; 
	this._pagesWithErrors = new Array();
	this._index = HtmlForm.Controls.length; 
	this._prefaceText = ""; 
	this.SaveOverride = null; 
	
	HtmlForm.Controls[HtmlForm.Controls.length] = this; 
	
	this._id = id; 
	this._dataBridgeObj = null; 
	this._onFormComplete = null; 
	this._onFormSaveComplete = null; 
	
	this._nonEditObjectArray = new Array(); 
	this._objectArray = new Array(); 		
	this.AddObject = function(objReference, value)
	{
		if(value == null) //Control is presented visible on the form
		{
			this._objectArray[this._objectArray.length] = objReference; 
		}
		else
		{
			objReference.Value = value; 
			this._nonEditObjectArray[this._nonEditObjectArray.length] = objReference; 
		}
	};
	this.GetFormControl = function(controlName)
	{
		for(var i = 0; i < this._objectArray.length; i++)
		{
			if(this._objectArray[i]._recordId == controlName)
			{
				return this._objectArray[i]; 
			}
		}
		
		return null; 
	};
	
	this.SetPrefaceText = function(textToSet)
	{
		this._prefaceText = textToSet;
	};
	
	this.SetDataBridgeObject = function(dataBridgeObject)
	{
		this._dataBridgeObj = dataBridgeObject; 		
	};

	this.Render = function(container, dataHandlerAddress, onFormComplete, editArray)
	{		
		if(this._dataBridgeObj.DataHandler != null)
		{
			this._dataHandlerAddress = this._dataBridgeObj.DataHandler; 
		}
		else
		{
			this._dataHandlerAddress = dataHandlerAddress; 
		}
		
		this._onFormComplete = onFormComplete; 
		
		var dataObjects = this._dataBridgeObj.DataObjects; 		
		
		//Initialize the first element
		this._pageContainers[this._pageContainerIndex] = ""; 
		this._pageDataObjects[this._pageContainerIndex] = null; 
		var containerTxt = '<div style="padding:10px;">';// + this.GetCommandButtons(); 
		containerTxt += '<div id="' + this.GetPageId(0) + '">'; 
		
		//If we have been given an HTML template, use it. Otherwise, create one from scratch.
		if(this.ViewTemplate != null)
		{
			containerTxt += this.ViewTemplate.innerHTML.replace(/\$ID/g,this._id); 
		}
		else
		{
			this.CreateContainers(dataObjects); 
			var i = 0; 
			for(i = 0; i < this._pageContainers.length; i++)
			{
				containerTxt += this._pageContainers[i]; 	
			}
		}
				
		containerTxt += '</div>'; 
		
		if(!this.ViewOnly)
		{
			containerTxt += '<br /><span class="error" style="float:left;"><b>* Field is required.</b></span><br />' +   
		    '<hr />'; 		
		}
		
		containerTxt += '' + '<div id="formStatusContainer"></div>' + 
			'<span id="' + this._id + 'command_button" style="white-space:nowrap;"></span>' + 
		'</div>'; 	
		
		container.innerHTML = this._prefaceText + containerTxt; 				
		this.RenderControls(dataObjects, editArray); 	
			
		if(this._pageContainers.length > 1)
		{
			this.GoToPage(1); 
		}
		else
		{
			this.GoToPage(0); 
		}		
				
		if(this._pageContainers.length > 2)
		{
			$("SubNavMenu").style.display = "block";			
		}
		else
		{
			$("SubNavMenu").style.display = "none";				
		}
	};
	
	this.GlobalPageCount = 0; 
	this.CreateContainers = function(dataObjects)
	{	
		var dataTypeHigh = ""; 
		var containers = ''; 
		
		//Create Containers for each object
		for(var i = 0; i < dataObjects.length; i++)
		{		
			this.GlobalPageCount++; 
			//Recursive call to get nested objects
			if(dataObjects[i].DataType == "NestedDataBridgeObject")
			{
				this.CreateContainers(dataObjects[i].DataBridgeObject.DataObjects); 
			}						
			else if(dataObjects[i].DataType == "Page")
			{
				dataObjects[i].Index = this.GlobalPageCount; 
				this._pageDataObjects[this._pageDataObjects.length] = dataObjects[i]; 			
				this._pageContainers[this._pageContainerIndex] += '</div>'; 				
				this._pageContainerIndex++; 
				this._pageContainers[this._pageContainerIndex] = '' + 
				'<div id="' + this.GetPageId(this._pageContainerIndex) + '" pageNumber="' + this._pageContainerIndex + '" pageName="' + this._pageContainerIndex + ' ' + dataObjects[i].DisplayName + '" style="display:none;">'; 
			}
			else if(dataObjects[i].Editable && dataObjects[i].DataTypeHigh == null)
			{				
				this._pageContainers[this._pageContainerIndex] += '<div style="padding-bottom:5px;" id="' + 
					this.GetContainerName(dataObjects[i]) + '"></div>';
			}
			else if(dataObjects[i].DataTypeHigh != null && dataObjects[i].DataTypeHigh != "")
			{
				if(dataTypeHigh == "" || dataTypeHigh != dataObjects[i].DataTypeHigh)
				{
					this._pageContainers[this._pageContainerIndex] +='<div style="padding-bottom:5px;" id="' + 
						this.GetContainerName(dataObjects[i]) + '"></div>';
				}
			}
			
			dataTypeHigh = dataObjects[i].DataTypeHigh;			
		}		
	};
	
	this.RenderControls = function(dataObjects, editArray)
	{
		this._editArray = editArray; 
		
		if(this.ServerObject != null)
		{
			editArray = this.ServerObject.DataRows[0]; 
		}
		
		if(editArray != null)
		{
			this.Editing = true; 
		}
	
		for(var i = 0; i < dataObjects.length; i++)
		{	
			//Recursive call to get nested objects
			if(dataObjects[i].DataType == "NestedDataBridgeObject")
			{
			    var valueObj = null; 
			    if(editArray != null)
			    {
				    valueObj = editArray[dataObjects[i].ColumnIndex].parseJSON();							
				}
				
				if(this.Editing)
				{
					var nestedEditArray = new Array(); 
					for(var iter2 = 0; iter2 < dataObjects[i].DataBridgeObject.DataObjects.length; iter2++)
					{
						var thisValue = ""; 
						if(valueObj != null)
						{	
							thisValue = valueObj[dataObjects[i].DataBridgeObject.DataObjects[iter2].Name]; 				
						}

						if(thisValue == null) thisValue = ""; 							
						nestedEditArray[nestedEditArray.length] = thisValue; 
					}
				}
				
				this.RenderControls(dataObjects[i].DataBridgeObject.DataObjects, nestedEditArray); 
			}		
			else if(!dataObjects[i].Editable && editArray != null)//Only care about non editable value when editing
			{
				this.AddObject(dataObjects[i], editArray[dataObjects[i].ColumnIndex]); 
			}
			else if(dataObjects[i].DataTypeHigh == null)
			{				
			    var containerName = this.GetContainerName(dataObjects[i]); 
			    
			    var editVal = ""; 
			    if(editArray != null)
			    {
			    	editVal = editArray[dataObjects[i].ColumnIndex];
			    }
				
				var thisControl = UIControls.GetControlFromDataBridgeObj(dataObjects[i], $(containerName), this.ViewOnly, editVal);
				if(this.ViewOnly)
				{
					if($(containerName) != null)
					{
						$(containerName).innerHTML = thisControl;
					}
				}
				else if(thisControl != null)
				{
					if($(containerName) != null)
					{
						this.AddObject(thisControl); 
						thisControl.Render();
						if(editArray != null)
						{
							thisControl.SetValue(editArray[dataObjects[i].ColumnIndex]); 
						}			    
					}
				}
			}
			else if(dataTypeHigh == "" || dataTypeHigh != dataObjects[i].DataTypeHigh)
			{
				var editVal = ""; 
			    if(editArray != null)
			    {
			    	editVal = editArray;//[dataObjects[i].ColumnIndex];
			    }
				
				var thisControl = UIControls_High.GetControlFromDataBridgeObj(dataObjects[i], $(this.GetContainerName(dataObjects[i])), this.ViewOnly, editVal, dataObjects[i].ColumnIndex);

				if(this.ViewOnly)
				{
					if($(this.GetContainerName(dataObjects[i])) != null)
					{
						$(this.GetContainerName(dataObjects[i])).innerHTML = thisControl;
					}
				}
				else if(thisControl != null)
				{
					this.AddObject(thisControl); 
					thisControl.Render();
					if(editArray != null)
					{
						thisControl.SetValueFromDataRow(editArray, dataObjects[i].ColumnIndex); 
					}			    
				}
			}
			
			dataTypeHigh = dataObjects[i].DataTypeHigh;						
		
		}				
	};
	
	this.RenderCommandButtons = function()
	{
		var txt = ""; 
	    var saveTxt = this._saveTxt; 
	    if(this.Editing)
	    {
		    saveTxt = "Update";
	    }
		    	    
		if(this._pageContainers.length == 1)
		{
			if(!this.ViewOnly)
			{
				txt = '' + 
				'<span style="text-align:right;padding-top:0px;">' + 
					'<button onclick="' + this.GetThisReference() + '.Save(\'' + this.GetThisReference() + '\');" style="margin-right:10px;">' + saveTxt + '</button>' + 
					'<button onclick="' + this.GetThisReference() + '.Return(' + this.GetThisReference() + ');" style="width:60px;">Cancel</button>' + 
				'</span>';
			}
		}	    
	    else if(this._pageNumber == (this._pageContainers.length - 1))
	    {
		    txt = '' + 
		    '<span style="text-align:left;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.GoToPreviousPage();"">Previous Page</button>' + 
		    '</span>' + 
		    '<span NOWRAP style="margin-left:100px;text-align:right;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.Save(\'' + this.GetThisReference() + '\');" style="margin-right:10px;width:70px;">' + saveTxt + '</button>' + 
		    	'<button onclick="' + this.GetThisReference() + '.Return(' + this.GetThisReference() + ');" style="width:60px;">Cancel</button>' + 
		    '</span>';
	    }
	    else if(this._pageNumber == 1)
	    {
		    txt = '' + 
		    '<span style="text-align:left;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.GoToNextPage();">Next Page</button>' + 
		    '</span>' + 
		    '<span NOWRAP style="margin-left:220px;text-align:right;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.Save(\'' + this.GetThisReference() + '\');" style="margin-right:10px;width:70px;">' + saveTxt + '</button>' + 
		    	'<button onclick="' + this.GetThisReference() + '.Return(' + this.GetThisReference() + ');" style="width:60px;">Cancel</button>' + 
		    '</span>';
	    }
	    else
	    {
		    txt = '' + 
		    '<span style="text-align:left;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.GoToPreviousPage();"">Previous Page</button>' + 
				'<button onclick="' + this.GetThisReference() + '.GoToNextPage();">Next Page</button>' + 
		    '</span>' + 
		    '<span NOWRAP style="margin-left:140px;text-align:right;padding-top:0px;">' + 
				'<button onclick="' + this.GetThisReference() + '.Save(\'' + this.GetThisReference() + '\');" style="margin-right:10px;width:70px;">' + saveTxt + '</button>' + 
		    	'<button onclick="' + this.GetThisReference() + '.Return(' + this.GetThisReference() + ');" style="width:60px;">Cancel</button>' + 
		    '</span>';
	    }
	    
	    $(this._id + 'command_button').innerHTML = txt; 
	};

	this.Save = function(sender, passedErrors)
	{
		var thisObj = eval(sender); 		
		if(thisObj.SaveOverride != null)
		{
			thisObj.SaveOverride(); 
			return; 
		}
		
		if(passedErrors == null) 
		{
			validateErrors = thisObj.Validate(); 
			if(validateErrors == "" && this.ValidateFunction != null)
			{
				//This function must call back the 'Save' method with a list of errors. This is for server-side
				//pre-validation of form information
				this.ValidateFunction(); 
				return; 
			}		
		}
		else
		{
			validateErrors = passedErrors; 
		}
		
		if(validateErrors == "")
		{			
			var commandTxt = "insert";
			if(this.Editing)
			{
				commandTxt = "update";
			}

			var serverData = new ServerData.SenderObject(commandTxt, null, thisObj._dataHandlerAddress, thisObj.GetURIFormat());             
			Globals.ShowSpinner("MiddleBody", "Sending data...")    
			serverData.SendData(
				function(results)
				{
					if(thisObj._onFormSaveComplete != null)
					{
						if(typeof thisObj._onFormSaveComplete == 'function')
						{
							thisObj._onFormSaveComplete(this.ReturnObject); 
						}
						else
						{
							eval(thisObj._onFormSaveComplete);
						}
					}
					else
					{
						if(typeof thisObj._onFormComplete == 'function')
						{
							thisObj._onFormComplete(this.ReturnObject); 
						}
						else
						{
							eval(thisObj._onFormComplete);
						}
					}
				}
			); 					
		}
		else
		{
			alert(validateErrors); 			
		}
	};
	
	this.Delete = function(id, sender)
	{
		var commandTxt = "delete";
		var thisObj = eval(sender); 		
		
		var serverData = new ServerData.SenderObject(commandTxt, null, thisObj._dataHandlerUrl, "Id=" + id);             
		Globals.ShowSpinner("MiddleBody", "Deleting...")    
		serverData.SendData(function(results){eval(thisObj._basePage);}); 					 
	};
	
	this.GoToNextPage = function()
	{
        var nextPage = this._pageNumber + 1;         	
	    this._pageNumber = nextPage; 
	    
	    this.GoToPage(nextPage);
	};
	
	this.GoToPreviousPage = function()
	{
        var nextPage = this._pageNumber - 1;         		    
	    this.GoToPage(nextPage); 
	};
	
	this.GoToPage = function(pageNumber)
	{
	    this._pageNumber = pageNumber; 
	
        for(var i = 0; i < this._pageContainers.length; i++)
		{
		    if(i == pageNumber)
		    {
		        $(this.GetPageId(i)).style.display = "block";
		    }
		    else 
		    {
		        $(this.GetPageId(i)).style.display = "none";
		    }
        }
        
        this.RenderCommandButtons(); 
        this.SetAllPagesLinks(); 
        scrollTo(0,0); 
	};
	
	this.SetAllPagesLinks = function()
	{
		var txt = "<div style='width:100%;padding-left:20px;padding-right:20px;'><table cellspacing='0' cellpadding='0'><tr style='height:40px;'>"; 
        var progress = ""; 
        var currentPage = false; 
        
        for(var i = 1; i < this._pageContainers.length; i++)
		{
		    if(currentPage)
		    {
		    	progress += "<td></td>";
		    }
		    else
		    {
		    	progress += '<td style="background-color:#2b5a8a;height:4px;"></td>';
		    }
		    
		    if(i == this._pageNumber)
		    {
		    	txt += '<td class="multipage_selected">' + i + ' ' + this._pageDataObjects[i].DisplayName + '</td>'; 
		    	currentPage = true; 
		    }
		    else 
		    {
		    	txt += '<td class="multipage_unselected"><a href="javascript:' + this.GetThisReference() + '.GoToPage(' + i + ');">' + i + ' ' + this._pageDataObjects[i].DisplayName + '</a></td>'; 
		    }
		    
        }

		$("SubNavMenu").innerHTML = //'<td style="width:100%;padding:10px;border-bottom:solid 1px #eeeeee;"><br />&nbsp;&nbsp;' + 
		txt +  
		'</tr><tr style="background-color:#cccccc;height:4px;">' + progress +
		'</tr></table></div>'; 
	};
	
	this.GetPageId = function(index)
	{
	    return this._id + '_page_' + index;
	};
	
	this.Return = function(sender)
	{
		var thisObj = eval(sender); 
		eval(thisObj._onFormComplete); 	
	};
	
	this.GetContainerName = function(dataBridgeObj)
	{
		if(dataBridgeObj.DataTypeHigh != null && dataBridgeObj.DataTypeHigh != "")
		{
			return this._id + '_' + dataBridgeObj.DataTypeHigh + '_container';
		}
		else
		{
			return this._id + '_' + dataBridgeObj.Name + '_container';
		}
	};
	
	this.GetJSONString = function()
	{
		var returnString = "{"; 		
		for(var i = 0; i < this._objectArray.length; i++)
		{
			if(i != 0)
			{
				returnString += ",";
			}
			
			returnString += "\"" + this._objectArray[i]._recordId + "\":" + this._objectArray[i].toJSONString() + ""; 
		}
		
		return returnString + "}"; 
	};
	
	this.GetURIFormat = function()
	{
		var returnString = ""; 		
		for(var i = 0; i < this._objectArray.length; i++)
		{
			if(this._objectArray[i].GetURIFormat)
			{
				if(i != 0)
				{
					returnString += "&";
				}

				returnString += this._objectArray[i].GetURIFormat(); 
			}
		}
		
		
		if(this._dataBridgeObj != null && this.Editing)
		{
			for(var i = 0; i < this._nonEditObjectArray.length; i++)
			{
				if(returnString != "")
				{
					returnString += "&";
				}
				
				returnString += this._nonEditObjectArray[i].Name + "="; 
				returnString += Globals.UrlEncode(this._nonEditObjectArray[i].Value); 
			}

		
			/*
			var objects = this._dataBridgeObj.DataObjects; 
			for(var i = 0; i < objects.length; i++)
			{
				//Object wasn't included with the UI, so get the value from the data
				if(!objects[i].Editable)
				{
					returnString += this.GetURIFormatFromValue(this._editArray[i], objects[i]); 
				}
			}
			*/
		}
		
		return returnString; 
	};	

	this.Disable = function()
	{
		for(var i = 0; i < this._objectArray.length; i++)
		{
			this._objectArray[i].Disable(); 
		}
	};
	
	this.Enable = function()
	{
		for(var i = 0; i < this._objectArray.length; i++)
		{
			this._objectArray[i].Enable(); 
		}
	};	
	
	this.Validate = function()
	{
		this._pagesWithErrors = new Array();
				
        var validate = true; 
		for(var i = 0; i < this._objectArray.length; i++)
		{
			if(this._objectArray[i].Validate)
			{
				if(!this._objectArray[i].Validate())
				{
					if(this._pageContainers.length > 1)
					{
						var pageInfo = new function(){};
						pageInfo.Number = this._objectArray[i]._container.parentElement.getAttribute("pageNumber"); 
						pageInfo.Name = this._objectArray[i]._container.parentElement.getAttribute("pageName"); 

						var add = true; 
						for(var iter = 0; iter < this._pagesWithErrors.length; iter++)
						{
							if(this._pagesWithErrors[iter].Number == pageInfo.Number)
							{
								add = false; 
							}
						}

						if(add)
						{
							this._pagesWithErrors[this._pagesWithErrors.length] = pageInfo; 
						}
					}
					
					validate = false; 
				} 
			}
		}
		
		var goToPage = true; 
		var pagesTxt = ""; 
		for(var i = 0; i < this._pagesWithErrors.length; i++)
		{
			pagesTxt += "\n\t " + this._pagesWithErrors[i].Name + "\n";
			if(goToPage && this._pageContainers.length > 1)
			{
				this.GoToPage(this._pagesWithErrors[i].Number); 
				goToPage = false; 
			}
		}

		var returnVal = ""; 
		if(!validate)
		{
			if(this._pageContainers.length > 1)
			{
				returnVal = "One or more fields is missing or not formatted correctly. The following pages contain errors:" + pagesTxt; 
			}
			else
			{
				returnVal = "One or more fields is missing or not formatted correctly.\n\n"; 
			}
		}

		return returnVal; 
	};	
	
	this.GetThisReference = function()
	{
		return "HtmlForm.Controls[" + this._index + "]"; 
	};
	
	this.GetURIFormatFromValue = function(value, dataBridgeObject)
	{
		return "&" + dataBridgeObject.Name + "=" + Globals.UrlEncode(value); 
	};	
};

HtmlForm.PopulateTemplateFromDataRow = function(dataBridgeObject, dataRow, template, parentName, level)
{
	if(level == null) level = 0; 
	if(parentName == null) parentName = ""; 
	level++; 
	
	if(parentName != "")
	{
		//alert(parentName); 
		//alert(dataBridgeObject); 
	}
		
	for(var i = 0; i < dataBridgeObject.DataObjects.length; i++)
	{
		if(dataBridgeObject.DataObjects[i].DataType == "NestedDataBridgeObject")
		{	
			parentName += "___" + level + dataBridgeObject.DataObjects[i].Name; 
			var valueObj = dataRow[dataBridgeObject.DataObjects[i].ColumnIndex].parseJSON(); 			
			
			var nestedEditArray = new Array(); 
			for(var iter2 = 0; iter2 < dataBridgeObject.DataObjects[i].DataBridgeObject.DataObjects.length; iter2++)
			{
				var thisValue = ""; 
				if(valueObj != null)
				{	
					thisValue = valueObj[dataBridgeObject.DataObjects[i].DataBridgeObject.DataObjects[iter2].Name]; 				
				}

				if(thisValue == null) thisValue = ""; 							
				nestedEditArray[nestedEditArray.length] = thisValue; 
			}			

			
			template = HtmlForm.PopulateTemplateFromDataRow(dataBridgeObject.DataObjects[i].DataBridgeObject, nestedEditArray, template, parentName, level);
		}
		else if(dataBridgeObject.DataObjects[i].DataType == "Image")
		{
			var imageObj = dataRow[dataBridgeObject.DataObjects[i].ColumnIndex].parseJSON(); 
			if(imageObj != null)
			{
				var tagBaseName = parentName + "___" + level + dataBridgeObject.DataObjects[i].Name + "___" + (level + 1); 

				template = template.replace(tagBaseName + "Name", imageObj.Name);
				template = template.replace(tagBaseName + "InternalName", imageObj.InternalName);
				template = template.replace(tagBaseName + "RelativePath", imageObj.RelativePath);
				template = template.replace(tagBaseName + "Extension", imageObj.Extension);
			}
		}
		else if(dataBridgeObject.DataObjects[i].DataType == "File")
		{
			var fileObj = dataRow[dataBridgeObject.DataObjects[i].ColumnIndex].parseJSON(); 			
			if(fileObj != null)
			{
				var fileTxt = UIControls.FileUpload.GetFileDisplay(fileObj, ""); 

				var tagBaseName = parentName + "___" + level + dataBridgeObject.DataObjects[i].Name; 			
				template = template.replace(tagBaseName, fileTxt);
			}
		}
		else
		{
			if(dataBridgeObject.DataObjects[i].ColumnIndex != -1)
			{
				var tagName = parentName + "___" + level + dataBridgeObject.DataObjects[i].Name; 
				template = template.replace(tagName, dataRow[dataBridgeObject.DataObjects[i].ColumnIndex]);
			}		
		}
	}
	
	return template; 
}; 



//--- \ui\Address.Control.js

UIControls_High.Address = function(id, container)
{	
	var address1Span 	= document.createElement("div");
	var address2Span 	= document.createElement("div");	
	
	container.appendChild(address1Span);
	container.appendChild(address2Span);
	
	address1Span.style.marginBottom = "5";
	address2Span.style.marginBottom = "5";

	var t1 = new Table(2,3);
	var spanStart = "<span class='error'>* </span><b>";
	
	t1.cell(0,0).innerHTML = spanStart + "City</b>";
	t1.cell(0,1).innerHTML = spanStart + "State</b>";
	t1.cell(0,2).innerHTML = spanStart + "Zip</b>";

	t1.cell(1,0).innerHTML = "<span id='" + id + "_citySpan'></span>";
	t1.cell(1,1).innerHTML = "<span id='" + id + "_stateSpan'></span>";
	t1.cell(1,2).innerHTML = "<span id='" + id + "_zipSpan'></span>";
	
	t1.table.cellPadding = 0; 
	t1.table.cellSpacing = 0; 
	
	container.appendChild(t1.table);
	
	var dataSet = function(){}; 
	dataSet.Address1 		= new UIControls.Text("Address1_" + id, address1Span); 
	dataSet.Address1.Label 	= "Address 1";
	dataSet.Address1.Required = true; 
	dataSet.Address2 		= new UIControls.Text("Address2_" + id, address2Span); 
	dataSet.Address2.Label 	= "Address 2";
	dataSet.City 			= new UIControls.Text("City_" 	+ id, $(id + "_citySpan")); 
	dataSet.City.Label = "City";
	dataSet.City.DisplayLabel = false;
	dataSet.State 			= new UIControls.StateControl("State_" 	+ id, $(id + "_stateSpan")); 
	dataSet.State.Label = "State";
	dataSet.State.DisplayLabel = false;
	dataSet.Zip				= new UIControls.ZipCodeControl("Zip_" 	+ id, $(id + "_zipSpan")); 
	dataSet.Zip.Label = "Zip";
	dataSet.Zip.DisplayLabel = false;
	
	
	dataSet.Address1._validateF = function(){ return this.GetValue().length > 0; };
	dataSet.Address1.ValidationErrorTxt = "Cannot be empty";
	dataSet.Address1.ValidationErrorWriteOut = true; 
	dataSet.City._validateF = function(){ return this.GetValue().length > 0; };
	dataSet.City.ValidationErrorTxt = "Cannot be empty";
	
	var getValueF = function() 
	{
		var returnObj = new Object();
		
		returnObj.Address1 	= this.GetDataSet().Address1.GetValue();
		returnObj.Address2 	= this.GetDataSet().Address2.GetValue();
		returnObj.City 		= this.GetDataSet().City.GetValue();
		returnObj.State 	= this.GetDataSet().State.GetValue();
		returnObj.Zip 		= this.GetDataSet().Zip.GetValue();
				
		return returnObj;
	};
	
	var setValueF = function(valueToSet) 
	{ 
		if(valueToSet.Address1 == null) //Assume is a JSON string
		{
			valueToSet = valueToSet.parseJSON();
			
			if(!valueToSet)
			{
				Throw("Error parsing passed address in UIControls.High.js"); 
			}
		}
		
		this.GetDataSet().Address1.SetValue(valueToSet.Address1);
		this.GetDataSet().Address2.SetValue(valueToSet.Address2);
		this.GetDataSet().City.SetValue(valueToSet.City);
		this.GetDataSet().State.SetValue(valueToSet.State);
		this.GetDataSet().Zip.SetValue(valueToSet.Zip);
	};
	
	var renderF = function(defaultValue) 
	{ 
		this.GetDataSet().Address1.Render(); 
		this.GetDataSet().Address2.Render(); 
		this.GetDataSet().City.Render(); 
		this.GetDataSet().State.Render(); 
		this.GetDataSet().Zip.Render(); 
		
		return null; 
	};
		
	dataObject = new IDataControl(id, container, null, dataSet, getValueF, setValueF, renderF);			
	
	dataObject.SetValueFromDataRow = function(array, startValue) 
	{ 
		//Address1
		//Address2 
		//City 
		//State 
		//Zip
		
		this.GetDataSet().Address1.SetValue(array[startValue]);
		this.GetDataSet().Address2.SetValue(array[startValue + 1]);
		this.GetDataSet().City.SetValue(array[startValue + 2]);
		this.GetDataSet().State.SetValue(array[startValue + 3]);
		this.GetDataSet().Zip.SetValue(array[startValue + 4]);
	};
	
	dataObject._disableF = function()
	{
		this.GetDataSet().Address1.Disable(); 
		this.GetDataSet().Address2.Disable(); 
		this.GetDataSet().City.Disable(); 
		this.GetDataSet().State.Disable(); 
		this.GetDataSet().Zip.Disable(); 
		
		return null; 
	}
	
	dataObject._enableF = function()
	{
		this.GetDataSet().Address1.Enable(); 
		this.GetDataSet().Address2.Enable(); 
		this.GetDataSet().City.Enable(); 
		this.GetDataSet().State.Enable(); 
		this.GetDataSet().Zip.Enable(); 
		
		return null; 
	}
	
	dataObject._getURIFormat = function()
	{
		return this.GetDataSet().Address1.GetURIFormat() + "&" +  
		this.GetDataSet().Address2.GetURIFormat() + "&" + 
		this.GetDataSet().City.GetURIFormat() + "&" + 
		this.GetDataSet().State.GetURIFormat() + "&" + 
		this.GetDataSet().Zip.GetURIFormat();  
	};
	
	dataObject._validateF = function()
	{
	    var returnVal = true; 
	    returnVal = this.GetDataSet().Address1.Validate() && returnVal; 
		returnVal = this.GetDataSet().Address2.Validate() && returnVal;
		returnVal = this.GetDataSet().City.Validate() && returnVal; 
		returnVal = this.GetDataSet().State.Validate() && returnVal; 
		returnVal = this.GetDataSet().Zip.Validate() && returnVal; 
		
		return returnVal; 
	};
	
	return dataObject; 
}



//--- \ui\Contact.Control.js

UIControls_High.Contact = function(id, container)
{	
    var t1 = new Table(3,1);
	
	t1.cell(0,0).innerHTML = "<div id='" + id + "_phoneSpan' style='padding-bottom:5px;'></div>";
	t1.cell(1,0).innerHTML = "<div id='" + id + "_emailSpan' style='padding-bottom:5px;'></div>";
	t1.cell(2,0).innerHTML = "<div id='" + id + "_addressSpan' style='padding-bottom:5px;'></div>";
	
	t1.table.cellPadding = 0; 
	t1.table.cellSpacing = 0; 
	
	container.appendChild(t1.table);
	
	var dataSet = function(){}; 
	dataSet.Phone 	= new UIControls.PhoneControl("Phone_" + id, $(id + "_phoneSpan")); 
	dataSet.Phone.Label = "Phone:";
	dataSet.Email 	= new UIControls.EmailControl("Email_" + id, $(id + "_emailSpan")); 
	dataSet.Email.Label = "Email:";
	dataSet.Email.Required = true; 
	dataSet.Address = new UIControls_High.Address("Address_" + id, $(id + "_addressSpan")); 

	var getValueF = function() 
	{
		var returnObj = new Object();
		
		returnObj.Address 	= this.GetDataSet().Address.GetValue();
		returnObj.Phone 	= this.GetDataSet().Phone.GetValue();
		returnObj.Email 	= this.GetDataSet().Email.GetValue();
				
		return returnObj;
	};
		
	var setValueF = function(valueToSet) 
	{ 
	};
	
	var renderF = function(defaultValue) 
	{ 
		this.GetDataSet().Phone.Render(); 		
		this.GetDataSet().Email.Render(); 		
		this.GetDataSet().Address.Render(); 		
		return null; 
	};
		
	var dataObject = new IDataControl(id, container, null, dataSet, getValueF, setValueF, renderF);			
	
	//For full data rows, this will allow the data to be tranfered.
	dataObject.SetValueFromDataRow = function(array, startValue) 
	{ 	
		this.GetDataSet().Phone.SetValue(array[startValue]);
		this.GetDataSet().Email.SetValue(array[startValue + 1]);
		this.GetDataSet().Address.SetValueFromDataRow(array, startValue + 2); 
	};

	dataObject._disableF = function()
	{		
		return null; 
	}
	
	dataObject._enableF = function()
	{
		return null; 
	}
	
	dataObject._getURIFormat = function()
	{
		return this.GetDataSet().Phone.GetURIFormat() + "&" +  
		this.GetDataSet().Email.GetURIFormat() + "&" + 
		this.GetDataSet().Address.GetURIFormat(); 
	};
	
	dataObject._validateF = function()
	{
	    var returnVal = true; 
	    returnVal = this.GetDataSet().Phone.Validate() && returnVal; 
		returnVal = this.GetDataSet().Email.Validate() && returnVal;
		returnVal = this.GetDataSet().Address.Validate() && returnVal; 
		
		return returnVal; 
	};
	
	return dataObject; 
}



//--- \ui\PhotoGallery.Control.js
//http://localhost:2033/server/ServerData/FILES/trloveland@xactware.com/Gallery/thumbs/iStock_000002117034.jpg
//http://localhost:2033/server/ServerData/FILES/trloveland@xactware.com/Gallery/thumbs/iStock_000003197996Medium.jpg

/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.PhotoGallery = function(id, container, movieSizeInPixels, xmlFile)
{	
	if(!movieSizeInPixels) movieSizeInPixels = 800; 
	var getValueF = function() 
	{
		return "";
	};
	
	var setValueF = function(valueToSet) 
	{ 
		//Set the xml file
		//$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 
		var funToCall = this.GetSelfReferenceString() + '.SetMovieXML(\'' + this._xmlFile + '\');'; 
		this.loadEvent = window.setInterval(
			function()
			{
				eval(funToCall); 
			}
		, 300);
		
		var returnVal = '' + 			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + movieSizeInPixels + '" height="' + movieSizeInPixels + '" id="' + id + '" align="middle">' + 
				'<param name="allowScriptAccess" value="always" />' + 				'<param name="movie" value="PhotoGallery.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="PhotoGallery.swf" quality="high" bgcolor="#ffffff" width="' + movieSizeInPixels + '" height="' + movieSizeInPixels + '" name="' + id + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' + 
			'</object>' + 
		''; 
		
		return returnVal; 
	};

	var returnControl = new IDataControl(id, container, null, null, getValueF, setValueF, renderF);
	returnControl._xmlFile = xmlFile; 	
	returnControl.SetMovieXML = function(xmlFile)
	{
		var movie = GetMovieName(this._recordId); 
		if(movie)
		{
			if(movie.ResetGallery)
			{
				movie.ResetGallery(xmlFile);	
				window.clearTimeout(this.loadEvent); 
			}
    	}
    	else
    	{
			alert("Flash Photo Gallery not loaded, PhotoGallery.Control.js:SetMovieXML");     		
    	}
	};
	
	return returnControl; 
}

function GetMovieName(movieName)
{
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		return window[movieName]
	}
	else
	{
		return document[movieName]
	}
}	
    


//--- \ui\ShoppingCart.Control.js
/**************************************************************
//HTML Text control
/**************************************************************/
UIControls.ShoppingCart = function(id, container, masterTemplate, itemRenderer, prms)
{	
	var dataSet = function(){}; 
	dataSet.Options = new Array(); 
	
	var getValueF = function() 
	{
		return $F(this._recordId); 
	};
	
	var setValueF = function(valueToSet) 
	{ 
		$(this._recordId).value = valueToSet; 
	};
	
	var renderF = function(defaultValue) 
	{ 	
		var itemsHTML = ""; 
		for(var i = 0; i < this._items.length; i++)
		{
			if(this._items[i].Quantity != 0)
			{
				itemsHTML += this.ItemRenderer(this._items[i], i); 
			}
		}
		
		if(this._container)
		{
			$(this._container).innerHTML = returnObj.MasterTemplate.Content;
		}	
		
		$("ShoppingCartContents").innerHTML = itemsHTML; 		
		$("ShoppingCartSubTotal").innerHTML = this.GetSubTotal(); 
		
		return null;
	};

	var returnObj = new IDataControl(id, container, prms, dataSet, getValueF, setValueF, renderF);
	returnObj.MasterTemplate = masterTemplate; 
	returnObj.ItemRenderer = itemRenderer; 
	returnObj._items = new Array(); 
	
	returnObj.AddItem = function(itemObj)
	{
		for(var i = 0; i < this._items.length; i++)
		{
			if(this._items[i].Id == itemObj.Id)
			{
				this._items[i].Quantity++; 
				return; 
			}
		}
		
		returnObj._items[returnObj._items.length] = itemObj; 	
	};
	
	returnObj.GetSubTotal = function()
	{
		var subTotal = 0; 
		for(var i = 0; i < this._items.length; i++)
		{
			subTotal += this._items[i].GetTotal(); 
		}
		
		return subTotal; 
	};

	returnObj.UpdateQuantity = function()
	{
		for(var i = 0; i < this._items.length; i++)
		{
			if($("ShoppingItem_index" + i))
			{
				this._items[i].Quantity = $F("ShoppingItem_index" + i); 
			}
			else
			{
				this._items[i].Quantity = 0; 
			}
		}
		
		this.Render(); 
	}
	
	returnObj.SetQuantity = function(id, newQnty)
	{
		this._items[id].Quantity = newQnty;
	}
	
	returnObj.Checkout = function()
	{
		alert("checkout code here!"); 
	};
	
	return returnObj; 
};

UIControls.ShoppingCart.Item = function(id, details, unitPrice, quantity)
{
	this.Id = id; 
	this.Details = details; 
	this.UnitPrice = unitPrice; 
	this.Quantity = quantity; 
	this.GetTotal = function()
	{
		return this.UnitPrice * this.Quantity; 
	}
};


//--- \ui\Layout.js
var curLayoutLoading = ""; 
//Caching Article online: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

//Setup initial container for dhtml
//document.body.innerHTML = "<span id='dhtmlHistoryContainer' style='display:none'></span>"; 
function LayoutLoadFail(obj)
{
	Error.DebugWrite("Loading " + curLayoutLoading + " Failed: <br />" + obj.responseText);
}

function DataBridgeLayout(layoutName, pageURL)
{
	var returnObj = new Layout(layoutName, pageURL, false); 
	returnObj.IsDataBridgeDefinition = true; 

	return returnObj; 
}

function Layout(layoutName, pageURL, setBody, dataBridgeLayoutName)
{
	curLayoutLoading = pageURL; 
	this.PageURL = pageURL; 
	this.Content = null; 
	this.TopNavOffset = 140; 
	this.CenterNavOffset = 46; 
	this.CrumbHeight = 29; 
	this.LayoutName = layoutName; 
	this.Loaded = false; 
	this.Loading = false; 
	this.DataBridge;
	this.IsDataBridgeDefinition = false; 
	this.DataBridgeLayoutName = dataBridgeLayoutName; 
	this.DataBridgeLayout = null; //dataBridgeLayout; 	
	this.EditorForm = null; 
	
	if(setBody == null)
	{
		this.SetBody = false; 
	}
	else
	{
		this.SetBody = setBody; 	
	}
	
	this.PageURL = pageURL; 
	var _this = this; 
	
	this.RenderEditor = function(container, onSave, onCancel)
	{
		var thisLayout = _this; 
		if(this.DataBridgeLayout == null)
		{
			Error.DebugWrite("Attempting to call Layout.RenderEditor for " + this.LayoutName + " when DataBridgeLayout is null.<hr />");							
			return; 
		}	
					
		if(this.EditorForm == null)
		{
			this.EditorForm = new HtmlForm.Control(this.LayoutName + "_FormAdd"); 
		}
		
		this.EditorForm.SetDataBridgeObject(this.DataBridgeLayout.DataBridge); 
		this.EditorForm.SaveOverride = function()
		{
			//alert(_this.EditorForm.GetJSONString()); 

			var validateErrors = this.Validate(); 
			if(validateErrors == "")
			{			
				var commandTxt = "save";
				
				var sendParams = "contentVal=" + Globals.UrlEncode(this.GetJSONString()) + "&PageUrl=" + thisLayout.PageURL; 
				var serverData = new ServerData.SenderObject(commandTxt, null, Globals.Location.ASHX.Content, sendParams);             
				Globals.ShowSpinner("MiddleBody", "Saving data...")    
				
				serverData.SendData(
					function(results)
					{
						_this.Render(
						function()
						{
							if(_this.EditorForm._onFormSaveComplete != null)
							{
								if(typeof _this.EditorForm._onFormSaveComplete == 'function')
								{
									_this.EditorForm._onFormSaveComplete(this.ReturnObject); 
								}
								else
								{
									eval(_this.EditorForm._onFormSaveComplete);
								}
							}
							else
							{
								if(typeof _this.EditorForm._onFormComplete == 'function')
								{
									_this.EditorForm._onFormComplete(this.ReturnObject); 
								}
								else
								{
									eval(_this.EditorForm._onFormComplete);
								}
							}
							
							_this.EditorForm = null; 
						});
					}
				); 					
			}
			else
			{
				alert(validateErrors); 			
			}		
		};
		
		this.EditorForm.Render(container, null, onCancel); 				
		
		var dataObj = _this.Content.parseJSON();
		var i = 0; 
		for(var x in dataObj)
		{
			if(dataObj[x].Value)
			{
				//There is extra data stored in the data file. This can happen if a field is removed. 
				if(i < this.EditorForm._objectArray.length)
				{
					this.EditorForm._objectArray[i].SetValue(dataObj[x].Value);
				}
				i++; 
			}
		}			
	};
	
	this.GetDatabridgeMergedContent = function()
	{
		if(!this.SetupDataBridgeLayout()){return ;}
		var content = this.DataBridgeLayout.Content; 
		
		var dataObj = _this.Content.parseJSON();
		var i = 0; 
		
		var d = document.createElement('div'); 
		d.innerHTML = this.DataBridgeLayout.Content; 
						
		for(var x in dataObj)
		{
			if(dataObj[x].Value)
			{				
				//alert(dataObj[x].Name); 
				
				for(var j = 0; j < d.all.length; j++)
				{
					var ele = d.all[j];
					if(ele.getAttribute("id") == dataObj[x].Name && this.NotSpecialTag(dataObj[x].Name))
					{
						switch(ele.getAttribute("dbridge_type").toLowerCase())
						{
							case "richtext":
							{							
								ele.innerHTML = Globals.UrlDecode(dataObj[x].Value); 
								break; 
							}
							default:
							{
								ele.innerHTML = Globals.HtmlEscape(Globals.UrlDecode(dataObj[x].Value)); 								
							}
						}
					}
				}
				i++; 
			}
		}						
		
		return d.innerHTML; 
	}
	
	this.SetupDataBridgeLayout = function()
	{
		if(this.DataBridgeLayout == null)
		{
			if(this.DataBridgeLayoutName != null && this.DataBridgeLayoutName != "")
			{
				this.DataBridgeLayout = Layouts.Get(this.DataBridgeLayoutName); 
				if(this.DataBridgeLayout == null)
				{
					Error.DebugWrite("Attempting to call Layout.SetupDataBridgeLayout for " + this.LayoutName + " when Layouts.Get(" + 
					this.DataBridgeLayoutName + ") returns null.<hr />");							
					return false; 
				}
			}
			else
			{			
				Error.DebugWrite("Attempting to call Layout.SetupDataBridgeLayout for " + this.LayoutName + " when DataBridgeLayout is null.<hr />");							
				return false; 
			}
		}	
		
		return true; 
	};
	
	this.GetAttribute = function(attributeToGet)
	{
		//this.SetupDataBridgeLayout(); 
	
		var dataObj = _this.Content.parseJSON();
		for(var x in dataObj)
		{
			if(dataObj[x].Value)
			{				
				if(dataObj[x].Name.toLowerCase() == attributeToGet.toLowerCase())
				{
					return dataObj[x].Value; 
				}				
			}
		}
	}
			
	this.NotSpecialTag = function(tagName)
	{
		switch(tagName.toLowerCase())
		{
			case "pagecategory":
			case "pagemaintitle":
			{
				return false; 
				break; 
			}
			default:
			{
				return true; 
			}
		}
	}
	
    this.Render = function(returnFunction)
    {    	
		this.ReturnFunction = returnFunction; 
        var myAjax = new Ajax.Request(
	            this.PageURL, 
	            {
		            method: "get", 
		            parameters: "",
		            requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
		            onComplete: function(req){_this.ParseReturn(req);}//,
		            //onException: LayoutLoadFail,
		            //onFailure: LayoutLoadFail
	            });
        
        return myAjax;  
    };
    
    this.ParseReturn = function(req)
    {       	
    	this.Content = req.responseText; 
		if(this.SetBody)
		{
			document.body.innerHTML = this.Content + "<span id='dhtmlHistoryContainer' style='display:none'></span>"; 
		}
		
		if(this.IsDataBridgeDefinition)
		{
			this.ParseDatabridgeObjFromTemplate(this.Content); 
		}
		
		this.Loaded = true; 		
		if(this.ReturnFunction != null)
		{
			this.ReturnFunction(); 
		}		
   };    
   
   this.ParseDatabridgeObjFromTemplate = function(templateHtml)
   {
		//this.SetupDataBridgeLayout(); 
   
		var d = document.createElement('div'); 
		d.innerHTML = this.Content; 
		
		for(var i = 0; i < d.all.length; i++)
		{
		    var ele = d.all[i];
		    var thisType = ele.getAttribute("dbridge_type"); 
		    if(thisType != null)
		    {
				if(!this.DataBridge)
				{
					this.DataBridge = new DataBridge(this.LayoutName); 
				}
				var thisDataBrigeObject = new DataBridgeObject(ele.getAttribute("dbridge_name"), ele.getAttribute("dbridge_name"), thisType);
				var returnUIControl = UIControls.GetControlFromDataBridgeObjAux(thisDataBrigeObject, null);         	   

				//Using one place to verify that the databridge is an active type. Here, the UI knows which are true types
				if(!returnUIControl)
				{
					Error.DebugWrite("Parsing databridge template failed for: <b>" + this.PageURL + 
					"</b><br />Type '<i>" + thisType + 
					"</i>' not defined. <br /><br /><div id='errorHtmlText_" + i + 
					"'></div><br /><br /><hr />");					
					
					$("errorHtmlText_" + i).innerText = this.Content; 
				}
				else //Setup all other attributes
				{					
					thisDataBrigeObject.Name							= ele.getAttribute("id");
					thisDataBrigeObject.DisplayName 					= ele.getAttribute("id");
					thisDataBrigeObject.DisplayName						= this.GetDataBridgeAttribute(ele, "DisplayName", thisDataBrigeObject.DisplayName);
					thisDataBrigeObject.DataType 						= this.GetDataBridgeAttribute(ele, "DataType", thisDataBrigeObject.DataType);
					thisDataBrigeObject.DataTypeHigh					= this.GetDataBridgeAttribute(ele, "DataTypeHigh", thisDataBrigeObject.DataTypeHigh);
					thisDataBrigeObject.JavascriptValidationFunction	= this.GetDataBridgeAttribute(ele, "JavascriptValidationFunction", thisDataBrigeObject.JavascriptValidationFunction);
					thisDataBrigeObject.ValidationErrorText				= this.GetDataBridgeAttribute(ele, "ValidationErrorText", thisDataBrigeObject.ValidationErrorText);
					thisDataBrigeObject.WriteValidationError			= this.GetDataBridgeAttribute(ele, "WriteValidationError", thisDataBrigeObject.WriteValidationError);
					thisDataBrigeObject.Key								= this.GetDataBridgeAttribute(ele, "Key", thisDataBrigeObject.Key);
					thisDataBrigeObject.GridVisible						= this.GetDataBridgeAttribute(ele, "GridVisible", thisDataBrigeObject.GridVisible);
					thisDataBrigeObject.Editable						= this.GetDataBridgeAttribute(ele, "Editable", thisDataBrigeObject.Editable);
					thisDataBrigeObject.MaxLength						= this.GetDataBridgeAttribute(ele, "MaxLength", thisDataBrigeObject.MaxLength);
					thisDataBrigeObject.Style 							= this.GetDataBridgeAttribute(ele, "Style", thisDataBrigeObject.Style);
					thisDataBrigeObject.Required 						= this.GetDataBridgeAttribute(ele, "Required", thisDataBrigeObject.Required);				
					this.DataBridge.Add(thisDataBrigeObject); 
				}
			}		
		}		
   };
   
   this.GetDataBridgeAttribute = function(ele, attribute, oldValue)
   {   
   		//Don't change the value unless a valid value is presentl
		if(ele.getAttribute("dbridge_" + attribute.toLowerCase()) != null)
		{
			return ele.getAttribute("dbridge_" + attribute.toLowerCase()); 
		}
		
		return oldValue; 
   };
}

var Layouts = function(){}; 
Layouts._listOfLayouts = new Array(); 
Layouts._onLoadComplete = null; 
Layouts.Loaded = function(layoutName)
{
	for(var i = 0; i < Layouts._listOfLayouts.length; i++)
	{
		if(layoutName == Layouts._listOfLayouts[i].LayoutName)
		{
			return Layouts._listOfLayouts[i].Loaded; 
		}
	}

	return false; 
};
	
Layouts.Get = function(layoutName)
{
	for(var i = 0; i < Layouts._listOfLayouts.length; i++)
	{
		if(layoutName == Layouts._listOfLayouts[i].LayoutName)
		{
			return Layouts._listOfLayouts[i]; 
		}
	}

	return null; 
};
	
Layouts.AddURL = function(layoutName, urlToQueue, dataBridgeLayoutName)
{
	if(Layouts.Get(layoutName) == null)
	{
		Layouts._listOfLayouts[Layouts._listOfLayouts.length] = new Layout(layoutName, urlToQueue, false, dataBridgeLayoutName); 
	}
};

Layouts.AddDataBridgeURL = function(layoutName, urlToQueue)
{
	if(Layouts.Get(layoutName) == null)
	{
		Layouts._listOfLayouts[Layouts._listOfLayouts.length] = new DataBridgeLayout(layoutName, urlToQueue, false); 
	}
};

Layouts.AddLayout = function(layoutToQueue)
{
	if(Layouts.Get(layoutToQueue.LayoutName) == null)
	{
		Layouts._listOfLayouts[Layouts._listOfLayouts.length] = layoutToQueue; 
	}
};

Layouts.LoadAllAsync = function()
{
	for(var i = 0; i < Layouts._listOfLayouts.length; i++)
	{
		if(!Layouts._listOfLayouts[i].Loaded && !Layouts._listOfLayouts[i].Loading)
		{
			Layouts._listOfLayouts[i].Loading = true; 
			Layouts._listOfLayouts[i].Render();
		}
	}
};

Layouts.LayoutLoaded = function(layoutName)
{
	/*
	for(var i = 0; i < Layouts._listOfLayouts.length; i++)
	{
		if(layoutName == Layouts._listOfLayouts[i].LayoutName)
		{
			Layouts._listOfLayouts[i].Loaded = true; 
		}
	}
	*/
};

Layouts.IsLayoutLoaded = function(layoutName)
{
	for(var i = 0; i < Layouts._listOfLayouts.length; i++)
	{
		if(layoutName == Layouts._listOfLayouts[i].LayoutName)
		{
			return Layouts._listOfLayouts[i].Loaded; 
		}
	}

	return false; 
};

Layouts.LoadAll = function(onLoadComplete)
{
	this._onLoadComplete = onLoadComplete; 
	//Code to load each layout with a total count, updating the total count
	//and calling external event for each one that is loaded so UI can update.
};


