// JavaScript Document
var cgf_public_root = "http://www.athenaconsulenzadirezionale.it/iri/";
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;

/*
	TASKS
		ritorna una stringa identificativa del tipo di browser
	OUTS
		["ie4"|"ns4"|"ns6"]
*/
function akBrowser_get() {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all;
	if (ie4) {
		return "ie4";
	} else if (ns4) {
		return "ns4";
	} else if (ns6) {
		return "ns6";
	}
}

/*
	TASKS
		ritorna il riferimento all'oggetto style, se esiste, relativo all'oggetto di id=iObjId
	USAGE
		akObj_getStyle("[ID]");
*/
function akObj_getStyle(iObjId) {
	var styleObj;
	if(ns4) styleObj = document[iObjId];
    else if(ns6) styleObj = document.getElementById(iObjId).style;
    else if(ie4) styleObj = document.all[iObjId].style;
	return styleObj;
}

function akObj_traceProps (iObj) {	
	var c = "----------------------------------<br>";
	if (iObj.tagName) {
		c += "-- tracing del <b>TAG</b> " + iObj.tagName + " - <b>ID</b> " + iObj.id + "<br>";
	} else {
		c += "-- tracing di " + iObj + "<br>";
	}
	c += "----------------------------------<br>";
	for (var o in iObj) {
		c += o + " => " + iObj[o] + "<br>";
	}
	c += "----------------------------------<br>";
	if (iObj.tagName) {
		c += "-- tracing del <b>TAG</b> " + iObj.tagName + " - <b>ID</b> " + iObj.id + "<br>";
	} else {
		c += "-- tracing di " + iObj + "<br>";
	}
	c += "----------------------------------<br>";
	document.write(c);
}

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;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
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;
}

/* Functions that handle preload. */
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){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function setCursor (iObjId) {
	var objStyle = akObj_getStyle(iObjId);
	if (objStyle) {
		if (ns6) {
			objStyle.cursor = "pointer";
		} else if (ie4) {
			objStyle.cursor = "hand";
		}
	}
}

function annunci_goDetail (iDetailID,iDetailRef,iMid) {
	
	var url = new String(document.location);
	var firstSeparator = (url.indexOf("?") == -1) ? "?" : "&" ;
	
	var dettaglioID = firstSeparator + "dID=" + iDetailID;
	var dettaglioRef = "&dRef=" + iDetailRef;
	var menuId = (url.indexOf("mid") == -1) ? "&mid=" + iMid : "" ;
	
	url += dettaglioID + dettaglioRef + menuId;
	
	document.location = url;
	
}

function goHome (langID) {
	document.location = "../../?langID=" + langID;
}

function goAdminHome (langID) {
	document.location = "../../home.php?langID=" + langID;
}

function popitup(url)
{
	var newwindow;
	var properties = 'width=415,height=600,titlebar=0,resizable=1,top=100,left=200,scrollbars=yes';	
	newwindow = window.open(url,'name',properties);
	if (window.focus) {newwindow.focus()}
	return false;
}

function openNuovocorsoPopup (iFileName) {
	var fName = iFileName;
	var windowName = "nuovocorso";
	var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var width = (NS6) ? 485 : 485 ;
	var height = (NS6) ? 550 : 550 ;
	var scrollbars = "no";
	ak_openPopup(fName,windowName,width,height,scrollbars);
}

function openDPAPopup (iFileName) {
	
	var fName = iFileName;
	var windowName = "DPA";
	var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var width = (NS6) ? 1024 : 1024 ;
	var height = (NS6) ? 768 : 768 ;
	var scrollbars = "yes";
	winDPA = ak_openPopup(fName,windowName,width,height,scrollbars);
	
	fName = cgf_public_root + "includes/DPAchecker.php";
	windowName = "DPAchecker";
	NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	width = (NS6) ? 100 : 100 ;
	height = (NS6) ? 290 : 290 ;
	var scrollbars = "no";
	var top = "0";
	var left = "0";
	ak_openPopup(fName,windowName,width,height,scrollbars,top,left);
	
}

function ak_openPopup (fileName,windowName,width,height,scrollbars,top,left) {
	ileft = (left != undefined) ? left : (screen.width-width)/2;
	itop = (top != undefined) ? top : (screen.height-height)/2;
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	var scrollbars = (scrollbars) ? scrollbars : "yes" ;
	params += "scrollbars=" + scrollbars + ",";
	params += "resizable=yes,";
	params +="top=" + itop + ",";
	params +="left=" + ileft + ",";
	params += "width=" + width + ","; // Explorer, Navigator 2,3
	params += "height=" + height + ","; // Explorer, Navigator 2,3	
	params += "innerHeight=" + height + ","; // Navigator 4+
	params += "innerWidth=" + width; // Navigator 4+
	win = window.open(fileName, windowName, params);
	win.focus();
	return win;
}

/*
	##############################################################################################
	######################################################################################## ADMIN
*/

function annunci_adminNew (iMid,iLangID) {	
	openAnnunciAdmin_new(iMid,iLangID);	
}

function openAnnunciAdmin_new (iMid,iLangID) {
	
	var url = new String(document.location);
	var langID = "?langID=" + iLangID;
	var fName = "new_gui.php" + langID;
	
	var windowName = "AdminAnnunci";
	var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var width = (NS6) ? 820 : 820 ;
	var height = (NS6) ? 600 : 600 ;
	var scrollbars = "yes";
	ak_openPopup(fName,windowName,width,height,scrollbars);
}

function annunci_adminModify (iDetailID,iDetailRef,iMid,iLangID) {
	openAnnunciAdmin_modify(iDetailID,iDetailRef,iMid,iLangID);	
}

function openAnnunciAdmin_modify (iDetailID,iDetailRef,iMid,iLangID) {
	
	var firstSeparator = "?";
	var dettaglioID = firstSeparator + "dID=" + iDetailID;
	var dettaglioRef = "&dRef=" + iDetailRef;
	var langID = "&langID=" + iLangID;
	var menuId = "&mid=" + iMid;
	
	var fName = "modify_gui.php" + dettaglioID + dettaglioRef + menuId + langID;	
	
	var windowName = "AdminAnnunci";
	var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var width = (NS6) ? 820 : 820 ;
	var height = (NS6) ? 600 : 600 ;
	var scrollbars = "yes";
	ak_openPopup(fName,windowName,width,height,scrollbars);
	
}

function annunci_adminDelete (iDetailID,iLangID) {	
	openAnnunciAdmin_delete(iDetailID,iLangID);	
}

function openAnnunciAdmin_delete (iDetailID,iLangID) {
	
	var dettaglioID = "?dID=" + iDetailID;
	var langID = "&langID=" + iLangID;
	var fName = "delete_gui.php" + dettaglioID + langID;	
	
	var windowName = "AdminAnnunci";
	var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var width = (NS6) ? 600 : 600 ;
	var height = (NS6) ? 400 : 400 ;
	var scrollbars = "yes";
	ak_openPopup(fName,windowName,width,height,scrollbars);
}

function killCountDown () {
	var t = setTimeout("kill()",2000);
}	
function kill () {
	window.opener.location = window.opener.location;
	window.close();
}