﻿showTagBox = {

    init : function(elemID) {
        var tagEntryBox = document.getElementById(elemID);
        showTagBox.getRadio3Value('widget_choices', tagEntryBox);
    },
    getRadio3Value : function(radioID, tagEntryBox) {
        var radioList = document.getElementById(radioID);
        var radioItems = radioList.getElementsByTagName('input');
        for (i=0;i<radioItems.length;i++) {
            rB = radioItems[i];
            rBID = radioItems[i].id;
            if (rB.checked) {
                showTagBox.boxVisible(tagEntryBox);
            }
            else {
                showTagBox.boxVisible(tagEntryBox);
            }
            addNewEvent(rB,'click', function () {
                if (rB.checked) {
                    showTagBox.boxVisible(tagEntryBox);
                }
                else {
                    showTagBox.boxVisible(tagEntryBox);
                }
            });
        }
        return;
    },
    boxVisible : function(tagEntryBox) {
        if (rB.checked) {
            tagEntryBox.className = 'tag_entry';
        }
        else {
            tagEntryBox.className = 'hide';
        }
    },
    setUpBoxClick : function(codeBox) {
        var codeBox = document.getElementById(codeBox);
        addNewEvent(codeBox,'click',function(){this.select();});
    }
}

function clearSpringWidgetCode (myLocale,dunkUserName) {
    var userChoice;
    var widgetInputs = document.getElementsByTagName('input');
        for ( i=0; i < widgetInputs.length; i++ ) {
            if (widgetInputs[i].className == "tag_entry") {
                var getTagEntryBox = widgetInputs[i].id;
                var tagEntryBoxID = document.getElementById(getTagEntryBox);
                var tagsInTextBox = tagEntryBoxID.value;
            }
            if (widgetInputs[i].checked) {
                userChoice = widgetInputs[i].value;
            }
        }
    switch (userChoice) {
    case "taggedArt" :
        document.getElementById('PutWidgetHere').innerHTML = "";
        var newdiv = document.createElement('div');
        newdiv.innerHTML = '<p>&nbsp;</p><object width="288" height="407"><param name="movie" value="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'&tags='+tagsInTextBox+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'&tags='+tagsInTextBox+'" type="application/x-shockwave-flash" wmode="transparent" width="288" height="407"></embed></object>';
        document.getElementById('PutWidgetHere').appendChild(newdiv);
        return fadeModal.init('modal','clearspring','');
        break;
    case "favouriteArt" :
        document.getElementById('PutWidgetHere').innerHTML = "";
        var newdiv = document.createElement('div');
        newdiv.innerHTML = '<p>&nbsp;</p><object width="288" height="407"><param name="movie" value="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'&artist='+dunkUserName+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'&artist='+dunkUserName+'" type="application/x-shockwave-flash" wmode="transparent" width="288" height="407"></embed></object>';
        document.getElementById('PutWidgetHere').appendChild(newdiv);
        return fadeModal.init('modal','clearspring',''); 
        break;
    default :
        document.getElementById('PutWidgetHere').innerHTML = "";
        var newdiv = document.createElement('div');
        newdiv.innerHTML = '<p>&nbsp;</p><object width="288" height="407"><param name="movie" value="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.nike1-1.com/library/flash/Widget.swf?locale='+myLocale+'" type="application/x-shockwave-flash" wmode="transparent" width="288" height="407"></embed></object>';
        document.getElementById('PutWidgetHere').appendChild(newdiv);
        return fadeModal.init('modal','clearspring',''); 
    }
}
