function encodeUrl(url) {
	if (url.indexOf("?") > 0) {
		encodedParams = "?";
		parts = url.split("?");
		params = parts[1].split("&");
		for (i = 0; i < params.length; i++) {
			if (i > 0) {
				encodedParams += "&";
			}
			if (params[i].indexOf("=") > 0) //Avoid null values
			{
				p = params[i].split("=");
				encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));
			}
			else {
				encodedParams += params[i];
			}
		}
		url = parts[0] + encodedParams;
	}
	return url;
}

var myPopupWindow = '';
function openPopupWindow(url, name, width, height)
{
  //Remove special characters from name
  name = name.replace(/\/|\-|\./gi, "");

  //Remove whitespaces from name
  var whitespace = new RegExp("\\s","g");
  name = name.replace(whitespace,"");

  //If it is already open
  if (myPopupWindow!=null && !myPopupWindow.closed && myPopupWindow.location)
  {
      myPopupWindow.location.href = encodeUrl(url);
  }
  else
  {
  	myPopupWindow = window.open(encodeUrl(url), name, "location=no,scrollbars=no,resizable=no,toolbar=no,menubar=no,titlebar=no,width=" + width + ",height=" + height);
      if (myPopupWindow != null && !myPopupWindow.opener) myPopupWindow.opener = self;
  }

   //If my main window has focus - set it to the popup
  if (myPopupWindow != null && window.focus) { myPopupWindow.focus() }
 }



/*function __doPostBack2(eventTarget, eventArgument){
	//alert('a');
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		theform = document.forms["ctl00"];
	}
	else {
		theform = document.ctl00;
	}
	//theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	//theform.__EVENTARGUMENT.value = eventArgument;
	theform.submit();
}*/
function prova(){
	alert('a');
}
function MM_preloadImages() { //v3.0
  var d=document; 
  if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("_")!=0)
		{	
			//alert(a[i]);
			try{
			d.MM_p[j]=new Image; 
			d.MM_p[j++].src=a[i];
			//alert(d.MM_p[j].src);
			}catch(ex)
			{
				alert('err: '+ex.message);
			}
		}
    }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v5 powered by BertinuX con impostazione alt e larg effettive foto
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3){
   //Seleziono element del 1° param (trMain)
   if ((x=MM_findObj(a[i]))!=null){
    //Effect.Fade(x.id,{duration: 1, from:1, to:0.1});
    //changeVis(x.id,"hide");
    //OK 
    lightup(x.id,0);
    //NEW
	//MyFade(x);
	/*do
    {}
    while(x.id.style.index()
    */
	document.MM_sr[j++]=x; 
	//Imposto la mia immagine con source 3° param
	myImage = new Image(); 
	myImage.src = a[i+2];
	
	// {image].complete sembra che non funzioni con Asp.Net Development Server
	/*
	if (!myImage.complete)
	{
		//alert('Non caricata...');
	    //MM_preloadImages('/images/Caricamento.JPG');
	    //Carico l'immagine di caricamento in corso indicata
		myImage.src=a[i+3];//'images/Caricamento.jpg';
		//alert('MM_swapImage(\'' + a[i] + '\',\'' + a[i+1] + '\',\'' + a[i+2] + '\',1)');
		setTimeout('MM_swapImage(\'' + a[i] + '\',\'' + a[i+1] + '\',\'' + a[i+2] + '\',1)',2000);
		return;
	}
	else
	{
		//alert('caricata...');
		//clearTimeout('MM_swapImage(\'' + a[i] + '\',\'' + a[i+1] + '\',\'' + a[i+2] + '\',1)');
	}
	*/
	//window.alert('myImage width: ' + myImage.width + ' - height: ' +myImage.height );
	
	if(!x.oSrc) x.oSrc=x.src; 
	x.src=a[i+2];
	//Imposto altezza del tag IMG con quelle reali della jpg
	x.width=myImage.width;
	//Imposto larghezza del tag IMG con quelle reali della jpg
	x.height=myImage.height;
	//alert('width:' +myImage.width + ' height: '+myImage.height)
	//changeVis(x.id,"hide");
	//lightup(x.id,0);
	//Effect.Appear(x.id, { duration: 3.0 });
	//OK
	
    if(x.id!=""){
	    new Effect.Opacity(x.id, {duration:0.8, from:0, to:1.0});
	}

	//NEW
	//MyAppear(x);
	//Effect.Appear(x.id, {duration:1.0, from:0.01, to:1, queue:'end',scope:x.id});
	//Effect.toggle(x.id,'appear'); 
   }
  }
}

