dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.form.Button");


function tabClick(tab) {
    if (tab.id == "archives_pane") {
        var ref = escape(window.location.pathname);
        var product = escape(document.getElementById("product_name").innerHTML);
        window.location.href = "http://downloads.mysql.com/archives.php?ref=" + ref + "&product=" + product;
    } else {
    	var frm_name = tab.id.replace(/_pane/, "_os_selection_form");
	var os_field = tab.id.replace(/_pane/, "_os");

	if (document.getElementById(os_field).value != "0") {
	    document.getElementById(frm_name).submit();
	}
    }
}

dojo.addOnLoad(function() {
    dojo.connect(dijit.byId('mainTabContainer').tablist, 'onButtonClick', tabClick);
});

