// JavaScript Document
jQuery.fn.exists = function(){return jQuery(this).length>0;}

jQuery(document).ready(function($) {
	
	/*************************************************************************
	*             FONT FACE FIX
	*             If firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUC
	*************************************************************************/
	
	var d = document, e = d.documentElement, s = d.createElement('style');
	if ($.browser.mozilla && e.style.MozTransform === '') // gecko 1.9.1 inference
	{ 
		s.textContent = 'body{visibility:hidden}';
		e.firstChild.appendChild(s);
		function f(){ s.parentNode && s.parentNode.removeChild(s); }
		addEventListener('load',f,false);
		setTimeout(f,1); 
		setTimeout(f,100); 
		setTimeout(f,250); 
		setTimeout(f,500); 
	}
	
	/************************************************************************/

								
	$.fn.emptySelect = function(optionsDataArray){
		return this.each(function(){
			if(this.tagName =='SELECT') this.options.length = 0;							
		});
	};
	
	$.fn.loadSelect = function(optionsDataArray){
		return this.emptySelect().each(function(){
			if(this.tagName == "SELECT") 
			{
				var selectElement = this;
				$.each(optionsDataArray, function(index, optionData) {
					if(optionData)
					{
						var option = new Option(optionData.caption,optionData.value,optionData.selected);
						if($.browser.msie)
							selectElement.add(option);
						else
							selectElement.add(option, null);
					}
				});
				
			}
		});
	};
	
	$("input, textarea").live('focus', function(){
		if($(this).val() == $(this).attr('title'))
			$(this).val('');
	}).live('blur', function(){
		if($(this).val() == '')
			$(this).val($(this).attr('title'));
	});
	
	//$(".content-section:containts(&bull;)").
	if($.browser.msie && $.browser.version < 8) {
		$('.submenu').each(function(){
			if($(this).children().length == 0)
				$(this).remove();
		});
	}

});

function debug($msg) {
	if (window.console && window.console.log)
		window.console.log($msg);
}

function jQueryUiIcon(icon) {
	return '<span class="ui-icon ui-icon-'+icon+'"></span>';
}
