// carica funzioni javascript
function addLoadEvent(func) {
  var addLoadEvent_oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      addLoadEvent_oldonload();
      func();
    }
  }
}


// scrolling verticale del div con id="scroll", a velocità 30
scrollDivDown_step=1
scrollDivDown_timerDown="" 
function scrollDivDown() {
	scrollDivDown_el=document.getElementById("scroll")
	clearTimeout(scrollDivDown_timerDown) 
	if (!scrollDivDown_el) return;
	scrollDivDown_el.scrollTop+=scrollDivDown_step	

	scrollDivDown_timerDown=setTimeout("scrollDivDown()",30)

	if(scrollDivDown_el.scrollTop>=scrollDivDown_el.scrollHeight-scrollDivDown_el.offsetHeight) {		
		scrollDivDown_el.scrollTop=0
	}
}



// mostra Google map
function load() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("HOME_map"));
	map.setCenter(new GLatLng(47.549739,19.054117), 14);
	map.setMapType(G_SATELLITE_TYPE);
	map.addControl(new GSmallMapControl());

  }  
}


function Accordian() {
	new Accordian('basic-accordian-1',3,'header_highlight');
	new Accordian('basic-accordian-2',3,'header_highlight');
}


// apre un lyteframe
function loadLyteframe1() {

	var date1 = new Date() // data di oggi
	var date2 = new Date(2009, 7, 11) // 11 agosto 2009
	var one_day = 86400000 // millisecondi in un giorno
	var diff = Math.ceil((date2.getTime() - date1.getTime()) / one_day); // giorni di differenza
	
	if (diff > 0) {
		var timeoutID = null;
		if (typeof myLytebox != 'undefined') {
			var a = document.createElement("a");
			a.href = "assets/templates/sziget08/separate_pages/avvisi/avviso4.htm?v=2";
			a.rel = "lyteframe";
			a.title = "Pagamento online, e vendite fino al 10 agosto";
			
			a.rev = "width: 450px; height: 452px; scrolling: no;";
			//a.rev = "width: 760px; height: 520px; scrolling: no;";
			//a.rev = "width: 490px; height: 520px; scrolling: no;";
			
			myLytebox.start( a, false, true);
		} else {
			// wait 1/10th of a second and attempt loading again...
			if (timeoutID) { clearTimeout(timeoutID); }
			timeoutID = setTimeout('loadLyteframe1()', 100);
		}	
	}
}


// apre un lyteframe
function loadLyteframe2() {

	var date1 = new Date() // data di oggi
	var date2 = new Date(2010, 9, 9) // 9 agosto 2010
	var one_day = 86400000 // millisecondi in un giorno
	var diff = Math.ceil((date2.getTime() - date1.getTime()) / one_day); // giorni di differenza
	
	if (diff > 0) {
		var timeoutID = null;
		if (typeof myLytebox != 'undefined') {
			var a = document.createElement("a");
			a.href = "assets/templates/sziget08/separate_pages/ticket_e_viaggi_2010/ticket_e_viaggi_2010.htm?v=3";
			a.rel = "lyteframe";
			a.title = "Ticket e Viaggi - Prenotazioni possibili anche dopo il 15 luglio 2010";
			a.rev = "width: 720px; height: 622px; scrolling: no;";
			myLytebox.start( a, false, true);
		} else {
			// wait 1/10th of a second and attempt loading again...
			if (timeoutID) { clearTimeout(timeoutID); }
			timeoutID = setTimeout('loadLyteframe2()', 100);
		}	
	}
}



