/* *	2011 Header Country Language Chooser */ //var ctrlngdefault = { ctr: "XAR", lng: "English" };//var ctrlngdefault = { };$(document).ready(function(){	// set pointers to key elements	var $choosectr = $('#choose_ctr');	var $chooselng = $('#choose_lng');	// fill countrylist with websites	for( var country in ctrlngs ){		$choosectr.append(			$('<option />')				.html( ctrlngs[ country ]["name"] ) // use .html instead of .text because of html entities for arabian etc.				.attr("value",country)		);	}	// bind change event to country list	$choosectr.change(function(){		$this = $(this);		$thisval = $this.val();				if( $this[0].selectedIndex === 0 ) {			$chooselng.hide();			return false;		}		if( typeof( ctrlngs[ $thisval ]["url"] )  == "undefined" ) {			// this means: we have sub-languages			$chooselng.find("option:gt(0)").remove();			var lngs =  ctrlngs[ $thisval ][ "langs" ];			// fill language selection			for( lng in lngs ) {				$chooselng.append(					$('<option />')						.html( lngs[lng][ "name" ] ) // use .html instead of .text because of html entities for arabian etc.						.attr("value", lngs[lng][ "url" ])					);			};			// show language selection			$chooselng.show();		} else {			$chooselng.hide();			//alert( "we're going to: " + ctrlngs[ $thisval ]["url"] );			location.href = ctrlngs[ $thisval ]["url"];		}	});	// append lng change behaviour	$chooselng.change(function(){		$this = $(this);		if( $this[0].selectedIndex === 0 ) {			return false;		}		$this = $(this);		$thisval = $this.val();		//alert( "we're going to: " + $thisval )		location.href = $thisval;	});		/*	 * Fill the defaults	 */	if( typeof( ctrlngdefault ) !== "undefined" ){			if( $choosectr && typeof( ctrlngdefault.ctr ) !== "undefined" )  {			$choosectr.val( ctrlngdefault.ctr ) //.trigger('change');						if( $chooselng && typeof( ctrlngdefault.lng ) !== "undefined" )  {				if( 					ctrlngdefault.ctr.substr(0,1) !== "X" && 					typeof( ctrlngs[ ctrlngdefault.ctr ]["url"] ) == "undefined"				) { 					// if no countrylist, vals begin with "X"					// trigger change and show language-chooser only when 					// "Countruies" Vvals do not begin with X					$choosectr.trigger('change');					if( (/;/g).test(ctrlngdefault.lng) && (/&/g).test(ctrlngdefault.lng)  ) {						ctrlngdefault.lng = $("<div/>").html(ctrlngdefault.lng).text();					}					$chooselng.val( $chooselng.find('option:contains(' + ctrlngdefault.lng + ')').val() ).show();				}			}		}	}	// show / hide logig of the country/lng-chooser	$('#countrylngchooser .selecttext').click( function() {		$('#countrylngpopup').fadeIn();	});	$('#countrylngpopup .close').click(function(){		$('#countrylngpopup').fadeOut();	});})	
