/* +++ UI INITIALIZATION  +++ */

function InitUI( hideMask, fnc )
{
	menuTweak();
	titlesTweak();
	formElementsTweak();
	adsTweak();
}

function menuTweak()
{
	//$("#lnkMenuHome").css("border-bottom", "0px none");
	$("#page_header").hover(
		function()
		{
			$("#lnkMenuHome").css("visibility", "visible");
		},
		function()
		{
			$("#lnkMenuHome").css("visibility", "hidden");
		}
	);
}

function titlesTweak()
{
	$('h1 .h1_text').each(
		function()
		{
			var hText = $(this).text();
			$(this).parent().append( "<span class=\"h1_text_shadow\">" + hText + "</span>");
		}
	);
}

function adsTweak()
{
	$("a img", "#ads_content").each(
		function()
		{
			var jsImg = $(this);
			jsImg.fadeTo("fast", 0.4).hover(
				function()
				{
					$(this).fadeTo("fast", 1.0); 
				},
				function()
				{
					$(this).fadeTo("fast", 0.4); 
				}
			);
		}
	);
}


function formElementsTweak()
{
	$("form input.text").each(
		function()
		{
			formElementTweak(this);
		}
	);

	$("form textarea.textarea").each(
		function()
		{
			formElementTweak(this);
		}
	);

	$("form select").each(
		function()
		{
			formElementTweak(this);
		}
	);

	$("form .checkbox").each(
		function()
		{
			formElementTweak(this);
		}
	);

	$("form .frm_selfvalue").each(
		function()
		{
			$(this).bind( 
				"focus",
				function()
				{
					var obj = $(this);
					var eVal = obj.val();
					var defValue = "";
					if( obj.attr("rel") !== undefined ) defValue = obj.attr("rel").toString().trim();
					if( eVal.toString().trim() == "" || eVal == defValue )
						obj.val("");
					obj.removeClass("frm_clear_generic");					
				}
			).bind( 
				"blur",
				function()
				{
					var obj = $(this);
					var eVal = obj.val();
					if( obj.attr("rel") !== undefined && eVal.toString().trim() == "" )
					{
						var defValue = obj.attr("rel");
						obj.val(defValue).addClass("frm_clear_generic");
					}
				}
			);
		}
	);

}

function formElementTweak(obj)
{
	$(obj).hover(
		function()
		{
			$(this).addClass( "text_hover");
		},
		function()
		{
			$(this).removeClass( "text_hover");
		}
	);
	$(  obj ).bind( "focus",
		function()
		{
			if( $(this).attr("id") !== undefined )
			{
				$("label[for=" + $(this).attr("id")+ "]").addClass("focused");
			}
			$(this).addClass( "text_pressed");
		}
	);
	$( obj ).bind( "blur",
		function()
		{
			if( $(this).attr("id") !== undefined )
			{
				$("label[for=" + $(this).attr("id") + "]").removeClass("focused");
			}
			$(this).removeClass( "text_pressed" );
		}
	);
}




$("a").mousedown(function()
{
	 this.blur();
	 this.hideFocus = true;
	 this.style.outline = 'none';
});

$('a').click(function() { $(this).blur(); });


