var http = false;
if (window.XMLHttpRequest) {
	http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
	http = new ActiveXObject("Microsoft.XMLHTTP");
}
		var statusText = new Array();
		statusText[100] = "Continue";
		statusText[101] = "Switching Protocols";
		statusText[200] = "OK";
		statusText[201] = "Created";
		statusText[202] = "Accepted";
		statusText[203] = "Non-Authoritative Information";
		statusText[204] = "No Content";
		statusText[205] = "Reset Content";
		statusText[206] = "Partial Content";
		statusText[300] = "Multiple Choices";
		statusText[301] = "Moved Permanently";
		statusText[302] = "Found";
		statusText[303] = "See Other";
		statusText[304] = "Not Modified";
		statusText[305] = "Use Proxy";
		statusText[306] = "(unused, but reserved)";
		statusText[307] = "Temporary Redirect";
		statusText[400] = "Bad Request";
		statusText[401] = "Unauthorized";
		statusText[402] = "Payment Required";
		statusText[403] = "Forbidden";
		statusText[404] = "Not Found";
		statusText[405] = "Method Not Allowed";
		statusText[406] = "Not Acceptable";
		statusText[407] = "Proxy Authentication Required";
		statusText[408] = "Request Timeout";
		statusText[409] = "Conflict";
		statusText[410] = "Gone";
		statusText[411] = "Length Required";
		statusText[412] = "Precondition Failed";
		statusText[413] = "Request Entity Too Large";
		statusText[414] = "Request-URI Too Long";
		statusText[415] = "Unsupported Media Type";
		statusText[416] = "Requested Range Not Satisfiable";
		statusText[417] = "Expectation Failed";
		statusText[500] = "Internal Server Error";
		statusText[501] = "Not Implemented";
		statusText[502] = "Bad Gateway";
		statusText[503] = "Service Unavailable";
		statusText[504] = "Gateway Timeout";
		statusText[505] = "HTTP Version Not Supported";
		statusText[509] = "Bandwidth Limit Exceeded";
function rc_post(idget){
	
	var num = document.getElementById(idget).elements.length;
	var url = "";

	//radio button 
	var j = 0;
	var a = 0;
	var radio_buttons = new Array();
	var nome_buttons = new Array();
	var the_form = window.document.getElementById(idget);
	for(var i=0; i<the_form.length; i++){
		var temp = the_form.elements[i].type;
		if ( (temp == "radio") && ( the_form.elements[i].checked) ) { 
			nome_buttons[a] = the_form.elements[i].name;
			radio_buttons[j] = the_form.elements[i].value; 
			j++; 
			a++;
		}
	}
	for(var k = 0; k < radio_buttons.length; k++) {
		url += nome_buttons[k] + "=" + radio_buttons[k] + "&";
	}
	//checkbox
	var j = 0;
	var a = 0;
	var check_buttons = new Array();
	var nome_buttons = new Array();
	var the_form = window.document.getElementById(idget);
	for(var i=0; i<the_form.length; i++){
		var temp = the_form.elements[i].type;
		if ( (temp == "checkbox") && ( the_form.elements[i].checked) ) { 
			nome_buttons[a] = the_form.elements[i].name;
			check_buttons[j] = the_form.elements[i].value; 
			j++; 
			a++;
		}
	}
	for(var k = 0; k < check_buttons.length; k++) {
		url += nome_buttons[k] + "=" + check_buttons[k] + "&";
	}
	for (var i = 0; i < num; i++){
		
		var chiave =document.getElementById(idget).elements[i].name;
		var valore =document.getElementById(idget).elements[i].value;
		var tipo =document.getElementById(idget).elements[i].type;

		if ( (tipo == "submit") || (tipo == "radio") || (tipo == "checkbox") ){}
		else {
			url += chiave + "=" + valore + "&";
		}
	}
	return url;
}
function ajax(action,target,get,idform) {
	if (!get){
		get="GET";
	}
	parameters="";
	get=get.toUpperCase();
	document.getElementById(target).innerHTML = '<img src="i/loader.gif" alt="" style="border:0;" /><br /><br /><br />';
	if (get=="GET"){
		if(idform){
			parameters = rc_post(idform);
			action=action+"?"+parameters;
		}
		http.open(get, action);
		http.onreadystatechange = function (){
			ajaxdone(target);
		}
		http.send(null);
	}
	if (get=="POST"){
		parameters= rc_post(idform);
		http.open(get, action);
		http.onreadystatechange = function (){
			ajaxdone(target);
		}
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.send(parameters);	
	}
}
function ajaxdone(target){
	if (http.readyState == 4) { 
		//if(statusText[http.status] === "OK") {
			document.getElementById(target).innerHTML = http.responseText;
		//}else{
		//	document.getElementById(target).innerHTML = "Impossibile effettuare l'operazione richiesta.<br />" +"Errore riscontrato:  "+http.status+" - " + statusText[http.status];
		//}
 	}
}


