var url = 'http://www.peyrot-immo.fr/images/';
function over(img)
{
   tabimage = img.src.split(url);
   tab = tabimage[1].split('.');
   img.src = url+tab[0]+"_over.png";
   
   
}

function out(img)
{
   tabimage = img.src.split(url);
   tab = tabimage[1].split('.');
   
   img.src = url+tab[0].substring(0,tab[0].length - 5)+".png";
}

var i = 0;
	
function scroll_dg(direction,nb_photo)
{

   var pixMax = nb_photo * 110;
   var nbCoupMax = Math.ceil(pixMax / 330);
        if (direction == "droite") // = clic sur la fleche de gauche
        {
                if (i != 0)
                {				
                        $('#block').animate( {
                                "left":
                                "+=330px"},
                                1500);
                                i--;
                }
        }
        
        else if (direction == "gauche") // = clic sur la fleche de droite
        {
                if (i != (nbCoupMax - 1))
                {				
                        $('#block').animate( {
                                "left":
                                "-=330px"},
                                1500);
                                i++;
                }
        }
        
         if(i == 1)
            document.getElementById('f_g').src="images/f_g.png";
         if(i == 0)
            document.getElementById('f_g').src="images/pixel.png";
         if(i == (nbCoupMax - 1))
            document.getElementById('f_d').src="images/pixel.png";
         if(i == (nbCoupMax - 2))
            document.getElementById('f_d').src="images/f_d.png";
            
         
}


		$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='example1']").colorbox();
			$("a[rel='example2']").colorbox({transition:"fade"});
			$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
			$("a[rel='example4']").colorbox({slideshow:true});
			$(".example5").colorbox();
			$(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
			$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
			$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			$(".example9").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
		});


function changeImage(numero, idAnnonce,width,height)
{
   document.getElementById('image').src="http://www.peyrot-immo.fr/upload/hektor/photo"+numero+"_"+idAnnonce+".jpg";
   document.getElementById('lienLB').href="http://www.peyrot-immo.fr/upload/hektor/photo"+numero+"_"+idAnnonce+".jpg";
   
   if(width>height)
      document.getElementById('image').style.marginLeft="5px";
   else
   {
      var ratio = height / 292;
      var marge = (390 - (width/ratio)) / 2;
      document.getElementById('image').style.marginLeft=marge+"px";
      document.getElementById('image').style.height="292px";
      document.getElementById('image').style.width="";
   }
}

function changeImageLocation(numero, idAnnonce,width,height)
{
   document.getElementById('image').src="http://www.peyrot-immo.fr/uploc/"+idAnnonce+"img_vue"+numero+".jpg";
   document.getElementById('lienLB').href="http://www.peyrot-immo.fr/uploc/"+idAnnonce+"img_vue"+numero+".jpg";
   
   if(width>height)
      document.getElementById('image').style.marginLeft="5px";
   else
   {
      var ratio = height / 292;
      var marge = (390 - (width/ratio)) / 2;
      document.getElementById('image').style.marginLeft=marge+"px";
      document.getElementById('image').style.height="292px";
      document.getElementById('image').style.width="";
   }
}

function changeImageLocationAnnee(numero, idAnnonce,width,height)
{
   document.getElementById('image').src="http://www.peyrot-immo.fr/uploc/"+idAnnonce+"img_transaction"+numero+".jpg";
   document.getElementById('lienLB').href="http://www.peyrot-immo.fr/uploc/"+idAnnonce+"img_transaction"+numero+".jpg";
   
   if(width>height)
      document.getElementById('image').style.marginLeft="5px";
   else
   {
      var ratio = height / 292;
      var marge = (390 - (width/ratio)) / 2;
      document.getElementById('image').style.marginLeft=marge+"px";
      document.getElementById('image').style.height="292px";
      document.getElementById('image').style.width="";
   }
}

function verifFormReserv()
{
   var ok = false;
   if(document.forms["formReserv"].login.value != "")
   {
      if(document.forms["formReserv"].passwd.value != "")
      {
         if(document.forms["formReserv"].nom.value != "")
         {
            if(document.forms["formReserv"].prenom.value != "")
            {
               if(document.forms["formReserv"].adresse.value != "")
               {
                  if(document.forms["formReserv"].cp.value != "")
                  {
                     if(document.forms["formReserv"].ville.value != "")
                     {
                        if(document.forms["formReserv"].pays.value != "")
                        {
                           if(document.forms["formReserv"].tel.value != "")
                           {
                              if(document.forms["formReserv"].email.value != "")
                              {
                                 if(document.forms["formReserv"].pays.value != "")
                                 {
                                    var ok = true;
                                 }
                                 else
                                    alert("Message");
                              }
                              else
                                 alert("Email");
                           }
                           else
                              alert("Telephone");
                        }
                        else
                           alert("Pays");
                     }
                     else
                        alert("Ville");
                  }
                  else
                     alert("Code postal");
               }
               else
                  alert("Adresse");
            }
            else
               alert("Prenom");
         }
         else
            alert("Nom");
      }
      else
         alert("Mot de passe");
   }
   
   else
      alert("Identifiant");
      
   if(ok)
      return true;
   else
      return false;
}

function verifContact()
{
   var ok = false;
   if(document.forms["formContact"].nom.value != "")
   {
      if(document.forms["formContact"].email.value != "")
      {
         if(document.forms["formContact"].ville.value != "")
         {
            ok = true;
         }
         else
            alert("ville");
      }
      else
         alert("Email");
   }
   else
      alert("Nom");
   
   if(ok)
      return true;
   else
      return false;
}

