$(document).ready(function(){
						   
/*******************************************************
LEAVE ALL THESE ALONE - THEY ARE STANDARD
*******************************************************/
	// fixes png images for ie6.
	jQuery(document).pngFix();

	// opens anything pdf link to a new page.
	$("a[href*=.pdf]").click(function()	{
		$(this).attr({"target":"_self"});
		return false;
	});
	
	// opens a link to a new page
	$('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	
	
	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$('input[type="password"]').addClass("idleField");
	$('input[type="password"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="password"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$('textarea').addClass("idleField");
	$('textarea').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('textarea').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
	$('a[rel="loginClick"]').click(function(){
		var cameFromVal	= window.location.protocol + "//" + window.location.host + window.location.pathname;
		$.cookie('cameFrom',cameFromVal,{ expires: 7, path: '/'});
	});
	
	
/*******************************************************
FOR THIS WEBSITE.
*******************************************************/
	
    $(document).bind("contextmenu",function(e){
        return false;
    });

	// validate the contact form
	$("#contactForm").validate({
		rules: {
			fullName: "required",
			userEmail: "required",
			comment: "required"
		},
		messages: {
			fullName: "",
			userEmail: "",
			comment: ""
		}
	});
	
	
	
	$("#registerForm").validate({
		rules: {
			firstName: "required",
			lastName: "required",
			phone: "required",
			bestTime: "required",
			emailAddress: "required",
			propType: "required",
			locationType: "required",
			features: "required",
			priceRange: "required",
			comments: "required"			
		},
		messages: {
			firstName: "",
			lastName: "",
			phone: "",
			bestTime: "",
			emailAddress: "",
			propType: "",
			locationType: "",
			features: "",
			priceRange: "",
			comments: ""
		}
	});

	
	
	
	
	$("#clientLogin").validate({
		rules: {
			username: "required",
			password: "required"
		},
		messages: {
			username: "",
			password: ""
		}
	});
	
	
	
	
	
	
	
	
	
	
	// Lets Deal with the drop down menus.							
	$("#van-one li").hover(
		function(){ $("ul", this).fadeIn("slow"); }, 
		function() { } 
	);
	if (document.all) {
		$("#van-one li").hoverClass("sfHover");
	}
	
	
	$(".grid_22 .zPhone:last").css("border-right","none");
	
	
	
	$(".mIMGchg").click(function(){
		var imgXchange	= $(this).attr("rel");
		var newTitle	= $(this).attr("title");
		//alert(imgXchange);
		var imgOld		= $("#mainIMGchg img").attr("src");
		var aList 		= imgOld.split("/");
		var imgLocation	= "/"+aList[1]+"/"+aList[2]+"/"+imgXchange;
		$("#mainIMGchg img").attr("src",imgLocation);
		$("#mainIMGchg img").attr("alt",newTitle);
		//alert(imgLocation);
		return false;
	});
	$(".mIMGchg2").click(function(){
		var imgXchange	= $(this).attr("rel");
		var newTitle	= $(this).attr("title");
		//alert(imgXchange);
		var imgOld		= $("#mainIMGchg2 img").attr("src");
		var aList 		= imgOld.split("/");
		var imgLocation	= "/"+aList[1]+"/"+aList[2]+"/"+aList[3]+"/"+imgXchange;
		$("#mainIMGchg2 img").attr("src",imgLocation);
		$("#mainIMGchg2 img").attr("alt",newTitle);
		//alert(imgLocation);
		return false;
	});
	
	
	$(".googleMap").click(function(){
		var linkURL = $(this).attr("href");
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(linkURL, '" + id + "', 'toolbar=no,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=655,height=495,left = 495,top = 392');");
		return false;
	});
	
	$(".streetMap").click(function(){
		var linkURL = $(this).attr("href");
		window.open(linkURL,"Street Map","menubar=no,width=600,height=400,toolbar=no" );
		return false;
	});
	
	$('#homepageFlashBox').flash(
        { 
          src: '/img/main.swf',
          width: 980,
          height: 568//,
          //flashvars: { foo: 'bar', baz: 'zoo' }
        },
        { version: 8 }
    );



	$(".quickSearchPop").click(quickSearchPop);

	
}); // END DOM

// For the Dropdowns in the main menu as well.
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	




function openSendFriendPop()
{
	var linkURL = $('a[rel="send_to_friend"]').attr("href");
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(linkURL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=580,height=240,left = 350,top = 392');")
}
function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=580,height=240,left = 350,top = 392');");
}
function quickSearchPop()
{
	var linkURL = $('a.quickSearchPop').attr("href");
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(linkURL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=340,left = 350,top = 392');");
	return false;
}




var site = function() {
	this.navLi = $('#vanID li').children('ul').hide().end();
	this.init();
};

site.prototype = {
 	
 	init : function() {
 		this.setMenu();
 	},
 	
 	// Enables the slidedown menu, and adds support for IE6
 	
 	setMenu : function() {
 	
 	$.each($('#vanID li'), function() {
 		if ( $(this).children('ul')[0] ) {
 			$(this)
 				.append('<span />')
 				.children('span')
 					.addClass('hasChildren')
 		}
 	});
 	
 		this.navLi.hover(function() {
 			// mouseover
 			$(this).find('> ul').stop(true, true).slideDown(250);
 		}, function() {
 			// mouseout
 			$(this).find('> ul').stop(true, true).hide(); 		});
 		
 	}
 
}


new site();
