// Pimengo v 1.0 functions script
// Last update: 04.11.08

$(document).ready(function AnimatedScreenshot() {

    $('.extra_logo').fadeIn('fast', function() {
        $(this).animate({ opacity: 1.0 }, 3000, function() {
            $(this).fadeOut('slow', function() {
                $('.screenshot').fadeIn('fast', function() {
                    $(this).animate({ opacity: 1.0 }, 3000, function() {
                        $(this).fadeOut('slow', function() {
                                $('.extra_logo').fadeIn('fast',AnimatedScreenshot());
                            });
                        });
                    });
                });
            });
        });
    });



$(document).ready(function () {
	$('#basicModal input:eq(0)').click(function (e) {
	    e.preventDefault();
		$('#basicModalContent').modal();
		$('.popUpWhiteBackground').show();
		$('.popUpWhiteBackground').fadeTo(10,0.8);
		
	});
});

(function($){$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close(true);};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={overlay:50,overlayId:'',overlayCss:{},containerId:'modalContainer',containerCss:{},close:true,closeTitle:'Close',closeClass:'modalClose',persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}this.opts=$.extend({},$.modal.defaults,options);if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.original=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div>').html(data);}else{if(console){console.log('SimpleModal Error: Unsupported data type: '+typeof data);}return false;}this.dialog.data=data.addClass('modalData');data=null;this.create();this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}return this;},create:function(){this.dialog.overlay=$('<div>').attr('id',this.opts.overlayId).addClass('modalOverlay').css($.extend(this.opts.overlayCss,{opacity:this.opts.overlay/100,height:'100%',width:'100%',position:'fixed',left:0,top:0,zIndex:3000})).hide().appendTo('body');this.dialog.container=$('<div>').attr('id',this.opts.containerId).addClass('modalContainer').css($.extend(this.opts.containerCss,{position:'fixed',zIndex:31000000})).append(this.opts.close?'<a class="modalCloseImg '+this.opts.closeClass
+'" title="'+this.opts.closeTitle+'"></a>':'').hide().appendTo('body');if($.browser.msie&&($.browser.version<7)){this.fixIE();}this.dialog.container.append(this.dialog.data.hide());},bindEvents:function(){var modal=this;$('.'+this.opts.closeClass).click(function(e){e.preventDefault();modal.close();$('.popUpWhiteBackground').fadeOut(200); });},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click');},fixIE:function(){var wHeight=$(document.body).height()+'px';var wWidth=$(document.body).width()+'px';this.dialog.overlay.css({position:'absolute',height:wHeight,width:wWidth});this.dialog.container.css({position:'absolute'});this.dialog.iframe=$('<iframe src="javascript:false;">').css($.extend(this.opts.iframeCss,{opacity:0,position:'absolute',height:wHeight,width:wWidth,zIndex:1000,width:'100%',top:0,left:0})).hide().appendTo('body');},open:function(){if(this.dialog.iframe){this.dialog.iframe.show();}if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}this.bindEvents();},close:function(external){if(!this.dialog.data){return false;}if($.isFunction(this.opts.onClose)&&!external){this.opts.onClose.apply(this,[this.dialog]);}else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}else{this.dialog.data.remove();this.dialog.original.appendTo(this.dialog.parentNode);}}else{this.dialog.data.remove();}this.dialog.container.remove();this.dialog.overlay.remove();if(this.dialog.iframe){this.dialog.iframe.remove();}this.dialog={};}this.unbindEvents();}};})(jQuery);


