﻿// ----------------------------------------------------------------------------------------------
//                                  ConcatÃ©nation des JS
//                            RECUPERATION DU FICHIER bannieres2.js
// ----------------------------------------------------------------------------------------------

var delai=20000; 
var viNbImgOoshop = 2; 
var viNbImgCarrefour = 0; 
var viMaxCpt = viNbImgOoshop+viNbImgCarrefour; 
var cpt=Math.round(Math.random()*viMaxCpt); 
var viCptImg = (cpt==0)?1:cpt; 
var ptrIdImage = null; 
var ptrLinkTo = null; 
var idImage = "bandeau_ima"; 
var dossier = ""; 
var mes_images = ""; 
var mes_pages = ""; 
var dossierImgCarrefour = 'http://www.carrefour.fr/static/cfr/bannieres/shop/img'; 
var pageImgCarrefour = 'http://www.carrefour.fr/static/cfr/bannieres/shop/page'; 
var dossierImgOoshop = '/Media/PubBandeauxImages/img'; 
var pageImgOoshop = '/Content/FR/PubBandeauxRedir/page'; 

function changeimages(idImage,dossier,mes_images,mes_pages) 
{ 
    ptrIdImage = (ptrIdImage == null)?document.getElementById(idImage):ptrIdImage; 
    ptrLinkTo = (ptrLinkTo == null)?document.getElementById("linkTo"):ptrLinkTo; 
    
    if( (ptrIdImage != null) && (ptrLinkTo != null) ) 
    { 
        if(viCptImg > viNbImgOoshop) 
        { 
            ptrIdImage.src = dossierImgCarrefour+(viCptImg-viNbImgOoshop)+".gif"; 
            ptrLinkTo.href = pageImgCarrefour+(viCptImg-viNbImgOoshop)+".html"; 
            ptrLinkTo.target= '_blank'; 
        } 
        else 
        { 
            ptrIdImage.src = dossierImgOoshop+viCptImg+".gif"; 
            ptrLinkTo.href = pageImgOoshop+viCptImg+".html"; 
            ptrLinkTo.target= '_self'; 
        } 
        
        viCptImg = ((viCptImg++)>=viMaxCpt)?viCptImg=1:viCptImg; 
    } 
    
    setTimeout("changeimages(idImage, dossier, mes_images, mes_pages)",delai);
}


// ----------------------------------------------------------------------------------------------
//                                  ConcatÃ©nation des JS
//                            RECUPERATION DU FICHIER CheckMail.js
// ----------------------------------------------------------------------------------------------
function checkEmail(pEmail) {

	var atCnt,i;
	
	if (pEmail) {

		if (pEmail.length < 5) {
			return false;
		}
		if (pEmail.indexOf('@') < 1) {
			return false;
		}
		if (pEmail.indexOf('.') < 1) {
			return false;
		}
		if ((pEmail.length - pEmail.lastIndexOf('.') - 1) > 3) {
			return false;
		}

		if (pEmail.lastIndexOf('_') >= 0 && pEmail.lastIndexOf('_') > pEmail.lastIndexOf('@')) {
			return false;
		}

		atCnt = 0;
		for (i=0;i<pEmail.length;i++) {
			if (pEmail.charAt(i) == '@') {
				atCnt++;
		}
		}
		if (atCnt > 1) {
			return false;
		}

		for (i=0;i<pEmail.length;i++) {
			if (	( pEmail.charAt(i) < '0' || pEmail.charAt(i) > '9' ) &&
					( pEmail.charAt(i).toLowerCase() < 'a' || pEmail.charAt(i).toLowerCase() > 'z' ) &&
					( pEmail.charAt(i) != '_' ) &&
					( pEmail.charAt(i) != '-' ) &&
					( pEmail.charAt(i) != '.' ) &&
			(pEmail.charAt(i) != '@')) {
				return false;
		}
		}

		return true;
	}
	else {
		return false;
	}

}

// ----------------------------------------------------------------------------------------------
//                                  ConcatÃ©nation des JS
//                            RECUPERATION DU FICHIER ooshop.js
// ----------------------------------------------------------------------------------------------
/** CrÃ©ation : DST 06/08/2008
    Fonctions JavaScript gÃ©nÃ©riques
*/

/**
    fonction Ã  utiliser avec un bouton submit pour faire un postback Ã  partir d'un popup
    param inputName : le nom du input submit
    param paramIds : les ids html des parametres Ã  envoyer
*/
function popupPostback(inputName, paramIds)
{
    var parameters = '';
    if(paramIds){
        for (var i=0; i<paramIds.length; i++){
        	var param = document.getElementById(paramIds[i]);
			if(param && param.className.contains('required', ' ')){
			    if(!param.value || param.value.length<=0){
				    return false;
				}
			}
            if(param && param.id && param.value){
               parameters+=param.id+"="+param.value+";";
            }
        }
    }
    __doPostBack(inputName, parameters);
    return true;
}

