function login(){var username=document.getElementById("username").value
var password=document.getElementById("password").value
if(username==''){alert("Please enter your username")}else if(password==''){alert("Please enter your password")}else{document.frmLogin.action='login-process.php'
document.frmLogin.submit()}}
function submitSearch(){document.frmShopSearch.submit();}
function checkoutLogin(){var username=document.getElementById("username").value
var password=document.getElementById("password").value
if(username==''){alert("Please enter your username")}else if(password==''){alert("Please enter your password")}else{document.frmLogin.action='checkout-login-process.php'
document.frmLogin.submit()}}
function signUp(){var username=document.getElementById("usernameNEW").value
var password=document.getElementById("passwordNEW").value
if(username==''){alert("Please enter your email address")}else if(password==''){alert("Please enter a password")}else{document.frmRegister.action='register.php'
document.frmRegister.submit()}}
function sendPassword(){if(document.getElementById("username").value==""){alert("Please enter your email address")}else{http=createRequestObject();http.open('get','send-password.php?email='+document.getElementById("username").value);http.onreadystatechange=handlePasswordResponse;http.send(null);document.getElementById("passwordL").innerHTML='<img src="images/loader.gif"/ >';}}
function handlePasswordResponse(){if(http.readyState==4){var stResponse=http.responseText;document.getElementById("passwordL").innerHTML=stResponse;}}
function checkoutSignUp(){var username=document.getElementById("usernameNEW").value
var password=document.getElementById("passwordNEW").value
if(username==''){alert("Please enter your email address")}else if(password==''){alert("Please enter a password")}else{document.frmRegister.action='register.php?redirect=confirm'
document.frmRegister.submit()}}
var xmlhttp;function GetXmlHttpObject(){if(window.XMLHttpRequest){return new XMLHttpRequest();}if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}return null;}
function dictionary(){if(document.getElementById("location").value==""){document.getElementById("dictionary").style.display='none';}else{document.getElementById("dictionary").style.display='block'
var theInput=document.getElementById("location").value;var theType=document.getElementById("searchType").innerHTML;xmlhttp=GetXmlHttpObject();if(xmlhttp==null)
{alert("Browser does not support HTTP Request");return;}
var url="dictionary.php";url=url+"?theInput="+theInput;url=url+"&theType="+theType;xmlhttp.onreadystatechange=stateChanged;xmlhttp.open("GET",url,true);xmlhttp.send(null);document.getElementById("dictionary").innerHTML='<img src="images/loader.gif"/ > Searching, please wait!'}}
function stateChanged(){if(xmlhttp.readyState==4){var theResponse=xmlhttp.responseText;if(theResponse.indexOf("zoomtoit")!=-1){tempArray=theResponse.split("|");useThisTown(tempArray[1],tempArray[2],tempArray[3],'Town');}else{document.getElementById("dictionary").innerHTML=theResponse;}}}
function createRequestObject(){var ro;if(window.XMLHttpRequest){ro=new XMLHttpRequest();}else if(window.ActiveXObject){try{ro=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{ro=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
return ro;}
function sendNewsletter(){if(document.getElementById("theEmail").value==""){alert("Please enter a valid email address")}else if(document.getElementById("theName").value==""){alert("Please enter your name")}else if(document.getElementById("theName").value=="Name"){alert("Please enter your name")}else if(document.getElementById("theEmail").value=="Email Address"){alert("Please enter a valid email address")}else{http=createRequestObject();http.open('get','newsletter.php?email='+document.getElementById("theEmail").value+'&name='+document.getElementById("theName").value);http.onreadystatechange=handleNLR;http.send(null);document.getElementById("newsletter").innerHTML='<img src="images/loader.gif"/ > Adding you to the subscriber list...'}}
function handleNLR(){if(http.readyState==4){var stResponse=http.responseText;document.getElementById("newsletter").innerHTML=stResponse;}}
function searchForStreet(theStreet){http=createRequestObject();http.open('get','searchStreet.php?street='+theStreet);http.onreadystatechange=handleStreetResponse;http.send(null);document.getElementById("dictionary").innerHTML='<img src="images/loader.gif"/ > Searching, please wait a sec!'}
function handleStreetResponse(){if(http.readyState==4){var stResponse=http.responseText;document.getElementById("dictionary").innerHTML=stResponse;}}
function getGlobetrotter(theContinent){http=createRequestObject();http.open('get','get-globetrotter.php?continent='+theContinent);http.onreadystatechange=handleGTResponse;http.send(null);document.getElementById("GTContent").innerHTML='<img src="images/loader.gif"/ > Searching for all products in '+theContinent;}
function handleGTResponse(){if(http.readyState==4){var theResponse=http.responseText;document.getElementById("GTContent").innerHTML=theResponse;}}
function handleDictionaryResponse(){if(http.readyState==4){var theResponse=http.responseText;document.getElementById("dictionary").innerHTML=theResponse;}}
function useThisTown(theTown,thex,they,theType){var theTown=theTown;document.getElementById("location").value=theTown
document.getElementById("dictionary").style.display='none'
document.getElementById("theCoords").value=thex+","+they
document.getElementById("theX").value=thex
document.getElementById("theY").value=they
zoomToSearchPoint(theType)}
function useThisStreet(theStreet,theTown,thex,they){var theStreet=theStreet;var theTown=theTown;document.getElementById("location").value=theStreet+", "+theTown;document.getElementById("distanceStart").innerHTML=theTown
document.getElementById("dictionary").style.display='none'
document.getElementById("theCoords").value=thex+","+they
document.getElementById("theX").value=thex
document.getElementById("theY").value=they
zoomToSearchPoint('street')}
function calculateDistance(){if(document.getElementById("txtDistance").value=''){alert("Please enter an end point!")}else{}}
function getEndPoint(){var theInput=document.getElementById("txtDistance").value;http=createRequestObject();http.open('get','getEndPoint.php?search='+theInput);http.onreadystatechange=handleEndPointResponse;http.send(null);document.getElementById("endPointList").innerHTML='<img src="images/loader.gif"/ >';}
function handleEndPointResponse(){if(http.readyState==4){var theResponse=http.responseText;document.getElementById("endPointList").innerHTML=theResponse;}}
function calculateDistance(endTown,endX,endY){var endTown=endTown;var endX=endX;var endY=endY;document.getElementById("txtDistance").value=endTown;var startTown=document.getElementById("distanceStart").innerHTML;var startX=document.getElementById("theX").value;var startY=document.getElementById("theY").value;http=createRequestObject();http.open('get','calculateDistance.php?startX='+startX+'&startY='+startY+'&endX='+endX+'&endY='+endY+'&startTown='+startTown+'&endTown='+endTown);http.onreadystatechange=handleDistanceResponse;http.send(null);document.getElementById("endPointList").innerHTML='<img src="images/loader.gif"/ > <span style=\"font-size:11px\">Calculating distance.  This should only take a few seconds...</span>';var size=new OpenLayers.Size(22,36);var offset=new OpenLayers.Pixel(-(size.w/2),-size.h);var icon=new OpenLayers.Icon('http://77.246.172.232/images/mapmarkerEnd.png',size,offset);eMarker=new OpenLayers.Marker(new OpenLayers.LonLat(endX,endY),icon);pointLayer.addMarker(eMarker);}
function handleDistanceResponse(){if(http.readyState==4){var theResponse=http.responseText;document.getElementById("endPointList").innerHTML=theResponse;}}
function showLayer(theLayer){var tabImage=document.getElementById("tabImage");var aboutOn=document.getElementById("aboutLayer");var reviewsOn=document.getElementById("reviewsLayer");if(theLayer=='about'){tabImage.src="images/aboutTop.png";aboutOn.className='layerOn';reviewsOn.className='layerOff';}else{tabImage.src="images/reviewsTop.png";aboutOn.className='layerOff';reviewsOn.className='layerOn';}}
function showBookTab(theTab){var theImage=document.getElementById("bookTab");if(theTab=='reviews'){theImage.src='images/bookReviewsTop.jpg';document.getElementById("bookReviewsBack").className='layerOn';document.getElementById("bookRelatedBack").className='layerOff';document.getElementById("bookLookBack").className='layerOff';}else if(theTab=='related'){theImage.src='images/bookRelatedTop.jpg';document.getElementById("bookReviewsBack").className='layerOff';document.getElementById("bookRelatedBack").className='layerOn';document.getElementById("bookLookBack").className='layerOff';}else if(theTab=='lookInside'){theImage.src='images/bookLookTop.jpg';document.getElementById("bookReviewsBack").className='layerOff';document.getElementById("bookRelatedBack").className='layerOff';document.getElementById("bookLookBack").className='layerOn';}}
function hideCartAdded(){document.getElementById("cartAdded").style.display='none';}
function updateCart(){var theForm=document.getElementById("cart");theForm.submit();}
function useCode(){var theCode=document.getElementById("discountCode").value;var theForm=document.getElementById("updateCode");if(theCode==''){alert("Please enter your code!");}else{theForm.action="cart.php?discountCode="+theCode;theForm.submit();}}
function applySwap(){document.getElementById("applyImage").src='images/btnApplyCodeON.jpg';}
function applyRestore(){document.getElementById("applyImage").src='images/btnApplyCode.jpg';}
function showDetail(theImage,theISBN){var mainImage=document.getElementById("wallmapMain");imgPath="product-images/main/wallmaps/";if(theImage==1){mainImage.src="product-images/main/wallmaps/"+theISBN+".jpg";}else if(theImage==2){mainImage.src=imgPath+theISBN+"_s2.jpg";}else if(theImage==3){mainImage.src=imgPath+theISBN+"_s3.jpg";}else{}}
function submitReview(){var theName=document.getElementById("reviewName").value;var theEmail=document.getElementById("reviewEmail").value;var theReview=document.getElementById("reviewText").value;var theForm=document.getElementById("frmReview")
if(theName==""){alert("Please enter your name")}else if(theEmail==""){alert("Please enter your email address")}else if(theReview==""){alert("Please enter your review")}else{theForm.submit()}}
function submitConfirm(){if(!document.frmTerms.terms.checked){alert("Please accept the Terms and Conditions before continuing")}else{document.frmConfirm.action="confirm.php";document.frmConfirm.submit();}}
function submitConfirm1(){if(!document.frmTerms.terms.checked){alert("Please accept the Terms and Conditions before continuing")}else{document.frmConfirm.action="confirm1.php";document.frmConfirm.submit();}}
function submitConfirmTEST(){if(!document.frmTerms.terms.checked){alert("Please accept the Terms and Conditions before continuing")}else{document.frmConfirm.action="confirmEFT.php";document.frmConfirm.submit();}}
function checkout(){document.frmCheckout.action="checkout.php";document.frmCheckout.submit();}
function checkout1(){document.frmCheckout.action="checkout1.php";document.frmCheckout.submit();}
function eft(){document.frmCheckout.action="eft.php";document.frmCheckout.submit();}
function eft1(){document.frmCheckout.action="eft1.php";document.frmCheckout.submit();}
function chooseStore(theStore){document.getElementById("theStore").value=theStore}

function changeSport(){
	document.getElementById("sportN").className = "layerOff";
	document.getElementById("sportE").className = "layerOn";
}	

function saveSportChanges(){
	http = createRequestObject();
	var theUser = document.getElementById("userID").value;
	var theWeight = document.getElementById("uWeight").value;
	var theUsername = document.getElementById("spUsername").value;
	//var theHeight = document.getElementById("uHeightFt").value + ' ' + document.getElementById("uHeightIn").value;
	//var theAge = document.getElementById("uAge").value;
	http.open('get', 'updateSportValues.php?userID='+theUser+'&weight='+theWeight+'&username='+theUsername);
	http.onreadystatechange = updateTheValues;
	http.send(null)
}
function updateTheValues() {
	if(http.readyState == 4){
		//Update the page
		location.reload(true);
		//var theResponse = http.responseText;
		//alert(theResponse)
	}
}
