﻿//Troca de imagens
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_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 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;
}

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];
  }
}

//Troca fundo TD menu
function changeColor(obj, flag) {
    if (obj.parentNode != null && obj.parentNode != undefined) {
        var color = (flag == 'on') ? '#B79889' : '#FEEFE2';
        var opositeColor = (flag == 'on') ? '#FEEFE2' : '#B79889';
        obj.parentNode.style.backgroundColor = color;
        obj.parentNode.style.color = opositeColor;
    }
}

//aparece e desaparece div ou layer
function show(obj)
{
	MM_swapImage('view','','Images/ajax-loader2.gif',1);
	obj = document.getElementById(obj);
	obj.style.visibility = 'visible';
}
function hide(obj)
{
	MM_swapImage('view','','Images/ajax-loader2.gif',1);
	obj = document.getElementById(obj);
	obj.style.visibility = 'hidden';
}


//Cadastro reserva (retorna numero de dias de um mes dado)
function carregaDias(selDia,selAno,selMes) {
  var objAno = document.getElementById(selAno);
  var objMes = document.getElementById(selMes);
  var objDia =  document.getElementById(selDia);
  
  var dia = 0;
  var mes = objMes[objMes.selectedIndex].value;
  var ano = objAno[objAno.selectedIndex].value;
  
  
  if ( objDia != null && objDia != undefined) { 
    
    //retorna numero de dias do mes
    //se 4,6,9,11
    if( mes == 4 || mes == 6 || mes == 9 || mes == 11) {
        dia = 30;
    } else {
        //se fevereiro
        if(mes == 2) {
            //se nao for bisexto
            if( (ano % 4 != 0) || ((ano % 100 == 0) && (ano % 400 != 0)) ) {
                dia = 28;
            } else {
                dia = 29;
            }
        //outros meses
        } else {
        dia = 31;
        }
    }
    //limpa select
    var count = objDia.length - 1;
    for (var i=count; i >= 0; i--) {
    objDia.remove(i);
    }
    for(var i=1; i <= dia; i++) {
        var oOption = document.createElement("OPTION");
        oOption.text = i;
        oOption.value = i;
        objDia.add(oOption);
    }
  }
}


//Google maps
function initialize() {
  var obj =  document.getElementById("map_canvas");
 // if (GBrowserIsCompatible()) {
    if ( obj != null && obj != undefined) { 
    var map = new GMap2(obj); 
        
    map.addControl(new GSmallMapControl()); 
    map.addControl(new GMapTypeControl()); 
        

    map.setMapType(G_NORMAL_MAP);
    map.setCenter(new GLatLng(-23.5740985,-46.6432770), 16); 

    var point = new GLatLng(-23.5740985, -46.6432770); 
    map.addOverlay(new GMarker(point));
    //map.openInfoWindow(map.getCenter(), document.createTextNode("Residenza Mantovani"));
    }
  //}//if GBrowser
}

