﻿// MENU
//http://jquery.sanchezsalvador.com/jquery/page/jquerycomboboxexamplealternatestyle.aspx
        $(function() {
            $("#A1").lavaLamp({
                fx: "backout",
                speed: 700,
                click: function(event, menuItem) {
                    //return false;
                }
            });
        });


// ----- Popup Control ---------------------------------------------------------
function at_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- Show Aux -----
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----
function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}
// ----- Hide ----
function at_hide()
{
  var c = document.getElementById(this["at_child"]);
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
 }
function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible")
       at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";
 
  return false;
}

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
function Nombre(){
if(event.keyCode < 45 || event.keyCode > 57) event.returnValue = false; if(event.which < 45 || event.which > 57) return false;
} 


// PIECES
function ref(num){
var theForm = document.forms.form1;
var ReccupValue = theForm.HiddPiece.value;
var ReplaceValue = "";


if (ReccupValue.indexOf(num)>=0){
		ReplaceValue = ReccupValue.replace(num,'');
		theForm.HiddPiece.value = ReplaceValue;
		
if(num == 'T1,'){
document.forms.form1.T1.style.borderColor ="#FFFFFF"
}		
if(num == 'T2,'){
document.forms.form1.T2.style.borderColor ="#FFFFFF"
}	
if(num == 'T3,'){
document.forms.form1.T3.style.borderColor ="#FFFFFF"
}	
if(num == 'T4,'){
document.forms.form1.T4.style.borderColor ="#FFFFFF"
}	
if(num == 'T5,'){
document.forms.form1.T5.style.borderColor ="#FFFFFF"
}			
		
}else{

theForm.HiddPiece.value = theForm.HiddPiece.value + num;

if(num == 'T1,'){
document.forms.form1.T1.style.borderColor ="#FF0000"
}
if(num == 'T2,'){
document.forms.form1.T2.style.borderColor ="#FF0000"
}
if(num == 'T3,'){
document.forms.form1.T3.style.borderColor ="#FF0000"
}
if(num == 'T4,'){
document.forms.form1.T4.style.borderColor ="#FF0000"
}
if(num == 'T5,'){
document.forms.form1.T5.style.borderColor ="#FF0000"
}

}

}


// RECHERCHE
img1 = "http://www.acheter-neuf.com/images/Check_appartement_off.png";
img1_1 = "http://www.acheter-neuf.com/images/Check_appartement_on.png";
img2 = "http://www.acheter-neuf.com/images/Check_villa_off.png";
img2_2 = "http://www.acheter-neuf.com/images/Check_villa_on.png";
img3 = "http://www.acheter-neuf.com/images/Check_terrain_off.png";
img3_3 = "http://www.acheter-neuf.com/images/Check_terrain_on.png";

function change_img(num){
if(num == 'appartement'){
document.form1.appartement.src = img1_1;
document.form1.villa.src = img2;
document.form1.terrain.src = img3;
document.form1.TypeBien.value = "appartement";
}
if(num == 'villa'){
document.form1.appartement.src = img1;
document.form1.villa.src = img2_2;
document.form1.terrain.src = img3;
document.form1.TypeBien.value = "villa";
}
if(num == 'terrain'){
document.form1.appartement.src = img1;
document.form1.villa.src = img2;
document.form1.terrain.src = img3_3;
document.form1.TypeBien.value = "terrain";
}
}


// SUPP
addEvent(window, 'load', init, false);
function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}




