$(document).ready(function() {
	var lang = 	document.documentElement.lang.substring(0,2);
					   
						   
    var flashvars = {};
    var params = {};
    params.quality = 'best';
    params.wmode = 'opaque';
    params.bgcolor = '#eeeeeb';
    var attributes = {};
    swfobject.embedSWF('/flash/clients.swf', 'clients_flash', '309', '60', '9.0.0', false, flashvars, {allowScriptAccess: 'always', quality: 'best', wmode: 'opaque', bgcolor: '#eeeeeb'}, attributes);
    
    flashvars.videoPath = '/flash/ellicom_reel.flv';
    flashvars.expressinstall = '/flash/expressInstall.swf';
    flashvars.version = '9';
    params.bgcolor = '#333333';
    params.wmode = 'opaque';
    params.allowScriptAccess = 'always';
    params.swLiveConnect = 'true';
    
    swfobject.embedSWF('/flash/videoPlayerOnly.swf', 'reel', '490', '273', '9.0.0', false, flashvars, params, attributes);
	
    $('.nav .home a, .nav .lang a, .nav .nous-joindre a').mouseover(function() {
      	$(this).stop().animate({ paddingTop: '15px'}, 'fast');
    }).mouseout(function() {
        $(this).stop().animate({paddingTop: '8px'}, 'fast'); 
    });
    
	$("#nav .solutions, #nav .showcase, #nav .softwares, #nav .ellicom, #nav .blog").stop().css('height','84px'); /* Jump fix */
    $('#nav .solutions, #nav .showcase, #nav .softwares, #nav .ellicom, #nav .blog').mouseover(function() {
        $(this).stop().animate({'height': '104px'}, 'fast');
    }).mouseout(function() {
        $(this).stop().animate({'height': '84px'}, 'fast');
    });
    
    $('.address').each(function() {
        $(this).html($(this).text().split('[at]').join('@').split('[dot]').join('.'));
        $(this).attr('href', 'mailto:' + $(this).text());
    });
    
    if ($.browser.msie && $.browser.version == "6.0")
        $("div#content").css('background', 'none');
	

	$(".lienPoste").toggle(function(){
		$(this).next("div").css("display","block");
		}, function () {
		$(this).next("div").css("display","none");
	});
	
	var element	=	"#screenshot .selected";
	$("#infoProduit li").mouseenter(function(){				
		$(element).stop().animate({'width': '130px'}, 'fast');
		element	=	this;
		$(element).stop().animate({'width': '350px'}, 'fast');
	});
	
	var txtImage = "Image";
	var txtOf 	 = "de";
	if (lang == "en"){
		txtImage = "Picture";
		txtOf	 = "of";
	} else if (lang == "fr"){
		txtIamge	=	"Image";
		txtOf		=	"de";
	}
	
	$("#infoProduit a").lightBox({
		imageBtnClose: '/images/site/lightbox/lightbox-btn-close-' + lang + '.gif',
		imageBtnPrev: '/images/site/lightbox/lightbox-btn-prev-' + lang + '.gif',
		imageBtnNext: '/images/site/lightbox/lightbox-btn-next-' + lang + '.gif',
		containerResizeSpeed: 350,
		txtImage: txtImage,
		txtOf: txtOf
   });
	
	$(".imgRealisation a").lightBox({
		imageBtnClose: '/images/site/lightbox/lightbox-btn-close-' + lang + '.gif',
		imageBtnPrev: '/images/site/lightbox/lightbox-btn-prev-' + lang + '.gif',
		imageBtnNext: '/images/site/lightbox/lightbox-btn-next-' + lang + '.gif',
		containerResizeSpeed: 350,
		txtImage: txtImage,
		txtOf: txtOf
   });
   
	// Check email address
	if ($("#email").length > 0) {
		$("form").submit(function() { 
			var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
			var ok = $("#email").val().match(re);
			if (!ok) {
				alert($("#validation").val());
				return false;
			}
			return true;
		});
	}
	
	//Apelle des champs à valider
	$("#nom").blur(function(){
		verifierChampCaractere("nom");						
	});
	$("#prenom").blur(function(){
		verifierChampCaractere("prenom");						
	});
	$("#courriel").blur(function(){
		verifierCourriel("courriel");							 
	});
	$("#telephone").blur(function(){
		verifierNoTelephone("telephone");							 
	});
	$("#informationForm").submit(function(){
		valide	=	true;
		verifierChampCaractere("nom");
		verifierChampCaractere("prenom");
		verifierCourriel("courriel");
		if (valide	==	true){
			return true;	
		}	
		$("#informationForm :input:visible:enabled:first").focus();
		return false;
	});

		var slideshowParams = {};
		var slideshowVars = {};
		var slideshowAttributes = {};
		slideshowParams.wmode = 'transparent';
		slideshowParams.bgcolor = '#ff3300';
		slideshowVars.rootPath	=	'/';
		slideshowVars.productsSlidePath	=	'images/productsSlide/';
		slideshowVars.productFolder	=	(lang == "en") ? "software/" : "logiciels/";
		slideshowVars.lang = lang;
		slideshowVars.expressinstall = '../../flash/expressInstall.swf';
		slideshowVars.version = '9';
		swfobject.embedSWF('/flash/productsSlide.swf','slideshow','860','390','9.0.0',false,slideshowVars, slideshowParams, slideshowAttributes);
		
		if (lang == "en"){
			var a_messageErreur	   =	new Array();
			a_messageErreur[0] =	"This field is required";
			a_messageErreur[1] = 	"This field must contain only letters";
			a_messageErreur[2] = 	"This field should be an e-mail address in the format 'user@domain.com'";
			a_messageErreur[3] = 	"This field should be a phone number in the format '555-555-5555'";
		} else if (lang == "fr"){
				var a_messageErreur	   =	new Array();
				a_messageErreur[0] =	"Ce champ est obligatoire";
				a_messageErreur[1] = 	"Le champ ne doit contenir que des lettres";
				a_messageErreur[2] = 	"Votre courriel doit respecter le format : nom@domaine.com";
				a_messageErreur[3] = 	"Votre numéro de téléphone doit comporter 10 chiffres (ex: 418-555-5555)";	
			}
});
