<!-- hide from old browsers

var days = new Array();
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";

var months = new Array();
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";


function changeImage(newImg) {
	document.mainimage.src = "/gallery-big/" + newImg + ".jpg";
}

function switchMonth(direction,allowrollover) {
	$.ajaxSetup({
		cache: false
	});
	
	cottageid = document.getElementById('cottageid').value
	prevmonth = parseInt(document.getElementById('prevmonth').value);
	prevyear = parseInt(document.getElementById('prevyear').value);
	nextmonth = parseInt(document.getElementById('nextmonth').value);
	nextyear = parseInt(document.getElementById('nextyear').value);
	StartDay = document.getElementById('StartDay').value;

	if (direction=="prev") {
	
		if (prevmonth==1) {
			document.getElementById('prevmonth').value = 12;
			document.getElementById('prevyear').value = prevyear - 1;
		}else{
			document.getElementById('prevmonth').value = prevmonth - 1;
		}
		if (nextmonth==1) {
			document.getElementById('nextmonth').value = 12;
			document.getElementById('nextyear').value = nextyear - 1;
		}else{
			document.getElementById('nextmonth').value = nextmonth - 1;
		}
	
		themonth = prevmonth;
		theyear = prevyear;
	
	}else{

		if (prevmonth==12) {
			document.getElementById('prevmonth').value = 1;
			document.getElementById('prevyear').value = prevyear + 1;
		}else{
			document.getElementById('prevmonth').value = prevmonth + 1;
		}
		if (nextmonth==12) {
			document.getElementById('nextmonth').value = 1;
			document.getElementById('nextyear').value = nextyear + 1;
		}else{
			document.getElementById('nextmonth').value = nextmonth + 1;
		}

		
		themonth = nextmonth;
		theyear = nextyear;
	}
	
	var d=new Date();
	var e=new Date();
	curmonth = d.getMonth();
	curmonth = curmonth+1;
	lastmonth = curmonth-1;
	
	e.setMonth(d.getMonth() + 11);
	lastyear = e.getFullYear();
	
	if (curmonth==13) { curmonth = 1 }
	if (lastmonth==0) { lastmonth = 12 }
	
	if (allowrollover=="No") {
		lastmonth = 12;
		lastyear = theyear;
	}
	

	if (themonth==curmonth && theyear==d.getFullYear()) {
		document.getElementById('prevbut').src="/images/calendar-up-grey.gif";
		document.getElementById('prevbut').disabled="disabled";
		document.getElementById('prevbut').onclick="";
	}else{
		document.getElementById('prevbut').src="/images/calendar-up.gif";
		document.getElementById('prevbut').disabled="";
		document.getElementById('prevbut').onclick= function(){return switchMonth('prev',allowrollover);};
	}
	
	if ((themonth==lastmonth && theyear==lastyear)) {
		document.getElementById('nextbut').src="/images/calendar-down-grey.gif";
		document.getElementById('nextbut').disabled="disabled";
		document.getElementById('nextbut').onclick="";
	}else{
		document.getElementById('nextbut').src="/images/calendar-down.gif";
		document.getElementById('nextbut').disabled="";
		document.getElementById('nextbut').onclick= function(){return switchMonth('next',allowrollover);};
	}
	
	$("#calendarcontainer").load("inc_calendar.asp?StartDay="+StartDay+"&allowrollover="+allowrollover+"&reload=1&cottageid="+cottageid+"&dispmonth="+themonth+"&dispyear="+theyear,function() {});
	
	return false;
}

