﻿var _quoteSelectPanel;
var _quoteSelectBox;
var _applySelectBox;

function quickQuoteIni(){
    _quoteSelectPanel = getElementsByClassName(document,'div','quickQuotePanelContent')[0];
    
    if(_quoteSelectPanel){
        _quoteSelectBox = _quoteSelectPanel.getElementsByTagName('select')[0];
        _applySelectBox = _quoteSelectPanel.getElementsByTagName('select')[1];
        
        _quoteSelectBox.selectedIndex = 0;
        _applySelectBox.selectedIndex = 0;
        
        attachEventListener(_quoteSelectBox, "change", followQuoteUrl, false);
        attachEventListener(_applySelectBox, "change", followApplyUrl, false);
    }else{
        _quoteSelectPanel = getElementsByClassName(document,'div','formsQuoteApply')[0];
        if(_quoteSelectPanel){
            _quoteSelectBox = _quoteSelectPanel.getElementsByTagName('select')[0];
            _applySelectBox = _quoteSelectPanel.getElementsByTagName('select')[1];
            
            _quoteSelectBox.selectedIndex = 0;
            _applySelectBox.selectedIndex = 0;
            
            attachEventListener(_quoteSelectBox, "change", followQuoteUrl, false);
            attachEventListener(_applySelectBox, "change", followApplyUrl, false);
        }
    }
    
}

function followQuoteUrl(e){
    if(_quoteSelectBox.value != ""){
        window.location = _quoteSelectBox.value;
    }
}

function followApplyUrl(e){
    if(_applySelectBox.value != ""){
        window.location = _applySelectBox.value;
    }
}

addLoadListener(quickQuoteIni);