// JavaScript Document
Shadowbox.init({
	language:   "it",
	players:    ["qt","swf","flv","qt","wmp", "img", "iframe"]
});

// JavaScript Document
var InitScroll = 0;
function scrollNext(oList){
	var toScroll = InitScroll + $(oList).getSize().x;
	var maxScroll = $(oList).getScrollSize().x - $(oList).getSize().x;
	if (toScroll > maxScroll){
		toScroll = maxScroll;
	}
	InitScroll = toScroll;
	var myScroll = new Fx.Scroll(oList, {
		wait: false,
		duration: 1500,
		transition: Fx.Transitions.Cubic.easeInOut
		//transition: Fx.Transitions.linear
	});
	myScroll.start(toScroll, false);
}
function scrollPrev(oList){
	var toScroll = InitScroll - $(oList).getSize().x;
	if(toScroll < 0){toScroll = 0};
	InitScroll = toScroll;
	var myScroll = new Fx.Scroll(oList, {
		wait: false,
		duration: 2500,
		transition: Fx.Transitions.Cubic.easeInOut
	});
	myScroll.start(toScroll, false);
} 

function LoadProductInfo(){
	//completeAHAH.likeSubmit("/modules/basket_getPrdInfo.asp", "POST", "QuickAddForm", "ProductInfo");
	var req = new Request.HTML({url:"/ajax/basket_getPrdInfo.asp", 
		onRequest: function(){
			$("ProductInfo").addClass("loading");
			$("ProductInfo").set("html", "");
		},
		onSuccess: function(html) {
			$("ProductInfo").removeClass('loading');
			//Clear the text currently inside the results div.
			$("ProductInfo").set("text", "");
			//Inject the new DOM elements into the results div.
			$("ProductInfo").adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$("ProductInfo").removeClass('loading');
			$("ProductInfo").set("text", "Errore caricamento...");
		}
	}).post($('QuickAddForm'));
	//req.send();
}

function confirmSubmitForm(form, aValues, url){
	if (confirm("Sei sicuro?")){
		submitForm(form, aValues, url);
	}
}
function submitForm(form, aValues, url){
	setValues(aValues);
	if (url != "" && url != null) $(form).action = url;
	$(form).submit();
}
function setValues(arrValues){
	var x;
	var tmpArray = new Array();
	if (isArray(arrValues)){
		if(isArray(arrValues[0])){
			for (x = 0; x < arrValues.length; x++){
				tmpArray = arrValues[x];
				$(tmpArray[0]).value = tmpArray[1];
			}
		}else{
			$(arrValues[0]).value = arrValues[1];
		}
	}
}
function isArray(arrInput){
	if (typeof arrInput == 'object'){  
		var criterion =  arguments[0].constructor.toString().match(/array/i); 
 		return (criterion != null);  
	}
	return false;
}

var arrMesi = ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'];
var arrGiorni = ['Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato']

function init_printbuttons(){
		$$('.print-window').addEvent('click',function(e){
			new Event(e).stop(); // if you code your print link as a link, this basically does the same as "return false;"
			window.print();
		});
}

window.addEvent('domready', function() {
	init_printbuttons();
	
	if($("header_logo")){
		var movie = $("header_logo").hasClass("english")? "logo_due_eng.swf":($("header_logo").hasClass("home")? "logo_due_intro.swf":"logo_due_ita.swf");
		swfobject.embedSWF(
						   "/media/"+movie, 
						   "header_logo", 
						   "180", "70", 
						   "7.0.0", 
						   "/media/expressInstall.swf", 
						   "", {wmode: 'transparent'}
						   );
	}
	
	if (Browser.Engine.gecko || Browser.Engine.webkit) new Asset.css("/css/FF.css");
	
});
