jQuery(document).ready(function($) {
	
	var isiPhone = navigator.userAgent.match(/iPhone/i) != null,
	 	isiPod = navigator.userAgent.match(/iPod/i) != null,
		isiPad = navigator.userAgent.match(/iPad/i) != null,
		isAndroid = navigator.userAgent.match(/Android/i) != null;
	
	if(isiPhone || isiPod || isiPad || isAndroid){
		
		$("#footer").css({
			'position': 'relative',
			'float': 'left'
		});
		
	}
	
	$("input.default, textarea.default").each(function(index) {
		
		var default_value = this.value;

		$(this).focus(function(){
			if(this.value == default_value) {
				this.value = '';
			}
		});

		$(this).blur(function(){
			if(this.value == '') {
				this.value = default_value;
			}
		});	
		
	});
	
	$("#contact-form").submit(function() {
		
		var action = $(this).attr('action'),
			$fields = $(this).serializeArray();
		
		$.post(action, $fields, function(data, textStatus, xhr) {
			
			alert(data);			
			
			if(data == "\nThank you for visiting Westroc. A representative will contact you shortly. Have a wonderful day!"){
			
			}
		
		});
		
		return false;
	});
	
	$("#menu-primary .current_page_item").parent().show();
	
	$('#menu-primary .current_page_item a').addClass('active-link');
	
	$('#navigation > ul.sub-menu li').hide();

	$('#navigation ul#menu-primary a').click(function() {
		
		if($(this).parent().find('ul').length != 0) {
		
		$(this).next('ul.sub-menu').slideToggle(600,'easeInOutBack');
		return false;
		
		}
		
	});
	
	$("#menu-footer > li > a").live('click', function(event) {
	
		$("#menu-footer > li ul.sub-menu").not($(this).parent().find('ul.sub-menu')).fadeOut();
		
		$(this).parent().find("ul.sub-menu").fadeToggle('fast');
	
		return false;
	
	});	
	
	$('#navigation ul#menu-primary a:first').addClass('first-nav');	

	$('#navigation ul#menu-primary a:last').addClass('last-nav');
	
	$('ul#menu-footer.menu li:first').addClass('footer-last');		
	
	$('.caption-right').hide();
	
	$(window).load(function(){
		$('.anythingWindow li.activePage .caption-right').show();
	});
	
	////////////////////////////No functions other than the Slider1 beyond this point!!!!!!!!!!!!!!!!
	
	$('#slider1').anythingSlider({
		delay: 7000,
		startPanel: 3,		
		autoPlay: true,  // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		buildArrows: true,
		animationTime: 1000,
		easing: "swing",
		buildNavigation: true,
		stopText: 'Stop',		
	  	pauseOnHover: true				
	}).anythingSliderFx({
	   inFx: {
	    '.caption-right'  : { right: 10, opacity: 1, duration: 150 }
	   },
	   outFx: {
	    '.caption-right'  : { right: -250, opacity: 0, duration: 450 }
	   }
	});
		
});
