// Onload When Document Ready

$(document).ready(function() {
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
			window.onscroll = function() {document.getElementById('footer').style.top = (window.pageYOffset + window.innerHeight - 85) + 'px';};
			var isIphone = 1;			
	} else {
			var isIphone = 0;
	}

	
  $("div#sidebar").prepend("<div class=\"sidebarCap\">&nbsp;</div>");
  $("div#sidebar").append("<div class=\"sidebarBase\">&nbsp;</div>");
  $("div.contentBlock").prepend("<div class=\"CBCap\">&nbsp;</div>");
  $("div.contentBlock").append("<div class=\"CBBase\">&nbsp;</div>");
  $('a[rel=external]').attr('target', '_blank');
  $('.equalize').equalHeights('true');
  $("img[src$=png],.pngfix").pngfix();

	if($('a.slideshow').length) {
  	$("a.slideshow").colorbox({
			slideshow	:	true,
			slideshowSpeed	: 6000
		
		});
	}

	if($('a.virtualTour').length) {
	  $("a.virtualTour").colorbox({
			iframe		:		true,
			'height'	:		750,
			'width'		:		850
		});
	}

	if($('a.iframeCB').length) {
	  $("a.iframeCB").colorbox({
			iframe		:		true,
			'overlayClose' : false,
			'height'	:		640,
			'width'		:		760
		});
	}

	if($('a.saveListing').length) {
	  $("a.saveListing").colorbox({
			'width'		:		500,
			'height'	:		165,
			inline		: true,
			href			: '#saveListing'
		});
	}
	
	if($('a.cbloginbox').length) {
		if(!isIphone){		
		  $("a.cbloginbox").colorbox({
				'height'	:		320,
				'width'		:		500,
				'overlayClose' : false,
				iframe		: true
			});
		}
	}

	if($('a.iframe').length) {
	  $("a.iframe").colorbox({
			'height'	:		625,
			'width'		:		655,
			iframe		: true
		});
	}
	
	if($('a.iframeWide').length) {
	  $("a.iframeWide").colorbox({
			'height'	:		660,
			'width'		:		800,
			'opacity'	: .5,
			iframe		: true
		});
	}

	if($('a.iframeWideDos').length) {
	  $("a.iframeWideDos").colorbox({
			'height'	:		767,
			'width'		:		800,
			'opacity'	: .5,
			iframe		: true
		});
	}
	
	if($('a.iframeMap').length) {
	  $("a.iframeMap").colorbox({
			'height'	:		660,
			'width'		:		900,
			'opacity'	: .5,
			iframe		: true
		});
	}
	

	
	if($('a.loginbox').length) {
		  $("a.loginbox").colorbox({
				'height'	:		285,
				'width'		:		500,
				'overlayClose' : false,
				iframe		: true
			});
	}


	if($('.featureRot').length) {
  	$('.featureRot').cycle({ 
    	speed: 1000,  // speed of the fade transition effect
    	timeout: 4000 // time between transitions from one image to the next
  	});
	}

/*	if($('#howToReachSubmit').length){
    $.getScript('/javascript/jquery.validate.min.js',
      function() {
        $('#specialEventRequest,#eClubSignup,#informationRequest,#emailFriend').validate();
    });
		
	} */

	if($('#howToReachForm').length){$.getScript('/javascript/jquery.validate.min.js');}

	$('#howToReachSubmit').click(function(){
			var reachFormValidate = $('#howToReachForm').validate();
			if(reachFormValidate.form()){
				$.post('/howToReachProc.cfm', $('#howToReachForm').serialize(), function(){

					$('.footSlider #containForm').html('Your Comments Were Submitted!');
					setTimeout('$(\'.howToReach:first\').click();', 1500)
		
				}); 
			}
	});


	if($('#specialEventRequest,#eClubSignup,#informationRequest,#emailFriend').length) {
    $.getScript('/javascript/jquery.validate.min.js',
      function() {
        $('#specialEventRequest,#eClubSignup,#informationRequest,#emailFriend').validate();
    });
	}



	
	if($('#memberProfile').length) {
    $.getScript('/javascript/jquery.validate.min.js',
      function() {
        $('#memberProfile').validate({
					rules: {
						memPasswordConfirm: {	equalTo: "#memPassword"	}
					},
					messages: {
						memPasswordConfirm: {
							equalTo: "Please enter the same password as above"
						}
					}
				});
    	});
		}


	var reachToggle = 'down';	

  $('.howToReach').click(function(){
			if(reachToggle == 'down') {
				reachToggle = 'up';
				$('.howToReach').addClass('active');
				$('.footSlider').animate({top:'-122px'}, 200);      
			} else {
				reachToggle = 'down';
				$('.footSlider').animate({top:'5px'}, 200);      
				$('.howToReach').removeClass('active');
			
			}
  });
  



/*	
	$("#flowpanes").scrollable({size: 1}).circular().mousewheel(400).navigator({ 
	        // select #flowtabs to be used as navigator 
	        navi: "#pods", 
	        // select A tags inside the navigator to work as items (not direct children) 
	        naviItem: 'a', 
	        // assign "current" class name for the active A tag inside navigator 
	        activeClass: 'current' 
    });
*/

});

function addBookmark(title,url) {
  if (window.sidebar) {
    window.sidebar.addPanel(title, url,"");
  } else if( document.all ) {
    window.external.AddFavorite( url, title);
  } else if( window.opera && window.print ) {
    return true;
  }
}