function MyFade(x)
{
    Effect.Fade(x.id, {duration:1.0, from:1, to:0.01, queue:'end',scope:x.id});
    while(x.style.opacity!=0.01)
    {
      /*alert('Fade non finito'+ x.style);
	  if (confirm('Vuoi uscire?')) {
		break; 
	  }*/
	  setTimeout('MyFade(\'' + x + '\')',2000);
    }
	clearTimeout('MyFade(\'' + x + '\')');
}

function MyAppear(x)
{
    Effect.Appear(x.id, {duration:1.0, from:0.01, to:1, queue:'end',scope:x.id});
}

function apri(collegamento,nome,larg,altez) {
searchWin = window.open(collegamento,nome,"width="+larg+",height="+altez+",scrollbars=no,resizable=no,status=no,location=no,toolbar=no");
searchWin.focus();
// searchWin.refer = self;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function changeVis(id, action) {
	if (action=="hide") {
		while (document.getElementById(id).style.display != "none")
		{
			document.getElementById(id).style.display = "none";
		}
	} 
	if (action=="show")  {
		while (document.getElementById(id).style.display != "block")
		{
			document.getElementById(id).style.display = "block";
		}
	}
}

function lightup(imageobject, opacity){
 try {
	//alert(imageobject.id);
	if (navigator.appName.indexOf("Netscape")!=-1
	&&parseInt(navigator.appVersion)>=5)
	{
		//alert('Moz');
		try
		{
			imageobject.style="opacity:" + opacity/100;
		}catch(eMoz)
		{
			//alert(eMoz.message);
			try
			{
				imageobject.style.MozOpacity=opacity/100;
			}
			catch(eMoz2)
			{
				alert(eMoz2.message);
			}
		}
	}
	else if (navigator.appName.indexOf("Microsoft")!= -1 
	&&parseInt(navigator.appVersion)>=4)
	{
		//alert('IE');
		try{
		imageobject.style="filter:alpha(opacity=" + opacity + ")";
		}
		catch(eIE)
		{
			//alert(eIE.message);
			try{
				imageobject.filters.alpha.opacity=opacity;
			}
			catch(eIE2)
			{
				//alert(eIE22.message);
			}
		}
	}
		
	}
  catch(e) 
  {
	alert(e.message);
  }
}
//Shadow Ini
var gradientshadow={}
gradientshadow.depth=5 //Depth of shadow in pixels
gradientshadow.containers=[]

gradientshadow.create=function(){
var a = document.all ? document.all : document.getElementsByTagName('*')
for (var i = 0;i < a.length;i++) {
	if (a[i].className == "shadow") {
		for (var x=0; x<gradientshadow.depth; x++){
			var newSd = document.createElement("DIV")
			newSd.className = "shadow_inner"
			newSd.id="shadow"+gradientshadow.containers.length+"_"+x //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth) 
			if (a[i].getAttribute("rel"))
				newSd.style.background = a[i].getAttribute("rel")
			else
				newSd.style.background = "black" //default shadow color if none specified
			document.body.appendChild(newSd)
		}
	gradientshadow.containers[gradientshadow.containers.length]=a[i]
	}
}
gradientshadow.position()
window.onresize=function(){
	gradientshadow.position()
}
}

gradientshadow.position=function(){
if (gradientshadow.containers.length>0){
	for (var i=0; i<gradientshadow.containers.length; i++){
		for (var x=0; x<gradientshadow.depth; x++){
  		var shadowdiv=document.getElementById("shadow"+i+"_"+x)
			shadowdiv.style.width = gradientshadow.containers[i].offsetWidth + "px"
			shadowdiv.style.height = gradientshadow.containers[i].offsetHeight + "px"
			shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px"
			shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px"
		}
	}
}
}

if (window.addEventListener)
window.addEventListener("load", gradientshadow.create, false)
else if (window.attachEvent)
window.attachEvent("onload", gradientshadow.create)
else if (document.getElementById)
window.onload=gradientshadow.create
//Shadow Fin
