var fieldcount = 4;

var fieldvalid = 0;

var name = false;

var email = false;

var tel = false;

var message = false;

function validate(fieldname) {

	switch(fieldname)

	{

		case "name":

			fieldvalue = document.getElementById(fieldname).value

			if (fieldvalue.length > 1) {

  				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/tick.gif' height='10px' />";

				if (name==false) {

				fieldvalid++;

				name = true;

				}

			} else {

				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/cross.gif' height='10px' />";

				if (name==true) {

				fieldvalid--;

				}

				name=false;

			}

  			break;

		case "email":

			fieldvalue = document.getElementById(fieldname).value

			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   			if(reg.test(fieldvalue) == false) {

      			document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/cross.gif' height='10px' />";

				if (email==true) {

					fieldvalid--;

				}

				email=false;

			} else {

  				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/tick.gif' height='10px' />";

				if (email==false) {

					fieldvalid++;

					email = true;

				}

			}

  			break;

		case "tel":

			fieldvalue = document.getElementById(fieldname).value

			if (fieldvalue.length > 10) {

  				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/tick.gif' height='10px' />";

				if (tel==false) {

				fieldvalid++;

				tel = true;

				}

			} else {

				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/cross.gif' height='10px' />";

				if (tel==true) {

				fieldvalid--;

				}

				tel=false;

			}

  			break;

		case "message":

			fieldvalue = document.getElementById(fieldname).value

			if (fieldvalue.length > 1) {

  				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/tick.gif' height='10px' />";

				if (message==false) {

				fieldvalid++;

				message = true;

				}

			} else {

				document.getElementById(fieldname+"_container").innerHTML = "<img src='././images/cross.gif' height='10px' />";

				if (message==true) {

				fieldvalid--;

				}

				message=false;

			}

  			break;

	}

	chkForm_complete()

}



function chkForm_complete() {

if (fieldvalid == fieldcount) {

		document.getElementById("submitholder").innerHTML = '<button name="send" type="submit">Submit</button>';

	} else {

		document.getElementById("submitholder").innerHTML = '<button name="send" disabled="disabled" class="disabled_button" type="submit">Submit</button>';

	}

}



<!--

/*document.write("<style type='text/css'>#thephoto {visibility:hidden;}</style>");*/



var lastid = "";

var lasttn = "";



function ungrey(id,tn,image) {

	if (id != lastid) {

		/*document.getElementById('photoholder').style.background ="#fff url('../images/white_fade.jpg') 50% 50% no-repeat";*/

		//field = eval("document.getElementById("+id+")");

		//field.innerHTML = '<img src="'+tn+'" class="image_row1" height="75" alt="The Arena" />';

		/*document.getElementById('thephoto').style.visibility = "hidden";*/

		document.getElementById('photoholder').innerHTML = '<a href="'+image+'" target="_blank"><img src="'+tn+'" id="thephoto" class="rightproduct" /></a>';

		/*initImage();*/

		lastid = id;

		lasttn = tn;

	}

}



function grey(id,grey,image) {

	//field = eval("document.getElementById("+id+")");

	//field.innerHTML = '<img src="'+grey+'" class="image_row1" height="75" alt="The Arena" />';

}



function initImage() {

	imageId = 'thephoto';

	image = document.getElementById(imageId);

	setOpacity(image, 0);

	image.style.visibility = "visible";

	fadeIn(imageId,0);

}

function fadeIn(objId,opacity) {

	if (document.getElementById) {

		obj = document.getElementById(objId);

		if (opacity <= 100) {

			setOpacity(obj, opacity);

			opacity += 5;

			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);

		}

		document.getElementById('photoholder').style.background ="#fff 50% 50% no-repeat";

	}

}

function setOpacity(obj, opacity) {

	opacity = (opacity == 100)?99.999:opacity;

	// IE/Win

	obj.style.filter = "alpha(opacity:"+opacity+")";

	// Safari<1.2, Konqueror

	obj.style.KHTMLOpacity = opacity/100;

	// Older Mozilla and Firefox

	obj.style.MozOpacity = opacity/100;

	// Safari 1.2, newer Firefox and Mozilla, CSS3

	obj.style.opacity = opacity/100;

}

/*window.onload = function() {initImage()}*/

// -->



var lastid = "";



