if (document.all)
	document.getElementsByTagName = ie_getElementsByTagName

window.onload=function()
{
	var key = GetKey();
	SetCurrent(key);
	SmallOverview();
}

/* Divers functions */
function ie_getElementsByTagName(str)
{
	if (str=="*")
		return document.all
	else
		return document.all.tags(str)
}

function externalLinksSetup()
{
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.className && a.className == 'external') {
			a.target = '_blank';
		}
	}
}

/* Navigation Part */
var menuAbout    = 'menuAbout';
var menuProducts = 'menuProducts';
var menuHelp     = 'menuHelp';
var pages        = new Array();

pages['about']          = menuAbout;
pages['contact']        = menuAbout;
pages['contactinfo']    = menuAbout;
pages['map']            = menuAbout;
pages['services']       = menuAbout;
pages['links']          = menuAbout;
pages['humor']          = menuAbout;
pages['products']       = menuProducts;
pages['checkout']       = menuProducts;
pages['releases']       = menuProducts;
pages['search']         = menuProducts;
pages['advancedsearch'] = menuProducts;
pages['gadget']         = menuProducts;
pages['downloads']      = menuProducts;
pages['help']           = menuHelp;
pages['helpdatabase']   = menuHelp;
pages['helppric']       = menuHelp;
pages['legal']          = menuHelp;
pages['sitemap']        = menuHelp;

function GetKey()
{
	var key = new String(document.location);
	key = key.substr(key.lastIndexOf('/')+1);
	key = key.substr(0, key.indexOf('.'));

	if (key.match("gadget") == "gadget")
		key = "gadget";
	return key;
}

function SetCurrent(key)
{
	if (pages[key] != undefined)
		document.getElementById(pages[key]).className = 'current';
}

/* Cart Functions */
var loadSmall = new XMLHttpRequest();

function SmallOverview()
{
	var uri = "asp/cart.asp?paramAction=ajax&cd" + new Date().getTime();
	loadSmall.open("GET", uri, true);
	// if needed set header information 
	// using the setRequestHeader method
	loadSmall.send('');
	// updateContentFromURI
	loadSmall.onreadystatechange = DisplaySmallCart;
}

function DisplaySmallCart()
{
	if(loadSmall.readyState == 4)
	{
		if (loadSmall.status != 404)
		{
			if (loadSmall.responseText.length > 100)
			{
				document.getElementById('ShopBox').style.display = 'block';
				document.getElementById('ShoppingCartSmallOverview').innerHTML = loadSmall.responseText;
			}
		}
		document.getElementById('ColumnLeft').style.visibility = 'visible';
	}
};

/* Help windows */
var newwindow;
function showWindow1(){newwindow  = window.open("help/helpsim.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow2(){newwindow  = window.open("help/helptit.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow3(){newwindow  = window.open("help/helpart.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow4(){newwindow  = window.open("help/helppro.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow5(){newwindow  = window.open("help/helpins.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow6(){newwindow  = window.open("help/helpgen.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow7(){newwindow  = window.open("help/helpins2.html",  "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=300");}
function showWindow8(){newwindow  = window.open("help/helppri.html",   "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow9(){newwindow  = window.open("help/helpid.html",    "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow10(){newwindow = window.open("help/fileinfo1.html", "newwindow", "titlebar=no, toolbar=no, width=280, height=350, top=40, left=40");}
function showWindow11(){newwindow = window.open("help/fileinfo2.html", "newwindow", "scrollbars=yes,titlebar=no ,toolbar=no,width=280,height=350,top=40,left=40");}
function closeWindow(){newwindow.close();}

/* Form Functions */

function Submit_onclick() {
	//check for client side (form) validation
	
	if (Form_Validate() == true) {							
		return true;
	} else {
		return false;
	}
}

function Form_Validate() {

	if (document.postForm.author_nameStr.value==""){
		alert("[Your Name] cannot be blank");
		return false;
	}
	
	if (document.postForm.author_emailStr.value==""){
		alert("[Your Email] cannot be blank");
		return false;
	}
	
	if (document.postForm.detailStr.value==""){
		alert("[Your Response] cannot be blank");
		return false;
	}
	
	return true;
}

function FlashBookCover(id)
{
	document.getElementById('imageflip').src = "/newsimages/new/" + id + ".jpg"; return true;
}