//javascript
var closepage = 0;

function ChangeButtonColor(id) {
	document.getElementById(id).style.backgroundColor="#FFFFFF";
	document.getElementById(id).style.color="#000000";
}

function functemp() {
	alert('Non ancora disponibile...!\n\nMa non te lo hanno detto che lo faccio a tempo perso ??!!!??');
}

function chngPage(url) {
	closepage = 1;
	location.href=url;
}

var qsParm = new Array();
function qs() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			qsParm[i] = new Array();
			qsParm[i][0] = parms[i].substring(0,pos);
			qsParm[i][1] = parms[i].substring(pos+1);
			/*
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
			*/
		}
	}
}

function chngLan(idlan) {
	qrystr = "";
	qs();
	parfound=false;
	for (i=0;i<qsParm.length;i++) {
		if (qsParm[i][0]=="idlan") {
			qsParm[i][1] = idlan;
			parfound=true;
		}
		qrystr = qrystr + qsParm[i][0] + "=" + qsParm[i][1];
		if (i<qsParm.length-1) qrystr = qrystr + "&";
	}
	if (!parfound) {
		if (qrystr.length>0) qrystr = qrystr + "&";
		qrystr = qrystr + "idlan=" + idlan;
	}
		
	chngPage(location.pathname + "?" + qrystr);
}

function popup(title,img_name,img_x,img_y,win_name,img_orig,desc) {

	var wx=img_x+40;
	var wy=img_y+90;
	if (img_x < 200) {
	   var wy=img_y+90;
	}
	if (desc!="") wy = wy + 30;
	if (img_orig!="") wy = wy + 30;
	var mystring = "height="+wy+",width="+wx+",toolbar=no,scrollbars=no,menubar=no,resizable=no,status=no";
	OpenWindow=window.open("", win_name, mystring)
	OpenWindow.document.write("<HTML>\n");
	OpenWindow.document.write("<HEAD>\n");
	OpenWindow.document.write("<TITLE>"+title+"</TITLE>\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"../css_library/style.css\">\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"css_library/style.css\">\n");
    OpenWindow.document.write("</HEAD>\n");
    OpenWindow.document.write("<BODY bgcolor=\"#0A396E\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" marginright=\"0\">\n");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"left\" class=\"textwhitebold\" style=\"padding-left:20px;\">" + title + "</div>");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" style=\"width:" + wx + "px;text-align:center;\">");
	OpenWindow.document.write("<img style=\"border: 2px solid #FFFFFF;\" src=\""+img_name+"\" width=\"" + img_x + "\" height=\"" + img_y + "\" onClick=\"javascript:window.close();\">\n");
	OpenWindow.document.write("<\div>\n");
	if (desc!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" class=\"textwhite\">" + desc + "</div>");
	}
	if (img_orig!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\"><a href=\"" + img_orig + "\" target=\"_blank\" class=\"textwhite\">visualizza foto nel formato originale</a></div>");
	}
   	OpenWindow.document.write("</BODY>\n");
	OpenWindow.document.write("</HTML>\n");
	OpenWindow.document.close();
}

function popupsite(title,img_name,img_x,img_y,win_name,img_orig,desc,usr) {

	var wx=img_x+40;
	var wy=img_y+90;
	if (img_x < 200) {
	   var wy=img_y+90;
	}
	if (desc!="") wy = wy + 30;
	if (img_orig!="") wy = wy + 30;
	var mystring = "height="+wy+",width="+wx+",toolbar=no,scrollbars=yes,menubar=no,resizable=yes,status=no";
	OpenWindow=window.open("", win_name, mystring)
	OpenWindow.document.write("<HTML>\n");
	OpenWindow.document.write("<HEAD>\n");
	OpenWindow.document.write("<TITLE>"+title+"</TITLE>\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"../css_library/style.css\">\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"css_library/style.css\">\n");
    OpenWindow.document.write("</HEAD>\n");
    OpenWindow.document.write("<BODY bgcolor=\"#0A396E\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" marginright=\"0\">\n");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"left\" class=\"textwhitebold\" style=\"padding-left:20px;\">" + title + "</div>");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" style=\"width:" + wx + "px;text-align:center;\">");
	OpenWindow.document.write("<img style=\"border: 2px solid #FFFFFF;\" src=\""+img_name+"\" width=\"" + img_x + "\" height=\"" + img_y + "\" onClick=\"javascript:window.close();\">\n");
	OpenWindow.document.write("<\div>\n");
	OpenWindow.document.write("<div align=\"center\" style=\"height:10px;\"></div>");
	OpenWindow.document.write("<div align=\"right\" class=\"textwhite\" style=\"padding-right:20px;\">Fotografia inserita da " + usr + "</div>");
	if (desc!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" class=\"textwhite\">" + desc + "</div>");
	}
	if (img_orig!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\"><a href=\"" + img_orig + "\" target=\"_blank\" class=\"textwhite\">visualizza foto nel formato originale</a></div>");
	}
   	OpenWindow.document.write("</BODY>\n");
	OpenWindow.document.write("</HTML>\n");
	OpenWindow.document.close();
}

function popupsitelan(title,img_name,img_x,img_y,win_name,img_orig,desc,usr,lan) {

	var wx=img_x+40;
	var wy=img_y+90;
	if (img_x < 200) {
	   var wy=img_y+90;
	}
	if (desc!="") wy = wy + 30;
	if (img_orig!="") wy = wy + 30;
	var mystring = "height="+wy+",width="+wx+",toolbar=no,scrollbars=yes,menubar=no,resizable=yes,status=no";
	
	if (lan==1) {
		usr = "Fotografia inserita da " + usr;
		vistxt = "fotografia nel formato originale";
	} else {
		usr = "Photo inserted by " + usr;
		vistxt = "photo in original size";
	}
	
	OpenWindow=window.open("", win_name, mystring)
	OpenWindow.document.write("<HTML>\n");
	OpenWindow.document.write("<HEAD>\n");
	OpenWindow.document.write("<TITLE>"+title+"</TITLE>\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"../css_library/style.css\">\n");
	OpenWindow.document.write("<link rel=\"stylesheet\" href=\"css_library/style.css\">\n");
    OpenWindow.document.write("</HEAD>\n");
    OpenWindow.document.write("<BODY bgcolor=\"#0A396E\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" marginright=\"0\">\n");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"left\" class=\"textwhitebold\" style=\"padding-left:20px;\">" + title + "</div>");
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" style=\"width:" + wx + "px;text-align:center;\">");
	OpenWindow.document.write("<img style=\"border: 2px solid #FFFFFF;\" src=\""+img_name+"\" width=\"" + img_x + "\" height=\"" + img_y + "\" onClick=\"javascript:window.close();\">\n");
	OpenWindow.document.write("<\div>\n");
	OpenWindow.document.write("<div align=\"center\" style=\"height:10px;\"></div>");
	OpenWindow.document.write("<div align=\"right\" class=\"textwhite\" style=\"padding-right:20px;\">" + usr + "</div>");
	if (desc!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\" class=\"textwhite\">" + desc + "</div>");
	}
	if (img_orig!="") {
	OpenWindow.document.write("<div align=\"center\" style=\"height:15px;\"></div>");
	OpenWindow.document.write("<div align=\"center\"><a href=\"" + img_orig + "\" target=\"_blank\" class=\"textwhite\">" + vistxt + "</a></div>");
	}
   	OpenWindow.document.write("</BODY>\n");
	OpenWindow.document.write("</HTML>\n");
	OpenWindow.document.close();
}
