
function loadFaq(){
	for(i=1;i<=tabFaq.length; i++){
		document.getElementById("lienFAQ"+i).style.backgroundImage="url(https://media.laredoute.fr/INTL/PT/pt/btn-greyArrow.gif)";
		
		document.getElementById("defFAQ"+i).style.display="none";
	}
}

function ColapsFaq(idColapse){
		if(document.getElementById("defFAQ"+idColapse).style.display=="none"){
			document.getElementById("lienFAQ"+idColapse).style.backgroundImage="url(https://media.laredoute.fr/INTL/PT/pt/btn-greyArrow_bottom.gif)";
			document.getElementById("lienFAQ"+idColapse).style.backgroundPosition="0px 2px";
			
			document.getElementById("defFAQ"+idColapse).style.display="block";
		}else{
			document.getElementById("lienFAQ"+idColapse).style.backgroundImage="url(https://media.laredoute.fr/INTL/PT/pt/btn-greyArrow.gif)";
			document.getElementById("lienFAQ"+idColapse).style.backgroundPosition="0px 0px";
			
			document.getElementById("defFAQ"+idColapse).style.display="none";
		}

}
//_________________________________________________________________________login text truncation
function login_name_length_shrinker(divID){

     var loginBox = document.getElementById(divID);
     var loginBox_width = 170;
     var loginName, loginName_orig_text, loginName_text, i = 0, loginNameEL = loginBox.getElementsByTagName('span');
        
        while (loginName = loginNameEL.item(i++)) {
            link_orig_text = loginName.firstChild.nodeValue;
            while ((loginName.offsetWidth >= loginBox_width)||(newElDiv(loginNameEL))){
            
                   loginName.chomped = true;
                   
                   loginName_text = loginName.firstChild.nodeValue;
                   loginName.firstChild.nodeValue = loginName_text.substring(0, loginName_text.length - 1);
            }
            
            if (loginName.chomped) {
            
                   loginName_text = loginName.firstChild.nodeValue;
                   
                   loginName_text = loginName_text.substring(0, loginName_text.length - 2);
                   
                   loginName_text = loginName_text + '...';
                   loginName.firstChild.nodeValue = loginName_text;
                   //loginName.title = loginName_orig_text;
            }
        }


}

function newElDiv(el){
//alert(el[0].offsetHeight);
  if(el[0].offsetHeight > 30){ return true;}
 return false;
}

//_________________________________________________________________________the end of login text truncation
function WelcomeMessageInterface(cookieStringFirstName,listLogin,MessagePrefix,LoginLinkMessage,LoginLink,
                AnonymousUserMessage,listRegister,RegisterMessagePrefix,RegisterLinkMessage,RegisterLink)
	{
	    var cookieValueFirstName  = GetCookieValueFor(cookieStringFirstName);		
		var _LoginLabel = document.getElementById(listLogin);
		var _RegisterLabel= document.getElementById(listRegister);
		
		if(	_LoginLabel == null || _RegisterLabel==null)
		{
		    return;
		}		
		
		if (cookieValueFirstName != null && cookieValueFirstName.length > 0)
		{
		    if(_LoginLabel != null)
			{

		        _LoginLabel.innerHTML = '<div id="user_name_hello_message"><span>'+ MessagePrefix + ' ' + cookieValueFirstName + ' ' + '</span></div>';
		if(cookieValueFirstName.length > 26){         
		        login_name_length_shrinker("user_name_hello_message");
                }
	            
				//hides arrow
				var login_arrow = document.getElementById("thirdNav").getElementsByTagName("div");
				for(var i = 0; i < login_arrow.length; i++){
				if(login_arrow[i].className == "gr-arrow"){
				login_arrow[i].style.display="none";
				}
				}
				//end of hides arrow
				document.getElementById("second_li").style.display="none";
			}else{
			    document.getElementById("second_li").style.display="block";
			}
		}
		else
		{  
		   if(_LoginLabel!=null)
		   {
		     //  _LoginLabel.innerHTML= MessagePrefix + '&nbsp;<a href=' + LoginLink +'>'+ LoginLinkMessage + '</a>&nbsp;' + AnonymousUserMessage;
	          _LoginLabel.innerHTML= '<a href=' + LoginLink +'>'+ LoginLinkMessage + '</a>';
		   }
		   if(_RegisterLabel != null)
			{   
			    _RegisterLabel.innerHTML= '<a href=' + RegisterLink +'>'+ RegisterLinkMessage +'</a>';
		    }		    			    
		}
	}
	
	function ViewPreviousArticles(lastViewedCookie,lastViewedLink)
    {
        var cookieValueLastViewed  = GetCookieValueFor(lastViewedCookie);
        var _LastViewedLabel = document.getElementById(lastViewedLink);
        if(_LastViewedLabel==null){return;}        
        
		if (cookieValueLastViewed != null && cookieValueLastViewed.length!=0)
		{
		    _LastViewedLabel.style.display ="block";
		}
		else
		{
		    _LastViewedLabel.style.display ="none";
		}
    }
    
	function GetCookieValueFor(CookieNameString)
	{
		var cookieContents = this.document.cookie; 		
		var startIndex = cookieContents.indexOf(CookieNameString + '=');
		var cookieValue = "";
		
		if (startIndex != -1)
		{
			startIndex += CookieNameString.length + 1;			
			var endIndex = cookieContents.indexOf(';', startIndex);
			
			if (endIndex == -1)
				endIndex = cookieContents.length;		    
			cookieValue = decode(cookieContents.substring(startIndex, endIndex)).replace(/%0/g, '');
		    
			if (cookieValue.substring(0,3) == '%$&')
				cookieValue = unicodelessDecode(cookieContents.substring(startIndex, endIndex)).replace(/%0/g, '');
		}
		
		return cookieValue;
	}
