﻿// JScript File

        function EnregistreWeather(lead_id,strUICultureBase,idShingle,ctrlidSlope,ctrlicourse,ctrlidEAVE,ctrlilayer,ctrlidUnderlayment)
        {//AFFICHAGE DES NOTES LORS DE LA SÉLECTION DE LA SLOPE (PENTE)
        
        
        var idSlope=0;
        var icourse=0;
        var idEAVE=0;
        var ilayer=0;
        var idUnderlayment=0;
        var opt;
        var counter;                                                
        var Slope= document.getElementById(ctrlidSlope).getElementsByTagName("INPUT");                  
        /*****SLOPE******************/
        var SlopeId;
        for (counter = 0; counter < Slope.length; counter++)
            {
            if (Slope[counter].checked)
            idSlope = Slope[counter].value; 
            }                                              
            
        /*****COURSE******************/
        opt =document.getElementById(ctrlicourse).selectedIndex;         
        icourse =  document.getElementById(ctrlicourse)[opt].value;
        
        /*****EAVE******************/
        opt =document.getElementById(ctrlidEAVE).selectedIndex;         
        idEAVE =  document.getElementById(ctrlidEAVE)[opt].value;
        
        /*****layer******************/
        opt =document.getElementById(ctrlilayer).selectedIndex;         
        ilayer =  document.getElementById(ctrlilayer)[opt].value;
        
        /*****Underlayment******************/
        opt =document.getElementById(ctrlidUnderlayment).selectedIndex;         
        idUnderlayment =  document.getElementById(ctrlidUnderlayment)[opt].value;
        
        //ON ENREGISTRE
        var pAjax = new Ajax.Request( "AjaxWeatherproofing.aspx",
                    {
                        method: "get",
                        parameters: "?Save=" + 'true' + "&idShingle=" + idShingle + "&idSlope=" + idSlope + "&icourse=" + icourse + "&idEAVE=" + idEAVE + "&ilayer=" + ilayer + "&idUnderlayment=" + idUnderlayment + "&lead_id=" + lead_id + "&strUICultureBase=" + strUICultureBase ,
                        onSuccess: function(pRequest) {
                        results = pRequest.responseText.split("|")
                        $("lblSave" + lead_id).innerHTML = results[0];
                        //$("lblUnderlaymentNote" + lead_id).innerHTML = results[1];                
                        },                    
                        onFailure: function(pRequest) {                            
                        },                    
                        onException: function(pRequest) {
                        }
                    }
                );
            }
        
		function HideDIVweather(d) {
		
		document.getElementById(d).style.display = "none"; }
		function DisplayDIVweather(id,step) 
		{ 
		    HideDIVweather("divWeather" + id + "Step1");	
		    HideDIVweather("divWeather" + id + "Step2");	
		    HideDIVweather("divWeather" + id + "Step3");	
		    HideDIVweather("divWeather" + id + "Step4");			    	    
		    document.getElementById("divWeather" + id + step ).style.display = "block"; 
		    
		}
		function AfficheInfoNote(lead_id,product_id,lang,ctrl)
        {//AFFICHAGE DES NOTES LORS DE LA SÉLECTION DE LA SLOPE (PENTE)
        var counter;                                    
        var Slope= document.getElementById(ctrl.id).getElementsByTagName("INPUT");                  
        var SlopeId;
        for (counter = 0; counter < Slope.length; counter++)
            {
            if (Slope[counter].checked)
            SlopeId = Slope[counter].value; 
            }                              
                var pAjax = new Ajax.Request( "AjaxWeatherproofing.aspx",
                    {
                        method: "get",
                        parameters: "?lang=" + lang + "&Slope=" + SlopeId + "&Product=" + product_id ,
                        onSuccess: function(pRequest) {
                        results = pRequest.responseText.split("|")
                        $("lblEaveNote" + lead_id).innerHTML = results[0];
                        $("lblUnderlaymentNote" + lead_id).innerHTML = results[1];                
                        },                    
                        onFailure: function(pRequest) {                            
                        },                    
                        onException: function(pRequest) {
                        }
                    }
                );
    }   
        
    function AfficheSommaire(controlid,lblid)
    {//AFFICHAGE DU SOMMAIRE    
    var opt;    
    opt = document.getElementById(controlid).selectedIndex;
    document.getElementById(lblid).innerHTML = document.getElementById(controlid)[opt].text;    
    } 
    
    function AfficheDescr(ctrlId,lblid,lang)
    {//AFFICHAGE DES DESCRIPTIONS
    var opt;
    opt =document.getElementById(ctrlId).selectedIndex; 
    var productId;
    productId =  document.getElementById(ctrlId)[opt].value;
    var pAjax = new Ajax.Request( "AjaxWeatherproofing.aspx",
                    {
                        method: "get",
                        parameters: "?lang=" + lang + "&Descr=Oui" + "&Product=" + productId ,
                        onSuccess: function(pRequest) {
                        results = pRequest.responseText.split("|")
                        $(lblid).innerHTML = results[0];                        
                        },                    
                        onFailure: function(pRequest) {
                            //$('aImage').value = '';
                        },                    
                        onException: function(pRequest) {
                           // $('aImage').value = '';
                        }
                    }
                );
    }      
    	
	function SelectSlope(nb,ctrlId) {
	//alert(nb);
	    var counter;                                    
        var Slope= document.getElementById(ctrlId).getElementsByTagName("INPUT"); 
        if (Slope[nb] != null)
        {
            Slope[nb].checked = true;
            }
		//document.formContent.radiobutton[nb].checked = true;
	}
	
    