﻿// Gestion des sous formulaires d'ajout en popup 
var mouseOverColor="#e4007b"  
    
function SaveSubForm(sfName)
    {var url = new String
    url="../inc/async/InsertItem.aspx?sfName="+sfName
    
    var ddlName = new String
    var params = ""
    if (sfName=="Periodique")
        {params+="&p1="+GetLocalValue("tb_Per_Titre","tb")
        //params+="&p2="+GetLocalValue("ddl_Per_Editeur","ddl")
        //params+="&p3="+GetLocalValue("ddl_Per_Domaine","ddl")
       // params+="&p4="+GetLocalValue("ddl_Per_Periodicite","ddl")
        ddlName="tb_ddl_Periodique"
        }
    if (sfName=="Discipline")
        {params+="&p1="+GetLocalValue("tb_Disc_Discipline","tb")
        ddlName="tb_ddl_Discipline"
        }
    if (sfName=="Editeur")
        {params+="&p1="+GetLocalValue("tb_Ed_Editeur","tb")
        //params+="&p2="+GetLocalValue("tb_Ed_Contact","tb")
        //params+="&p3="+GetLocalValue("tb_Ed_Adresse","tb")
        //params+="&p4="+GetLocalValue("tb_Ed_CP","tb")
        //params+="&p5="+GetLocalValue("tb_Ed_Ville","tb")
        //params+="&p6="+GetLocalValue("tb_Ed_Téléphone","tb")
        //params+="&p7="+GetLocalValue("tb_Ed_Fax","tb")
        //params+="&p8="+GetLocalValue("tb_Ed_Email","tb")
        //params+="&p9="+GetLocalValue("tb_Ed_Site","tb")
        ddlName="tb_ddl_Editeur"
        }
    if (sfName=="Collection")
        {params+="&p1="+GetLocalValue("tb_Col_Collection","tb")
        ddlName="tb_ddl_Collection"
        }
    if (sfName=="Format")
        {params+="&p1="+GetLocalValue("tb_Form_Format","tb")
        ddlName="tb_ddl_Format"
        }
    //window.open(url + params)         
    var ret = new String
    ret = updateParamWithReturn(url+params)  
    var retId = ret.substring(0,ret.indexOf("_"))
    var retVar = ret.substring(ret.indexOf("_")+1)
    //alert(ret)
    document.getElementById("ctl00_Content_"+ddlName).value=retVar
    document.getElementById("ctl00_Content_"+ddlName+"_Id").value=retId
    ClosePopup()
    } 

function GetLocalValue(CtrlId,CtrlType)
    {var ret = new String
    if (CtrlType=="ddl")
        {ret = ddl_GetValue("ctl00_Content_"+CtrlId)}
    else    
        {ret=document.getElementById("ctl00_Content_"+CtrlId).value}
    return ret
    }
function setPopUpMemberValue(obj,srcId,srcType)
    {if (srcType=="ddl")
        {ddl_SetSelectedValue("ctl00_Content_"+srcId,obj.options[obj.selectedIndex].value)}
    else    
        {document.getElementById("ctl00_Content_"+srcId).value=obj.value}
    }        
    

// function spécifiques
  function CheckNature(cId) {
    
    if (document.getElementById("tbody_Period")==null)
        {return;}
    document.getElementById("tbody_Period").style.display="none"
    document.getElementById("tbody_Colloq").style.display="none"
    document.getElementById("tbody_Memoire").style.display="none"
    
    if (cId==2) // périodique
        {document.getElementById("tbody_Period").style.display="block";}
        
    if (cId==4) // actes de colloques
        {document.getElementById("tbody_Colloq").style.display="block";}
        
    if (cId==3) // Thèse ou mémoire
        {document.getElementById("tbody_Memoire").style.display="block";}
    
    CheckDoubles()    
    }
  
//survols et Focus    
var curObjWithFocus = null
function GetFocus(obj) {
    
        if (curDivShow != null)
        { curDivShow.style.display = "none" }
        
        if (curObjWithFocus != null)
        {curObjWithFocus.style.backgroundColor="#fff"
        //curObjWithFocus.style.borderColor="#bbb"
        curObjWithFocus.style.cursor="default"
        }
    obj.style.backgroundColor="#eee"
    //obj.style.borderColor="#aa0000"
    obj.style.cursor="auto"
     
    var objId = obj.id.replace("ctl00_Content_","")
    if (document.getElementById("Div_Auteurs")!=null)
        {document.getElementById("Div_Auteurs").style.display="none"
        document.getElementById("Div_AuteursColle").style.display="none"
        document.getElementById("Div_McMatiere").style.display="none"
        document.getElementById("Div_McDomaine").style.display="none"
        document.getElementById("Div_McLibres").style.display="none"
        }
        
    if (objId=="lb_Auteur")
        {document.getElementById("Div_Auteurs").style.display="block"}
    if (objId=="lb_AuteursColl")
        {document.getElementById("Div_AuteursColle").style.display="block"}
    if (objId=="lb_McMatiere")
        {document.getElementById("Div_McMatiere").style.display="block"}
    if (objId=="lb_McDomaine")
        {document.getElementById("Div_McDomaine").style.display="block"}
    if (objId=="lb_McLibres")
        {document.getElementById("Div_McLibres").style.display="block"}
   
        
    curObjWithFocus=obj
    return true
    }
    

var FloatHelpLeftPos=0;

function HideFloatHelp()
    {document.getElementById("FloatHelp").style.display="none"
    }
function ShowFloatHelp(event,tbId,objSource,top, leftRech) {
    if (_inputField!=null)
        {_inputField.blur()}
        var objSourceTop = calculateOffset(objSource.parentNode, "offsetTop")
        var left;
        var width = 162;
        if (calculateOffset(objSource.parentNode, "offsetLeft") < 100)
            {left=4 }
            else { left = 664 }

            if (leftRech != null)
            { left = leftRech }
        //document.getElementById("Tb_Ddl_Content").style.display="none"
        var FloatDiv = document.getElementById("FloatHelp")
        var e = event || window.event;
        FloatDiv.style.display="block"
        FloatDiv.innerHTML = document.getElementById("help_" + tbId).innerHTML
        FloatDiv.style.left = left + "px";
        FloatDiv.style.width = width + "px";
        //FloatDiv.style.top = String((e.y || e.clientY) - FloatDiv.offsetHeight - 10 + document.documentElement.scrollTop ) + "px"
        FloatDiv.style.top = (objSourceTop + 20)  + "px"
    }
        
    
function SetHelp(helpId)
    {//var helpDiv = document.getElementById(helpId)  
    //if (helpDiv!=null)
    //    {document.getElementById("HelpContent").innerHTML = helpDiv.innerHTML}
    }   
function mouseMove(obj,sens)
    {/*if (sens=="in")
        {obj.style.borderColor=mouseOverColor}
    else
        {if (obj!=curObjWithFocus)
            {obj.style.borderColor="#bbb"}                
        }
    */
    //var objId = obj.id.replace("ctl00_Content_","")
    //var helpDiv = document.getElementById("help_"+objId)
      
    //if (helpDiv!=null)
    //    {document.getElementById("HelpContent").innerHTML = helpDiv.innerHTML}

    }       