// JavaScript Document

var marginetop 	= 0;
var hSlide 		= 160;

function init()
{
	/*multibox avanzato
	var box = {};
	if(document.getElementById("showsdfsdf")) 
		{
			if($$('.mb').length > 0)//only triggered if 'mb' class found on page
			{
				var box = new multiBox('mb', {
					descClassName: 'multiBoxDesc',//the class name of the description divs
					path: './Files/',//path to mp3 and flv players
					useOverlay: false,//use a semi-transparent background. default: false;
					maxWidth: 900,//max width (set to false to disable)
					maxHeight: 700,//max height (set to false to disable)
					addDownload: true,//do you want the files to be downloadable?
					addRollover: true,//add rollover fade to each multibox link
					addOverlayIcon: true,//adds overlay icons to images within multibox links
					addChain: true,//cycle through all images fading them out then in
					recalcTop: true//subtract the height of controls panel from top position
				});
			};
		}
		*/
	//validazione forms
	
	var formv = document.getElementsByTagName("form");
	if (formv)
	{
	  for(i=0;i<formv.length;i++)  
	  {
		  if (!formv[i].getAttribute('id') || formv[i].getAttribute('id')=="") formv[i].id = formv[i].getAttribute('name');
		  var nome = formv[i].getAttribute('id');
		  if(/valida/.test(formv[i].className))
		  {
			jQuery("#"+nome).validate();
		  }
		  if(/xmail/.test(formv[i].className))
		  {
		  	var divmsg = formv[i].getAttribute('target');
			formv[i].target = '_self';
			formv[i].action = "javascript:invia_email('"+nome+"','phpmyformmail','"+divmsg+"');";
		  }
	  }
	}
		jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		/* fast/slow/normal */
		animationSpeed: 'fast', 
		/* padding for each side of the picture */
		padding: 40, 
		/* Value betwee 0 and 1 */
		opacity: 0.45, 
		/* true/false */
		showTitle: true,
		/* true/false */
		allowresize: true,
		/* The separator for the gallery counter 1 "of" 2 */
		counter_separator_label: '/', 
		/* light_rounded / dark_rounded / light_square / dark_square */
		theme: 'light_rounded', 
		callback: function(){

		}
	});
}

function invia_email(nomeForm,dest,divid)
{	
	
	var objForm = document.getElementById(nomeForm);
	var objDiv	= document.getElementById(divid);
	dati="";
	for(x=0;x<objForm.length;x++)
	{
		if(x>0) dati+="&";
		dati += objForm[x].name+"="+objForm[x].value;
	}
		jQuery.ajax({
			type: "POST",
			url: website+"/"+dest+".php?",
			data: dati,
			success: function(msg){
				objDiv.innerHTML = msg;
			}
		});
	
}
if (window.addEventListener){
	window.addEventListener("load", init, false)
}
else if (window.attachEvent) {
	window.attachEvent("onload", init)
}
else if (document.getElementById){
	window.onload=init
}