// JavaScript Document

// Images listing référence
$(function(){
	$(".ref-image-fade").fadeTo("slow", 0.7); // This sets the opacity of the thumbs to fade down to 60% when the page loads
 
	$(".ref-image-fade").hover(function(){
		$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
	},function(){
   		$(this).fadeTo("slow", 0.7); // This should set the opacity back to 60% on mouseout
	});
	// Partage Twitter Facebook détail références
	$(".partage-facebook").hide();
	$(".partage-twitter").hide();
	// Partage Twitter 
	$(".img-twitter").hover(function(){
		$(".partage-twitter").show(); 
	},function(){
   		$(".partage-twitter").hide();
	});
	// Partage Facebook
	$(".img-facebook").hover(function(){
		$(".partage-facebook").show(); 
	},function(){
   		$(".partage-facebook").hide();
	});

});


function objet() 
{
	this.length = objet.arguments.length
	for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}

function changer() 
{
	document.image.src = "upload/clients/"+nom[numero];
	document.image.alt = alt[numero];
	numero += 1;
	if (numero == nom.length + 1) numero = 1;
	setTimeout("changer()", 3000);
}

/* Fonction qui pointe sur une url selon le choix d'une liste déroulante */
function liens_types() 
{
	i = document.form_choix_types.types_liste.selectedIndex;
	if (i == 0) return;
	url = document.form_choix_types.types_liste.options[i].value;
	parent.location.href = url;
}

function GereControle(Controleur, Controle, Masquer) {
var objControleur = document.getElementById(Controleur);
var objControle = document.getElementById(Controle);
	if (Masquer=='1')
		objControle.style.visibility=(objControleur.checked==true)?'visible':'hidden';
	else
		objControle.disabled=(objControleur.checked==true)?false:true;
	return true;
}

window.addEvent('domready', function(){
	//First Example
	var el = $('myElement'),
		color = el.getStyle('backgroundColor');
	
	// We are setting the opacity of the element to 0.5 and adding two events
	$('myElement').set('opacity', 0.5).addEvents({
		mouseenter: function(){
			// This morphes the opacity and backgroundColor
			this.morph({
				'opacity': 1,
				'background-color': '#c6d880'
			});
		},
		mouseleave: function(){
			// Morphes back to the original style
			this.morph({
				opacity: 0.5,
				backgroundColor: color
			});
		}
	});

	// Second Example
	
	// The same as before: adding events
	$('myOtherElement').addEvents({
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.set('tween', {
				duration: 1000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '150px');
		},
		'mouseleave': function(){
			// Resets the tween and changes the element back to its original size
			this.set('tween', {}).tween('height', '20px');
		}
	});
});

////// Detection des mobiles //////
function detectDevice(user_agent)
{
   if (!mobile_base_url)
   {
      mobile_base_url = 'http://m.vemeo.fr'
   }

   var url_mobile = mobile_base_url+document.location.pathname;
   var html_1 = 'Visitez notre site optimis&eacute; pour ';
   var html_2 = ' <a href="'+url_mobile+'">m.vemeo.fr</a>';

   // Liste des supports mobiles
   var device = new Array(
                  "Android",
                  "Blackberry",
                  "Blazer",
                  "Handspring",
                  "iPhone",
                  "iPod",
                  "Kyocera",
                  "LG",
                  "Motorola",
                  "Nokia",
                  "Palm",
                  "PlayStation Portable",
                  "Samsung",
                  "Smartphone",
                  "SonyEricsson",
                  "Symbian",
                  "WAP",
                  "Windows CE"
                );

   var max_device = device.length;

   for(i=0 ; i<max_device ; i++)
   {
      if(user_agent.indexOf(device[i]) != -1)
      {
         if (device[i] == "iPhone")
         {
            document.getElementById('annonce_site_mobile').innerHTML = html_1 + 'l\'iPhone' + html_2;
            document.getElementById('annonce_site_mobile').style.display = 'block';
         }
         else if (device[i] == "iPod")
         {
            document.getElementById('annonce_site_mobile').innerHTML = html_1 + 'l\'iPod Touch' + html_2;
            document.getElementById('annonce_site_mobile').style.display = 'block';
         }
         else if (device[i] == "Android")
         {
            document.getElementById('annonce_site_mobile').innerHTML = html_1 + 'Android' + html_2;
            document.getElementById('annonce_site_mobile').style.display = 'block';
         }
         else
         {
            document.location = url_mobile;
         }
         return;
      }
   }
}
////// Fin Detection des mobiles //////




