/*Script jQuery Ulisse di inizializzazione*/


function fadeImage()  {
		var active;
		var next;
		$active = $('#Template_Slideshow img.active');
    	$next = $active.next();
		
		if($active.is('#Template_Slideshow img:last-child')){
	 		$next = $('#Template_Slideshow img:first');
	    }
	
		$next.addClass('next');
		
		$('#Template_Slideshow img').css({opacity: 1.0});
		$active.animate({opacity: 0.0}, 1000, function() {
	     	$active.removeClass('active');
			$next.removeClass('next');
			$next.addClass('active');
       	});
}

/**
 * Crea uno slideshow delle tabelle all'interno dell'elemento con ID=Template_Slideshow_Table
 * L'html della pagina dovrà essere:
 * <div id="Template_Slideshow">
 *     <table class="active"><tr><td><img src="..." /></td></tr></table>
 *     <table><tr><td><img src="..." /></td></tr></table>
 *     <table><tr><td><img src="..." /></td></tr></table>
 * </div>
 */
function fadeTable()  {
	var tableActive;
	var tableNext;
	$tableActive = $('#Template_Slideshow_Table table.active');
	$tableNext = $tableActive.next();
	
	if($tableActive.is('#Template_Slideshow_Table table:last-child')){
		$tableNext = $('#Template_Slideshow_Table table:first');
	}

	$tableNext.addClass('next');
	
	$('#Template_Slideshow_Table table').css({opacity: 1.0});
	$tableActive.animate({opacity: 0.0}, 1000, function() {
		$tableActive.removeClass('active');
		$tableNext.removeClass('next');
		$tableNext.addClass('active');
   	});
}

$(document).ready(function() {
	setInterval( 'fadeImage()', 3000 );
	setInterval( 'fadeTable()', 3000 );
});

function sendCAP() {
	cap = document.getElementById('CAP').value;
	window.location=('http://www.tecnoalarm.com/installatori&cap='+cap);
}

function sendCAPCDS() {
	cap = document.getElementById('CAP').value;
	window.location=('http://www.tecnoalarm.com/cds&cap='+cap);
}

urlHistory = new Array();
function requestContent(url) {
	$('#ContentArea').html("<div>Loading...</div>");
	if (url==undefined) {
		$('#ContentArea').load('/content.php');
	} else {
		urlHistory.push(url);
		$('#ContentArea').load(url);
	}
}


loaderIDSelected = 0;

function OpenCloseMenu(me) {

		if (loaderIDSelected!=me) {

			//document.getElementById('Menu02Icon' + me).src = "img_struct/arrow.Menu02.Selected.gif";
			document.getElementById('PMenu' + me).style.display = "";
			loaderIDSelected = me;
		
		} else {
			//document.getElementById('Menu02Icon' + me).src = "img_struct/arrow.Menu02.gif";
			document.getElementById('PMenu' + me).style.display = "none";
			loaderIDSelected = -1;
		
		}

}
