function deferredinitGuideMenuActivate() {
  setTimeout("deferredinitGuideMenu()", 500);
}
var countinit = 0;
function deferredinitGuideMenu(){
  // alert("ciccia");
  if (typeof meta == "object") {
    initGuideMenu();
  } else
    countinit++
  // put a cap on the number of attempts
  // dom must be stable in 2.5 seconds, otherwise we will miss the effect
  if (countinit < 5)
    setTimeout("deferredinitGuideMenu()", 100);
}

// $(document).ready(function(){
//     $(document).pngFix();
// });

//
// important: pass through aj metastructure
function fixThePng() {
    $(document).pngFix();
}

function openPopup(pagina,finestra,dimensioni,scroll) {
	stile=dimensioni+",left=50,top=50,toolbar=no,directories=no,status=no,statusbar=no,resizable=0,menubar=no,location=no,"+scroll;
  objPopup = window.open(pagina, finestra, stile);
}

function openParent(url) {
	opener.location.href=url;
  self.close();
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  else {
  	return false;
}
  return unescape(strReturn);
}

function submitForm(idForm) {
    meta.$(idForm).submit();
}

function waitingLayer() {
  $.blockUI({ message: '<div class="waitingMsg">Elaborazione in corso<br/>attendi qualche secondo</div>', css: { color: '#4DAC26' } });
  //setTimeout($.unblockUI, 2000);
}

/*
 * 20090302
 * Enrico's patch for inner html, from http://domscripting.com/blog/display/99
 */
function innerHTMLPatch(strReferenceDivId,innerHTML){
  //var container = $(strReferenceDivId); //document.getElementById(strReferenceDivId);
  var container = meta.$(strReferenceDivId);
  var theidifany = strReferenceDivId + "_rcnt";
  //var formermiddiv = $(theidifany); //document.getElementById(theidifany);
  var formermiddiv = meta.$(theidifany);
  if (formermiddiv) {
    try {
      //Element.remove(formermiddiv);
      meta.remove(formermiddiv);
    } catch(e) {
    this.dispatchException(e);
    }
  }
  var newdiv = document.createElement("div");
  newdiv.id = theidifany;
  newdiv.innerHTML = innerHTML;
  container[0].appendChild(newdiv);
}
