// JavaScript Document
var InitScroll = 0;
function scrollNext(){
	//alert($('ContentListImages').getSize().scrollSize.x);
	var toScroll = InitScroll + $('ListImages').getSize().size.x;
	var maxScroll = $('ListImages').getSize().scrollSize.x - $('ListImages').getSize().size.x;
	if (toScroll > maxScroll){
		toScroll = maxScroll;
	}
	InitScroll = toScroll;
	//$('demo-wrapper').scrollTo(toScroll);
	var scroll = new Fx.Scroll('ListImages', {
		wait: false,
		duration: 1500,
		transition: Fx.Transitions.Cubic.easeInOut
		//transition: Fx.Transitions.linear
	});
	scroll.scrollTo(toScroll);
}
function scrollPrev(){
	//alert($('ContentListImages').getSize().size.x);
	var toScroll = InitScroll - $('ListImages').getSize().size.x;
	if(toScroll < 0){toScroll = 0};
	InitScroll = toScroll;
	var scroll = new Fx.Scroll('ListImages', {
		wait: false,
		duration: 2500,
		transition: Fx.Transitions.Cubic.easeInOut
	});
	scroll.scrollTo(toScroll);
}

function clearInput(idObject) {
	getRef(idObject).value = "";
}

function openClose(id){
	if($(id)) $(id).toggleClass('active');
}
function openCloseCV(id){
	if($('boxCV_'+id)) $('boxCV_'+id).toggleClass('active');
	if($('linkCV_'+id)) $('linkCV_'+id).toggleClass('active');
}

Shadowbox.loadSkin('classic', '/javascript/shadowbox/skin');
Shadowbox.loadLanguage('it', '/javascript/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'img', 'swf', 'html', 'iframe'], '/javascript/shadowbox/player');
window.onload = function(){
    Shadowbox.init();
};

window.addEvent('domready', function(){
	if ($("Box_UltimeNews")){
		var opt = {
		  duration: 3000,
		  delay: 2000,
		  auto:true,
		  direction: 'v',
		  onMouseEnter: function(){this.stop();},
		  onMouseLeave: function(){this.play();}
		}
		var oNewsScrollerV = new QScroller('Box_UltimeNews_Text',opt);
		oNewsScrollerV.load();
	};
});

// disabilita il tasto destro del mouse
function nrcIE(){
if (document.all){return false;}}
function nrcNS(e){
if(document.layers||(document.getElementById&&!document.all)){ 
if (e.which==2||e.which==3){
return false;}}} 
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=nrcNS;
}else{document.onmouseup=nrcNS;document.oncontextmenu=nrcIE;}
document.oncontextmenu=new Function("return false");

// input di soli numeri
function numbersonly(myfield, e, dec) {
  var key;
  var keychar;

  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;

  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
    return true;

  // decimal point jump
  else if (dec && (keychar == ".")) {
    myfield.form.elements[dec].focus();
    return false;
  } else
    return false;
}

function changePrice(x){
	var totale;
	var totaleOrdine;
	var array;
	
	totale = 0;
	
	totale = Number(($('DAT_Partecipanti_'+x).value).replace(",",".")) * Number(($('PROD_PrezzoUnitario').value).replace(",","."));
	
	$('prezzoTotale_'+x).innerHTML = (totale+'').replace(".",",");
	
	totaleOrdine = 0;
	
	array = document.forms[0].elements["DAT_Attiva"]; 

	for (i=0; i<array.length; i++) {
		if (array[i].checked) {
			totaleOrdine = totaleOrdine + Number(($('DAT_Partecipanti_'+array[i].value).value).replace(",",".")) * Number(($('PROD_PrezzoUnitario').value).replace(",","."));
		}
	}
	
	$('totalePrenotazione').innerHTML = (totaleOrdine+'').replace(".",",");		
	$('ORD_Totale').value = (totaleOrdine+'').replace(".",",");
}

function changeTotal() {
	var totaleOrdine;
	var array;
	
	totaleOrdine = 0;
	
	array = document.forms[0].elements["DAT_Attiva"]; 

	for (i=0; i<array.length; i++) {
		if (array[i].checked) {
			totaleOrdine = totaleOrdine + Number(($('DAT_Partecipanti_'+array[i].value).value).replace(",",".")) * Number(($('PROD_PrezzoUnitario').value).replace(",","."));
		}
	}
	
	$('totalePrenotazione').innerHTML = (totaleOrdine+'').replace(".",",");		
	$('ORD_Totale').value = (totaleOrdine+'').replace(".",",");
}