function ValidateReceiverNameValue()
{
    // Get the value of the receiver name to personalize the form
    var receiverNameVal = $('.receiverNameValue').val();
    var amountVal = $('.amountVal').val();
    var giverNameVal = $('.giverNameVal').val();
    var messageVal = $('.messageVal').val();
    
    // Generate random variables of messages
    var r_text = new Array ();
    r_text[0] = 'Laissez un message pour ' + receiverNameVal;
    r_text[1] = 'Un petit mot pour ' + receiverNameVal + ' ?';
    r_text[2] = receiverNameVal + ' aime bien les messages';
    r_text[3] = 'Un message pour ' + receiverNameVal + ' ?';
    var i = Math.floor(4*Math.random());
    
    // If receiver name input is empty, then displayed text must be different
    // TODO: If receiver name start by A, E, I, O, U or Y then display "d'" instead of "de"
    
    
    
    if(receiverNameVal == '')
    {
        $('.previewReceiver').text("Madame/Mademoiselle/Monsieur");
        $('.receiverMail').text("Quel est l'email du receveur ?");
        $('.personalMessage').text('Message personnel');
        // If receiver name input is empty, the background became red (error)
        
    }
    else if(receiverNameVal == 'xXx')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Quel est l'email du petit coquin/de la petite coquine ?");
        $('.personalMessage').text('Un truc chaud pour moi ?');
    }
    else if(receiverNameVal == 'Pimengo')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Quel est l'email de Pimen... Ho ! Mais je connais mon email !");
        $('.personalMessage').text('Vous voulez vraiment me laisser un message ?');
    }
    else if(receiverNameVal == 'Nicolas Saison')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Je crois que c'est nicolas.saison@gmail.com !!!");
        $('.personalMessage').text('Si tu as trouve un bug, ecrit ca ici :');
    }
    else if(receiverNameVal == 'Nicolas Benady')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Je crois que c'est un truc qui fini par @gmail.com ! non ?");
        $('.personalMessage').text('Un cadeau pour Monsieur le President ??? ;)');
    }
    else if(receiverNameVal == 'Olivier Berthelier')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Attention Olivier a plusieurs adresses mail !!!");
        $('.personalMessage').text('Un cadeau pour le directeur marketing ? ;)');
    }
    else if(receiverNameVal == 'Antoine Asfar')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Envoie lui sur son adresse gmail !!!");
        $('.personalMessage').text('Antoine est actuellement en train de developper veuillez lui laisser un message !');
    }
    else if(receiverNameVal == 'Jerome Connac')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Quel est son petit mail perso ?");
        $('.personalMessage').text('Jerome est en RDV client ... laissez lui un message !');
    }
    else if(receiverNameVal == 'Christophe Bourbier')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Pas de Blackberry le weekend ? Quel est son petit mail perso alors ?");
        $('.personalMessage').text('Le DG est toujours OQP, laissez lui un message ! ;)');
    }
    else if(receiverNameVal == 'toto')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Il a un mail toto ? t'es sur ? ;)");
        $('.personalMessage').text("Une blague pour toto peut etre ?");
    }
    else if(receiverNameVal == 'Vinh')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("C'est quoi deja son mail a lui ?");
        $('.personalMessage').text('Vinh adore les messages coquin');
    }
    else if(receiverNameVal == 'Magnetik Band')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("magnetikband@gmail.com ? non ? !");
        $('.personalMessage').text('Un message pour le Magnetik Band ?');
    }
    else if(receiverNameVal == 'Daille Daille')
    {
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Haha, trop beau ce site... Allez, donne moi l'email !");
        $('.personalMessage').text('Ceci est le boite vocale de Didier Forest, laissez lui un message !');
    }            
    else
    {
    
        $('.previewReceiver').text(receiverNameVal);
        $('.receiverMail').text("Quel est l'email de " + receiverNameVal + ' ?');
        $('.personalMessage').text(r_text[i]);
        // If receiver name input is no more empty, the background became normal
        
    }

};

function ValidateReceiverName()
{
    // Get the value of the receiver name to personalize the form
    var receiverNameVal = $('.receiverNameValue').val();
    
    if(receiverNameVal == '')
    {
        
        $('.receiverNameValue').addClass('inputError');

    }        
    else
    {
        
        // If receiver name input is no more empty, the background became normal
        $('.receiverNameValue').removeClass('inputError');
    }

};

function ValidateAmount(){

    var amountVal = $('.amountVal').val();
    
    
    
    if(amountVal == '')
    {
        $('.previewAmount').text("750");
        $('.amountVal').addClass('inputError');

    }    
    else
    {
        $('.previewAmount').text(amountVal);
        $('.amountVal').removeClass('inputError');
    }
};

