function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function PopWindow (url,w,h,scroll,resize,center,max,args) {
	//var isSP2 = (window.navigator.userAgent.indexOf("SV1")!= -1);
	//if (isIE && isWin && isSP2) h += 25;
	if (center) { var winPos = ',top='+((screen.height - h) / 2)+',left='+((screen.width - w) / 2); }
	var scrollArg = (scroll == false) ? '' : ',scrollbars=1';
	var resizeArg = (resize == false) ? '' : ',resizable=1';
	flyout = window.open (url,"newin"+scroll+resize+center,"width=" + w + ",height=" + h + scrollArg + resizeArg + winPos + args);
	if (max == true) {
		flyout.moveTo(0,0);
		flyout.resizeTo(screen.availWidth,screen.availHeight);	}
	else { 
		if ((flyout.innerWidth !== null)&&(flyout.innerWidth !== undefined)) {
			if ((window.navigator.userAgent.indexOf("Safari")!= -1)) { w+=0; h+=8; }
			if ((window.navigator.userAgent.indexOf("Camino")!= -1)) { w+=0; h+=8; }
			flyout.resizeBy(w-flyout.innerWidth,h-flyout.innerHeight);
		}else if ((flyout.document.body !== null)&&(flyout.document.body.clientWidth !== null)) {
			flyout.resizeBy(w-flyout.document.body.clientWidth,h-flyout.document.body.clientHeight);
		}else{
			flyout.resizeTo(w,h);
		}
	}
	flyout.focus();	
}

function getPopup ( url, height, width, left, top, getscroll)
	{
	
	if(left == "" && left != 0)
		{
		
		// you can change the defaults
		left = 50;
		
		}else if(top == "" && top != 0){
		
		// you can change the defaults
		top = 50;
		
		}
	
	var outStr = 'height=' + height + ',width=' + width + ',left=' + left + ',top=' + top;
	outStr = outStr + ',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=' + getscroll + ',resizable=no';
	
	// you can also change the name ...
	window.open(url, "popup", outStr);
	
	}




function checkFORM(f){

var radio_choice = false;

	
	
	var regex = /^[A-Za-z_0-9'\.\-]+@[A-Za-z_0-9'\.\-]+(\.\w+)+$/;
		var emailTest = regex.exec(f.email.value);
									
			if(f.name_first.value == ''){
				
				alert("Please fill out the name field.");
				f.name_first.focus();
				return false;			
				
				
				/// phone				
				}else if(f.mainphone_area.value != '' && f.mainphone_pre.value == '' && f.mainphone_post.value == ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				
				}else if(f.mainphone_area.value != '' && f.mainphone_pre.value != '' && f.mainphone_post.value == ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				
				}else if(f.mainphone_area.value != '' && f.mainphone_pre.value == '' && f.mainphone_post.value != ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				
				}else if(f.mainphone_area.value == '' && f.mainphone_pre.value != '' && f.mainphone_post.value == ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				
				}else if(f.mainphone_area.value == '' && f.mainphone_pre.value != '' && f.mainphone_post.value != ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				
				}else if(f.mainphone_area.value == '' && f.mainphone_pre.value == '' && f.mainphone_post.value != ''){
				alert("Please provide a complete phone number");				
				f.mainphone_area.focus();
				return false;
				/// end phone
					

				}else if(f.email.value == ''){
				
				alert("Please fill out the Email field.");
				f.email.focus();
				return false;
				
				}else if(emailTest == null){
				
				alert("Please fill out a valid Email Address.");
				f.email.focus();
				return false;
				
				}else if(f.email2.value != f.email.value){
				
				alert("Your Confirmed Email Address does not match your Email Address.");
				f.email2.focus();
				return false;
				
				}else if(f.hear_about.value == ''){
				
				alert("Please fill out the 'How did you hear about us?' field.");
				f.hear_about.focus();
				return false;
				
				}else if((f.hear_about.value == 'Other' || f.hear_about.value == 'Broker or Realtor') && (f.referred.value == '')){
				
				alert("Please fill out the 'Would you tell us by whom you were referred?' field.");
				f.referred.focus();
				return false;
													
				}else{
				
				return true;
				
				}

}




var agt=navigator.userAgent.toLowerCase();
var is_mac		= (agt.indexOf("mac")		!= -1);
var is_ie   	= (agt.indexOf("msie")		!= -1);
var is_safari   = (agt.indexOf("safari")	!= -1);
var is_camino   = (agt.indexOf("camino")	!= -1);

