document.write ('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function checkOS() {
  if(navigator.userAgent.indexOf('Linux') != -1)
    { var OpSys = "Linux"; }
  else if((navigator.userAgent.indexOf('Win') != -1) &&
  (navigator.userAgent.indexOf('95') != -1))
    { var OpSys = "Windows95"; }
  else if(navigator.userAgent.indexOf('Win') != -1)
    { var OpSys = "Windows3.1 or NT"; }
  else if(navigator.userAgent.indexOf('Mac') != -1)
    { var OpSys = "Macintosh"; }
  else { var OpSys = "other"; }
  return OpSys;
}

var OpSys = checkOS();

beginRollover = false;// This handles a bug in Nav4.0x that executes the code too quickly.

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                      (agt.indexOf("; nav") != -1)) );
var is_nav5 = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));

var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var isIE4, isIE4PC, isNav4PC, isNav4, isNav3;

if (is_ie4 || is_ie4up || is_nav5 || is_nav5up) {
        isIE4 = true;
        if (OpSys != "Macintosh") {
                isIE4PC = true;
        }
} else if (is_nav4) {
        isNav4 = true;
        if (OpSys != "Macintosh") {
                isNav4PC = true;
        }
} else if  (is_nav) {
        isNav3 = true;
}

self.name = "parentWin";
function openDec(url, name, w, h) {
        popupWin = window.open(url, name, 'resizable=0,scrollbars=0,width=' + w + ',height=' + h + '');
    // focus window (only for Navigator >= 3.0)
    if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") )
    popupWin.focus();
}
        // Browser check Function
function Browser() {
        var b=navigator.appName;
        if (b=="Netscape") this.b="ns";
        else if (navigator.userAgent.indexOf("Opera")>0) this.b = "opera";
        else if (b=="Microsoft Internet Explorer") this.b="ie";
        if (!b) alert('Unidentified browser./nThis browser is not supported,');
        this.version=navigator.appVersion;
        this.v=parseInt(this.version);
        this.ns6=(this.v>=5 && this.b=='ns')
        this.ns=(this.b=="ns" && this.v>=4);
        this.ie=(this.b=="ie" && this.v>=4);
        var ua=navigator.userAgent.toLowerCase();
        if (ua.indexOf("win")>-1) this.platform="win32";
        else if (ua.indexOf("mac")>-1) this.platform="mac";
        else this.platform="other";
}
is  = new Browser();
// Function to write style sheet dependng on browser
if (is.platform=='mac')	{
                    if (is.ns6)	{
                                        document.write('<link rel="stylesheet" href="/css/Mcom_ns6mac.css">');
                        }
                        else if (is.ns) {
                                        document.write('<link rel="stylesheet" href="/css/Mcom_nsmac.css">');
                        }

                        else {
                                        document.write('<link rel="stylesheet" href="/css/Mcom_iemac.css">');
                        }
}
else if (is.platform=='win32')	{
                        if (is.ns6)	{
                                        document.write('<link rel="stylesheet" href="/css/Mcom_ns6.css">');
                        } else if (is.ns){
                                        document.write('<link rel="stylesheet" href="/css/Mcom_ns.css">');
                        }
                        else {
                                        document.write('<link rel="stylesheet" href="/css/Mcom_ie.css">');
                        }
}
else {
                document.write('<link rel="stylesheet" href="/css/Mcom_ie.css">');
}



function showImage(filename, imageName)
                        {
                        document.images[imageName].src = filename;
                    }



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function doLoad() {
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 60000 );
}

function doLoadSec(s) {
    // the timeout value should be the same as in the "refresh" meta-tag
    var tempo;
    tempo = 1000 * s;
    setTimeout( "refresh()", tempo);
}

function refresh() {
    window.location.href = window.location.href;
}

function chiudi(){
    window.close() ;
}


