function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}

function linkover(name) {
  document.getElementById(name).src="images/bullet2.gif";
}

function linkout(name) {
  document.getElementById(name).src="images/bullet1.gif";
}

function gallery(no,gal) {
   if (no>0 && no<totalimg+1) {
   	  if (no>firstpic-1 && no<lastpic+1) {
   		document.getElementById("image").src = 'files/gallery'+gal+'/b'+no+'.jpg?'+new Date().getTime();
      	imgno = no; 
	  } else if (no==firstpic-1) {
	    window.location = 'galleries.php?page='+gal+'&galpage='+(page-1)+'&pic='+(firstpic-1);
	  } else if (no==lastpic+1) {
	    window.location = 'galleries.php?page='+gal+'&galpage='+(page+1)+'&pic='+(lastpic+1);
	  }
   }
}

function changepic(source,id) {
   		document.getElementById(id).src = source+'?'+new Date().getTime();
}

function lodgeselect(lodge) {
		var chars=lodge.length;
		var lodgeno=lodge.charAt(chars-1);
		if (lodgeno==1) lodge="Upper";
		if (lodgeno==2) lodge="Lower";
   		document.getElementById('item_name').value = bookinginfo+': '+lodge+' Lodge';
}

function changelink(source,id,page) {
	if (page=='avail') {
		var checkid = id.substring(0,3);
		if (checkid=='day') document.getElementById(id).href = source;
	} else {
		document.getElementById(id).href = source;	
	}
}

function setdates(day,month,year) {
	document.getElementById('day').value=day;
	document.getElementById('month').value=month;
	document.getElementById('year').value=year;
	alert('The date '+day+'/'+month+'/'+year+' has been placed in the booking form on the left.  Please choose the length of your stay and click "Book" to continue.');
}