function PopWindowResize(s) {
	var w=770, h=700, max=false;
	var flags='',x,y,newx,newy,cmd='';
	var debug=0, str='';
	
	if (max == true) {
		self.moveTo(0,0);
		str += 'Location 1a: resizeTo('+ screen.availWidth +','+ screen.availHeight +')\n';
		self.resizeTo(screen.availWidth,screen.availHeight);	}
	else {
		if (self.innerHeight) // all except Explorer
		{
			flags += 'cond1';	x = self.innerWidth;	y = self.innerHeight;
			if (debug==1) alert('BEFORE x:'+ x +' y:'+ y);
			if (is_safari) { w+=0; h+=8; flags += ':Safari'; }
			if (is_camino) { w+=0; h+=8; flags += ':Camino'; }
			cmd = 'resizeBy('+ (w-x) +','+ (h-y) +')<br>';
			if (debug==1) alert(cmd);
			self.resizeBy(w-x,h-y);
			flags += 'cond1';	x = self.innerWidth;	y = self.innerHeight;
			if (debug==1) alert('AFTER ['+ flags +'] x:'+ x +' y:'+ y);
		}
		else if (document.documentElement && !(is_mac && is_ie) )	// Explorer 6 Strict Mode
		{
			flags += 'cond2';	x = document.documentElement.clientWidth;	y = document.documentElement.clientHeight;
			if (debug==1) alert('BEFORE x:'+ x +' y:'+ y);
			cmd = 'resizeBy('+ (w-x) +','+ (h-y) +')<br>';
			if (debug==1) alert(cmd);
			self.resizeBy(w-x,h-y);
			flags += 'cond2';	x = document.documentElement.clientWidth;	y = document.documentElement.clientHeight;
			if (debug==1) alert('AFTER ['+ flags +'] x:'+ x +' y:'+ y);
		}
		else if (document.body) // other Explorers
		{
			flags += 'cond3';	x = document.body.clientWidth;	y = document.body.clientHeight;
			if (debug==1) alert('BEFORE x:'+ x +' y:'+ y);
			cmd = 'resizeBy('+ (w-x) +','+ (h-y) +')<br>';
			if (debug==1) alert(cmd);
			self.resizeBy(w-x,h-y);
			flags += 'cond3';	x = document.body.clientWidth;	y = document.body.clientHeight;
			if (debug==1) alert('AFTER ['+ flags +'] x:'+ x +' y:'+ y);
		}
		else
		{
			flags += 'cond4';	x = 0;	y = 0;		// you should never get here
			if (debug==1) alert('BEFORE x:'+ x +' y:'+ y);
			//flyout.resizeTo(w,h);
			if (debug==1) alert('AFTER ['+ flags +'] x:'+ x +' y:'+ y);
		}
	}
}

MM_preloadImages('/images/wrapper_bg.jpg','/images/bg.jpg','/images/map_btn_over.jpg','/images/news_btn_over.jpg','/images/live_stowe_btn_over.gif','/images/ownership_btn_over.gif','/images/mountain_club_btn_over.gif','/images/vision_btn_over.gif','/images/contact_btn_over.gif','/images/learn_btn_over.jpg','/images/tmpl_learn_btn_over.jpg','/images/view_video_btn_over.jpg','/images/news_events_btn_over.gif','/images/tmpl_contact_btn_over.jpg','/images/tmpl_club_btn_over.jpg', '/images/ownership_front_four_over.jpg','/images/ownership_condominiums_over.jpg','/images/ownership_mountain_cabins_over.jpg','/images/ownership_homesites_over.jpg','/images/ownership_services_over.jpg','/images/ownership_amenities_over.jpg','/images/ownership_features_over.jpg','/images/ownership_faq_over.jpg','/images/neighborhood_plan_over.jpg','/images/mountaincabins_btn_roll.gif','/images/mountainlodge_btn_roll.gif','/images/frontfour_btn_roll.gif','/images/golfcoursemaplink_over.gif','/images/golfcoursevideolink_over.jpg','/images/audubonbtn_over.gif');



showHideState = function(v){

	if(v == "United States"){
		document.getElementById("province_div").style.display = 'none';
		document.getElementById("state_div").style.display = 'inline';
	}else{
		document.getElementById("state_div").style.display = 'none';
		document.getElementById("province_div").style.display = 'inline';
	}
}

