(function ($) {
$.fn.vAlign = function($align) 
{
    return this.each(function(i)
    {
    var ah = $(this).height();
    var ph = $(this).parent().height();
    switch ($align)
    {
        case 'top':
            var mh = 0;
        break;
        case 'middle':
            var mh = Math.ceil((ph-ah) / 2);
        break;
        case 'bottom':
            var mh = Math.ceil(ph-ah);
        break;
   }
   
   $(this).css('margin-top', mh);
   });
};
})(jQuery);

$(document).ready(function()
{    
    $('.hasSubmenu').mouseover(function() {
        $(this).children('ul').show();
    });
    
    $('.hasSubmenu').mouseout(function() {
        $(this).children('ul').hide();
    });
    
    $("a[rel='lightbox']").colorbox();
    
      
    $(".validateForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
    
    $('#homeCarousel').jcarousel();
    
     
    
});

$(window).load(function() 
{
    $('#homeCarousel li a img').vAlign('middle');
    $('.innerfade li a img').vAlign('middle');  
    
    $('.innerfade').innerfade({
		speed: 750,
		timeout: 6000
	});  
    
});

function reloadCaptcha()
{
	document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
}
