﻿if (typeof window.addEventListener == "function")
{window.addEventListener("load", function(){onLaunch();}, false);}
else
{window.attachEvent("onload", function(){onLaunch();}, false);}
 
 
/// init carousel 
function onLaunch()
{
    var width = 0;
    var height = 0;
    
    if (document.getElementById("widgetRechercheMollatSimple"))
    {
        //IE
	    if(!window.innerWidth)
	    {
		    //strict mode
		    if(!(document.documentElement.clientWidth == 0))
		    {
			    width = document.documentElement.clientWidth; 
			    height = document.documentElement.clientHeight; 
		    }
		    //quirks mode
		    else
		    {
			    width = document.body.clientWidth;
			    height = document.body.clientHeight;
		    }
	    }
	    //w3c
	    else
	    {
		    width = window.innerWidth; 
		    height = window.innerHeight; 
	    }
    	
	    if (width < 170 || height < 95)
	    { 
	        document.getElementById("widgetRechercheMollatSimple").className = "verySmall";
	        document.getElementById("txt_search").value="Livres, auteurs";
	        document.getElementById("txt_search").setAttribute("onfocus","if(this.value=='Livres, auteurs') this.value='';");
	        document.getElementById("txt_search").setAttribute("onblur","if(this.value == '') this.value='Livres, auteurs';");
	    } 
	    if (width > 170)
	    {  	    
	        document.getElementById("envoiRecherche").src ="/ds/i/nv/btn-recherche-large.png";
	        document.getElementById("envoiRecherche").style.height="";
	    }
    }
}
 

/*
//###########################################################################################################
function widgetNotice_genCode(root_url)
{
	var ean_ok = false;
	
	if (document.getElementById('widgetNotice_ean')) 
	{
	    var ean = document.getElementById('widgetNotice_ean').value;
	    
	    var widget_url = root_url + '/widgets/notice.aspx?ean=';
	    
	    if (ean.length == 13) 
	    {
    	    if (widgetNotice_checkEAN(ean)) 
    	    {
	            ean_ok = true;
	            
	            // Rechargement du code du widget dans le textarea : 
                var code = '<object data="' + widget_url + ean + '" type="text/html" width="220" height="250">'
                         + 'alt : <a href="' + widget_url + ean + '">Widget Notice Mollat</a>'
                         + '</object>';
                         
	            document.getElementById('widgetNotice_code').innerHTML = code;
	            document.getElementById('widgetNotice_code').select();
	        }
	        else {
	            ean_ok = false;
	        }
	    }
	    else 
	    {
	        ean_ok = false;
	    }
	}
	else {
	    ean_ok = false;
	}
	
	
	if (!ean_ok) 
	{
	    document.getElementById('widgetNotice_code').innerHTML = 'Veuillez saisir un Ean valide afin de pouvoir générer le code';
	}
	
}


//###########################################################################################################
// Vérification de l'Ean et rechargement du div contenant le widget 
function widgetNotice_checkEAN(ean)
{
    var xhr_url = '/widgets/ckeckEan.html?ean=' + ean;
    //  => /app_Ajax/frontOffice/AJAX_FO_RECHERCHES.aspx?sub=widget_ean
    
    var loading = '<div align="center" style="text-align:center;"><img src="/ds/i/loading-small.gif" /></div>';
    
    var myXHR = new httpRequest(xhr_url, "", "POST", true);
    myXHR.LoadContent("widgetNotice", loading, "");
    
    //alert(myXHR.xmlHttp.responseText);
    
    return (myXHR.xmlHttp.responseText.indexOf('<object') != -1);
}


//###########################################################################################################

*/