function createRequestObject() {
  var FORM_DATA;
  var separator;
  var query;
  var keypairs;
  var numKP;
  var i;
  var keyName;
  var keyValue;

  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.

  separator = ',';
    // The token used to separate data from multi-select inputs

  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.

  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.

  if (query.length < 1) { return false; }  // Perhaps we got some bad data?

  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.

  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.

  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }

    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics

    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}


function popUpInfo(pPage,nPage,width,height) {

  self.name = 'key';
  var dim = 'width='+width+',height='+height;
  var winOpts = 'toolbar=no, resizable=no, scrollbars=no,'+dim;

popUpWin = window.open(pPage,nPage,winOpts);

}

function popUpIng(pPage,nPage,width,height) {

  self.name = 'ing';
  var dim = 'width='+width+',height='+height;
  var winOpts = 'toolbar=no, resizable=no, scrollbars=yes,'+dim;

popUpWin = window.open(pPage,nPage,winOpts);

}

function apriPopupNews(theURL) {

self.name="news";

var winOpts = 'resizable=no,scrollbars=yes,width=710,height=700';

window.open(theURL,'',winOpts);
}


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;
}

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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

// AJAX BOX TESTATE CUCINA
function aggiornaTestateCucina() {
	var updatetestate =  new Ajax.Updater ('testatericerca','/app/Cucinahome/aggiornatestatericerca', {method:'post',parameters: {cbofonte: $F('cbofonte'), listaTestate: $F('listaTestate')}});			
}
	
function cancellaTestateCucina(eliminafonte, listaTestate){

   	var listaFonti = document.getElementById("listaTestate").value;
   	var array = listaFonti.split(",");
   	var newlistaFonti='';
   	
   	for (i=0; i< array.length-1; i++) {
		if (array[i] != eliminafonte) {
			newlistaFonti +=	array[i]+',';
		}
	} 	
	document.getElementById("listaTestate").value = newlistaFonti;
	var updatetestate =  new Ajax.Updater ('testatericerca','/app/Cucinahome/aggiornatestatericerca', {method:'post',parameters: {eliminatestata: eliminafonte, listaTestate: newlistaFonti}});				
}

// AJAX BOX TESTATE ARREDAMENTO
function aggiornaTestateArredamento() {
	var updatetestate =  new Ajax.Updater ('testatericerca','/app/Arredamentohome/aggiornatestatericerca', {method:'post',parameters: {testata: $F('testata'), listaIdtestate: $F('listaIdtestate')}});			
}

function cancellaTestateArredamento(eliminatestata, listaIdtestate){

   	var listaFonti = document.getElementById("listaIdtestate").value;
   	var array = listaFonti.split(",");
   	var newlistaFonti='';
   	
   	for (i=0; i< array.length-1; i++) {
		if (array[i] != eliminatestata) {
			newlistaFonti +=	array[i]+',';
		}
	} 
	document.getElementById("listaIdtestate").value = newlistaFonti;	
	var updatetestate =  new Ajax.Updater ('testatericerca','/app/Arredamentohome/aggiornatestatericerca', {method:'post',parameters: {eliminatestata: eliminatestata, listaIdtestate: newlistaFonti}});				
}

// Ajax box testate fotografi ricerca ordini
function aggiornaTestateFotografo() {
	var options = {  method:'post'
					   , parameters: {tipoordine: $F('tipoordine')}
	                   , onLoading  : function(){$("loader").show();}
	                   , onComplete : function(){$("loader").hide();}
	                  }

	var updatecombo =  new Ajax.Updater ('boxcombo','/app/amministrazione/aggiornatestatefotografo', options);			
}

function showPopupPdf(elementId){
	var sContent= document.getElementById(elementId).innerHTML;
	//alert(sContent);
	overlib(sContent,STICKY,'Scelta', CAPTION,'Scegli:', RIGHT, OFFSETX, OFFSETY);
	event.returnValue=false;
}

function openPopupPdf(url) {		
	window.open(url,'pdf','location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes, width=800,height=600,left=100,top=20');
}
