﻿function zoom(oObj) {
    var urlFoto = oObj.src;
    var width = oObj.width;
    var height = oObj.height;
    var w = 0;
    var h = 0;
    if (width > height) {
        w = 640; 
        h = 480;
    }else{
        w = 480;
        h = 640;
    }
    //alert(urlFoto + '-' + w + '-' + h);
    zoomWindow = window.open('zoom.aspx?urlFoto=' + urlFoto, 'Casee', 'top=100,left=100,width=' + w + ',height=' + h + ',status=1,scrollbars=1,resizable=1', true);
    zoomWindow.focus();
    return false;
}
function change (oObjThumb,idFoto)
{
    var oObjFoto = document.getElementById(idFoto);
    var srcFoto = oObjFoto.src;
    oObjFoto.src = oObjThumb.src.replace("thumbs/","");
    oObjThumb.src = srcFoto.replace("foto_inser/", "foto_inser/thumbs/");
    return false;
}
function login() {
    var par = document.getElementById("ctl00_ctl00_txtUte").value + "|" + document.getElementById("ctl00_ctl00_txtPwd").value;
    var parEx = escapeAll(par);
   // alert(parEx);
    //window.open("http://lnx.casee-web.com/agenzie/loginPortale.php?P=" + parEx, "Casee", "location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes", true);
	var urlWin = "http://lnx.casee-web.com/agenzie/loginPortale.php?P=" + parEx;
	var nomeWin = "CaseeLogin";
	var mode="location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes";
	OpenMenuLink (urlWin, nomeWin, false, mode)
	}

function escapeAll(string) {
    var hex = '';
    for (i = 0; i < string.length; i++) {
        hex += strPadLeft(string.charCodeAt(i).toString(16), 2);
    }
    return hex.toUpperCase();
}
function strPadLeft(n, l) {
    while (n.length < l) {
        n = '0' + n;
    }
    return n;
}

function iOnFocus(oObj){
    if(oObj.value=="nome utente" ||oObj.value=="password") {
        oObj.value="";
        oObj.style.fontStyle="normal";
        oObj.style.color="black" ;
        if (oObj.name == "ctl00$ctl00$txtPwd") {
            document.getElementById("passwordbox").innerHTML = "<input name=\"ctl00$ctl00$txtPwd\" type=\"password\" id=\"ctl00_ctl00_txtPwd\" value=\"\" class =\"iLogin\" onBlur=\"iOnBlur(this);\"/>";
            setTimeout("document.getElementById(\"ctl00_ctl00_txtPwd\").focus();", 100);
             //oObj.type="password";
            //oObj.value="";
        }
    }
}
function iOnBlur(oObj){
    if(oObj.value=="") {
        oObj.style.fontStyle="italic";
        oObj.style.color="#838383" ;
        if (oObj.name == "ctl00$ctl00$txtPwd") {
            document.getElementById("passwordbox").innerHTML = "<input name=\"ctl00$ctl00$txtPwd\" type=\"text\" id=\"ctl00_ctl00_txtPwd\" value=\"password\" class =\"iLogin\" onFocus=\"iOnFocus(this);\" onBlur=\"iOnBlur(this);\"/>";
            }
        else
            oObj.value="nome utente";
        }
}
function upper(oObj)
{
oObj.value=oObj.value.toUpperCase();
}
var arrWin=new Array();
var arrWinKeys=new Array();

function OpenMenuLink(urlWin, nomeWin, replace, mode)
// Apertura windows ASP.NET
{
  var flag = true;
  // se non devo fare il replace, la win non e nulla e non è chiusa vuole dire che la win c'è già e non la devo rinfrescare quindi faccio il focus
  if (!replace) {
    if (arrWin[nomeWin] != null) {
      if (!arrWin[nomeWin].closed) {
        flag = false;
      }
    }
  }
  if (flag) {
  // altrimenti se la cerco nell'array
    var bExist = false;
    for ( var i = 0 ; i < arrWinKeys.length ; i++ ) {
      if ( arrWinKeys[i].toUpperCase() == nomeWin.toUpperCase() ) 
		bExist = true;
    }
	//se non esiste ce la metto
    if ( !bExist ) 
		arrWinKeys[arrWinKeys.length] = nomeWin;
	// poi in ogni caso la ricreo e gli do il fuoco
    arrWin[nomeWin] = window.open(urlWin, nomeWin, mode, !bExist);
    arrWin[nomeWin].focus();
  }
  else
    arrWin[nomeWin].focus();    
  return false;
}
