
function validateEmail(field){
	var emailReg = "^[a-z|0-9]+([\-|_|\.]?[a-z|0-9|_]+)*@[a-z|0-9]+([\-|\.]+[a-z|0-9]+)+$";
	var regex = new RegExp(emailReg);
	if (!regex.test(document.getElementById(field).value.toLowerCase()))
	{
		return false;
	}					
return true;
}


function fncIsNumberMy(obj) {
	var digits="1234567890.";
	var n_strVal=document.getElementById(obj).value;
	if(n_strVal.length>0)
	{
	for (var i=0; i < n_strVal.length; i++)
		if (digits.indexOf(n_strVal.charAt(i)) == -1)
			return false;
	} else return false;

	return true;
}



	function validateContact(){
                var errstring='';
                var flag=1;

	                if(document.getElementById('fname').value.length<=0) { errstring=errstring+'- Your Name\n'; flag=0; }
	                if(document.getElementById('evdate').value.length<=0) { errstring=errstring+'- Event Date\n'; flag=0; }
	                if(document.getElementById('guests').value.length<=0) { errstring=errstring+'- # of Guests\n'; flag=0; }
	                if(document.getElementById('bottles').value.length<=0) { errstring=errstring+'- # of Bottles\n'; flag=0; }
	                if(document.getElementById('message').value.length<=0) { errstring=errstring+'- Your Message\n'; flag=0; }
                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {
						document.getElementById('contactform').submit();
					}
				return false;

	}


	function validateJoin(){
                var errstring='';
                var flag=1;

	                if(document.getElementById('join_name').value.length<=0) { errstring=errstring+'- Your Name\n'; flag=0; }
	                if(!validateEmail('join_email')) { errstring=errstring+'- Email\n'; flag=0; }
                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {
						document.getElementById('joinform').submit();
					}
				return false;

	}



	function validateReserve(){
                var errstring='';
                var flag=1;

	                if(document.getElementById('res_name').value.length<=0) { errstring=errstring+'- Your Name\n'; flag=0; }
	                if(document.getElementById('res_phone').value.length<=0) { errstring=errstring+'- Phone\n'; flag=0; }
	                if(document.getElementById('res_guests').value.length<=0) { errstring=errstring+'- Guests\n'; flag=0; }
                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {
						document.getElementById('reserveform').submit();
					}
				return false;

	}



	function initScroll(){
//		$('.scroll-pane').jScrollPane({showArrows:true, active:0, arrowSize:18, scrollbarWidth:18, maintainPosition: true, dragMaxHeight:43});
	}


	function animInit(){
//		setTimer("initScroll()",1000);
//		initScroll();
	}




function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getBodyScrollTop()
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getClientCenterX()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(wid/2);
}

function getClientCenterY()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(hei/2)+getBodyScrollTop();
}



	function openPopup()
		{
		var width=350;
		var height=200;
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1]-4;
		var wid=document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=hei+"px";
		document.getElementById('shaded').style.width=wid+"px";

		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height-60; else var tp=10;

		document.getElementById('infoiframe_div').style.top=tp+"px";
		document.getElementById('infoiframe_div').style.left=(getClientCenterX()-half_width)+"px";

		document.getElementById('infoiframe_div').style.width=width+"px";
		document.getElementById('infoiframe_div').style.height=height+"px";
	
		document.getElementById('shaded').className="shaded_vis";
		document.getElementById('infoiframe_div').className="infoiframe_visible";
		}


	function closepopup()
		{
			document.getElementById('shaded').className="shaded_hid";
			document.getElementById('infoiframe_div').className="infoiframe_hidden";

		}

	function openPopup2()
		{
		var width=350;
		var height=350;
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1]-4;
		var wid=document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=hei+"px";
		document.getElementById('shaded').style.width=wid+"px";

		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height-60; else var tp=10;
		                                       
		document.getElementById('infoiframe_div2').style.top=tp+"px";
		document.getElementById('infoiframe_div2').style.left=(getClientCenterX()-half_width)+"px";

		document.getElementById('infoiframe_div2').style.width=width+"px";
		document.getElementById('infoiframe_div2').style.height=height+"px";
	
		document.getElementById('shaded').className="shaded_vis";
		document.getElementById('infoiframe_div2').className="infoiframe_visible2";
		}


	function closepopup2()
		{
			document.getElementById('shaded').className="shaded_hid";
			document.getElementById('infoiframe_div2').className="infoiframe_hidden2";

		}



	function getAjaxImage($image){
		document.getElementById('vimage').src="stock/"+$image;
	}
