﻿// JScript File

function SetInitialActiveQuestion()
{
    if(activeQuestion)
    {
        var newquestionID = activeQuestion.split("themetab")[1];

        switch(newquestionID)
        {
            case "1":  // ugb
                sImage = "img/ugbtabactive.gif";
                break;
            case "2":  // soils
                sImage = "img/soilstabactive.gif";
                break;
            case "3":  // forest land
                sImage = "img/forestlandtabactive.gif";
                break;
            case "4": // fire risk
                sImage = "img/firerisktabactive.gif";
                break;
            case "5": // conservation opportunities
                sImage = "img/conopptabactive.gif";
                break;
            case "6": // ground water
                sImage = "img/groundwatertabactive.gif";
                break; 
            case "7": // M37 claims
                sImage = "img/m37tabactive.gif";
                                break;
        }
        var activeQuestionImage = $get(activeQuestion);
        if(activeQuestionImage)
            activeQuestionImage.src = sImage;
    }
}

function ToggleActiveThemeTab(newID)
{
    // get question id from new ID
    var oldquestionID = activeQuestion.split("themetab")[1];

    // get question id from new ID
    var newquestionID = newID.split("themetab")[1];
    
    switch(oldquestionID)
    {
        case "1":  // ugb
            sImage = "img/ugbtab.gif";
            break;
        case "2":  // soils
            sImage = "img/soilstab.gif";
            break;
        case "3":  // forest land
            sImage = "img/forestlandtab.gif";
            break;
        case "4": // fire risk
            sImage = "img/firerisktab.gif";
            break;
        case "5": // conservation opportunities
            sImage = "img/conopptab.gif";
            break;
        case "6": // ground water
            sImage = "img/groundwatertab.gif";
            break;
        case "7": // M37 claims
            sImage = "img/m37tab.gif";
                            break;
    }
    // change old active to non-active style
    var activeQuestionImage = $get(activeQuestion);
    if(activeQuestionImage)
        activeQuestionImage.src=sImage;

    // set activeQuestion to new active tab
    activeQuestion = newID;
    switch(newquestionID)
    {
        case "1":  // ugb
            sImage = "img/ugbtabactive.gif";
            break;
        case "2":  // soils
            sImage = "img/soilstabactive.gif";
            break;
        case "3":  // forest land
            sImage = "img/forestlandtabactive.gif";
            break;
        case "4": // fire risk
            sImage = "img/firerisktabactive.gif";
            break;
        case "5": // conservation opportunities
            sImage = "img/conopptabactive.gif";
            break;
        case "6": // ground water
            sImage = "img/groundwatertabactive.gif";
            break;
        case "7": // M37 claims
            sImage = "img/m37tabactive.gif";
                            break;
    }
    // change style of new active link
    activeQuestionImage = $get(activeQuestion);
    if(activeQuestionImage)
        activeQuestionImage.src=sImage;
}

function SelectTheme(e)
{
    var targ;
    if (!e) var e = window.event;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) // defeat Safari bug
	    targ = targ.parentNode;

    ToggleActiveThemeTab(targ.id);
    var hfExtent = $get('hfQuestionID');
    hfExtent.value = targ.id.split("themetab")[1];
    
    //ResetAttribute();
    
     __doPostBack('hfQuestionID','');
}

// the function below is not used.  I am resetting the attribute on the
// partial page postback.  This avoids getting two postbacks, one for the change of
// hfQuestionID and one for hfAttribute

function ResetAttribute()
{
    var attributeField = $get('hfAttribute');
    if(attributeField)
        attributeField.value="";
}
