/*
Title:				Right-To-Left Locale Tweaks Javascript
Author: 			Sapient
Date Modified: 		August 2009
Version:			1.0
*/


if ( !window.VisitBritain ) VisitBritain = {};


// Insert RTL CSS
if ( VisitBritain.path ) document.write( '<link rel="stylesheet" type="text/css" href="' + VisitBritain.path + '/css/rtl.js.css">' );



// Country Language Selector
VisitBritain.LocaleSelector.change = function(e)
{
	// create popup
	VisitBritain.LocaleSelector.popup = jQuery( '<div id="LocalePopup" class="loading"><div class="top"></div><div class="middle"><div class="content"></div></div><div class="bottom"></div><a href="#" id="LocalePopupClose"></a></div>' );
	
	// position popup
	VisitBritain.LocaleSelector.popup.css( { top:jQuery( this ).offset().top + jQuery( this ).height(), left:jQuery( this ).offset().left + jQuery( this ).width() / 2 - 90 } );
	
	// draw popup
	jQuery( 'body' ).append( VisitBritain.LocaleSelector.popup );
	if ( !jQuery.browser.msie ) VisitBritain.LocaleSelector.popup.css( { opacity:0 } ).animate( { opacity:1 }, 300, 'easeInOutQuad' );

	// trigger AJAX load of languages
	jQuery.ajax( { dataType:'html', success:VisitBritain.LocaleSelector.loadedLanguages, type:'GET', url:VisitBritain.LocaleSelector.languageUrl } );

	// add events to close the popup
	setTimeout( function() { jQuery( 'body' ).bind( 'click', VisitBritain.LocaleSelector.close ) }, 1 );
	VisitBritain.LocaleSelector.popup.bind( 'click', function(e) { e.stopPropagation() } );
	jQuery( '#LocalePopupClose' ).bind( 'click', VisitBritain.LocaleSelector.close );

	e.preventDefault();
}




// Links Lists
VisitBritain.LinksLists =
{
	setup: function()
	{
		jQuery( '.moduleLinkList' ).each( function()
		{
			jQuery( this ).find( 'li > a' ).unbind( 'mouseenter' ).unbind( 'mouseleave' ).parent().css( { backgroundPosition:'' } );
		} );
	}
}
jQuery( document ).ready( VisitBritain.LinksLists.setup );
