$(document).ready(function() {
						   
//Load the slideshow
theRotator();	

$('#diving_new').click(function (){
		

$.ajax({
		url: "diving.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		}		
	  }); //ajax


return false;
								});	//contact click
$('#contact').click(function (){
		

$.ajax({
		url: "contact/contact.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		}		
	  }); //ajax


return false;
								});	//contact click

$('#overview').click(function (){
stoprotator();		

$.ajax({
		url: "overview.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();

		}		
	  }); //ajax


return false;
								});	//contact click

$('#press').click(function (){
stoprotator();		

$.ajax({
		url: "pressroom.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();

		}		
	  }); //ajax


return false;
								});	//contact click

$('#home').click(function (){		
stoprotator();
$.ajax({
		url: "home.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();
		}		
	  }); //ajax
return false;
								});	//contact click

$('#accommodation').click(function (){		
stoprotator();
$.ajax({
		url: "accommodation.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();
		}		
	  }); //ajax
return false;
								});	//contact click


$('#restaurant').click(function (){		
stoprotator();
$.ajax({
		url: "restaurant.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();
		}		
	  }); //ajax
return false;
								});	//contact click

$('#services').click(function (){		
stoprotator();
$.ajax({
		url: "services.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		$('.content').html(html);
		$('.content').fadeIn('slow');
		theRotator();
		}		
	  }); //ajax
return false;
								});	//contact click


$('#spa').click(function (){
		

$.ajax({
		url: "spa.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		}		
	  }); //ajax


return false;
								});	//contact click

$('#sitemap').click(function (){
		

$.ajax({
		url: "sitemap.php",	
		cache: true,
		success: function (html) 
		{				
		$('.content').fadeOut('slow');
		
		$('.content').html(html);
		$('.content').fadeIn('slow');
		}		
	  }); //ajax


return false;
								});	//contact click


//**********************Language Selector **********************

$('#en_lang').click(function (){		
var data = 'lang=en'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax

return false;
});	//contact click

$('#fr_lang').click(function (){		
var data = 'lang=fr'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax
return false;
});	//contact click

$('#gr_lang').click(function (){		
var data = 'lang=gr'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax
return false;
});	//contact click

$('#sp_lang').click(function (){		
var data = 'lang=sp'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax
return false;
});	//contact click

$('#it_lang').click(function (){		
var data = 'lang=it'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax
return false;
});	//contact click

$('#ru_lang').click(function (){		
var data = 'lang=ru'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax

return false;
});	//contact click

$('#jp_lang').click(function (){		
var data = 'lang=jp'; 
$.ajax({
		url: "change_lang.php",	
		type: "GET",
		data:data,
		success: function() {   
		location.reload();
  		} 
		
	  }); //ajax
return false;
});	//contact click


//************************** end Language Selector **************
/**$('.admin').openDOMWindow({ // admin to modify content -- uncomment fo admin
											
height:500, 
width:700, 
eventType:'click', 
windowSource:'iframe',
positionTop:0,
windowPadding:0, 
loader:1, 
loaderImagePath:'animationProcessing.gif',
loaderHeight:16,
loaderWidth:17
});

$('.factsheet_loader').openDOMWindow({
											
height:500, 
width:800, 
eventType:'click', 
windowSource:'iframe',
positionTop:0,
windowPadding:0, 
loader:1, 
loaderImagePath:'Js/ajax-loader.gif',
loaderHeight:16,
loaderWidth:17
}); **/

$('#jsddm > li').bind('mouseover', jsddm_open)
$('#jsddm > li').bind('mouseout',  jsddm_timer)
	
});	


function theRotator() {

	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	timer = setInterval('rotate()',6000);
	
}

function stoprotator() {

	clearInterval(timer);
	
}
function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};
//************************** Function to display drop down menu **********************
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   $('#jsddm li').css('background','#d6b88f');
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
$('#jsddm li').css('background','');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

document.onclick = jsddm_close;