// apre un lyteframe
function loadLyteframe3() {

	var date1 = new Date() // data di oggi
	var date2 = new Date(2008, 11, 24) // 24 dicembre 2009
	var one_day = 86400000 // millisecondi in un giorno
	var diff = Math.ceil((date2.getTime() - date1.getTime()) / one_day); // giorni di differenza
	
	if (diff > 0) {
		var timeoutID = null;
		if (typeof myLytebox != 'undefined') {
			var a = document.createElement("a");
			a.href = "assets/templates/sziget08/separate_pages/wishlist09/scheda.htm?v=0";
			a.rel = "lyteframe";
			a.title = "Il Sziget 2009 ti fa risparmiare...";
			a.rev = "width: 760px; height: 540px; scrolling: no;";
			myLytebox.start( a, false, true);
		} else {
			// wait 1/10th of a second and attempt loading again...
			if (timeoutID) { clearTimeout(timeoutID); }
			timeoutID = setTimeout('loadLyteframe2()', 100);
		}	
	}
}


/*
Apre un lyteframe
=================
Per lanciare un lyteframe in apertura, e' sufficiente ad esempio fare cosi' (nella view):

<script type="text/javascript">

	var lyteframe_href = 'assets/templates/sziget08/separate_pages/avvisi/avviso4.htm?v=2';
	var lyteframe_title = 'titolo';
	var lyteframe_rev = 'width: 450px; height: 452px; scrolling: no;';

	var expire_year = 2009;
	var expire_month = 7; // start from Jan=0
	var expire_day = 11;
	addLoadEvent(loadLyteframe);

</script>

*/
function loadLyteframe() {

	var date1 = new Date() // data di oggi
	var date2 = new Date(expire_year, expire_month, expire_day) // 15 agosto 2009
	var one_day = 86400000 // millisecondi in un giorno
	var diff = Math.ceil((date2.getTime() - date1.getTime()) / one_day); // giorni di differenza	
		
	if (diff > 0) {
		var timeoutID = null;
		if (typeof myLytebox != 'undefined') {
			var a = document.createElement("a");
			a.href = lyteframe_href;
			a.rel = "lyteframe";
			a.title = lyteframe_title;
			a.rev = lyteframe_rev;
			myLytebox.start( a, false, true);
		} else {
			// wait 1/10th of a second and attempt loading again...
			if (timeoutID) { clearTimeout(timeoutID); }
			timeoutID = setTimeout('loadLyteframe()', 100);
		}	
	}
}


/*
Apre un lyteframe
=================
Per lanciare un lyteframe in apertura, e' sufficiente ad esempio fare cosi' (nella view):

<script type="text/javascript">

	var lyteframe_href = 'assets/templates/sziget08/separate_pages/avvisi/avviso4.htm?v=2';
	var lyteframe_title = 'titolo';
	var lyteframe_rev = 'width: 450px; height: 452px; scrolling: no;';

	var start_year = 2009;
	var start_month = 6; // start from Jan=0
	var start_day = 31;

	var expire_year = 2009;
	var expire_month = 7; // start from Jan=0
	var expire_day = 11;
	addLoadEvent(loadLyteframe);

</script>

*/
function loadLyteframe_2() {

	var date1 = new Date() // data di oggi
	var date2 = new Date(expire_year, expire_month, expire_day) // month start from Jan=0
	var date3 = new Date(start_year, start_month, start_day) // month start from Jan=0
	var one_day = 86400000 // millisecondi in un giorno
	//var diff = Math.ceil((date2.getTime() - date1.getTime()) / one_day); // giorni di differenza	
	
	//alert(Math.ceil(date3.getTime() - date1.getTime())/one_day);
	
	//if (diff > 0) {
	if ((date1.getTime() - date3.getTime() >= 0) && (date2.getTime() - date1.getTime() >= 0)) {
		var timeoutID = null;
		if (typeof myLytebox != 'undefined') {
			var a = document.createElement("a");
			a.href = lyteframe_href;
			a.rel = "lyteframe";
			a.title = lyteframe_title;
			a.rev = lyteframe_rev;
			myLytebox.start( a, false, true);
		} else {
			// wait 1/10th of a second and attempt loading again...
			if (timeoutID) { clearTimeout(timeoutID); }
			timeoutID = setTimeout('loadLyteframe()', 100);
		}	
	}
}
