$(document).ready(function()
{
	$('#scheduleService').find('br').remove();
	$('#scheduleService').find('.reqtxt, .emailreqtxt').parent('p').remove();
	// default value replacement
	var defaultValue = "MM/DD/YYYY";
	$('input[name=Service-Date]').val(defaultValue);
	$('input[name=Service-Date]').focus(function() {
		if( $(this).val() == defaultValue )
		{
			$(this).val("");
			$(this).removeClass('fade');
		}
	}).blur(function() {
		if( $(this).val() == "" )
		{
			$(this).addClass('fade');
			$(this).val(defaultValue);
		}
	}); 
	// sub page animated banners
	$('.bannerCycle').cycle({
		    fx:			'fade',
		    speed:		500,
		    timeout:	7000, // <--- the amount of time (in milliseconds) each slide is visible
		    sync:		1
	});
	// sub page slider
	$('.slider').cycle({
		    fx:			'scrollLeft',
		    speed:		750,
		    timeout:	4000, // <--- the amount of time (in milliseconds) each slide is visible
		    delay:		-1500,
		    easing:		'easeOutQuint'
	});
	// news/blog content slide
	$('a.linkToPost').click(function(e) {
		e.preventDefault();
		$(this).parent().next().next('.entry').slideToggle('fast');
	});
	// home banner
	if ( $('#homeBanner .cycle').length > 0 )
	{
		$('#homeBanner .cycle').cycle({
		    fx:			'fade',
		    speed:		1000,
		    timeout:	7000,
		    delay:		-1500,
		    cleartype:true,
		    cleartypeNoBg:true
		});
		$('#homeBanner .promo').cycle({
		    fx:			'fade',
		    speed:		1000,
		    timeout:	7000,
		    delay:		2000,
		    cleartype:true,
		    cleartypeNoBg:true
		});
	}
	// left subnav
	if ( $('#left .subNav .current_page_item').length > 0 )
	{
		$('#left .subNav .current_page_item a:first').after('<div class="wrap"></div>');
	}
	// form field highlighting
	if ($('form.cform').length > 0 ){
		$('form.cform input, form.cform textarea').focus(function() {
			$(this).addClass('selected');
		}).blur(function(){
			$(this).removeClass('selected');
		});
	}
	// unwrap images from wp_autop (paragraph tags)
	$('#content:not(.home)').children('#body').children('p').children('img.alignleft,img.alignright').unwrap().next('br').remove();
});

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

site.prototype = {

 	init : function() {
 		this.setMenu();
 	},

 	setMenu : function() {
 	
 		this.navLi.hoverIntent(function() {
 			// mouseover
			$(this).find('> ul').stop(true, true).slideDown('fast', 'easeOutQuint');
 		}, function() {
 			// mouseout
 			$(this).find('> ul').stop(true, true).slideUp('fast', 'easeInQuint'); 		
		});
 		
 	}
}

// Show sliding effect for non-IE
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) // IE
{
	var ieversion = new Number(RegExp.$1);
	if (ieversion >= 8)
	{
		new site();
	}
	if (ieversion >= 6)
	{
		// fix "click to chat" box
		$('.chatBox div').css({display: "block", position: "absolute", left: "113px"});
	}
}
else // Not IE
{
	new site();
}





