var bookmarkedSection = YAHOO.util.History.getBookmarkedState("menu"); 
var initialSection = bookmarkedSection || "info"; 
var bookmarkedSectionE = YAHOO.util.History.getBookmarkedState("e"); 
var initialSectionE = bookmarkedSectionE || ""; 
var bookmarkedSectionC = YAHOO.util.History.getBookmarkedState("c"); 
var initialSectionC = bookmarkedSectionC || ""; 
       
YAHOO.util.History.register("menu", initialSection, open);
YAHOO.util.History.register("e", initialSectionE, conf2);
YAHOO.util.History.register("c", initialSectionC, conf2);

YAHOO.util.History.onReady(function () {
    open( YAHOO.util.History.getCurrentState("menu") );
});

try {
    YAHOO.util.History.initialize("yui-history-field", "yui-history-iframe"); 
} catch (e) {
    open(initialSection);
}

function open (section) {
    state = YAHOO.util.History.getCurrentState("menu");
    if (section == null || section == "") {
        return;
    }
    var div = document.getElementById('main');
    if (section == 'register' || section == 'login' || section =='admin'
	|| section == 'results' || section == 'invite' || section == 'view'
	|| section == 'dashboard' || section == 'logout' || section == 'info' 
    || section == 'faq' || section == 'upload' || section =='standings') {
	div.innerHTML=phpSrc.replace('FILENAME', section);
	return;
    }
    /*
    if (section == 'info') {
	div.innerHTML=staticSrc.replace('FILENAME', section);
	return;
    }
    */
    if (section == 'confirm') {
	confirm();
	return;
    }

    div.innerHTML=staticSrc.replace('FILENAME', 'none');
}

function confirm() {
    var e = YAHOO.util.History.getCurrentState("e").replace('+', '%2B');
    var c = YAHOO.util.History.getCurrentState("c");

    if ( (e == null || e == '') && (c == null || c == '')) {
	return;
    }

    var div = document.getElementById('main');
    div.innerHTML = confirmSrc.replace('GETEMAIL', e).replace('GETCONF', c);
}

function conf2(state) {
    //do nothing. confirm() should be called
}