//Decoder
function decode(mystring) 
{
	b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	pad="000000";
	pads = mystring.match(/=+/) ? mystring.match(/=+/)[0].length : 0;
	mystring=mystring.replace(/=/g,"A");
	out="";
	for (var i = 0; i<mystring.length; i+=4) 
	{
		temp=((b64.indexOf(mystring.charAt(i))<<18) + (b64.indexOf(mystring.charAt(i+1))<<12) + (b64.indexOf(mystring.charAt(i+2))<<6) + (b64.indexOf(mystring.charAt(i+3)))).toString(16);
		out+=(pad.substring(0,6-temp.length)+temp).replace(/../g,"%$&");
	}
	out=unescape(out.substring(0,out.length-pads*3).replace(/%00/g,""));
	return out
} 

function BasketCountInterface(cookieName, countLabel)
	{
		var basketCookieId = cookieName;  
		var cookieContents = this.document.cookie;  
		var startIndex = cookieContents.indexOf(basketCookieId + '=');		
		if (startIndex == -1)
		{
			var _countLabel = document.getElementById(countLabel);
			_countLabel.innerHTML = "0";
		}
		else
		{
			startIndex += basketCookieId.length + 1;
			var endIndex = cookieContents.indexOf(';', startIndex);
			if (endIndex == -1)
				endIndex = cookieContents.length;
			var basketCount = cookieContents.substring(startIndex, endIndex);			
			var _countLabel = document.getElementById(countLabel);
			_countLabel.innerHTML = basketCount;
		}
	}


function OnSizeChange(ddlSizeID, panelSizeErrorID, txtSizeID, panelSubstitutableID)
			{
			    
				var ddlSize = document.getElementById(ddlSizeID);
				var panelSizeError = document.getElementById(panelSizeErrorID);
				var txtSize = document.getElementById(txtSizeID);
				var panelSubstitutable = document.getElementById(panelSubstitutableID);
				//txtSize.value = ddlSize.value;
				if(ddlSize.selectedIndex == 0)
				{
				    panelSizeError.style.display ="block";
				}
				else
				{
				    panelSizeError.style.display= "none";
				}
				
				if(ddlSize.options[ddlSize.selectedIndex].value != '' && ddlSize.options[ddlSize.selectedIndex].value.indexOf("--1") != -1)
				{
				    panelSubstitutable.style.visibility ="visible";
				}
				else
				{
				    panelSubstitutable.style.visibility= "hidden";
				}
			}
			
function popwin(_url, _width, _height)
{
	window.open(_url,'','topmargin=0,leftmargin=0,marginheight=0,marginwidth=0,width='+_width+',height='+_height+',toolbar=no,menubar=no,scrollbars=auto,resizable=yes'); 
}

//Rollover
function rollover(objId, src){
	document.getElementById(objId).src=src;
}

