function doOnLoad() {
	window.menus.setMacX();

	preloadImage('assets/images/btn_reserve-over.png');
	preloadImage('assets/images/btn_purchase-over.png');
	preloadImage('assets/images/btn_more-over.png');

	return true;
}

function preloadImage(imghref) {
	if(typeof(window.preloadedImages)=='undefined') window.preloadedImages = new Array();
	var i = window.preloadedImages.length;
	window.preloadedImages[i] = new Image();
	window.preloadedImages[i].src = imghref;

	return true;
}

function openmenu(that) {
	var win = window.open(that.href, 'winmenu', 'width=700,height=600,scrollbars=yes,resizable=yes');


	return false;
}



// error class
//function Errors() {
//	this.errors = new Array();
//
//	this.adderror = function(msg) {
//		this.errors[this.errors.length] = msg;
//	}
//	this.alert = function() {
//		if(!this.errors.length) return false;
//
//		var msg = '';
//
//		for(var i=0; i<this.errors.length; ++i) {
//			msg += '*  ' + this.errors[i];
//			if(i < this.errors.length - 1) msg += '\n\n';
//		}
//
//		alert(msg);
//		return true;
//	}
//}
// error class
function Errors() {
	this.errors = new Array();

	this.add = function(msg) {
		this.errors[this.errors.length] = msg;
	}
	this.adderror = this.add;
	this.alert = function(silent) {
		if(!this.errors.length) return false;

		var msg = 'The following error(s) have occurred:\n\n';

		for(var i=0; i<this.errors.length; ++i) {
			msg += '*  ' + this.errors[i];
			if(i < this.errors.length - 1) msg += '\n\n';
		}

		if(silent) return msg;
		else {
			alert(msg);
			return true;
		}
	}
}


// optin validation
function validate_optin(f) {
	var e = new Errors();
	if(!validate_email(f.email.value)) e.adderror("Sorry, Invalid Email Address!");

	return e.alert() ? false : true;
}

function validate_email(email) {
	if(email.length <= 5) return false;
	if(email.indexOf('@', 0) == -1) return false;
	return true;
}





// contact validation
//function validate_contact(f) {
//	var e = new Errors();

//	//if(f.recipient.selectedIndex == 0) e.adderror("Please select a recipient.");
//	if(!f.first_name.value) e.adderror("Sorry, Invalid First Name.");
//	if(!f.last_name.value) e.adderror("Sorry, Invalid Last Name.");
//	if(!validate_email(f.email.value)) e.adderror("Sorry, Invalid Email Address!");
//	if(!f.comments.value) e.adderror("Please enter your comments.");

//	return e.alert() ? false : true;
//}

// tellafriend validation
function validate_tellafriend(f) {
	var e = new Errors();

	if(!f.sender_name.value) e.adderror("Sorry, Invalid Name.");
	if(!validate_email(f.sender_email.value)) e.adderror("Sorry, Invalid Email Address!");

	if(!f.recipient_name.value) e.adderror("Sorry, Invalid Friend's Name.");
	if(!validate_email(f.recipient_email.value)) e.adderror("Sorry, Invalid Friend's Email Address!");

//	if(!f.title.value) e.adderror("Please enter a title.");
//	if(!f.message.value) e.adderror("Please enter your message.");

	return e.alert() ? false : true;
}

function winelistlinkclick(that, k) {
	var winelist = document.getElementById('winelist'+k);

	if(winelist.style.display == 'none') {
		winelist.style.display = '';
		that.innerHTML = 'hide wines';
	}
	else {
		winelist.style.display = 'none';
		that.innerHTML = 'show wines';
	}

}

// Show / Hide function
function show(that, k, more, less) {
	var what = document.getElementById('class'+k);

	if(what.style.display == 'none') {
		what.style.display = '';
		that.innerHTML = less;
	}
	else {
		what.style.display = 'none';
		that.innerHTML = more;
	}

}
//Image window pop up
imagename = '';
function enlrge(imgnme,width,height) {
    lrgewin = window.open("about:blank","","height=" + height + ",width=" + width + ",resizable,scrollbars=yes")
    imagename = imgnme;
    setTimeout('update(' + width + ',' + height +')',500)
}

function update(width,height) {
    doc = lrgewin.document;
    doc.open('text/html');
    doc.write('<HTML><HEAD><TITLE>Enlarged Image<\/TITLE><link rel="stylesheet" href="http://www.celadonnapa.com/assets/css/style.css"><\/HEAD><BODY bgcolor="white" onload= "var myX = (screen.availWidth-' + width + ')/2; var myY = (screen.availHeight-' + height +')/2; window.moveTo(myX, myY);">\n');
    doc.write('<div align="center"><img src="http://www.coleschophouse.com/cp/custom/images/cp_logo.gif" border="0" width="100" height="125"><br>\n');
    doc.write('<form name="viewn"><table width="100%"><tr><td><input type="button" value="Print Window" onClick="if (parseInt(navigator.appVersion) >= 4) window.print(); return false;" style="color: #ffffff; font-size: 10px; background-color: #532d23;"></td><td align="right"><input type="button" value="Close Window" onClick="self.close()" style="color: #ffffff; font-size: 10px; background-color: #532d23;"></td></tr></table><\/form>\n');
    doc.write('<IMG SRC="' + imagename + '">\n');
    doc.write('<\/div><\/BODY><\/HTML>\n');
    doc.close();
}