/*  
 * U.S. Tae Kwon Do College javascript
 *
 *
 */

function loadGallery(name) {
	switch(name) {
		case 'action':
			returnObjById(name).style.display = 'inline';
			returnObjById('history').style.display = 'none';
			returnObjById('community').style.display = 'none';
			break;
		case 'community':
			returnObjById(name).style.display = 'inline';
			returnObjById('history').style.display = 'none';
			returnObjById('action').style.display = 'none';
			break;
		case 'history':
			returnObjById(name).style.display = 'inline';
			returnObjById('community').style.display = 'none';
			returnObjById('action').style.display = 'none';
			break;
	}
}

function checkPass() {
	var result = prompt("Please enter the password:");
	if (result == "taekwondo")
		return true;
	else {
		alert("Sorry, that was incorrect. Please try again.");
		return false;	
	}
}

function showSubnav(whichlayer) {
	var subnavs = returnObjById(whichlayer).parentNode.getElementsByTagName('div');
	for (i = 0; i < subnavs.length; i++) {
		toggleDiv(subnavs[i].id,'hide');
	}
	toggleDiv(whichlayer,'show');
	
}

function blackSubNav() {
	var subnav = returnObjById('subnav');
	subnav.style.backgroundColor = 'black';
	subnav.style.backgroundImage = 'none';
	subnav.style.borderRightWidth = '2px';
}


function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function toggleDiv(whichLayer, action) {

        if (document.getElementById) {
                //this is the way the standards work
                var divtag = document.getElementById(whichLayer);
        } else
        if (document.all) {
                // this is the way old msie versions work
                var divtag = document.all[whichLayer];
        } else if (document.layers) {
                // this is the way nn4 works
                var divtag = document.layers[whichLayer];
        }

        style2 = divtag.style;

        if (!action) { //just toggle
                if (style2.display == "block") {
                        //alert("1 style2.display "+style2.display);
                        style2.display = "none";
                } else {
                        //alert("2 style2.display "+style2.display);
                        style2.display = "block";
                }
        } else { //show or hide
                if (action == 'show')
                        style2.display = "block";
                else
                        style2.display = "none";
        }

}
 
