jQuery(document).ready(function(){
	animateBoxes();
	animateBgHovers('#gallery-list li');
	gallery();
	thumbGallery();

	$('a.enquire').nyroModal({
		height: 540,
	     width: 460,
	     title: false
	});

	alignNavItems();
	 /*$("#enquiry-form").validate({
		errorElement: "div",
		errorPlacement: function(error, element) {
			var label = element.parent('div')
			error
			.hide()
			.addClass('error-message')
			.insertBefore(label)
			.fadeIn(500);
		},
		rules: {
			'your_name': "required",
			'company': "required",
			'email_address': {
				required:true,
				email: true
			},
			'message': "required"
		},
		messages: {
			'your_name': "Please enter your name",
			'company': "Please tell us your company",
			'email_address': "Please enter a valid email address",
			'telephone': "Please enter your telephone number",
			'subject': "Please write a subject",
			'message': "Please write your message"
		}
	 })*/
});

function animateBoxes(){
	var init_height = $('#hero-boxes article').height();

	$('#hero-boxes article').mouseenter(function(){
		$(this).addClass('active').animate({
			'height': init_height+40+'px',
			'backgroundColor' : '#CD052D'
		},250,
		'easeOutQuart', 
		function(){
			$(this).addClass('active');
		})
	}).mouseleave(function(){
		$(this).stop().animate({
			'height': init_height+'px',
			'backgroundColor' : '#fff'
		},250, 
		'easeInQuart',
		function(){
			$(this).removeClass('active');
		})
	}).click(function(){
		window.location = $(this).find('a').attr('href');
	});
}

function animateBgHovers(objects){
	var init_bgcolor = $(objects).css('backgroundColor');

	$(objects).mouseenter(function(){
		$(this).addClass('active').animate({
			'backgroundColor' : '#CD052D'
		},250,
		'easeOutQuart', 
		function(){
		
		})
	}).mouseleave(function(){
		//alert($(this).find('a').attr('href'));
		$(this).stop().animate({
			'backgroundColor' : init_bgcolor
		},250, 
		'easeInQuart',
		function(){
			$(this).removeClass('active');
		})
	})
}


function gallery(){
	if($('#thumb-slider').size()){
		$('#thumb-slider').cycle({ 
		    fx:     'scrollVert', 
		    speed:  1000, 
		    timeout: 0, 
		    next:   '#next-set', 
		    prev:   '#prev-set',
			easing: 'easeOutQuart',
			nowrap: true,
    		after:  function(curr, next, opts){
    			//$('#main-image-images').cycle(opts.currSlide);
    			if(parseInt(opts.currSlide + 1) == parseInt(opts.elements.length)){
    				$('#next-set').addClass('disabled');
    			}else{
    				$('#next-set').removeClass('disabled');
    			}
    			if(parseInt(opts.currSlide) == 0){
    				$('#prev-set').addClass('disabled');
    			}else{
    				$('#prev-set').removeClass('disabled');
    			}
    			
    			
    		}
    	});
    	//$('#main-image-images').any
		$('#main-image-images').cycle({ 
		    speed:  1000, 
		    timeout: 0, 
		    next:   '#next-large-image', 
		    prev:   '#prev-large-image',
			easing: 'easeOutQuart',
    		after:  function(curr, next, opts){
    			$('#thumb-slider a').removeClass('active');
    			$('#thumb-slider a').eq(opts.currSlide).addClass('active');
    			$('#thumb-slider').cycle(parseInt(opts.currSlide/6))
                $('span#image-number').text(opts.currSlide+1);
    		}
    	});
	}
}

function onGalleryAfter(slideCount){
	//alert(slideCount)
	alert('on after')
}



function initPlaceholderText(){
	if($.browser.msie){
		$('[placeholder]').each(function(){
			var input = $(this);
			input
			.addClass('placeholder')
			.val($(this).attr('placeholder'));
			input.focus(function(){
				input.val('');
		    	input.removeClass('placeholder');
			})
			input.blur(function(){
		    	input.addClass('placeholder');
		    	//input.val(input.attr('placeholder'));
			})			
		})
	}
}

function alignNavItems(){
	var num_nav_items 	= 	$('#nav-main li').size();
	var nav_width		=	$('#nav-main').outerWidth();

	$('#nav-main li').css({
	//	'width': parseInt(nav_width/num_nav_items)+'px'
	});

}


