FLLogin = new function(){
    this.Submit = function(){
    
        if (f.GetValue('FLpassword')=='' || f.GetValue('FLEmail')==''){
            alert('please enter your email and password');
            return;
        }
    
        var frmFL = document.getElementById('frmFL');
        document.frmFL.Email.value = f.GetValue('FLEmail');
        document.frmFL.Password.value = f.GetValue('FLpassword');
        document.frmFL.submit();
    }
}


function ButtonPostBack(oButton) {      
    oButton.disabled=true;
    Postback(oButton.id,'');
}

function Postback(sCommand, sArgument, bCheckDelete) {

	//confirm delete if required	
	if (bCheckDelete==true) {
		if (confirm('Are you sure that you want to delete this record?')==false) {
			return;
		}
	}
	
//	if (typeof(oWYSIWYG)!='undefined') {
//		TidyXHTML();
//	}
	
	document.forms[0].Command.value=sCommand;
	document.forms[0].Argument.value=sArgument;
	document.forms[0].submit();
}


function ClearSelection(oList) {
	document.getElementById('hid'+oList.name).value='';
}

function DropDownSelect(oList, oEvent, sAutoPostBack) {
				
	var oStoreKeyPress=document.getElementById('hid'+oList.name);
	
	if ((oEvent.keyCode==13)&&(sAutoPostBack!='true')) {
		return;
	} else if ((oEvent.keyCode==13)&&(sAutoPostBack=='true')) {
		Postback(oList.name,'')
	} else if (oEvent.keyCode!=27) {
		oStoreKeyPress.value=oStoreKeyPress.value+String.fromCharCode(oEvent.keyCode);
	} else {
		oStoreKeyPress.value='';
	}
	
	//find it
	SelectItemFromSearch(oList, oStoreKeyPress.value);
	return false;

}




//Form Handler Functions
var FormHandler = new function() {

    var me = this;
    this.MessageBoxEvent;
    
    
    //show a message
    this.BuildMessage = function (oMessages, sClass) {
        
        // build and add the div
        if (!f.GetObject('divInfo')) {

            var oInfo = document.createElement('div');
            oInfo.setAttribute('id', 'divInfo');
            f.SetClass(oInfo, sClass);
            
            var oFirstChild = f.GetObject('divContentHolder').childNodes[0];
            if (oFirstChild == null) return;

            f.GetObject('divContentHolder').insertBefore(oInfo, oFirstChild);
        } else {
            f.SetClass('divInfo', sClass);
        }

        
        //get array (either passed in, in which case use it, or make it)
        var aMessages;
        if (oMessages.constructor == Array) {
            aMessages = oMessages;
        } else {
            var aMessages = new Array;
            aMessages.push(oMessages);
        }


        //set messages
        f.SetHTML('divInfo', f.BuildList(aMessages));

        //add header
        var oHeader = document.createElement('div');
        oHeader.setAttribute('id', 'divInfoHeader');
        f.GetObject('divInfo').appendChild(oHeader);

        //add close
        var aClose = document.createElement('a');
        f.AttachEvent(aClose, 'click', function() { FormHandler.CloseInfo() });
        aClose.setAttribute('href', '#');
        aClose.setAttribute('id', 'aCloseInfo');
        f.SetHTML('aCloseInfo', 'close');
        f.GetObject('divInfo').appendChild(aClose);

        //add footer
        var oFooter = document.createElement('div');
        oFooter.setAttribute('id', 'divInfoFooter');
        f.GetObject('divInfo').appendChild(oFooter);

        me.MessageBoxEvent = f.AttachEvent(document, 'keypress',
		        function(event) {
		            if (f.GetKeyCodeFromEvent(event) == 27) {
		                f.DetachEvent(me.MessageBoxEvent);
		                me.CloseInfo();
		            }
		        });

        window.location = '#';
    }
    
    
    //show warning
    this.ShowWarning = function(sWarnings) {
        var aWarnings = sWarnings.split('|');
        me.BuildMessage(aWarnings, 'warning')
    }



    //show information
    this.ShowInformation = function(sInformation) {
        var aInformation = sInformation.split('|');
        me.BuildMessage(aInformation, 'information')
    }


    //CloseInfo
    this.CloseInfo = function() {

        if (f.GetObject('divInfo')) {
            f.GetObject('divInfo').parentNode.removeChild(f.GetObject('divInfo'));
        }
    }


}
