var inputRevertToDefault = [];
var lookUp = [];

lookUp['login_link'] = 'login_element';
lookUp['subscribe_link'] = 'subscribe_element';
lookUp['forgot_link'] = 'forgot_element';

/**
 * Load external scripts
 */
jQuery.fn.extend({
	inputRevertToDefault: function() {
		return this.each(
			function()
			{
				inputRevertToDefault[$(this).attr('id')] = $(this).focus(
					function()
					{
						if ( $(this).val() == inputRevertToDefault[$(this).attr('id')] ) $(this).val("");
					}
					).blur(
					function()
					{
						if ( $(this).val() == "" ) $(this).val( inputRevertToDefault[$(this).attr('id')] );
					}
				).val();
				
				return this;		
			}    
		);
	},
	
	ajaxLoadingStart: function () {
		$(this).hide();
		$(this).parent().append( '<div class="ajax-loading"><img src="' + 'http://' + window.location.hostname + '/images/image_loading_small.gif' + '" /></div>' );
	},
	
	ajaxLoadingStop: function () {
		$(this).show();
		$(this).parent().find('div.ajax-loading').remove();
	}	
});

$(document).ready(
	function()
	{
		$.each( 
			jQueryScript,
			function(i, n)
			{
		  		jQuery.getScript( 'http://' + n );
			}
		);	
				
		$.each( 
			jQueryCall,
			function(i, n)
			{
		  		n();
			}
		);			
								
		/**
		 * Imagebox config
		 */
		$('ImageBox').init(
			{
				loaderSRC	: 'images/imagebox/loading.gif',
				closeHTML	: '<img src="images/imagebox/close.jpg" />'
			}
		);	
		
				
		/**
		 * Searchbox
		 */
		$('#top_search_submit').click(
			function()
			{
				var search = $('#top_search_input').val();
				
				if ( search != '' && search != top_search_input_default )
					return true;
					
				$('#top_search_input').val('').focus();
				return false;
			}
		);
		
		top_search_input_default = 			
			$('#top_search_input').focus(
					function()
					{
						if ( $(this).val() == top_search_input_default ) $(this).val("");
					}
				).blur(
					function()
					{
						if ( $(this).val() == "" ) $(this).val( top_search_input_default );
					}
				).val();
					
		/**
		 * anchors having class track-(.*) are tracked by the google tracker
		 */
		/*
		$('a[@class^=track]').each(
			function()
			{
				$(this).attr( 'target', '_blank' );					
				//urchinTracker( '/track/outgoing/' + $(this).attr( 'class' ).split('-').pop() + '/' + $(this).attr( 'href' ) );
				pageTracker._trackPageview( $(this).val() );					
			}
		);*/
	}
);
	
	function onAnimate(show) 
	{
		//$(this).fadeIn('slow').show();
		if (show) 
		{
			$(this)
			.css('visibility', 'hidden').show()
			.css('width', $(this).innerWidth())
			.hide().css('visibility', 'visible')
			.fadeIn('normal');
		} 
		else 
		{
			$(this).fadeOut('fast');
		}
	}

	// We're passed an UL
	function onHideCheckMenu() 
	{
		return !$(this).parent().is('.LOCKED');
	}

	// We're passed a LI
	function onClickMenu() 
	{
		$(this).toggleClass('LOCKED');
		return true;
	}


	
	
	