// JavaScript Document
/*******************************************************
ACROBAT DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
modified by olivier wailly 12/12/2004 : detect only if Acrobat is installed
*******************************************************/
function getAcrobatVersion () {
var acrobat= false;
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x<navigator.plugins.length; x++)	{
		if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1) {
			acrobat=true;
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x=2; x<10; x++) {
		try	{
			oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
			if (oAcro)	{
				acrobat=true;
			}
		}
		catch(e) {}
	}

	try	{
		oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
		if (oAcro4) 	{
			acrobat=true;
		}
	}
	catch(e) {}
}
 return acrobat;
}

var win= null;

function getPDF(file,lang) {
	acrobat = 0;
	if (getAcrobatVersion()) acrobat = 1;
	file = "/download.php?lang="+lang+"&asA="+acrobat+"&file="+file;
	var w = 520;
	var h = 450;
	var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
	wint = wint/2;
  var settings  ='location=yes,status=yes,resizable=yes,scrollbars=yes,width='+w+',height='+h+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
  win=window.open(file,'',settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
	return false;
}

function downloadPDF() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("pdf")) {
      links[i].onclick = function() {
	  	if (this.href == 'undefined') return true;
		return getPDF(this.href,document.getElementsByTagName("html")[0].getAttribute('lang'));		
      }
    }
  }
}
window.onload = downloadPDF;

function checkPwd()
{
	var error = '';
	if (document.orderForm.pwd.value.length == 0)
		return true;
	if (document.orderForm.pwd.value.length < 6)
		error = error + 'Password troppo corta. Usare almeno 6 caratteri\n';
	if (document.orderForm.pwd.value !=  document.orderForm.pwd2.value )
		error = error + 'Le password non coincidono\n';	

if (error.length > 0)
{
	alert (error);
	document.orderForm.pwd.focus();
	return false;
} else
	return true;
			
		 
}

function nextAction()
{
if (checkPwd() ) {
	document.orderForm.submit();
} 
	return false;
}


//--- START YELLOW FADE

// This technique is a combination of a technique I used for highlighting FAQ's using anchors 
// and the ever popular yellow-fade technique used by 37 Signals in Basecamp.

// Including this script in a page will automatically do two things when the page loads...
// 1. Highlight a target item from the URL (browser address bar) if one is present.
// 2. Setup all anchor tags with targets pointing to the current page to cause a fade on the target element when clicked.

// This is the amount of time (in milliseconds) that will lapse between each step in the fade
var FadeInterval = 300;

// This is where the fade will start, if you want it to be faster and start with a lighter color, make this number smaller
// It corresponds directly to the FadeSteps below
var StartFadeAt = 7;

var WaitToFade = 500;

// This is list of steps that will be used for the color to fade out
var FadeSteps = new Array();
	FadeSteps[1] = "ff";
	FadeSteps[2] = "ee";
	FadeSteps[3] = "dd";
	FadeSteps[4] = "cc";
	FadeSteps[5] = "bb";
	FadeSteps[6] = "aa";
	FadeSteps[7] = "99";

// These are the lines that "connect" the script to the page.
var W3CDOM = (document.createElement && document.getElementsByTagName);
addEvent(window, 'load', StartFade);

// This function automatically connects the script to the page so that you do not need any inline script
// See http://www.scottandrew.com/weblog/articles/cbs-events for more information
function addEvent(obj, eventType,fn, useCapture)
{
	if (obj.addEventListener) {
		obj.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (obj.attachEvent) {
			var r = obj.attachEvent("on"+eventType, fn);
			return r;
		}
	}
}

function StartFade()
{
	setTimeout("initFades()", WaitToFade);
}

// The function that initializes the fade and hooks the script into the page
function initFades()
{
	if (!W3CDOM) return;
    
// This section highlights targets from the URL (browser address bar)
    
    // Get the URL
    var currentURL = unescape(window.location);
    // If there is a '#' in the URL
    if (currentURL.indexOf('#')>-1) 
        // Highlight the target
        DoFade(StartFadeAt, currentURL.substring(currentURL.indexOf('#')+1,currentURL.length));
    

}

// This is the recursive function call that actually performs the fade
function DoFade(colorId, targetId) {
    if (colorId >= 1) {
		document.getElementById(targetId).style.backgroundColor = "#ffff" + FadeSteps[colorId];
		
        // If it's the last color, set it to transparent
        if (colorId==1) {
            document.getElementById(targetId).style.backgroundColor = "transparent";
		}
        colorId--;
		
        // Wait a little bit and fade another shade
        setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
	}
}
//-- END YELLOW FADE
function carvermail(nome,domain)
{
	document.write( '<a href="mail' + 'to:' + nome + '@' + domain + '">' + nome + '@' + domain + '</a>');
}


