/*var __message_transmettre;
var __message_credits;
var __message;
var __message_zoom;
*/
function desinscriptionNewsletter() {

Lightview.show({ href: "#desinscriptionNews", options: { width: 500, height: 200} });
}


function subMail() {
  
    Lightview.show({ href: "#inscriptionNews", options: { width: 500, height: 200} });
    $('newsMail').setValue($('ctl00_emailNews').getValue())
    new TestForm({onClick:sendInscription, button: 'sendNewsletter', groupe: 'inscriptionNews', className: 'champcontactins', errorClassName: 'champcontacterreurins' });
    $('inscriptionNews1').show()
    $('inscriptionNews2').hide()
    $('inscriptionNews3').hide()
    return false;
}
function sendInscription() {
    $('inscriptionNews1').hide()
    $('inscriptionNews2').show()
    
      var a = new Ajax.Request('SendNewsletter.ajax', {
        method: 'POST',
        postBody: 'mail='+$('newsMail').getValue()+'&prenom='+$('newsPrenom').getValue()+'&nom='+$('newsNom').getValue(),
        onComplete: function(transport) {
                var r = transport.responseJSON
               
                    $('inscriptionNews2').hide()
                    $('inscriptionNews3').show()
                
        }
        })


    return false
}
//ANIMATIONS FLASH

function CreateFlash(id, chemin, width, height, vars) {
    document.observe('dom:loaded', function() {
        if ($(id) != null) {
            var d = document.getElementById(id);
            var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">' +
		'<param name="movie" value="' + chemin + '" />' +
		'<param name="quality" value="high" />' +
		'<param name="wmode" value="transparent" />' +
		'<param name="flashvars" value="' + vars + '">' +
		'<embed src="' + chemin + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="' + vars + '" width="' + width + '" height="' + height + '"></embed></object>'
            d.innerHTML = flash
        }
    });
}
var __currentMenu
window.onload = function() {


}


function hideAdresseLivraison(ch){
	if(ch.checked == true){
		$('adresselivraison').style.display='block'
	}else{
		$('adresselivraison').style.display='none'
	}
}
// #################### VERIFICATION FORMULAIRES ####################
var _nom, _prenom, _mail, _tel, _fonction, _societe, _adresse, _cp, _ville, _pays


function verifpwd(){
    var first=$('ctl00_ContentPlaceHolder1_mdp').value
    var second=$('ctl00_ContentPlaceHolder1_confmdp').value
    if(first==second){
        if(first.length>3){
            return true;

        }else{
            $('err').update('4 caracteres minimum')
        }
        
    }else{
        $('err').update('Le mot de passe et la verification sont diff&eacute;rents')
    }

    return false;

}
function VerifFormContact(){
	if(!VerifChamps($("ctl00_ContentPlaceHolder1_nom"))){_nom = false} else{_nom = true}
	if(!VerifChamps($("ctl00_ContentPlaceHolder1_prenom"))){_prenom = false} else{_prenom = true}
	if(!VerifChamps($("ctl00_ContentPlaceHolder1_tel"))){_tel = false} else{_tel = true}
	if(!VerifMail($("ctl00_ContentPlaceHolder1_email"))){_mail = false} else{_mail = true}
	
	if(_nom==false || _prenom==false || _tel==false || _mail==false ){
	    $("ctl00_ContentPlaceHolder1_laerror").style.display='block';
	    return false
	}
	$("ctl00_ContentPlaceHolder1_laerror").style.display='none';	
	return true
}

function VerifFormLivraison(arr)
{
	var isOk = true;
	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_nom'))) { isOk = false; }	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_prenom'))) { isOk = false; }	
	if (!VerifMail($('ctl00_ContentPlaceHolder1_email'))) { isOk = false; }
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_adresse'))) { isOk = false; }	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_ville'))) { isOk = false; }	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_pays'))) { isOk = false; }	
    if (!VerifChamps($('ctl00_ContentPlaceHolder1_cp'))) { isOk = false; }

    if($("ctl00_ContentPlaceHolder1_membre").checked){
        if (!VerifChamps($('ctl00_ContentPlaceHolder1_nomfact'))) { isOk = false; }	
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_prenomfact'))) { isOk = false; }	
	    if (!VerifMail($('ctl00_ContentPlaceHolder1_emailfact'))) { isOk = false; }
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_adressefact'))) { isOk = false; }	
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_villefact'))) { isOk = false; }	
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_paysfact'))) { isOk = false; }
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_cpfact'))) { isOk = false; }
	    	
    }    
        return isOk 

}

function VerifForm()
{
	var isOk = true;

	if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_nom'))) { isOk = false; }	
	if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_prenom'))) { isOk = false; }	
	if (!VerifMailIns($('ctl00_ContentPlaceHolder1_email'))) { isOk = false; }
	if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_adresse'))) { isOk = false; }	
	if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_ville'))) { isOk = false; }	
	if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_pays'))) { isOk = false; }	
    if (!VerifChampsIns($('ctl00_ContentPlaceHolder1_cp'))) { isOk = false; }	



	return isOk 
}

function VerifChampsIns(c){
	if (!c.value){c.className = 'champcontacterreurins'; return false}
	else{c.className = 'champcontactins'; return true}
}

function VerifMailIns(c){
	if (!c.value){
		c.className = 'champcontacterreurins'; return false}
	else if(c.value.search(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9]+)*$/) == -1){
		c.className = 'champcontacterreurins'; return false}	
    else{
	    c.className = 'champcontactins'; return true
	}
}

function VerifChamps(c){
	if (!c.value){c.className = 'champcontacterreur'; return false}
	else{c.className = 'champcontact'; return true}
}

function FocusChamps(c){c.className = 'champfocus bloq';}
function BlurChamps(c){c.className = 'champcontact bloq';}

function VerifMail(c){
	if (!c.value){
		c.className = 'champcontacterreur'; return false}
	else if(c.value.search(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9]+)*$/) == -1){
		c.className = 'champcontacterreur'; return false}	
    else{
	    c.className = 'champcontact'; return true
	}
}



//            menucontrole : catégories sur la gauche 
//onmouseover=""showHideCat('menucontrole" & i & "')""
function showHideCat(_id){
    if(__currentMenu){
        new Effect.BlindUp(__currentMenu,{duration: 0.25, afterFinish: function(){
            if(!$('ss' + _id))return
            __currentMenu = $('ss' + _id)
            new Effect.BlindDown(__currentMenu, 1)
            }.bind(this)
        })
    }
}

function menuProduitClick(sender, el){
    var objs = $('detProduit').select('DIV#div0, DIV#div1, DIV#div2, DIV#div3, DIV#div4')
    objs.each(function(node){if (node) {node.hide()}})
    $('div'+ el.value).show();
}


