
        sfHover = function() {
            var sfEls = document.getElementById("menu-primary").getElementsByTagName("LI");
            for (var i=0; i<sfEls.length; i++) {
                sfEls[i].onmouseover=function() {
                    this.className+=" sfhover";
                }
                sfEls[i].onmouseout=function() {
                    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
                }
            }
        }
        if (window.attachEvent) window.attachEvent("onload", sfHover);


/**
 * matches US phone number format 
 * 
 * where the area code may not start with 1 and the prefix may not start with 1 
 * allows '-' or ' ' as a separator and allows parens around area code 
 * some people may want to put a '1' in front of their number 
 * 
 * 1(212)-999-2345
 * or
 * 212 999 2344
 * or
 * 212-999-0983
 * 
 * but not
 * 111-123-5434
 * and not
 * 212 123 4567
 */
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");

/*   
=============================================================================== 
Base jQuery file
...............................................................................
																		2011/03
------------------------------------------------------------------------------- 
COPY / USE AT YOUR OWN SITE'S RISK
=============================================================================== 
*/

jQuery(document).ready( function() {

	//home page blog area
	$(".linkToBlog").each(function(){
		$(this).css("cursor","pointer");
		$(this).click(function(){
			window.location.href="http://www.arlingtonplace.com/blog/";
		});;
	});
	
	//$('.btn').blend(300);
	//$('#menu-primary > li > a').blend();
	
	//directions page
	$("#lnkObx").colorbox({width:"50%", inline:true, href:"#obx"});
	$("#lnkI95").colorbox({width:"50%", inline:true, href:"#I95"});
	$("#lnkRaleigh").colorbox({width:"50%", inline:true, href:"#Raleigh"});
	$("#lnkCoastBeaches").colorbox({width:"50%", inline:true, href:"#CoastBeaches"});
	$("#lnkNC-SC").colorbox({width:"50%", inline:true, href:"#NC-SC"});
	$("#lnkBoat").colorbox({width:"50%", inline:true, href:"#boat"});
	
	//calendar of events page
	$(".eventPopup").colorbox({width:"599px", height:"80%", iframe:true});
	
	
	/*get fast answers*/
	var answerSection = $('#GetAnswersContainer'),
	trigger = $('#GetAnswersTab a'),
	btnClose= $('#btnClose')
		
	var toggleRate = 1200;
	if(answerSection[0]){
		trigger.click(function(){
			answerSection.stop(true,true);
			answerSection.animate({top:0},toggleRate,'easeOutExpo');
		});
		btnClose.click(function(){
			answerSection.stop(true,true);
			answerSection.animate({top:-750},toggleRate,'easeOutExpo');
		});
	}
	
	
	/*start jquery for home page image slider
	From: http://www.sohtanaka.com/web-design/automatic-image-slider-w-css-jquery/
	*/
		//Show the paging and activate its first link
		$(".paging").show();
		$(".paging a:first").addClass("active");
		
		//Get size of the image, how many images there are, then determin the size of the image reel.
		var imageWidth = $(".window").width();
		var imageSum = $(".image_reel img").size();
		var imageReelWidth = imageWidth * imageSum;
		
		//Adjust the image reel to its new size
		$(".image_reel").css({'width' : imageReelWidth});
	
		//Paging  and Slider Function
		rotate = function(){
			var triggerID = $active.attr("rel") - 1; //Get number of times to slide
			var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
		
			$(".paging a").removeClass('active'); //Remove all active class
			$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
			//Slider Animation
			$(".image_reel").animate({
				left: -image_reelPosition
			}, 500 );
		
		}; 
		
		//Rotation  and Timing Event
		rotateSwitch = function(){
			play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
				$active = $('.paging a.active').next(); //Move to the next paging
				if ( $active.length === 0) { //If paging reaches the end...
					$active = $('.paging a:first'); //go back to first
				}
				rotate(); //Trigger the paging and slider function
			}, 7000); //Timer speed in milliseconds (7 seconds)
		};

		rotateSwitch(); //Run function on launch
		
		//On Hover
		$(".image_reel a").hover(function() {
			clearInterval(play); //Stop the rotation
		}, function() {
			rotateSwitch(); //Resume rotation timer
		});	
		
		//On Click
		$(".paging a").click(function() {
			$active = $(this); //Activate the clicked paging
			//Reset Timer
			clearInterval(play); //Stop the rotation
			rotate(); //Trigger rotation immediately
			rotateSwitch(); // Resume rotation timer
			return false; //Prevent browser jump to link anchor
		});
	
	/*end jquery for home page image slider*/
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		// form validation
	var formContact = jQuery("#formContact");
    if ( formContact[0] ) {
	    formContact.validate({
			rules: {
				captchaIn: {
					required: true,
					remote: "/siteassets/js/process.cfm"
				},
				firstname: "required",
				lastname: "required",
			//	phone: {
			//		phoneUS: true
			//	},
				email: {
					required: true,
					email: true
				}
			//	desire: "required",
			//	varSourceName: "required"
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				phone: {
					phoneUS: "Please enter a valid phone number"
				},
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address"
				},
				desire: "Please select one",
				varSourceName: "Please select one",
				captchaIn: {
					required: "Please enter the captcha.",
					remote: "Correct captcha is required."
				}/**/
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	
		var formFastAnswers = jQuery("#formFastAnswers");
    if ( formFastAnswers[0] ) {
	    formFastAnswers.validate({
			rules: {
				captchaIn: {
					required: true,
					remote: "/siteassets/js/process.cfm"
				},
				firstname: "required",
				lastname: "required",
			//	phone: {
			//		phoneUS: true
			//	},
				email: {
					required: true,
					email: true
				}
			//	desire: "required",
			//	varSourceName: "required"
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				phone: {
					phoneUS: "Please enter a valid phone number"
				},
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address",
				captchaIn: {
					required: "Please enter the captcha.",
					remote: "Correct captcha is required."
				}/**/
				}
				//desire: "Please select one",
				//varSourceName: "Please select one"
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	
	
	
	var formRegister = jQuery("#formRegister");
    if ( formRegister[0] ) {
	    formRegister.validate({
			rules: {
				captchaIn: {
					required: true,
					remote: "/siteassets/js/process.cfm"
				},
				firstname: "required",
				lastname: "required",
				phone: {
					required: true,
					phoneUS: true
				},
				email: {
					required: true,
					email: true
				},
				contactvia: "required"
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				phone: {
					phoneUS: "Please enter a valid phone number"
				},
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address"
				},
				contactvia: "Please select one",
				captchaIn: {
					required: "Please enter the captcha.",
					remote: "Correct captcha is required."
				}/**/
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	var formRegisterHOA = jQuery("#formRegisterHOA,#formUpdateProfile,#formHelpHOA");
    if ( formRegisterHOA[0] ) {
	    formRegisterHOA.validate({
			rules: {
				firstname: "required",
				lastname: "required",
				homesitelotnbr: "required",
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				homesitelotnbr: "Please enter your lot number",
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address"
				}
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	var formRegisterRealtor = jQuery("#formRealtorRegister,#formRealtorSupport");
    if ( formRegisterRealtor[0] ) {
	    formRegisterRealtor.validate({
			rules: {
				firstname: "required",
				lastname: "required",
				officephone: {
					required: true,
					phoneUS: true
				},
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				officephone: {
					required: "Please enter your office phone",
					phoneUS: "Please enter a valid phone number"
				},
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address"
				}
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	var formRealtorProfile = jQuery("#formRealtorProfile");
    if ( formRealtorProfile[0] ) {
	    formRealtorProfile.validate({
			rules: {
				firstname: "required",
				lastname: "required",
				officephone: {
					required: true,
					phoneUS: true
				},
				email: {
					required: true,
					email: true
				},
				LogoImage: {
					
					accept: 'gif|jpe?g'
				},
				BioImage: {
					
					accept: 'gif|jpe?g'
				}
			},
			messages: {
				firstname: "Please enter your first name",
				lastname: "Please enter your last name",
				officephone: {
					required: "Please enter your office phone",
					phoneUS: "Please enter a valid phone number"
				},
				email:  {
					required: "Please enter your email address",
					email: "Please enter a valid email address"
				},
				LogoImage: {
					accept: 'Invalid file type. Please select a different image'
				},
				BioImage: {
					accept: 'Invalid file type. Please select a different image'
				}
			},
			errorPlacement: function(error, element) { 
				if ( element.is(":radio") || element.is(":checkbox") ) 
					error.appendTo( element.closest('fieldset') );
				else 
					error.appendTo( element.parent() ); 
			}
		})
	}
	
	
});