//start: these functions are for the SkyScraper Chameleon zone on the home page
function getDebutSky(divAdvUrl)
{   
    var str="";
    try
    {   
        var adUrlValue = GetInnerText(divAdvUrl);
        
        if(adUrlValue !="" && adUrlValue != undefined && adUrlValue != null)
        {   
            str = "<scr"+"ipt language='javascript1.1' src='"+ adUrlValue + "'></scr" + "ipt>";
            
        }
        return(str);
    }
    catch(err)
    {   return("");}
}
function GetInnerText(divId)
{
    var s = "";
    var d = document.getElementById(divId);
 
    try
    {   if(navigator.userAgent.indexOf("MSIE") > 0)
        {    s = d.innerText;//for IE
        }
        else
        {    s = d.textContent;//for FF
        }
        //remove all spaces
        if(s != "" && s != undefined && s != null)
        {
            s = s.replace(/\s*/gim,"");
            return(s);
        }
        else
            return("");
    }
    catch(err)
    {   return("");
    }
}
function findPos(obj) 
{
    var curleft = curtop = 0;
    if (obj.offsetParent) 
    {   curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}
function placeAdv()
{
    try
    {   var advLayer = document.getElementById("advLayer2");
        var global = document.getElementById("LaRedouteScreen");
        var globalPos = findPos(global);
        advLayer.style.top  = '144px';
        var x = globalPos[0] + 783;
        advLayer.style.left = x+"px";
        
    }
    catch(err)
    {}
}
                

//end: these functions are for the SkyScraper Chameleon zone on the home page

//start: Function for links in Description tab in tab control
//function ShowClickableWord(word)
//{
//    var url = GetCountryLanguagePrefix();
//    if (url != null)
//    {
//        if (url.length == 7)
//        {
//            url = url + "Popups/Pop_Clickableword.aspx?word=" + word;
//            w=window.open(url, "ClickableWord", "scrollbars=yes,width=798,height=250,left=50, top=50");
//            w.focus();
//	    }
//	}
//}

function GetCountryLanguagePrefix()
{
    var path = window.location; 
    var re = new RegExp("(/[a-zA-Z]{2}/[a-zA-Z]{2}/)");
    var m = re.exec(path);
    if (m != null) {
        return m[0];
    }
}
//end: Function for links in Description tab in tab control











// BEGIN scripts for header 2010 

$j(document).ready(function () {

    /* Shopping per brands */
    $j('.header .brands a.btn,.header .brands ul').hover(function () {
        $j('.header .brands ul').show();
    }, function () {
        $j('.header .brands ul').hide();
    });



    /* Display Megatabs pink bubbles */
    $j('.megatabs li a').hover(function () {
        $j(this).parent().find('.bulle_mt').show();
    }, function () {
        $j(this).parent().find('.bulle_mt').hide();
    });

    DD_roundies.addRule('.coins', '4px', true);


    /* Main menu */
    $j('ul.cat_nav li[jsontab]').hover(function () {
        if ($j(this).attr('jsontab') == "OUTLET") {
            $j(this).addClass('outlet_selected');
        } else {
            $j(this).addClass('selected');
        }
        var submenu = $j(this).find('.ct_smenu');
        if (submenu.html() == '') {
            var content = c_generateMenuHMTL($j(this).attr('JSONTAB'), json);
            submenu.html(content);
        }
        submenu.show();
    }, function () {
        if ($j(this).attr('id').indexOf(active_cat) == -1) {
            if ($j(this).attr('jsontab') == "OUTLET") {
                $j(this).removeClass('outlet_selected');
            } else {
                $j(this).removeClass('selected');
            }
        }
        var submenu = $j(this).find('.ct_smenu');
        submenu.hide();

    });
});


/* Sub categories lmayers management */
function c_generateMenuHMTL(marche, items, isSub) {

    html = new Array();
    layer = 1;

    for (var i in items) {
        if (i == marche) {
            html.push('<div class="ct_smenu_ctn">');
            html.push('<div class="ct_cat_layer">');
            html.push('<div class="cat_layer">');
            if (items[i]) {
                var items2 = items[i];
                for (var j in items2) {
                    switch (layer) {
                        case 1:
                            classe = "cat_layer_left";
                            layer = layer + 1;
                            break;
                        case 2:
                            classe = "cat_layer_center";
                            layer = layer + 1;
                            break;
                        case 3:
                            classe = "cat_layer_right";
                            layer = layer + 1;
                            break;
                    }
                    html.push('<div class="' + classe + '">');
                    html.push('<dl>');
                    html.push('<dt class="gl_marche">');
                    html.push(j);
                    html.push('<\/dt>');
                    if (items2[j]) {
                        var items3 = items2[j];
                        html.push('<dd>');
                        html.push('<ul>');
                        for (var k in items3) {
                            html.push('<li>');
                            html.push(k);
                            if (items3[k]) {
                                var items4 = items3[k];
                                html.push('<ul>');
                                for (var l in items4) {
                                    html.push('<li>');
                                    html.push(l);
                                    html.push('<\/li>');
                                }
                                html.push('<\/ul>');
                            }
                            html.push('<\/li>');
                        }
                        html.push('<\/ul>');
                        html.push('<\/dd>');
                    }
                    html.push('<\/dl>');
                    html.push('<\/div>');
                }
            }
            html.push('</div>');
            html.push('</div>');
            html.push('</div>');
        }
    }
    return html.join('');
}


// END scripts for header 2010 
