
// JavaScript Document

//----------------------------------------------------------------------------------------------------
// Prompt erreur
//----------------------------------------------------------------------------------------------------
function runPrompt (){
    if( document.getElementById("bg_fonce")==null || document.getElementById("bg_Prompt")==null )
        return false;
    Bkg();
    autoShowHide    ('bg_fonce',   'show', false);
    autoShowHide    ('bg_Prompt',  'show', false);
    $("#bg_Prompt").css({
        'display':'block'
    });
    timer = window.setTimeout("stopPrompt()",10000);
	return true;
}

function stopPrompt (){
    autoShowHide    ('bg_fonce',   'hide', false);
    autoShowHide    ('bg_Prompt',  'hide', false);
    $("#bg_Prompt").css({
        'display':'none'
    });
    $("#htmlprompevent").html('');
    window.clearTimeout(timer);
}

function executerValidation ( retour ){
	window.setTimeout('PopInCreate		("", "popin")', 500);
	window.setTimeout('PopInRender		("'+retour+'")',	1500);
	window.setTimeout('PopInDesctruct	("popin")',		10000);
}

//----------------------------------------------------------------------------------------------------
// Fonctions relatives aux popins messages
//----------------------------------------------------------------------------------------------------

/*
 * title          : titre de la fenêtre
 */
function PopInCreate (title, id_name){
	if (title==null)
        title = "";
    if (id_name==null)
        id_name = "popin";
    this.node       = document.createElement("div");
    $(this.node).attr({
        id: id_name
    });
    $(this.node).addClass('hide');
    $(this.node).appendTo(document.body);

    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popin-node1"
    });
    $(this.node).addClass('box');
    $(this.node).addClass('box-prompt');
    $(this.node).appendTo("#"+id_name);

    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popin-node2"
    });
    $(this.node).addClass('box-title');
    $(this.node).appendTo("#popin-node1");
	if (title!="")
		document.getElementById("popin-node2").innerHTML =    "<p id=\"popintitle\"></p><div class=\"boxright\" onclick=\"PopInDesctruct('"+id_name+"');return false;\"></div>";
	else
		document.getElementById("popin-node2").innerHTML =    "<div class=\"boxright\" onclick=\"PopInDesctruct('"+id_name+"');return false;\"></div>";

    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popin-node3"
    });
    $(this.node).addClass('box-content');
    $(this.node).appendTo("#popin-node1");

    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popin-content"
    });
    $(this.node).addClass('box-body');
    $(this.node).appendTo("#popin-node3");

    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popinRender"
    });
    $(this.node).addClass('loader');
    $(this.node).appendTo("#popin-content");
    this.node       = document.createElement("div");
    $(this.node).attr({
        id: "popinAjax"
    });
    $(this.node).addClass('show');
    $(this.node).appendTo("#popinRender");
    Bkg();
    autoShowHide ('bg_fonce',           'show', false);
    autoShowHide (id_name,              'show', false);
    autoShowHide ('popin-content',      'show', false);
    PopInReset ();
    PopInTitle (title);
}
/*
* Attribut le nom titre de la popin
*/
function PopInReset (){
    if (document.getElementById("popinAjax"))
        document.getElementById("popinAjax").innerHTML = "<br /><br />";
    if (document.getElementById("popinRender"))
        $("#popinRender").addClass("loader");
}
/*
* Attribut le nom titre de la popin
*/
function PopInTitle (title){
    $("#popintitle").text(title);
}
/*
* Détruit le rendu de la popin
*/
function PopInDesctruct (id_name){
    if (id_name==null)
        id_name = "popin";
    $("#"+id_name).remove();
    autoShowHide ('bg_fonce',           'hide', false);
}
/*
 * Exécute le rendu de la confirmation d'ajout au panier
 */
function PopInRender (data){
    document.getElementById("popinAjax").innerHTML = data;
    $("#popinRender").removeClass("loader");
}