function ValidateGiverName(){
    var giverNameVal = $('.giverNameVal').val();

    
    if(giverNameVal == '')
    {
        $('.giverNameVal').addClass('inputError');
        $('.previewGiverName').text("Pimengo");
    }    
    else
    {
        $('.giverNameVal').removeClass('inputError');
        $('.previewGiverName').text(giverNameVal);

    }

};

function ValidateEmail(){
    var emailValue = $('.emailValue').val();
     
    if(emailValue == '')
    {
        $('.emailValue').addClass('inputError');
    }
    else
    {
        $('.emailValue').removeClass('inputError');
    }     

};

function ValidateDate(){
    var dateValue = $('.dateValue').val();
    
    if( document.getElementById('ctl00_cphContent_rbFuture').checked == true)
    {
    
        if(dateValue == '')
        {
            $('.dateValue').addClass('inputError');
        }
        else
        {
            $('.dateValue').removeClass('inputError');
        }
            
    }
    else
    {
        $('.dateValue').removeClass('inputError');
    }
};

function ValidateName(){
    var nameValue = $('.nameValue').val();
         
    if(document.getElementById('ctl00_cphContent_rbMaterialized').checked == true)
    {
       
        if(nameValue == '')
        {
            $('.nameValue').addClass('inputError');
           
        }
        else
        {
            $('.nameValue').removeClass('inputError');
        }
       
    }
};

function ValidateAddress(){
    
    var addressValue = $('.addressValue').val();
         
    if(document.getElementById('ctl00_cphContent_rbMaterialized').checked == true)
    {
              
        if(addressValue == '')
        {
            $('.addressValue').addClass('inputError');
        }
        else
        {
            $('.addressValue').removeClass('inputError');
        }
         
    }
};

function ValidatePostalCode(){
    
    var postalCodeValue = $('.postalCodeValue').val();
    var caractcount = /\b.{5}\b/;
    if(document.getElementById('ctl00_cphContent_rbMaterialized').checked == true)
    {

        if (postalCodeValue == '' || !postalCodeValue.match(caractcount))
        {
            $('.postalCodeValue').addClass('inputError');
        }
        else
        {
            $('.postalCodeValue').removeClass('inputError');
        }
               
    }
};

function ValidateTown(){
    
    var townValue = $('.townValue').val();
     
    if(document.getElementById('ctl00_cphContent_rbMaterialized').checked == true)
    {
        if(townValue == '')
        {
            $('.townValue').addClass('inputError');
        }
        else
        {
            $('.townValue').removeClass('inputError');
        }
            
    }
};

function ValidateCurrentPass() {

    var currentPassVal = $('.currentPassVal').val();
    if (currentPassVal == '') 
    {
        $('.currentPassVal').addClass('inputError');
    }
    else 
    {
        $('.currentPassVal').removeClass('inputError');
    }
}

function ValidateNewPass() {

    var newPassVal = $('.newPassVal').val();
    if (newPassVal == '') {
        $('.newPassVal').addClass('inputError');
    }
    else {
        $('.newPassVal').removeClass('inputError');
    }
}

function ValidateConfirmNewPass() {

    var confirmNewPassVal = $('.confirmNewPassVal').val();
    if (confirmNewPassVal == '') {
        $('.confirmNewPassVal').addClass('inputError');
    }
    else {
        $('.confirmNewPassVal').removeClass('inputError');
    }
}