function ajax_showBuy(id) {

	if (lastid != id) {

	

	if (lastid != "") {

		document.getElementById('buybox'+lastid).style.display = "none";

		//opacity("buybox"+lastid, 70, 0, 500);

	}

	

	lastid = id;

	

	try {

		if (document.getElementById('buybox'+id)) {

			rEs(document.getElementById('buybox'+id));

		}

	} catch(err) {}

	

	buybox = document.createElement('DIV');

	buybox.id = 'buybox'+id;

	buybox.style.position = 'absolute';

	/*buybox.id = 'buybox'+id;*/

	

	var elem;

	var elem = document.getElementById("productbox"+id);

	xPos = elem.offsetLeft;

	tempEl = elem.offsetParent;

  	while (tempEl != null) {

  		xPos += tempEl.offsetLeft;

	  	tempEl = tempEl.offsetParent;

  	}	



	yPos = elem.offsetTop;

	tempEl = elem.offsetParent;

	while (tempEl != null) {

  		yPos += tempEl.offsetTop;

	  	tempEl = tempEl.offsetParent;

  	}

	

	xPos = xPos + "px";

	yPos = yPos + "px";

	

	buybox.style.left = xPos;

	buybox.style.top = yPos;	

	buybox.style.width = "370px";

	//buybox.style.height = "175px";	

	buybox.style.height = "90px";

	buybox.style.marginTop = "50px";

	/*buybox.style.borderTop = "4px solid #000";

	buybox.style.borderBottom = "4px solid #000";*/

	buybox.style.display='block';

	/*buybox.style.background='white';*/

	buybox.style.backgroundImage = "url(./images/product_back.gif)";

	buybox.style.backgroundRepeat = "no-repeat";

	buybox.style.opacity=0;

	buybox.style.filter='alpha(opacity: 0)';

	document.body.appendChild(buybox);

	buybox.innerHTML = "<div class='roundbox'><span class='qty_section'>Qty: <input name='qty' id='qty' type='text' size='2' value='1' class='border2' /></span> <span class='qty_button'><button type='button' class='button' name='qty_add' onclick='qty_add("+id+");'>Add to Cart</button></span><br /><span class='details_button'><button type='button' class='button' name='moredetails' onclick='navigate("+id+");'>More details...</button></span></div>";

	

	opacity("buybox"+id, 0, 90, 1000);

	

	}

}



function navigate(nav) {

	window.location = "productDetails.php?id="+nav;

}



function opacity(id, opacStart, opacEnd, millisec) {

    //speed for each frame

    var speed = Math.round(millisec / 100);

    var timer = 0;



    //determine the direction for the blending, if start and end are the same nothing happens

    if(opacStart > opacEnd) {

        for(i = opacStart; i >= opacEnd; i--) {

            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));

            timer++;

        }

    } else if(opacStart < opacEnd) {

        for(i = opacStart; i <= opacEnd; i++)

            {

            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));

            timer++;

        }

    }

}



//change the opacity for different browsers

function changeOpac(opacity, id) {

    var object = document.getElementById(id).style;

    object.opacity = (opacity / 100);

    object.MozOpacity = (opacity / 100);

    object.KhtmlOpacity = (opacity / 100);

    object.filter = "alpha(opacity=" + opacity + ")";

} 



function ajax_hideBuy()

{

	buybox.style.display='none';

}



function showDelivery() {

	if (document.getElementById('delivery_different').checked == true) {

		document.getElementById('delivery_add').style.display = "block";

	} else {

		document.getElementById('delivery_add').style.display = "none";

	}

}



function rEs(tO) { var i, n; if (!tO) { return false; }

  if (!tO.nodeName) { if (tO.length) for (n=tO.length; n--;) rEs(tO[n]); }

  else tO.parentNode.removeChild(tO);

}



var lastid = "";



function qty_add(id) {

	var qty = document.getElementById('qty').value;

	

	window.location = "cart.php?action=add&id="+id+"&qty="+qty;

}



