function oe(e,state){
	if (document.all)
		source4=event.srcElement
	else if (document.getElementById)
		source4=e.target
	if (source4.className=="c1")
		source4.style.borderStyle=state
	else {
		while(source4.tagName!="TABLE") {
			source4=document.getElementById? source4.parentNode : source4.parentElement
			if (source4.className=="c1")
				source4.style.borderStyle=state
		}
	}
}

function oe_vert(e,state){
	if (document.all)
		source4=event.srcElement
	else if (document.getElementById)
		source4=e.target
	if (source4.className=="cvert")
		source4.style.borderStyle=state
	else {
		while(source4.tagName!="TABLE") {
			source4=document.getElementById? source4.parentNode : source4.parentElement
			if (source4.className=="cvert")
				source4.style.borderStyle=state
		}
	}
}

function findObj(n, d) {
	var p,i,x; 
	if(!d) 
		d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}

function showL() {
	var i,p,v,obj,args=showL.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=findObj(args[i]))!=null) { 
		v=args[i+2];
		if (obj.style) { 
			obj=obj.style; 
			v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
		}
		obj.visibility=v; 
	}
}

//Get url from menu and navigate
function url(sel)
{
	location.href = sel ;
}

/////////// Shopping Cart Functions //////////////
// alterError - fixes a rounding bug in Netscape 2
function alterError(value) {
	if (value<=0.99) {
		newPounds = '0';
	} else {
		newPounds = parseInt(value);
	}
	newPence = parseInt((value+.0008 - newPounds)* 100);
	if (eval(newPence) <= 9) newPence='0'+newPence;
	newString = newPounds + '.' + newPence;
	return (newString);
}

// buyItem - adds an item to the shooping basket
function buyItem(newItem, newPrice, productID, cartID, newQuantity) {
	if (newQuantity <= 0) {
		rc = alert('The quantity entered is incorrect');
	} else {
		if (confirm('Add '+newQuantity+' x '+newItem+' to basket')) {
			index = document.cookie.indexOf("TheBasket");
			countbegin = (document.cookie.indexOf("=", index) + 1);
			countend = document.cookie.indexOf(";", index);
			if (countend == -1) {
				countend = document.cookie.length;
			}
			document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newPrice+"|"+productID+"|"+cartID+"|"+newQuantity+"]";
		}
	}
}

// resetShoppingBasket - resets to shopping basket to empty
function resetShoppingBasket() {
	index = document.cookie.indexOf("TheBasket");
	document.cookie="TheBasket=.";
}

function add(guide, guidePrice, tutorialPrice, guideID, cartID) {
	if( tutorialPrice > 0 ) {
		buyItem(guide + ' + Online Course Tutorial', guidePrice + tutorialPrice, guideID+'T', cartID, 1);
	}
	else {
		buyItem(guide, guidePrice, guideID, cartID, 1);
	}
}

function roll(img_name, img_src) {
   document[img_name].src = img_src;
}

function checkEnter(e) { //e is event object passed from function invocation
	var characterCode; //literal character code will be stored in this variable

	if(e && e.which) { //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
		document.forms['logform'].submit(); //submit the form
		return false;
	}
	else{
		return true;
	}
}