$(document).ready(function()
    {
        // Display text on the load of the page
        ValidateReceiverNameValue();
        
                   
        $('.receiverNameValue').blur(function ()
            {
                ValidateReceiverName();
                ValidateReceiverNameValue();
            });
        
        // Function to display error when amount input is empty    
        $('.amountVal').blur(function ()
            {
                ValidateAmount();
            });
            
        // Function to display error when giver name input is empty    
        $('.giverNameVal').blur(function ()
            {
                ValidateGiverName();
            });   
            
        $('.messageVal').blur(function ()
            {
                $('.previewMessage').text($('.messageVal').val());  
            });   
            
        $('.emailValue').blur(function ()
            {
                ValidateEmail();

            });
            
        $('.dateValue').change(function ()
            {
                ValidateDate();

            });
            
         $('.dateValue').blur(function ()
            {
                ValidateDate();

            });
        
        $('.nameValue').blur(function ()
            {
                ValidateName();

            });
             
        $('.addressValue').blur(function ()
            {
                ValidateAddress();

            }); 
            
        $('.townValue').blur(function ()
            {
                ValidateTown();

            }); 
            
        $('.postalCodeValue').blur(function ()
            {
                ValidatePostalCode();

            });

        $('.currentPassVal').blur(function() 
        {
            ValidateCurrentPass();
            
        });

        $('.newPassVal').blur(function() 
        {
            ValidateNewPass();

        });

        $('.confirmNewPassVal').blur(function() {
            ValidateConfirmNewPass();

        });

        
    });
    



function ValidateStep1(oSrc, args)
{   
    ValidateAmount();    
    ValidateReceiverName();  
    ValidateGiverName();
    
    
    if(document.getElementById('ctl00_cphContent_rbEmail').checked == true){
        
        ValidateEmail();
        ValidateDate();
        
        if(document.getElementById('ctl00_cphContent_rbFuture').checked == true)
        {
            args.IsValid = ( Page_ClientValidate('vgAll') &&  Page_ClientValidate('vgEmail') && Page_ClientValidate('vgDate'));
        }
        else
        {
            args.IsValid = ( Page_ClientValidate('vgAll') && Page_ClientValidate('vgEmail'));        
        }
        
    }
    else
    {
        
        if(document.getElementById('ctl00_cphContent_rbMaterialized').checked == true)
        {        
            ValidateName();
            ValidateAddress();
            ValidatePostalCode();
            ValidateTown();
            
            args.IsValid = ( Page_ClientValidate('vgAll') && Page_ClientValidate('vgMaterialized'));            
        }
        else
        {
            args.IsValid = Page_ClientValidate('vgAll');
        }
    }
    
    return args.IsValid;
};


function ValidatePasswordRecovery()
{
    if(Page_ClientValidate('vgPasswordRecovery')==true)
    {   
        $('.buttonPasswordRecovery').hide();
        $('.passwordRecovery').hide();
        $('.textPasswordRecovery').show();
    }
   
};
// Wizard Step 1 Functionnalities


function HiddenMail ()
    {
               
        
        $('.hiddenTrAll').hide();
        $('.hiddenTrCard').hide();
        $('.hiddenTrMail').show(); 
        $('.imgPrintandMail').hide()
        $('.imgBoxandCard').hide()
        $('.imgPrint').show();
        $('.iconChoice1').removeClass('iconChoiceActive').addClass('iconChoice');
        $('.iconChoice3').removeClass('iconChoiceActive').addClass('iconChoice');
        $('.iconChoice2').removeClass('iconChoice').addClass('iconChoiceActive');    
            
        
    };
function HiddenCard ()
    {
    
        
          $('.hiddenTrAll').hide();
          $('.hiddenTrMail').hide();
          $('.hiddenTrCard').show();
          $('.imgPrintandMail').hide()
          $('.imgBoxandCard').show()
          $('.imgPrint').hide();
          $('.iconChoice1').removeClass('iconChoiceActive').addClass('iconChoice');
          $('.iconChoice2').removeClass('iconChoiceActive').addClass('iconChoice');
          $('.iconChoice3').removeClass('iconChoice').addClass('iconChoiceActive');    
             
         
    };
function HideAll()
    {
        
        $('.hiddenTrMail').hide();
        $('.hiddenTrCard').hide();
        $('.hiddenTrAll').show(); 
        $('.imgPrintandMail').show()
        $('.imgBoxandCard').hide()
        $('.imgPrint').hide();           
        $('.iconChoice2').removeClass('iconChoiceActive').addClass('iconChoice');
        $('.iconChoice3').removeClass('iconChoiceActive').addClass('iconChoice');
        $('.iconChoice1').removeClass('iconChoice').addClass('iconChoiceActive');
                 
  
    };
    