/**
    fonction Ã  utiliser avec un bouton submit pour faire un postback
    param inputName : le nom du input submit
    param param : le parametre Ã  envoyer
*/
function simplePostback(inputName, param)
{
    __doPostBack(inputName, param);
    return true;
}

/**
fermer toutes les popups
*/
function closePopup()
{
    popLayer.close(null);
}

/**
fermer un niveau de popup
*/
function closePopup(level)
{
    popLayer.close(level);
}

/**
fonction pour gerer le contenu des blocs et leur Ã©tat
*/
function toggleRightBlock(inputId, blocId, headId, show){
	  var iTimeToggle01 = new Date().getTime();
    var input = document.getElementById(inputId);
    //toggleBlock.toggle(input);
    if (input) {
    input.blur();
	}
    var scrollTop = document.body.scrollTop;

    var block = document.getElementById(blocId);
    var head = document.getElementById(headId);
    if(show=="True"){
        removeClass(block, 'toggleClosed');
        removeClass(head, 'toggleClosed');
    }
    else{
        addClass(block, 'toggleClosed');
        addClass(head, 'toggleClosed');
    }       
	  var iTimeToggle02 = new Date().getTime();
    document.body.scrollTop = scrollTop;
    document.body.style.zoom = 1;
	  var iTimeToggle03 = new Date().getTime();
    setTimeout(function() {document.body.style.zoom=0}, 1);
	  var iTimeToggle04 = new Date().getTime();
    setTimeout(fixCorners,2);
	  var iTimeToggle05 = new Date().getTime();
		logs("toggle" +  blocId + ": " + (iTimeToggle01-iTimeToggle02));
		logs("toggle" +  blocId + ": " + (iTimeToggle01-iTimeToggle03));
		logs("toggle" +  blocId + ": " + (iTimeToggle01-iTimeToggle04));
		logs("toggle" +  blocId + ": " + (iTimeToggle01-iTimeToggle05));
    return false;
}


/**
    fonction pour incrementer un champs quantitÃ© produit
    plus utilisÃ©e : on utilise les scripts Fullsix
*/
function incrementQuantite(qteElementId)
{
    var qteElement=document.getElementById(qteElementId);
    if(qteElement && qteElement.value<20){
        qteElement.value++;
    }
    return false;
}

/**
    fonction pour decrementer un champs quantitÃ© produit
    plus utilisÃ©e : on utilise les scripts Fullsix
*/
function decrementQuantite(qteElementId)
{
    var qteElement=document.getElementById(qteElementId);
    if(qteElement && qteElement.value>1){
        qteElement.value--;
    }
    return false;
}

/**
    fonction pour tester si l'explorateur accepte les cookies
*/
function checkCookie(){
    if ( Get_Cookie( 'SupportCookies' ) )
    {
        return;
    }
    // remember, these are the possible parameters for Set_Cookie:
    // name, value, expires, path, domain, secure
    Set_Cookie( 'SupportCookies', 'true', '', '/', '', '' );
    // if Get_Cookie succeeds, cookies are enabled, since 
    //the cookie was successfully created.
    if ( Get_Cookie( 'SupportCookies' ) )
    {
	    //window.location = "/Home.aspx";
    }
    else
    {
	    window.location = "/WebForms/Erreur/ErreurCookie.aspx";
    }
}

/*
Script Name: Javascript Cookie Script
Author: Public Domain, with some modifications
Script Source URI: http://techpatterns.com/downloads/javascript_cookies.php
Version 1.1.1
Last Update: 4 October 2007

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
*/

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );

// To use, simple do: Get_Cookie('cookie_name'); 
// replace cookie_name with the real cookie name, '' are required
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

var setProductRP = {
    btnPlus: function(element){
                var input = document.getElementById(element);
				if (input.value<20){
					input.value++;
				}
				else
				{
				    popLayer.openTag({content:'layer_upMaxArt'})
				}
			},

     btnMoins: function(element){
                var input = document.getElementById(element);
				if (input.value>0){
					input.value--;
				}
				else
				{
				    popLayer.openTag({content:'layer_upMinArt'})
				}
			},
			
	 btnMoinsSup0: function(element){
                var input = document.getElementById(element);
				if (input.value>1){
					input.value--;
				}
				else
				{
				    popLayer.openTag({content:'layer_upMinArtSup0'})
				}
			}
};

/**
    fonction pour supprimer le scrollbar des contenu infographique
*/
 function actu_iframe()
 {
  if(navigator.appName=="Microsoft Internet Explorer" )
   {
   if(document.all) document.all.iEdito.style.height = document.frames("iEdito" ).document.body.scrollHeight;
   else document.getElementById("iEdito" ).style.height = document.getElementById("iEdito" ).contentDocument.body.scrollHeight;
   }
 else
  {
   document.getElementById("iEdito" ).style.height = document.getElementById("iEdito" ).contentDocument.body.offsetHeight+"px";
  }
 }