function showBlock (id) { document.getElementById(id).style.visibility = "visible";}
function hideBlock (id) { document.getElementById(id).style.visibility = "hidden";}
function showTab (id, status) {
if (id!=tabId)
	{
	if (status==0) {
		document.getElementById(id).src="images/tabs/"+ id +"_on.gif"
		}
	else 
		{
		document.getElementById(id).src="images/tabs/"+ id +"_off.gif"
		}
	}
}

function showSubmenu (id, status)
{	showOver (id, status);
	var subId=""
	subId = id + "_s";
	if (status == "0")
	{
			document.getElementById(subId).style.display = "block";
	}
	else
	{
			document.getElementById(subId).style.display = "none";
	}
}
function showOver (id, status) {

	if (status==0) {
		document.getElementById(id).src="images/nav/"+ id +"_on.gif"
		}
	else 
		{
		document.getElementById(id).src="images/nav/"+ id +"_off.gif"
		}

}
function showTab (id, status) {
if (id!=tabId)
	{
	if (status==0) {
		document.getElementById(id).src="images/tabs/"+ id +"_on.gif"
		}
	else 
		{
		document.getElementById(id).src="images/tabs/"+ id +"_off.gif"
		}
	}
}

// toggles "other game" textbox  
function checkOther(value) {
    var lbl_your_game, your_game;
    lbl_your_game = document.getElementById('lbl_your_game');
    your_game = document.getElementById('txt_your_game');
    if (value != "") {
        if (value == "0") {
            lbl_your_game.style.visibility = "visible";
            your_game.focus();
        } else {
            lbl_your_game.style.visibility = "hidden";
        }    
    }
     else {
        lbl_your_game.style.visibility = "hidden";
    }
}

// sets maxlength for textarea tags
function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}
function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}
// cookies! from http://www.quirksmode.org/js/cookies.html#script
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

// ******************************* page specific functions *****************************
// onload function for uploadphoto.aspx 
function upload_onload() {
    if (readCookie('underage') == 'Y') {
        document.location = 'underage.htm';
    }
    // check maxlength on description 
    setMaxLength(); 
    // make sure the "other game" field is displayed when "other" is selected 
    var ddl_game = document.getElementById('ddl_game');
    checkOther(ddl_game.options[ddl_game.selectedIndex].value); 
}
// onload function for underage.aspx
function underage_onload() {
    createCookie('underage','Y',180);
}

function showDetails (id) {
document.getElementById("prodInfo").src = "products/blank.htm";
	if (!document.getElementById("overlay"))	
	{
		document.getElementById("overlayM").style.display = "block";

	}
	else
	{
		document.getElementById("overlay").style.display = "block";
	}
	document.getElementById("lProduct").style.display = "block"
	document.getElementById("prodInfo").src = "products/"+id+".htm"
}
/*function showDetails1 (id) {
	document.getElementById("overlay").style.display = "block";
	document.getElementById("lProduct").style.display = "block"
	document.getElementById("prodInfo").width ="557";
	document.getElementById("prodInfo").src = "products/"+id+".htm"
}*/
function closeDetails () {
	parent.document.getElementById("prodInfo").src = "products/blank.htm";
	var objfr = parent.document.getElementById("prodInfo");
		
	if (!parent.document.getElementById("overlay")){
		
		parent.document.getElementById("overlayM").style.display = "none";
	
	}
	else 
	{
		parent.document.getElementById("overlay").style.display = "none";
	}

	parent.document.getElementById("lProduct").style.display = "none";
	parent.document.getElementById("prodInfo").src = "products/blank.htm";
	if (navigator.appName == "Netscape")
	{
		parent.window.location.href = parent.window.location.href.replace("#", "");
	}
}