function checkEmail(strng) {
	var error = "";
	var emailFilter=/^.+@.+\..{2,6}$/;
	if (!(emailFilter.test(strng))) {
		return false;
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\] ']/
	if (strng.match(illegalChars)) {
		return false;
	}
	return true;
}
function mailchimpVal(thefields,emailfields) {
	
	thereturn = true;
	if (thefields!='') {
		fparts = thefields.split(",");
		for (i = 0; i < fparts.length; i++) {
			if (document.getElementById(fparts[i]).value=="first name" || document.getElementById(fparts[i]).value=="last name") {
				document.getElementById(fparts[i]).value='';
			}
			if (document.getElementById(fparts[i]).value=='') {
				document.getElementById(fparts[i]).style.background='#f8dfed';
				document.getElementById(fparts[i]).style.borderColor='#ff0000';
				thereturn = false;
			}else{
				document.getElementById(fparts[i]).style.background='#e2f2c4';
				document.getElementById(fparts[i]).style.borderColor='#000000';
			}
		}
	}
	if (emailfields!='') {
		fparts = emailfields.split(",");
		for (i = 0; i < fparts.length; i++) {
			if (document.getElementById(fparts[i]).value=="email address") {
				document.getElementById(fparts[i]).value='';
			}
			if (!checkEmail(document.getElementById(fparts[i]).value)) {
				document.getElementById(fparts[i]).style.background='#f8dfed';
				document.getElementById(fparts[i]).style.borderColor='#ff0000';
				thereturn = false;
			}else{
				document.getElementById(fparts[i]).style.background='#e2f2c4';
				document.getElementById(fparts[i]).style.borderColor='#000000';
			}
		}
	}
	
	if (thereturn==false) { alert('You must complete all fields'); }
	return thereturn;
}

function formVal(thefields) {
	thereturn = true;
	fparts = thefields.split(",");
	for (i = 0; i < fparts.length; i++) {
		if (document.getElementById(fparts[i]).value=='') {
			document.getElementById(fparts[i]).style.background='#ff0000';
			thereturn = false;
		}else{
			document.getElementById(fparts[i]).style.background='#ffffff';
		}
	}
	if (thereturn==false) { alert('You must complete all required fields'); }
	return thereturn;
}

var theaction

var thestart
var theend

var histart
var hiend

var blankend

function doselect(theday,theact) {
	if (thestart==null) {
		thestart = theday
		theaction = theact
	}else{
		theend = theday;
	}
	
	
	if (thestart!=null && theend!=null) {
	
			// START AJAXING SHENANIGANS //
			var xmlhttp = false;

			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			// JScript gives us Conditional compilation, we can cope with old IE versions.
			// and security blocked creation of the objects.

			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
					xmlhttp = false;
				}
			}

			@end @*/

			if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
				xmlhttp = new XMLHttpRequest();
			}

			if (theaction.length >= 1) {
				var returnText;
				uri = "/x_saveavailability.asp?theaction="+theaction+"&thestart="+thestart+"&theend="+theend;

				xmlhttp.open("GET", uri ,true);
				xmlhttp.onreadystatechange=function() {
					if (xmlhttp.readyState==4) {
						returnText = xmlhttp.responseText;

						if (returnText == "EOF") {
							newText = "All Types";
						} else {
							newText = returnText;
						}

						eval(returnText);
						
					}
				}

				xmlhttp.send(null);
			}
			else {
			}
			// END AJAXING SHENANIGANS //
			
		
		$("#ownercalendar").load("inc_ownercalendar.asp");
		
		
		theaction=null;
		thestart=null;
		theend=null;
	}
	
}

function dohighlight(theday) {
	if (thestart!=null && theend==null) {
		startparts = thestart.split('y');
		histart = parseInt(startparts[1]);
		
		curparts = theday.split('y');
		hiend = parseInt(curparts[1]);
	
		for (hl = histart; hl <= hiend; hl++) {
			if (theaction=='add'){theclass='highlighted'}else{theclass='available'}
			document.getElementById('day'+hl).className=theclass;
		}
		
		for (hl = hiend+1; hl <= blankend; hl++) {
			if (document.getElementById('day'+hl).getAttribute("Rel")=="booked") {
				theclass='booked';
			}else{
				theclass='available';
			}
			document.getElementById('day'+hl).className=theclass;
		}
	}
}

function unhighlight(theday) {
	if (thestart!=null && theend==null) {
		
		blankparts = theday.split('y');
		blankend = parseInt(blankparts[1]);
	}
}

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"; 
 	} 
} 

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

window.onload = externalLinks;

// - end hiding -->
