var lf = {
	
	version: 1.1,
	

	
	
	
	/**
	 * returns or gives you the html to display a nice progress bar
	 *
	 *	arguments = array (
			barStyle - int - [1,2]
			element - string or boject - element to fill with progress content
	 )
	 *
	 * @param array args
	 *
	 * @returns string
	 */
	progresBarDiv: function(args) {
		
		//set any defaults propties for args
		args = this.defaultObjectProperties(args,{
			style: 		1,
			element: 	false
		});
		
		var image = '';
		switch(args.style) {
			case 2:
				image = 'progress_main.gif';
				break;
			default:
				image = 'progress.gif';
				break;
		}
		
		var progress = "<div class='wrapper-progress-bar'><img src='/images/" + image + "' /></div>";
		
		if(args.element) {
			lf.element.get(args.element).innerHTML = progress;
		}
		
		return progress;
	},
	
	/**
	 * used to setup the default properties on any object
	 * which is helpfull when you are passing an object to a method
	 * and you need some default values
	 *
	 * the first object will have all properties the second object does
	 * by the time it is returned
	 *
	 * @param object obj
	 * @param object args - essentially an assoc array with the propeties you want the first object to have
	 *
	 * @returns object
	 */
	defaultObjectProperties: function(obj, args) {
		
		//if obj is not an object, make it one
		if(!this.isObject(obj)) {
			obj = {};
		}
		
		for(var prop in args) {
			if(this.isUndefined(obj[prop])) {
				obj[prop] = args[prop];
			}
		}
		
		return obj;
		
	},
	
	/**
	 * used with firebug, outputs a string to the console (works in safari as well)
	 *
	 * @param string string
	 */
	trace:function(string) {
		if(console && console.log) {
			console.log(string);
		}
	},
	
	/**
	 * Convenience method to mimic the functionality of foreach in php
	 *
	 * @param array arr - array or object you are passing
	 * @param function fnc - the function that is called each iteration, it must accept an arg that is the value of the current iteration
	 * @param scop object - option - if instance of object, the function will be called from this scope
	 */
	foreach:function(arr, fnc, scope) {
		
		if(lf.isArray(arr)) {
			for(var c=0;c<arr.length;c++) {
				if(scope) {
					fnc.call(scope, arr[c]);
				} else {
					fnc(arr[c]);
				}
			}
		} else if(lf.isObject(arr)) {
			for(var prop in arr) {
				if(scope) {
					fnc.call(scope, arr[prop]);
				} else {
					fnc(arr[prop]);
				}
			}
		}
	},
	
	/**
	 * Basic async request (ajax)
	 *
	 * @param string url - the url to post/get to
	 * @param object callback - callback.success is called when the call is done, it can accept the xmlhttprequest object
	 * @param string postData - additional query string of information to be submitted as well
	 * @param string method - "GET" || "POST" (default is POST)
	 */
	asyncRequest: function(url, callback, postData, method) {
		return YAHOO.util.Connect.asyncRequest(method || "POST", url, callback || {}, postData || '');
	},
	
	/**
	 * creates a query string from the passed form and then calls asyncrequest
	 * @param string url - where to post the form to
	 * @param domelement form - the form you want to submit
	 * @param object callback - any function that will accept the xmlhttprequest object.
	 * @param string method - "GET" || "POST" (default is same as asynRequest)
	 */
	submitForm:function(url, form, callback, method) {
		YAHOO.util.Connect.setForm(form);
		callback.form = form;
		this.asyncRequest(url,callback,'',method);
	},
	
	/**
	 * Takes any form and creates a query string of data from it
	 *
	 * @param domelement form - the form you want the data from
	 *
	 * @returns string
	 */
	formQueryString: function(form) {
		var queryString = YAHOO.util.Connect.setForm(form);
		YAHOO.util.Connect.resetFormState();
		
		return queryString;
	},
	
	/**
	 * Updates the contents of a div with the results of a call
	 *
	 * @param string or object - reference to the element that will be populated
	 * @param string url - url that is going to be called
	 * @param object callback - callback.success is called when everything is done
	 * @param string method - "POST" || "GET" (default POST)
	 */
	asyncUpdate: function(container, url, callback, postData, method) {
	
		var thisCallback = {
			callback: 	callback,
			container:	container,
			success: 	function(r) {
								
				lf.element.get(this.container).innerHTML = r.responseText;
				
				if(this.callback) {
					var scope = this.callback.scope;
					if(scope) {
						this.callback.success.call(scope,r);
					} else {
						this.callback.success(r);
					}
				}
			}
		};
		
		this.asyncRequest(url,thisCallback,postData,method);
	},
	
	isArray: function(obj) {
		return YAHOO.lang.isArray(obj);
	},
	
	isObject: function(obj) {
		return YAHOO.lang.isObject(obj);	
	},
	
	isBool: function(obj) {
		return YAHOO.lang.isBoolean(obj);
	},
	
	isUndefined: function(obj) {
		return YAHOO.lang.isUndefined(obj);
	}
	
	
	
}

lf.userAgent = {
	isWebKit: function() {
		return /Konqueror|Safari|KHTML/.test( navigator.userAgent );
	},
	
	isIe: function() {
		return /MSIE/.test( navigator.userAgent );
	},
	
	isOpera: function() {
		return /Opera/.test( navigator.userAgent );
	},
	
	isFirefox: function() {
		return /Firefox/.test( navigator.userAgent );
	}
}


