/*************************** Navigation Menu Positioning ***************************/

jQuery(document).ready(function(){
	jQuery("#primary-nav>ul>li").each(function() {
		pos = jQuery(this).offset();
		if(pos.left + 100 > jQuery(window).width()+document.body.scrollLeft-jQuery(this).width()) {
		jQuery(this).addClass("nav-shift");}
	});
});


/*************************** Widgets Panel ***************************/

jQuery(document).ready(function(){
jQuery("#widgets-panel").hide(); 

jQuery("#widgets-panel-button").toggle(function(){
	jQuery(this).addClass("minimize");
	}, function () {
	jQuery(this).removeClass("minimize");
});

jQuery("#widgets-panel-button").click(function(){
	jQuery(this).next("#widgets-panel").slideToggle();
});
});


/*************************** Lightbox ***************************/

jQuery(window).load(function() {

	jQuery("div.gallery-item .gallery-icon a").attr("rel", "prettyPhoto[gallery]");

	jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'pp_default'
	});

});


/*************************** Contact Form ***************************/

jQuery(document).ready(function(){
	
	jQuery('#contact-form').submit(function() {

		jQuery('.contact-error').remove();
		var hasError = false;
		jQuery('.requiredFieldContact').each(function() {
			if(jQuery.trim(jQuery(this).val()) == '') {
				jQuery(this).addClass('input-error');
				hasError = true;
			} else if(jQuery(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
					jQuery(this).addClass('input-error');
					hasError = true;
				}
			}
		});
	
	});
				
	jQuery('#contact-form .contact-submit').click(function() {
		jQuery('.loader').css({display:"block"});
	});	

});
