document.documentElement.className = 'jsEnabled_acctSelect_demo';

$(document).ready(function(){
    fn_resetAllSelect();

	$("select.sList").change(function(){
        var selected = $(this).children("option:selected");
        var selectedClass = selected.attr("class");
        var selectedURL = selected.attr("name");
       
        var currDisclaimer = "undefined";
        var currURL = "undefined";
        var defaultURL = $(this).children("option:first-child").attr("name");

	//add class "curr" to current select and sNotify
        for (var i = 0; i < $("select.sList").size(); i++)
        {
            $("select.sList:eq("+i+")").removeClass("curr");
            $("div.sNotify:eq("+i+")").removeClass("curr");
        }
        $(this).addClass("curr").next("div.sNotify").addClass("curr");
		
	//hide all non-curr
        $("select.sList").not(".curr").attr("selectedIndex", 0);
        $("div.sNotify").not(".curr").children("div").hide();
		
	//set currDisclaimer       
        switch (selectedClass) {
            case ("null"):   
            case ("undefined"):   
            case ("default"):   
                var currDisclaimer = "undefined";
                break;
           
            case(""):
                currDisclaimer = "default";
                break;
               
            default:
                currDisclaimer = selectedClass;
        }
	
	//set currURL       
        switch (selectedURL) {
            case ("undefined"):
            case (undefined):
            case (""):
                currURL = defaultURL;
                break;
               
            default:
                currURL = selectedURL;
        }
	
	//display disclaimers and buttons
        if (selectedClass == "default" || selectedClass == "null") {
            $("div.sNotify").children("div").hide();
        }
        else {
            $("div.sNotify").children("div").hide();
            $(this).next("div.sNotify").children("div." + currDisclaimer).show();
            $(this).next("div.sNotify").children("div.sBtn").show().children("a").attr("href", currURL); 
        }
    });
});

//Functions:
function fn_resetAllSelect() {
     $("select.sList").attr("selectedIndex", 0);
}

/*
==========
Usage:
==========
1. put class "default" on first list item, which holds the default URL

2. put [  name="URL.jsp"  ] inside any list item that requires a URL different from that account box's default.

3. for list item requiring a disclaimer, add any classname to list item, and the SAME classname to the corresponding disclaimer div.
	(If the country list item is duplicated in the same form, be sure to put the same classname and URL on all instances)

==> PLEASE NOTE... If there are 2 or more countries that require the same URL or DISCLAIMER, or if the country item is duplicated in the same form, be sure to put the same classname and URL on EACH instance.

4. put class "null" on any list item used as a divider etc (ie "------")

5. If you require a box with an always-visible button and no select box, remove "a.btn-submit-small" from its containing div ("div.sBtn").
==========
*/