// JavaScript Document
// OUvre les fenetre avec les vignettes ou la photo du produit (pour la boutique)

function ShowCourtier (id, file) {
window.open ("FormCourtier_commande.php?id="+id+"&file="+file,"FREEDEVIS","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420")
}

function ShowExpert (id, file) {
window.open ("FormExpert_commande.php?id="+id+"&file="+file,"FREEDEVIS","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420")
}

function ShowCourtier_enr (id) {
window.open ("FormCourtier_commande_enr.php?id="+id,"FREEDEVIS","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420")
}


function MontantExtras (id) {
window.open ("devisextras/list.php?id="+id,"FREEDEVIS","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420")
}


function ShowEmailAdmin (id) {
window.open ("email/voir_email.php?id_courrier="+id,"FREEDEVIS","scrollbars=1, directories=0")
}

function ShowEmailGestionnaire (id) {
window.open ("gestion/dossier/voir_email.php?id_courrier="+id,"FREEDEVIS","scrollbars=1, directories=0")
}


function ShowVignette (id) {
window.open ("prod/vignette.php?id="+id,"FREEDEVIS","scrollbars=0, directories=0")
}
function ShowPhoto (id) {
window.open ("prod/photo.php?id="+id,"FREEDEVIS","scrollbars=0, directories=0")
}
// Ouvre la fenetre pour le graphique sur les pages des dimensions de la pi?ce.
function OpenGraphic() {
window.open ("graphique_piece.php","FREEDEVIS","scrollbars=0, directories=0, width=470, height=300")
}

// Ouvre la fenetre pour le graphique du couloir sur le select du type de pi?ce
function AfficheGraphicCouloir() {
if (document.form_piece.p_type_piece.value == 'Couloir')
 {
window.open ("el/affichecouloir.php","FREEDEVIS","scrollbars=0, directories=0, width=270, height=200")
} 
else
{
document.form_piece.p_long_piece.focus();
}
}

// Ouvre la fenetre "Mot de passe oubli?" 
function mdp () {
window.open ("mdp.php","FREEDEVIS","scrollbars=0, directories=0, width=320, height=140, top=20, left=20")
}

function confirmDel_enr(id) {
window.open ("el/confirm_del_enr.php?cde="+id,"FREEDEVIS","scrollbars=0, directories=0, width=280, height=100, top=20, left=20")
}

function showinfo(idappel,fichier,name,width,height){
window.open(""+fichier+".php?"+idappel,""+name+"","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=0,width="+width+",height="+height+",left=120,top=20")
}
//

function showinfo2(idappel,fichier,name,width,height){
window.open(""+fichier+".php?"+idappel,""+name+"","toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width="+width+",height="+height+",left=120,top=20")
}

//Commande de travaux
function open_cfd(id) {
window.open("fiches_travaux/commandedetravaux.php?id="+id,"cdt","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420");}

// Pr?facturation de travaux            
function open_pft(id) {
window.open("fiches_travaux/prefacturationtravaux.php?id="+id,"pft","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420");}

// description des travaux                 
function open_fdt(id,p) {				 
window.open("fiches_travaux/fichedescription.php?id="+id+"&p="+p,"fdt","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }
 
// proces verbal de reception des travaux          
function open_pvdrdt(id) {
window.open("fiches_travaux/procesverbalreceptiontravaux.php?id="+id,"pvdrdt","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }

// Commande de mission  
function open_cdm(id) {
window.open("fiches_mission/commandedemission.php?id="+id,"cdm","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }

// Pr? - facturation de mission
function open_pfm(id) {
window.open("fiches_mission/prefacturationmission.php?id="+id,"pfm","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }

// Fiche Qualit? mission
function open_fc(id) {
window.open("fiches_mission/fichequalite.php?id="+id,"fc","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }

// Fiche Qualit? travaux
function open_fc(id) {
window.open("fiches_travaux/fichequalite.php?id="+id,"fc","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420"); }

// POPUP DES PHOTOS DANS UN DOSSIER
function picture_window(id) {
window.open("picture_window.php","fc","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=770,height=380"); }

// Lien EL/?tape 1 
function etape1 (lieuid) {
document.location="index2.php?F=el/etape1"
}

// Lien validation de EL/l'?tape 1
function valid_etap1 (uid,lieuid) {
document.location="index2.php?F=el/valid_etap1&uid="+uid+"&lieu_id="+lieuid
}

// fonction pour popup AIDE_CODE_CLIENT.PHP
function code_client() { 
window.open("aide_code_client.php","code_client","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=440,height=380");
}

// popup de la fentre d'ajout des photos dans un dossier. 

function photo_dossier_1(dossier_id) { 
window.open("picture_window.php?d="+dossier_id,"photos","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,scrollbars=1,width=640,height=350");
}

//popup pour cr?ation d'un courrier chez le gestionnaire
function pdf_gestionaire(gestionnaire_id, dossier_id, type) { 
window.open("gestion/dossier/form_pdf_gestionnaire.php?d="+dossier_id+"&t="+type+"&gest_id="+gestionnaire_id,"gestionnaire_form_pdf","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,scrollbars=1,width=640,height=580");
}

//popup pour cr?ation d'un courrier chez l'admin 
function pdf_admin() { 
window.open("form_pdf_gestionnaire.php","admin_form_pdf","toolbar=0,location=1,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,scrollbars=1,width=640,height=550");
}

//popup pour cr?ation d'une facture chez l'admin
function pdf_facture() {
window.open("form_pdf_facture.php","admin_form_pdf_facture","toolbar=0,location=1,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,scrollbars=1,width=780,height=550");
}

//popup pour cr?ation d'un courrier chez l'admin 
function pdf_admin_dossier(gestionnaire_id, dossier_id, type) { 
window.open("form_pdf_admin.php?d="+dossier_id+"&t="+type+"&gest_id="+gestionnaire_id,"gestionnaire_form_pdf","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,copyhistory=0,scrollbars=1,width=640,height=420");
}

// popup de la pour envoyer une photo. 
function send_photo(dossier_id, photo_id) { 
window.open("what_mail_to_send_photo.php?d="+dossier_id+"&p="+photo_id,"sendphotodossier","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=0,width=520,height=240");
}

function voir_pdf(id_pdf) {
window.open("../../../entete_gestionnaire?id="+id_pdf,"voirPdf","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=1,width=595,height=420");
}

function del_photo_dossier(dossier_id, photo_id) { 
window.open("del_photo_dossier.php?d="+dossier_id+"&p="+photo_id,"delphotodossier","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=0,width=300,height=100");
}

// fenetre 'modification d'un grille tarifiaire d'un Code Cllient'
function EditGrilleUserCode(code_client_id) { 
window.open("code_client/choix.php?cc_id="+code_client_id,"grillecodeclient1","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=0,scrollbars=0,width=720,height=520");
}

// Fonction pour les couleurs des lignes si clic

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
		if (theAction == 'over' && thePointerColor != '') {
		    newColor              = thePointerColor;
		}
		else if (theAction == 'click' && theMarkColor != '') {
		    newColor              = theMarkColor;
		}
	}

    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
