
	 var today = new Date();
	 var the_date = new Date("December 31, 2023");
	 var the_cookie_date = the_date.toGMTString();
	 var the_cookie = screen.width;
	 var the_cookie = 'users_resolution=' + the_cookie + ";expires=" + the_cookie_date;
	 document.cookie=the_cookie;
	 
	function checkNewsletterForm(theObject) {	
		if(
		   	!theObject.name_first.value ||
			!theObject.name_last.value ||
			!theObject.email.value
		)
		alert("Please complete the form in full");
		return false;
	}

	function closeAdded() {
			var theObj = document.getElementById('addedAlert');
			theObj.style.display = 'none';
	}	 

	function setNull(theObject) {
		if(theObject.value == 'Keyword(s)') theObject.value = '';
	}
	
	function checkSearchForm(theObject) {	
		if((theObject.keywords.value == 'Keyword(s)' || theObject.keywords.value == '') && (theObject.wineRegionID.selectedIndex == 0) && (theObject.wineTypeID.selectedIndex == 0) && (theObject.price_range.selectedIndex == 0)) {alert('Please select one or more search criteria');return false;}	
	}

	function orderBy(existing_order_by) {

		var currentLocation = document.location.href;
		
		//////
		//New part to locate the category_id querystring if there is one in the URL
		var startPointOfCategoryID = currentLocation.indexOf("category_id");
		if(startPointOfCategoryID) {
			var strCategoryQuerystring = currentLocation.substring(startPointOfCategoryID,currentLocation.length);
			//alert(strCategoryQuerystring);
		}
		/////
		
		currentLocation = currentLocation.replace(" ","%20");
		var stringToSwap = "&order_by="+existing_order_by;		
		var stringToSwap2 = "?order_by="+existing_order_by;		
		currentLocation = currentLocation.replace(stringToSwap,"");
		currentLocation = currentLocation.replace(stringToSwap2,"");								
		var startPoint = currentLocation.length-4;
		var startPoint2 = currentLocation.length-5;		

		if((currentLocation.substring(startPoint) == '.php') || (currentLocation.substring(startPoint2) == '.html')) {
			var newLocation = currentLocation += '?order_by=' + document.frmOrderBy.order_by.value;
		} else {
			var newLocation = currentLocation += '&order_by=' + document.frmOrderBy.order_by.value;
		}

		location.href = newLocation;
			
	}