hearAbout = function(v){

			if(v == 'Broker'){
				
				Element.show('referred'); 

			}else if(v == 'Referral'){
				
				Element.show('referred'); 
				
			}else if(v == 'Other'){
				
				Element.show('referred');
			}else if(v == 'Broker or Realtor'){
				
				Element.show('referred');	
			}else{
				Element.hide('referred');
				
			}

}


function next(){
	// get id value
	document.storage.id.value = parseInt(document.storage.id.value) + 1;
	
	if(document.storage.id.value < img_array.length){
		var pr_count = parseInt(document.storage.id.value) + 1;
		document.getElementById('zplane').src = img_array[document.storage.id.value];
	}else{
		document.storage.id.value = 0;
		document.getElementById('zplane').src = img_array[0];
	}

}


function prev(){
	// get id value
	document.storage.id.value = parseInt(document.storage.id.value) - 1;
	
	if(document.storage.id.value < 0){
		document.storage.id.value = img_array.length - 1;
		var pr_count = parseInt(document.storage.id.value);
		document.getElementById('zplane').src = img_array[pr_count];
		
	}else{
		var pr_count = parseInt(document.storage.id.value);
		document.getElementById('zplane').src = img_array[pr_count];
		
	}
	//alert(document.storage.id.value)
}


function confDel(){
		
		var message = "Are you sure you want to remove this person?\n\n" +
								"Click OK to remove.";
								
		return confirm(message);	
			
		}



function writeit(selObj) {
	
	document.getElementById('mp').src = selObj.options[selObj.selectedIndex].value;
	
	  
	
	if (selObj.options[selObj.selectedIndex].value > 0) {
	
	
	var ipstring;
	var colname;
	
	ipstring = 'Please fill out Full Names of Attending Adults\n';
	
	for (var i = 0; i < selObj.options[selObj.selectedIndex].value; i++) {
		ni = i+1;
		ipstring = ipstring + "<input type='text' value='' name='adultname[]'/>\n";
		
	}
	
	
	document.getElementById('cp').innerHTML  = ipstring;
	
	} else {
	
	document.getElementById('cp').innerHTML  = '';
	
	}
	
	
	
}

function writeit2(selObj) {
	
	document.getElementById('cmp').src = selObj.options[selObj.selectedIndex].value;
	
	  
	
	if (selObj.options[selObj.selectedIndex].value > 0) {
	
	
	var ipstring;
	ipstring = 'Please fill out Full Names and Ages of Attending Children\n';
	
	for (var i = 0; i < selObj.options[selObj.selectedIndex].value; i++) {
		ni = i+1;
		ipstring = ipstring + "<input type='text' value=''  name='childname[]'/>"+"<input type='text' value='' class='short' name='childage[]'/>\n";
		
	}
	
	document.getElementById('ap').innerHTML  = 'Full Name/Age';
	document.getElementById('ccp').innerHTML  = ipstring;
	
	} else {
	document.getElementById('ap').innerHTML  = '';
	document.getElementById('ccp').innerHTML  = '';
	
	}
	
	
	
}

function checkrsvpFORM(f){
	
	
	
	var regex = /^[A-Za-z_0-9'\.\-]+@[A-Za-z_0-9'\.\-]+(\.\w+)+$/;
		var emailTest = regex.exec(f.email.value);
									
			if(f.name_first.value == ''){
				
				alert("Please fill out the first name field.");
				f.name_first.focus();
				return false;								
				
				} else if(f.name_last.value == ''){
				
				alert("Please fill out the last name field.");
				f.name_last.focus();
				return false;	
				
		
				
				}else if(f.email.value == ''){
				
				alert("Please fill out the Email field.");
				f.email.focus();
				return false;
				
				}else if(emailTest == null){
				
				alert("Please fill out a valid Email Address.");
				f.email.focus();
				return false;
				
				}else if(f.address.value == ''){
				
				alert("Please fill out the address field.");
				f.address.focus();
				return false;
				
				}else if(f.city.value == ''){
				
				alert("Please fill out the city field.");
				f.city.focus();
				return false;
				
				}else if(f.state.value == ''){
				
				alert("Please select a state.");
				f.state.focus();
				return false;
				
				
				
				}else if(f.zip.value == ''){
				
				alert("Please fill out the zip code field.");
				f.zip.focus();
				return false;

				
							
				}else{
				
				f.updateit.value = "yes";
				return true;
				
				}

}







