

function isValidEmail(str) {
   return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function goToByScroll(id){
	  $('html,body').animate({scrollTop: $("#"+id).offset().top},1500,'swing');
}

function checkouttwo(){
return true;
	if(document.cart.forename.value>""){
		if(document.cart.surname.value>""){
			if(document.cart.email.value>""){
				var email = document.cart.email.value;
				if(isValidEmail(email)==true){
					if(document.cart.telephone.value>""){
						if(document.cart.namenum.value>""){
							if(document.cart.street.value>""){
								if(document.cart.town.value>""){
									if(document.cart.county.value>""){
										if(document.cart.country.value>""){
											if(document.cart.postcode.value>""){
												document.cart.submit();
												return true;
											}else{
												alert("Please enter your postcode");
												document.cart.postcode.focus();
												return false;
											}	
										}else{
											alert("Please enter your country name");
											document.cart.country.focus();
											return false;
										}		
									}else{
										alert("Please enter your county name");
										document.cart.county.focus();
										return false;
									}				
								}else{
									alert("Please enter your town name");
									document.cart.town.focus();
									return false;
								}			
							}else{
								alert("Please enter your street name");
								document.cart.street.focus();
								return false;
							}					
						}else{
							alert("Please enter your house name or number");
							document.cart.namenum.focus();
							return false;
						}
					}else{
						alert("Please enter your telephone number");
						document.cart.telephone.focus();
						return false;
					}
				}else{
					alert("Please enter a valid email");
					document.cart.email.focus();
					return false;
				}
			}else{
				alert("Please enter your email");
				document.cart.email.focus();
				return false;
			}
		}else{
			alert("Please enter your surname");
			document.cart.surname.focus();
			return false;
		}
	}else{
		alert("Please enter your forename");
		document.cart.forename.focus();
		return false;
	}
}



function checkentry(){
	if(document.entercomp.forename.value>""){
		if(document.entercomp.surname.value>""){
			if(document.entercomp.email.value>""){
				var email = document.entercomp.email.value;
				if(isValidEmail(email)==true){
					if(document.entercomp.telephone.value>""){
						if(document.entercomp.namenum.value>""){
							if(document.entercomp.street.value>""){
								if(document.entercomp.town.value>""){
									if(document.entercomp.county.value>""){
										if(document.entercomp.country.value>""){
											if(document.entercomp.postcode.value>""){
												document.entercomp.submit();
												return true;
											}else{
												alert("Please enter your postcode");
												document.entercomp.postcode.focus();
												return false;
											}	
										}else{
											alert("Please enter your country name");
											document.entercomp.country.focus();
											return false;
										}		
									}else{
										alert("Please enter your county name");
										document.entercomp.county.focus();
										return false;
									}				
								}else{
									alert("Please enter your town name");
									document.entercomp.town.focus();
									return false;
								}			
							}else{
								alert("Please enter your street name");
								document.entercomp.street.focus();
								return false;
							}					
						}else{
							alert("Please enter your house name or number");
							document.entercomp.namenum.focus();
							return false;
						}
					}else{
						alert("Please enter your telephone number");
						document.entercomp.telephone.focus();
						return false;
					}
				}else{
					alert("Please enter a valid email");
					document.entercomp.email.focus();
					return false;
				}
			}else{
				alert("Please enter your email");
				document.entercomp.email.focus();
				return false;
			}
		}else{
			alert("Please enter your surname");
			document.entercomp.surname.focus();
			return false;
		}
	}else{
		alert("Please enter your forename");
		document.entercomp.forename.focus();
		return false;
	}
}





function checkoutnow(){
	document.cart.action="paymentchoice.php";
	document.cart.submit();
}

function continueshop(){
	document.location="search.php";
}

function backcheck(){
	document.cart.action="paymentchoice.php";
}
function backchecktwoinv(){
	document.location="checkout.php";
}
function backchecktwo(){
	document.paypal.action="checkout.php";
	document.location="checkout.php";
}
function completeorder(){
	document.location="sendorder.php";
}

function info(pk)
{
	open('info.php?pksent=' + pk ,'tuskainfo', 'toolbar=no, location=no, directories=no, status=no, menubar=no, width=550, height=560, left=180, top=40, scrollbars=yes, resizable=yes');
}

function add_to_basket_info(pk){
	opener.window.document.currentpageform.add_to_basket.value=pk
	opener.window.document.currentpageform.submit();
	
}

var clicked=0;

function changebackin(i,color) {
	if (document.getElementById)
	{
		if(window.document.getElementById('id' + i)){
			window.document.getElementById('id' + i).style.background = color;
		}
		if(window.document.getElementById('idt' + i)){
			window.document.getElementById('idt' + i).style.background = color;
		}
		if(window.document.getElementById('idm' + i)){
			window.document.getElementById('idm' + i).style.background = color;
		}
	}else if (document.layers){
		if(window.document.layers['id' + i]){
			window.document.layers['id' + i].bgColor = color;
		}
		if(window.document.layers['idt' + i]){
			window.document.layers['idt' + i].bgColor = color;
		}
		if(window.document.layers['idm' + i]){
			window.document.layers['idm' + i].bgColor = color;
		}
	}
	else if (document.all){
		if(window.document.all['id' + i]){
			window.document.all['id' + i].style.background = color;
		}
		if(window.document.all['idt' + i]){
			window.document.all['idt' + i].style.background = color;
		}
		if(window.document.all['idm' + i]){
			window.document.all['idm' + i].style.background = color;
		}
	}
}

function changebackout(i,color) {
	if (document.getElementById)
	{
		if(window.document.getElementById('id' + i)){
			window.document.getElementById('id' + i).style.background = color;
		}
		if(window.document.getElementById('idt' + i)){
			window.document.getElementById('idt' + i).style.background = color;
		}
		if(window.document.getElementById('idm' + i)){
			window.document.getElementById('idm' + i).style.background = color;
		}
	}else if (document.layers){
		if(window.document.layers['id' + i]){
			window.document.layers['id' + i].bgColor = color;
		}
		if(window.document.layers['idt' + i]){
			window.document.layers['idt' + i].bgColor = color;
		}
		if(window.document.layers['idm' + i]){
			window.document.layers['idm' + i].bgColor = color;
		}
	}
	else if (document.all){
		if(window.document.all['id' + i]){
			window.document.all['id' + i].style.background = color;
		}
		if(window.document.all['idt' + i]){
			window.document.all['idt' + i].style.background = color;
		}
		if(window.document.all['idm' + i]){
			window.document.all['idm' + i].style.background = color;
		}
	}
}




function remove_from_basket_in(){
	document.location="basket.php?remove_from_basket=remove_in";
	
}

function checkemail(){
	if(document.mail.email.value>"")
	{
		var email = document.mail.email.value;
		if(isValidEmail(email)==true){
			if(document.mail.name.value>"")
			{
				if(document.mail.message.value>"")
				{
					return true;
				}else{
					alert("Please enter a message!");
					return false;
				}
			}else{
				alert("Please enter your name!");
				return false;
			}
		}else{
			alert("Please enter a valid email address!");
			return false;
		}
	}else{
		alert("Please enter an email address!");
		return false;
	}
}


function flipBox(who) {
  var tmp; 
	if (document.images["im" + who].src.indexOf("_ON") == -1) { 
		tmp = document.images["im" + who].src.replace("_OFF", "_ON");
		document.getElementById('cat' + who).style.display = "none";
		document.images["im" + who].src = tmp;
	} else { 
		tmp = document.images["im" + who].src.replace("_ON", "_OFF");
		document.getElementById('cat' + who).style.display = "block";
		document.images["im" + who].src = tmp;
	} 
  }

function hideLayer(whichLayer)
{
	if (document.getElementById)
	{
	// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "hidden";
	}else if (document.all)
	{
	// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "hidden";
	}else if (document.layers)
	{
	// this is the way nn4 works
		document.layers[whichLayer].visibility = "hidden";
	}
}

function showLayer(whichLayer)
{
	if (document.getElementById)
	{
	// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "visible";
	}else if (document.all)
	{
	// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "visible";
	}else if (document.layers)
	{
	// this is the way nn4 works
		document.layers[whichLayer].visibility = "visible";
	}
}

function slideyu (id, y) {
  step = 5;
  if (document.layers) obj = document.layers[id];
  if (document.all) obj = document.all[id].style;
  if (document.getElementById) obj = document.getElementById(id).style
  obj.ypos = parseInt(obj.top);
  if (Math.abs(obj.ypos - y) > step) {
	if (y < 350)step = - step;
	obj.ypos += step;
	obj.top = obj.ypos;
	setTimeout("slideyu('" + id + "'," + y + ")", 20);
	return;
  }
}

function slidey (id, y) {
  step = 5;
  if (document.layers) obj = document.layers[id];
  if (document.all) obj = document.all[id].style;
  if (document.getElementById) obj = document.getElementById(id).style
  obj.ypos = parseInt(obj.top);
  if (Math.abs(obj.ypos - y) > step) {
	if (y < 0) step = - step;
	obj.ypos += step;
	obj.top = obj.ypos;
	setTimeout("slidey('" + id + "'," + y + ")", 20);
	return;
  }
  showLayer('search');
}

function clearsearch()
{
	document.search.search.value="";
	document.search.age_search.options[0].selected=true;
	document.search.category_search.options[0].selected=true;
		
}

function add_to_basket_no_form(theForm)
{
	var localQty = 0;
	var continueB = true;
	try{
		var localQty = parseInt(theForm.add_quant.value);
		if(localQty<1){
			alert('Please enter a quantity greater than 0');
			theForm.add_quant.focus();
			theForm.add_quant.select();
			continueB=false;
		}
	}
	catch(e)
	{
		alert('Please enter a valid quantity greater than 0');
		theForm.add_quant.focus();
		theForm.add_quant.select();
		continueB=false;
	}
	if(continueB){
		theForm.submit();
	}

}

//POPUP
/*
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function popup(windowname,pk) {
	blanket_size(windowname);
	toggle('blanket');
	toggle(windowname);	
	if ( document.getElementById('blanket').style.display != 'none' ) {
		setup_popup(pk);
	}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	
}
var currentpk;
function setup_popup(pk){
	currentpk = pk;
	document.getElementById('addtobasketframe').src="addtobasket.php?pk=" + pk;
}
*/


