function testsubmit() {
  	if (document.forms["simplesearch"].ingredient.value!="--") {
    	document.forms["simplesearch"].submit();
  	} else {
    	if (document.forms["simplesearch"].stext.value!="") {
	      document.forms["simplesearch"].submit();
    }
  }
  return
}

myListings=new Array();
mySearches=new Array();
cookieName='dastleListings';
searchCookieName='dastleSearches';

function getMyListings(){
  	if (myrec=getCookieValue(cookieName)) {
		myListings=myrec.split(',');
  	}
  	if (myrec=getCookieValue(searchCookieName)) {
		mySearches=myrec.split('|');
  	}
	return
}

function addListings(number) {
	recCnt=myListings.length;
	remLink="<a href=\"javascript:blank()\" onclick=\"javascript:removeListings('"+number+"')\" >Remove from my favourite listings</a>";
	found=0;
	for (x=0;x<recCnt;x++) {
    	if (myListings[x]==number) {
			found=1;
    	}
	}
	if (found==0) {
    	myListings.push(number);
		writePersistentCookie (cookieName, myListings.join(','), 'months',6);
		alert('This listing has been added to your favourites.  Select "My Favourite Listings" from the menu to view your listings');
		document.getElementById('mine'+number).innerHTML=remLink;
	}
  	return
}

function removeListings(number) {
	recCnt=myListings.length;
	addLink="<a href=\"javascript:blank()\" onclick=\"javascript:addListings('"+number+"')\" >Add to my favourite listings</a>";
	for (x=0;x<recCnt;x++) {
		if (myListings[x]==number) {
			myListings.splice(x,1)
			alert('This listing has been removed from your listings.');
			document.getElementById('mine'+number).innerHTML=addLink;
		}
	}
	writePersistentCookie (cookieName, myListings.join(','), 'months',6);
	return
}


function addSearches(search) {
	recCnt=mySearches.length;
	found=0;
	for (x=0;x<recCnt;x++) {
		if (mySearches[x]==search) {
			found=1;
		}
	}
	if (found==0) {
		mySearches.push(search);
		writePersistentCookie (searchCookieName, mySearches.join('|'), 'months',6);
		alert('This search has been added to your favourites.  Select "My Stored Searches" from the menu to view your searches');
  	}
  	return
}

function removeSearches(search) {
	answer = confirm ("Are you sure you want to remove this search");
	if (answer)
	{
		recCnt=mySearches.length;
		for (x=0;x<recCnt;x++) 
		{
			if (mySearches[x]==search) 
			{
				mySearches.splice(x,1)
				alert('This search has been removed from your stored searches.');
			}
		}
		writePersistentCookie (searchCookieName, mySearches.join('|'), 'months',6);
		document.location.reload();
	}
	return
}

function blank() {
  return
}