function copri(N) {
	
	for(i=2;i<=N;i++){
	div=document.getElementById('dettaglio-release'+i);
	gam=div.style.display;
	document.getElementById('dettaglio-release'+i).style.display="none";
				document.getElementById('specifiche'+i).style.display="none";
				
					document.getElementById('release'+i).style.background="#000";
				document.getElementById('release'+i).style.border="0";
				document.getElementById('release'+i).style.color="#fff";	
							document.getElementById('dett-rel-link'+i).style.display="block";	
				document.getElementById('dett-rel-link'+i).style.color="#fff";	
	document.getElementById('dettaglio-release'+i).style.display="none";

	}

	}


function pannello(NN , N) {

	for(i=2;i<=N;i++){
	div=document.getElementById('dettaglio-release'+N);
	gam=div.style.display;

	if(div!=('dettaglio-release'+NN))


					document.getElementById('release'+i).style.background="#000";
				document.getElementById('release'+i).style.border="0";
				document.getElementById('release'+i).style.color="#fff";	
								document.getElementById('dett-rel-link'+i).style.display="block";	
				document.getElementById('dett-rel-link'+i).style.color="#fff";	
	document.getElementById('dettaglio-release'+i).style.display="none";
	document.getElementById('specifiche'+i).style.display="none";

	}

	divx=document.getElementById('dettaglio-release'+NN);
	relx=document.getElementById('release'+NN);
		dttx=document.getElementById('dett-rel-link'+NN);
		spxx=document.getElementById('specifiche'+NN);
	gamx=divx.style.display;
	damx=relx.style.display;

	if(gamx=="none"){
		divx.style.display="block";
		relx.style.background="#fff";
				relx.style.border="1px solid #a9a9a9";
				relx.style.color="#a9a9a9";	
					dttx.style.display="none";	
					spxx.style.display="block";				
	}else{
		divx.style.display="none";
spxx.style.display="none";				
dttx.style.display="block"
	}
	

	
}

function replaceobject(uno,due,tre){
document.write('<object type="application/x-shockwave-flash" data="i/player.swf?traccia='+uno+'&amp;i='+due+'&amp;playit='+tre+'" width="100%" height="15"><param name="movie" value="i/player.swf?traccia='+uno+'&amp;i='+due+'&amp;playit='+tre+'" /><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;Lang=Italian&amp;P5_Language=Italian" class="getflash"><br />Non &egrave; installato il plug-in flash player. Per visualizzare questo elemento scarica il plug-in dal sito della Macromedia.</a></object>');
}

function robject(uno,due,tre){
document.write('<object type="application/x-shockwave-flash" data="'+uno+'" width="'+due+'" height="'+tre+'"><param name="movie" value="'+uno+'" /><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;Lang=Italian&amp;P5_Language=Italian" class="getflash"><br />Non &egrave; installato il plug-in flash player. Per visualizzare questo elemento scarica il plug-in dal sito della Macromedia.</a></object>');
}

function homeobject(uno){
document.write('<object type="application/x-shockwave-flash" data="'+uno+'" width="120" height="100"><param name="movie" value="'+uno+'" ?>" />Per visualizzare il filmato hai bisogno del Flash Player</object>');
}

//link esterni
function popUpLink(urlPop) {
	l = (screen.width-440)/2;
	t = (screen.height-380)/2;
  newWin = window.open(urlPop,"nuovafinestr");
}


var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;
		
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

window.onload = function() {
Drag.init(document.getElementById("titolo-della-news"),document.getElementById("pop-up"));
}

