﻿var myTabs = new YAHOO.widget.TabView("bestInClassVoting", { orientation: 'top' });

var AWARD = {
    init: function() {
        var els;
        
//        els = YAHOO.util.Selector.query('a:not([href^=#]), input[class=search_btn]');
//        els = YAHOO.util.Selector.filter(els, ':not(div[class=this_Page] > a)');
//        
//        for (var i = 0; i < els.length; i++) {
//            var link = els[i];
//            link.setAttribute('onclick', 'return navigateAway()');
//        }  
//        
//        els = YAHOO.util.Selector.query('select[name=select]');
//        for (var i = 0; i < els.length; i++) {
//            var link = els[i];
//            link.setAttribute('onchange', 'if (navigateAway()) { PB.JumpSelect(this) }');
//        }
        
        els = Dom.getElementsByClassName('selectedDescription');
        for (var i = 0; i < els.length; i++) {
            if (els[i].id !== 'tab1Text') {
                els[i].style.display = 'none';
            }
        }
        
        els = YAHOO.util.Selector.query('li[id^=tab]');
        YAHOO.util.Event.addListener(els, 'click', this.showHideDescription);        
    },
    
    showHideDescription: function (e) {
        var target = this;
        var el, re, id;
        
        var els = Dom.getElementsByClassName('selectedDescription');
        for (var i = 0; i < els.length; i++) {
            els[i].style.display = 'none';
        }

        re = /tab(\d+)Tab/i;
        id = re.exec(target.id)[1];
        el = document.getElementById('tab' + id + 'Text');
        
        el.style.display = '';
    }
    
    
};

Event.onDOMReady(AWARD.init, AWARD, true);

function showHideDescriptionById(id) {
    var el;
    
    var els = Dom.getElementsByClassName('selectedDescription');
    for (var i = 0; i < els.length; i++) {
        els[i].style.display = 'none';
    }
    el = document.getElementById('tab' + id + 'Text');
    
    el.style.display = '';
}

function navigateAway() {
    var leave = confirm('Your ballot has not been submitted.\n\rAre you sure you want to leave?');
    return leave;
}

function submit() {
    document.formID_58.submit();
}

var fields = [
        { id: 'award24',                 label: 'Innovator\'s Award' },
        { id: 'award25',                 label: 'Best Redesigned Web Site' },
        //{ id: 'award19',                 label: 'Best Marketing Use of Health Content' },
        { id: 'award27',                 label: 'Best Method of Driving Traffic to the Web Site' },
        //{ id: 'award13',                 label: 'Best Redesigned Intranet' },
        { id: 'award28',                 label: 'Best Use of Multimedia' },
        { id: 'award29',                 label: 'Best Use of Mobile Strategy' },
        { id: 'award37',                 label: 'Best Integration of Print-Web-Mobile ' },
        { id: 'award38',                 label: 'Best Use of Health Content to Drive ROI' },
        { id: 'award39',                 label: 'Best Use of Health Content for Patient Support ' },
        { id: 'award40',                 label: 'Best Redesigned Web Site - AMCs' },
        //{ id: 'award22',                 label: 'Best Redesigned Web Site - Microsites' }
        //{ id: 'award20',                 label: 'Best Use of Cross-Media Approaches' },
        //{ id: 'award26',                 label: 'Best Use of Social Media' },
        //{ id: 'award14',                 label: 'Most Efficient Use of Limited Web Resources' },
        { id: 'award41',                 label: 'Best Overall Social Media Strategy' },
        { id: 'award42',                 label: 'Best Execution of Social Media Tactics' }
        //{ id: 'award31',                 label: 'Convergence Award' }



//        { id: 'innovatorsAward',        label: 'Innovator\'s Award' },
//        { id: 'bestRedesignedWeb',      label: 'Best Redesigned Web Site' },
//        { id: 'bestRedesignedWebAMC',      label: 'Best Redesigned Web Site - AMC' },
//        { id: 'bestRedesignedIntranet', label: 'Best Redesigned Intranet' },
//        { id: 'bestAnalytics',          label: 'Best Use of Web Analytics' },
//        { id: 'mostEfficient',          label: 'Most Efficient Use of Limited Web Resources' },
//        { id: 'bestSocialMedia',        label: 'Best Use of Social Media' },
//        { id: 'bestIntegration',        label: 'Best Integration of Content to Drive Results' },
//        { id: 'bestMethod',             label: 'Best Method of Driving Traffic to Web Site' },
//        { id: 'bestCrossMedia',         label: 'Best Use of Cross-Media Approaches' },
//        { id: 'bestPromotion',          label: 'Best Promotion of Online Health Content' }
    ];

function votingSummary() {
    var summaryHtml = '<table id="votingSummaryTable">';
    var row = document.getElementById('votingSummaryRow');
    var selectedValue;
    
    for (var i = 0; i < fields.length; i++) {
        selectedValue = getRadioValue(document.getElementsByName(fields[i].id));
        if (selectedValue === '') {
            selectedValue = '<font color="red"><i>no options selected</i></font>';
        }
        summaryHtml += '<tr><td valign="top" align="right" width="50%"><b>' + fields[i].label + ':</b></td><td valign="top" width="50%">' + selectedValue; + '</td></tr>';
    }
    
    summaryHtml += '</table>';
    if (summaryHtml.length > 0) {
        row.innerHTML = summaryHtml;
    }    
}



// returns the selected value of a radio button collection.
function getRadioValue(radioObj) {
    if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