// Script that enable the login pop-up function
$(document).ready(function()
    {
        $('.memberLink').click(function()
            {
                $('.passwordRecoveryContent').hide();
                $('.loginMagic').show();
                $('.lbtnPasswordForgottenCss').show();
                
                $('.loginBackground').fadeTo(500,0.7);
                $('.login').fadeIn(500);
               
                
            });
        $('.closePopUpLogin').click(function()
            {   
                $('.popUpWhiteBackground').fadeOut(200);
                $('.loginBackground').fadeOut(500);
                $('.login').fadeOut(500);
                $('#previewPanel').fadeOut(500);
                $('#previewPanelMail').fadeOut(500);
                $('#previewPanelPrint').fadeOut(500);
                $('.buttonPasswordRecovery').show(500); 
                $('.passwordRecovery').show(500);
                $('.textPasswordRecovery').hide(500);  
                $('.popUpSplashPage').fadeOut(500);  
                $('#allShopsPopUp').fadeOut(200);                      
            });
        
        $('.demoModal').click(function()
            {   
                $('#allShopsPopUp').fadeIn(200);  
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);              
            });
        
        
         $('.closePopUpAbout').click(function()
            {  
                $('.popUpWhiteBackground').fadeOut(200);
                $('#aboutPanelPrint').fadeOut(500);
                $('#aboutPanelMail').fadeOut(500);
                $('#aboutPanelCard').fadeOut(500);
                                             
            });
            
            $('.modalClose').click(function()
            {  
                $('.popUpWhiteBackground').fadeOut(200);                                             
            });
           
    });
    
$(document).ready(function()
    {
        $('.lbtnPasswordForgottenCss').click(function()
            {
                $('.loginMagic').hide(200,function()
                    {
                        $('.passwordRecoveryContent').show(200);                       
                    });
            });
        $('.exitPasswordRecovery').click(function()
            {

                $('.passwordRecoveryContent').hide(200,function()
                    {
                        $('.loginMagic').show(200);
                        $('.lbtnPasswordForgottenCss').show(200);                        
                    });
            });            
            
            
    });


$(document).ready(function()
    {          
        $('.lmkButtonHelp').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('.popUpSplashPage').fadeIn(200);

            });
        $('.preview').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#previewPanel').fadeIn(200);

            });
        $('.previewMail').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#previewPanelMail').fadeIn(200);

                
            });
        $('.previewPrint').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#previewPanelPrint').fadeIn(200);

            });
        $('.aboutPrint').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#aboutPanelPrint').fadeIn(200);

            });
        $('.aboutMail').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#aboutPanelMail').fadeIn(200);

            });
        $('.aboutCard').click(function()
            {
                $('.popUpWhiteBackground').show(20);
                $('.popUpWhiteBackground').fadeTo(200,0.8);
                $('#aboutPanelCard').fadeIn(200);
            });
    });
    
