/*
################################################################################
    Doc: maitre.js

    Au sujet de: 
        routine pr le site de editionsliber.org
        
        *auteur* : André Beaudry
        
        *date* : 08 avr 2004 
        
        © 2003-2005, André Beaudry. Tous droits réservés.    		 
        
################################################################################     
*/


var obj_visiteur = new function(){        
    
    this.compatible = false;
    this.app = "";
    this.ver = 0;
    this.os = window.navigator.platform ? window.navigator.platform.toLowerCase() : "inconnu";
    this.agent = window.navigator.userAgent.toLowerCase();
    var v;
    var safari = (this.agent.indexOf('safari')!=-1);
    var gecko = (this.agent.indexOf('gecko')!=-1) && !safari;       // explicte famille de moz pas de safari
    
    if (gecko){
        v = this.agent.substr(this.agent.indexOf('rv:')+3 );    
        this.ver =  parseFloat(v.substr(0, v.indexOf(')') ));
        this.app = "gecko";
    } 
    else {
        var msie = ( (this.agent.indexOf("msie") != -1) && (this.agent.indexOf('opera') == -1) && (this.os=="win32"));
        if (msie){
            v = this.agent.substr(this.agent.indexOf('msie')+4 );
            this.ver =  parseFloat(v.substr(0, v.indexOf(';') ));
            this.app = "msie";
        }
    }
        
    switch (this.app){    
        case "msie" :
            if (this.ver >= 5.0)
                this.compatible = true;
            break;
        case "gecko" :
            if (this.ver >= 1.4)
                this.compatible = true;
            break;
        default :
            this.compatible = false;       
    }       
    
}

// teste incompatibilité
//
if (0){
    obj_visiteur.compatible = false
}


// redirection en fct de la compatibilité
//
if (  !obj_visiteur.compatible ){
    //document.close();
   // window.location = "/prerequis.html";
} 







var FI_preloadImg_preImages = new Array();
var FI_preloadImg_currCount = 0;
var FI_preloadImg_loaded = new Array()
var FI_preloadImg_timerID;

function FI_preloadImg_init(arr_img){
    var i;
    if( window.document.images ) {
        for (i=0; i < arr_img.length; i++) { 
            FI_preloadImg_preImages[i] = new Image();
            FI_preloadImg_preImages[i].src = arr_img[i];
        }
        
        for (i=0; i<FI_preloadImg_preImages.length; i++)
            FI_preloadImg_loaded[i] = false;
            
        FI_preloadImg_chk();
    }
}
function FI_preloadImg_chk(){
    // si ... alors terminer
	if (FI_preloadImg_currCount == FI_preloadImg_preImages.length) {
        window.document.close();
        return;
    }
	for (var i=0; i<=FI_preloadImg_preImages.length; i++)
		if (FI_preloadImg_loaded[i] == false && FI_preloadImg_preImages[i].complete) {
			FI_preloadImg_loaded[i] = true;
			// si code temoin alors ici le code
			FI_preloadImg_currCount++;
		}
	FI_preloadImg_timerID = setTimeout("FI_preloadImg_chk()",10);
}

function FI_setImg(str_name, str_href){
    for (var i=0; i<FI_preloadImg_preImages.length; i++){
        if (FI_preloadImg_preImages[i].src.indexOf(str_href)!=-1){
            window.document.images[str_name].src=FI_preloadImg_preImages[i].src;
            
            break;
        }
    }
}

function FI_setSrc(str_id, str_href){
    if (window.document.getElementById(str_id))
        window.document.getElementById(str_id).src = str_href;
}


function go2sub()
{
    window.open("http://www.subcommunication.com", "_blank" );
}

function mail2liber()
{
    window.document.location = "mailto:info" + "@" + "editionsliber.org";
}


// nav catalogue
//
function FI_cat_nav(get_p, get_idx, get_nbAff, get_idxVue)
{ 

    var str_url = str_base_doc + "?p="+get_p+"&idx="+get_idx+"&nbAff="+get_nbAff+"&idxVue="+get_idxVue;
    window.document.location.href = str_url;
 

    // notes
    // pr IE 
    // window.document.location.href accepte une valeur que si le script est appellé par
    // un href="javascript:maFct();"
    // n'est pas executé par un onClick="maFct();" !
    //
}

function FI_rech_nav(get_idx)
{
    window.document.forms['rech'].idx.value = get_idx;
    window.document.forms['rech'].submit();
}


function FI_nav_back()
{
    if (document.all){
        history.back();
        
    }
    else {
        window.back()
    }
}


var str_base_doc = "/";
window.onload = function(event){
 // preload img gui
 
    FI_preloadImg_init( new Array( 
        "/img_statik/liber_17_over.gif", 
        "/img_statik/liber_17.gif", 
        "/img_statik/liber_20_over.gif", 
        "/img_statik/liber_20.gif", 
        "/img_statik/liber_menu_0_03.gif", 
        "/img_statik/liber_menu_1_03.gif", 
        "/img_statik/liber_menu_0_05.gif", 
        "/img_statik/liber_menu_1_05.gif",
        "/img_statik/liber_menu_0_07.gif", 
        "/img_statik/liber_menu_1_07.gif", 
        "/img_statik/liber_menu_0_09.gif",
        "/img_statik/liber_menu_1_09.gif",
        "/img_statik/liber_menu_0_11.gif",
        "/img_statik/liber_menu_1_11.gif") ); 
 
}
