// JavaScript Document

function ReplaceContentInContainer(id,content){
var container = document.getElementById(id);
container.innerHTML = content;
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow1 IMG:last');
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function ChangeClass(id){
	
	document.getElementById('noi').className='';
	document.getElementById('cetara').className='';
	document.getElementById('piattievini').className='';
	document.getElementById('news').className='';
	document.getElementById('shop').className='';
	document.getElementById('prenota').className='';
	document.getElementById('contatti').className='';
	document.getElementById('live').className='';
	document.getElementById(id).className='current';
}
function isEmail(string) {
	
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
	return 1;
	else
	return 0;
}

function checkForm(){
	email = document.getElementById('email');
	if (isEmail(email.value) == 0 ) {
	alert("Inserire un indirizzo e-mail valido")
	email.focus();
	return false
	}
	if (isEmail(email.value) == 1 ) {
	ajaxpagefetcher.load('newsletter','newsletter.php?email='+email.value,true);

	}
}



function gup(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

$(function() {
         $('#navigation').hide();                     

});
function open_nav(){
	$('#navigation').hide();  
	setTimeout(function() {
         $('#navigation').fadeIn(1400);
         },5000);  
	
}

function close_nav(){        
	$("#navigation").fadeOut("slow");
};

function writetostatus(input){
    window.status=input
    return true
}



