//<![CDATA[

$(function()
{
	
	$('#caption').bind('click', function() {
		$('a.advance-link').click();
	});
	
	
	if ( $.browser.msie && $.browser.version < 7 )
	{
		// $('#headerMask').css({'position':'relative', 'top':'-6px', 'z-index':'0'});
		$('#headerMask').css({'display':'none'});
		// document.getElementById('headerMask').style.display = 'none';
	}
	
	$('.blackTrans').each(function() {
		$(this).click(function() {
			window.location = $(this).find('.green').attr('href');
		});
	});
	
	$('.slidedownLink').click(function() {
		$(this).parent().parent().find('.slidedownSlideText').slideDown('slow');
		$(this).hide();
	});
	
	$('.slideupLink').click(function() {
		$(this).parent().slideUp();
		$(this).parent().parent().find('a.slidedownLink').show();
	});
	
	$('a.showHideMore').click(function() {
		$(this).parent().find('.hiddenText').slideDown();
		$(this).parent().find('.showHideLess').show();
		$(this).parent().find('.showHideMore').hide();
	});
	
	$('a.showHideLess').click(function() {
		$(this).parent().find('.hiddenText').slideUp();
		$(this).parent().find('.showHideLess').hide();
		$(this).parent().find('.showHideMore').show();
	});
	
	if ( $.browser.msie && $.browser.version < 7 )
	{
		$('#headerMask').css('display','none');
	}

	$('#searchString').keyup(
		function (e) {
	        	if((e.which<=57 && e.which>=48)||(e.which<=90 && e.which>=65)||(e.which<=122 && e.which>=97)||e.which==32||e.which==8){
				var inputString =  document.getElementById('searchString').value;
				var inputLength = inputString.length;
	    			if(inputString.length!=0) {
	        			$.post("autocomplete.php", {queryString: ""+inputString+""}, function(data){
			            		if(data.length >0) {
	        	    	 			/*$('#searchString').val(data);*/
		            	 			/*setSelectionRange( inputLength );*/

							$('#search_results').html(data).css('display','block');

			            		}else{
							$('#search_results').html('').css('display','none');
						}
	        			});
	    			}else{
					$('#search_results').html('').css('display','none');
				}
		        }

			if($('#searchString').val().length==0) {
				$('#search_results').html('').css('display','none');
			}

		}
	);

	if($.browser.msie && $.browser.version<=7){
		$('#navigation').css('overflow','hidden');
	}
	
	var config = {   
		    sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		    interval: 1,
			over: showSubMenu,
			timeout: 500, // number = milliseconds delay before onMouseOut    
		    out: hideSubMenu // function = onMouseOut callback (REQUIRED)    
		};
			
	$('#navigation ul li').hoverIntent( config );

	
	
	
	if($.browser.msie && $.browser.version==6){
    	$('#navigation ul > li').css({
    		'display':'inline'		
    	});
    	
    	var arrWidths = new Array();
		
    	arrWidths[0] = 80;
    	arrWidths[1] = 66;
    	arrWidths[2] = 140;
    	arrWidths[3] = 92;
    	arrWidths[4] = 81;
    	arrWidths[5] = 64;
    	arrWidths[6] = 86;
    	arrWidths[7] = 59;
    	
    	for(i=0;i<arrWidths.length;i++){
    		$('#navigation ul > li:eq('+i+')').css({
	    		'width':arrWidths[i]+'px'    		
	    	});
    	}
    	
    }
    
    if($('embed').length > 0){
		$('embed').attr('wmode','transparent');
	}
	
	/*
	if($('object').length > 0){
    	//$('object').append('<param name="wmode" value="transparent" />');
    	$('object').html($('object').html()+'<param name="wmode" value="transparent" />');
	}
    */
	
	$('.favoriteCountry.notHome').click(function() {
		window.location = $('a', this).attr('href');
	});
	
});

function showSubMenu(){
	hideSubMenu();
	$('ul',$(this)).css('zIndex', 99).show();
}

function hideSubMenu(){
	$('ul',$(this)).css('zIndex', 9).hide();
}

function setSelectionRange( selectionStart ) {

	var input = document.getElementById('searchString');

	if( input.createTextRange )
	{
		var Range = input.createTextRange()
	    Range.moveEnd('character', input.value.length);
		Range.moveStart('character', selectionStart);								
		Range.select();
	}
	else
	{
		input.setSelectionRange( selectionStart, input.value.length );
	}

}

function selectAll(element){
	element.focus();
	element.select();
}

function swapMainImage(src, tit)
{
	document.getElementById("campMainImage").style.backgroundImage="url('"+src+"')";
	$('#campImageTitle').html(tit);
}



//]]>
