/*************************** Search Panel Toggle ***************************/

jQuery(document).ready(function(){
	jQuery("#search-box").hide(); 
	
	jQuery("#search-icon").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});
	
	jQuery("#search-icon").click(function(){
		jQuery(this).next("#search-box").slideToggle('fast');
	});
});


/*************************** Share Toggle ***************************/

jQuery(document).ready(function(){
	jQuery("#share-review").hide(); 
	jQuery("#share-review-link a").html("Share &#9660;");
	
	jQuery("#share-review-link a").toggle(function(){
		jQuery(this).html("Share &#9650;");
		}, function () {
		jQuery(this).html("Share &#9660;");
	});
	
	jQuery("#share-review-link a").click(function(){
		jQuery(this).next("#share-review").slideToggle('fast');
	});
});


/*************************** Transform Select Drop Down Form ***************************/

jQuery(document).ready(function() {

    jQuery("#dropdown-filter").show();
    jQuery(".order-by-form").jqTransform();
    jQuery(".order-form").jqTransform();

	jQuery(".order-by-form .jqTransformSelectWrapper ul li a").click(function(){
		var index = jQuery(this).attr('index');
		var value = jQuery('.order-by-form select.jqTransformHidden option:eq('+index+')').attr('value');
		window.location.href=value;
	});
	
	jQuery(".order-form .jqTransformSelectWrapper ul li a").click(function(){
		var index = jQuery(this).attr('index');
		var value = jQuery('.order-form select.jqTransformHidden option:eq('+index+')').attr('value');
		window.location.href=value;
	});
	
});


/*************************** Profile Details Height ***************************/

jQuery(document).ready(function(){

	var profiledetailsHeight = jQuery(".profile-details").height();
	if(profiledetailsHeight > 90) {
	jQuery(".profile-avatar").css({"height" : profiledetailsHeight});
	}
});


/*************************** Gallery Shortcode Lightbox Support ***************************/

jQuery(document).ready(function(){

	jQuery("div.gallery-item .gallery-icon a").prepend('<span class="hover-image"></span>');
	jQuery("div.gallery-item .gallery-icon a").attr("rel", "prettyPhoto[gallery]");
	var galleryimgWidth = jQuery("div.gallery-item .gallery-icon img").width();
	var galleryimgHeight = jQuery("div.gallery-item .gallery-icon img").height();
	jQuery("div.gallery-item .gallery-icon .hover-image").css({"width": galleryimgWidth, "height": galleryimgHeight});
	jQuery("div.gallery-item .gallery-icon a").css({"width": galleryimgWidth});

});


/*************************** Lightbox ***************************/

function gp_lightbox() {

	jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'pp_default'
	});

}

jQuery(document).ready(function(){
	gp_lightbox();
});


/*************************** Lightbox Image Hover ***************************/

function gp_image_hover() {

	jQuery('.hover-image, .hover-video').css({'opacity':'0'});
	jQuery('.overlay, div.gallery-item .gallery-icon').hover(
		function() {
			jQuery(this).find('.hover-image, .hover-video').stop().fadeTo(750, 1);
			jQuery(this).find("a[rel^='prettyPhoto'] img").stop().fadeTo(750, 0.5);
		},
		function() {
			jQuery(this).find('.hover-image, .hover-video').stop().fadeTo(750, 0);
			jQuery(this).find("a[rel^='prettyPhoto'] img").stop().fadeTo(750, 1);			
		}
	);
		
}

jQuery(document).ready(function(){
	gp_image_hover();
});


/*************************** Accordion ***************************/

jQuery(document).ready(function(){
	jQuery(".accordion").accordion({ header: "h3.accordion-title", autoHeight: false });
	jQuery("h3.accordion-title").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});	
});


/*************************** Tabs ***************************/

jQuery(document).ready(function(){
	jQuery(".sc-tabs").tabs({
		fx: {
			height:'toggle',
			duration:'fast'
		}
	});	
});


/*************************** Toggle Content ***************************/

jQuery(document).ready(function(){
	jQuery(".toggle-box").hide(); 
	
	jQuery(".toggle").toggle(function(){
		jQuery(this).addClass("toggle-active");
		}, function () {
		jQuery(this).removeClass("toggle-active");
	});
	
	jQuery(".toggle").click(function(){
		jQuery(this).next(".toggle-box").slideToggle();
	});
});


/*************************** 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"});
	});	

});