function showLogin() {

	

	backbox = document.createElement('DIV');

	backbox.style.position = 'absolute';

	backbox.id = 'backbox';

	

	if (screen.height > document.body.offsetHeight) {

		var backHeight = screen.height;

	} else {

		var backHeight = document.body.offsetHeight;

	}

	

	backbox.style.left = 0;

	backbox.style.top = 0;	

	backbox.style.width = screen.width + "px";

	backbox.style.height = screen.height + "px";

	backbox.style.margin = "0 auto";

	backbox.style.display='block';

	backbox.style.background='black';

	backbox.style.opacity=0.8;

	backbox.style.filter='alpha(opacity: 80)';

	document.body.appendChild(backbox);

	





	loginbox = document.createElement('DIV');

	loginbox.style.position = 'absolute';

	loginbox.id = 'loginbox';

	

	var width = 280;

	var height = 150;

	var x = 0;

	

	x = (document.body.offsetWidth - document.getElementById('page').offsetWidth) / 2;

	

	xPos = ((document.getElementById('page').offsetWidth / 2) + x) - (width / 2);

	yPos = ((screen.height-300) / 2) - (height / 2);

	

	xPos = xPos + "px";

	yPos = yPos + "px";

	

	loginbox.style.left = xPos;

	loginbox.style.top = yPos;	

	loginbox.style.width = width + "px";

	loginbox.style.height = height + "px";

	//loginbox.style.height = "175px";	

	loginbox.style.margin = "0 auto";

	loginbox.style.borderTop = "20px solid #000";

	loginbox.style.borderBottom = "1px solid #000";

	loginbox.style.borderLeft = "1px solid #000";

	loginbox.style.borderRight = "1px solid #000";

	loginbox.style.display='block';

	loginbox.style.background='white';

	loginbox.style.opacity=1;

	loginbox.style.filter='alpha(opacity: 100)';

	document.body.appendChild(loginbox);

	loginbox.innerHTML = "<div style='padding: 5px;'><form action='login.php' method='post' name='loginForm'><p>Please login below:</p><input name='currentURL' id='currentURL' type='hidden' value='"+location.href+"' /><table border='0' cellpadding='0' cellspacing='0'><tr><td width='100px'>Username:</td><td><input name='username2' id='username2' type='text' value='' class='border' /></td></tr><td style='padding-top: 2px;'>Password:</td><td style='padding-top: 2px;'><input name='password2' id='password2' type='password' class='border' value='' /></td></tr></tr><td style='padding-top: 2px;'>&nbsp;</td><td style='padding-top: 2px;'><button type='submit' class='button'>Login</button></td></tr></table><p><a onclick='hideLogin()' style='cursor:pointer;'>Close</a></p></form></div>";

	

	//opacity("loginbox"+id, 0, 70, 1000);

	

}



function hideLogin()

{

	loginbox.style.display='none';

	backbox.style.display='none';

}



/*function opacity(id, opacStart, opacEnd, millisec) {

    //speed for each frame

    var speed = Math.round(millisec / 100);

    var timer = 0;



    //determine the direction for the blending, if start and end are the same nothing happens

    if(opacStart > opacEnd) {

        for(i = opacStart; i >= opacEnd; i--) {

            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));

            timer++;

        }

    } else if(opacStart < opacEnd) {

        for(i = opacStart; i <= opacEnd; i++)

            {

            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));

            timer++;

        }

    }

}



//change the opacity for different browsers

function changeOpac(opacity, id) {

    var object = document.getElementById(id).style;

    object.opacity = (opacity / 100);

    object.MozOpacity = (opacity / 100);

    object.KhtmlOpacity = (opacity / 100);

    object.filter = "alpha(opacity=" + opacity + ")";

} 



function ajax_hideBuy()

{

	loginbox.style.display='none';

}



function showDelivery() {

	if (document.getElementById('delivery_different').checked == true) {

		document.getElementById('delivery_add').style.display = "block";

	} else {

		document.getElementById('delivery_add').style.display = "none";

	}

}*/



function change_ship() {

	if (document.getElementById('delivery_different').checked == true) {

		if (document.getElementById('del_country').value != "GB") {

			document.getElementById('non_europe').style.display = "block";

			document.getElementById('europe').style.display = "none";

		} else {

			document.getElementById('non_europe').style.display = "none";

			document.getElementById('europe').style.display = "block";

		}

	} else {

		if (document.getElementById('bill_country').value != "GB") {

			document.getElementById('non_europe').style.display = "block";

			document.getElementById('europe').style.display = "none";

		} else {

			document.getElementById('non_europe').style.display = "none";

			document.getElementById('europe').style.display = "block";

		}

	}

	unCheckRadio('shipping_method');

}



function unCheckRadio(oRadio) {

	  var or = document.getElementsByName(oRadio);

      for (var i = 0; i < or.length; i++) {

         or[i].checked = false;

     }

}