//$(document).ready(function()
//    {          
//        var giverNameVal = $('.giverNameVal').val();
//        var receiverNameValue = $('.receiverNameValue').val();
//    
//       //$(".amountVal").val('Entrez le montant');
//       if(giverNameVal == '')
//        {
//            $(".giverNameVal").val('Entrez votre nom'); 
//            $(".giverNameVal").addClass('inputTextOnLoad');
//        }
//      
//       if(receiverNameValue == '')
//        {
//            $(".receiverNameValue").val('Entrez le nom du receveur');
//            $(".receiverNameValue").addClass('inputTextOnLoad');
//        }
//       
//       //$(".messageVal").val('Entrez votre message');
//       
//       
//        $(".giverNameVal").click(function()
//        {
//            if(giverNameVal == 'Entrez votre nom')
//            {
//                $(giverNameVal).val('');
//                $(giverNameVal).removeClass('inputTextOnLoad');
//            }
//        });
//        $(".receiverNameValue").click(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".amountVal").click(function()
//        {
//            //$(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".messageVal").click(function()
//        {
//            //$(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".dateValue").click(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".calButton").click(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".clock").click(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".giverNameVal").focus(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".receiverNameValue").focus(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".amountVal").focus(function()
//        {
//            //$(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".messageVal").focus(function()
//        {
//            //$(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".dateValue").focus(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".calButton").focus(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//        $(".clock").focus(function()
//        {
//            $(this).val('');
//            $(this).removeClass('inputTextOnLoad');
//        });
//    });
   
    
$(document).ready(function()
    {  
           
                 
        $('.previewMail').click(function()
        {
                var giverNamePrev = $('.giverNameVal').val();
                var receiverNamePrev = $('.receiverNameValue').val();
                var amountNamePrev = $('.amountVal').val();
                var messagePrev = $('.messageVal').val();
                
                $('.amountNamePreview').text(amountNamePrev);
                $('.messagePreview').html(messagePrev.replace(/\n/g,''));
               
                if(messagePrev == '')
                {
                    $('.messageText').hide();
                    $('.fromText').hide();
                    
                }
                else
                {
                    $('.messageText').show();
                    $('.fromText').show();
                }
                
                if(receiverNamePrev == '')
                {
                     $('.receiverNamePreview').text('');
                }
                else
                {
                    $('.receiverNamePreview').text(receiverNamePrev);                
                }
                if(giverNamePrev == '')
                {
                    $('.giverNamePreview').text('Pimengo');
                }
                else
                {
                     $('.giverNamePreview').text(giverNamePrev); 
                }
                if($('.messageVal').val() == '')
                {
                    $('.giverNameMessagePreview').text('');
                }
                else
                {
                    if(giverNamePrev == '')
                    {
                        $('.giverNameMessagePreview').text('Pimengo vous a laisse un message :');
                    }
                    else
                    {
                        $('.giverNameMessagePreview').text(giverNamePrev.concat(' vous a laisse un message :'));
                    }
                }
               
            });
            
            $('.previewPrint').click(function()
            {
                var giverNamePrev = $('.giverNameVal').val();
                var receiverNamePrev = $('.receiverNameValue').val();
                var amountNamePrev = $('.amountVal').val();
                var messagePrev = $('.messageVal').val();
                
                
                $('.amountNamePreview').text(amountNamePrev);
                                
                if(messagePrev == '')
                {
                    $('.messageText').hide();
                    $('.fromText').hide();
                    
                }
                else
                {
                    $('.messagePreview').html(messagePrev.replace(/\n/g,' '));
                    $('.messageText').show();
                    $('.fromText').show();
                }
                
                if(giverNamePrev == '')
                {
                    $('.giverNamePreview').text('Pimengo');
                }
                else
                {
                     $('.giverNamePreview').text(giverNamePrev); 
                }
               
                $('.receiverNamePreview').text(receiverNamePrev);                
               
            });
            
         
            $('.messageVal').keyup(function()
            {
                document.getElementById('ctl00_cphContent_lblCaractere').innerHTML = " caract&egrave;res.";
                var zone = document.getElementById('ctl00_cphContent_txtPersonalMessage').value;
                document.getElementById('ctl00_cphContent_lblCountField').innerHTML = 170 - zone.length;                
                var messageVal = $('.messageVal').val();
                
                var results = messageVal.split(/\n/g);
                
                if(messageVal.length>=170)
                {     
                    var messageValue = $('.messageVal').val().slice(0,170);
                    document.getElementById('ctl00_cphContent_lblCountField').innerHTML = 0;
                    document.getElementById('ctl00_cphContent_lblCaractere').innerHTML = " caract&egrave;re.";
                    document.getElementById('ctl00_cphContent_txtPersonalMessage').value = messageValue ;                                    
                }  
                if(results.length==7)
                {
                    
                    var nbResultsLength = 0;
                    
                    for(var i=0;i<results.length-1;i++)
                    {
                        nbResultsLength += (results[i].length+1);                   
                    }          
                         
                    var messageValue = $('.messageVal').val().slice(0,nbResultsLength-1+28);
                    document.getElementById('ctl00_cphContent_txtPersonalMessage').value = messageValue ;   
                }              
                if(results.length>7)
                {
                    
                    var nbResultsLength = 0;
                    
                    for(var i=0;i<results.length-1;i++)
                    {
                        nbResultsLength += (results[i].length+1);                   
                    }          
                         
                    var messageValue = $('.messageVal').val().slice(0,nbResultsLength-1);
                    document.getElementById('ctl00_cphContent_txtPersonalMessage').value = messageValue ;   
                }
                
            });
            
            
            /* SPECIAL PROMO NOEL*/
           /* 
           var amountVal = parseInt($('.amountVal').val());
                
            if(amountVal>=30)
            {
                $('.formatPrice').hide();
                $('.promoNoelPrice').show();        
            }else{
                $('.formatPrice').show();
                $('.promoNoelPrice').hide();        
            }
            
            $('.amountVal').keyup(function()
            {
            
                var amountVal = parseInt($('.amountVal').val());
                
                if(amountVal>=30)
                {
                    $('.formatPrice').hide();
                    $('.promoNoelPrice').show();        
                }else{
                    $('.formatPrice').show();
                    $('.promoNoelPrice').hide();        
                }
            
            });*/
            
    });






    $(document).ready(function() {
        $(".step1_link").css("color", "#f1bfbf");
        $(".step2_link").css("color", "#ffffff");
        $(".step3_link").css("color", "#f1bfbf");
        
        $("li.switch1").hover(function() {
            $("#switcher #pill").stop(true, true);
            $(".step1_link").css("color", "#ffffff");
            $(".step2_link").css("color", "#f1bfbf");
            $(".step3_link").css("color", "#f1bfbf"); 
            $("#switcher #pill").animate({ left: "-15px" }, 250);
            $(".scroll").animate({ left: "0px", top: "0px" }, 350);
            $("#steps li.step1").fadeIn("slow");
            $("#steps li.step2").fadeOut("fast");
            $("#steps li.step3").fadeOut("fast");
            $("#steps li.step4").fadeOut("fast");
        },
		function() {
		    $(this).addClass("done");
		});

        $("li.switch2").hover(function() {
            $("#switcher #pill").stop(true, true);
            $(".step1_link").css("color", "#f1bfbf");
            $(".step2_link").css("color", "#ffffff");
            $(".step3_link").css("color", "#f1bfbf");
            $("#switcher #pill").animate({ left: "295px" }, 250);
            $(".scroll").animate({ left: "-930px", top: "0px" }, 350);
            $("#steps li.step1").fadeOut("fast");
            $("#steps li.step2").fadeIn("slow");
            $("#steps li.step3").fadeOut("fast");
            $("#steps li.step4").fadeOut("fast");
        },
		function() {
		    $(this).addClass("done");
		});

        $("li.switch3").hover(function() {
            $("#switcher #pill").stop(true, true);
            $(".step1_link").css("color", "#f1bfbf");
            $(".step2_link").css("color", "#f1bfbf");
            $(".step3_link").css("color", "#ffffff");
            $("#switcher #pill").animate({ left: "606px" }, 250);
            $(".scroll").animate({ left: "-1860px", top: "0px" }, 350);
            $("#steps li.step1").fadeOut("fast");
            $("#steps li.step2").fadeOut("fast");
            $("#steps li.step3").fadeIn("slow");
            $("#steps li.step4").fadeOut("fast");
        },
		function() {
		    $(this).addClass("done");
		});



    });


$(document).ready(function() {
    $('.group1').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2500,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group2').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 4000,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group3').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3000,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group4').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3500,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group5').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3600,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group6').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 4500,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group7').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2200,
        pause: 1
    });
});
$(document).ready(function() {
    $('.group8').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 4200,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group9').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3100,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group10').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 4300,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group11').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2900,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group12').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3600,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group13').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2400,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group14').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2300,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group15').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 3800,
        pause: 1
    });
});

$(document).ready(function() {
    $('.group16').cycle({
        fx: 'fade',
        speed: 800,
        timeout: 2600,
        pause: 1
    });
});