jQuery(function() {
	/* MASONRY */
	if(jQuery(".testimonials-wrapper").length>0) {
		jQuery('.testimonials-wrapper').masonry({
		    itemSelector : '.testimonial'
		});
	}
	
	/* PRETTYPHOTO */
	if(jQuery(".map-wrapper a.btn-view").length>0) {
		jQuery(".map-wrapper a.btn-view[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});
	}
	if(jQuery(".contact-us a.btn-view").length>0) {
		jQuery(".contact-us a.btn-view[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});
	}

	if(jQuery(".btn-inquiry").length>0){
		var inq_open = false;
		jQuery(".btn-inquiry").click(function () { 
			if(!inq_open){
				inq_open = true;
				jQuery(this).addClass('inquiry-active');
				jQuery('.inquiry-div').show(); 
			}
			else if(inq_open){
				inq_open = false;
				jQuery(this).removeClass('inquiry-active');
				jQuery('.inquiry-div').hide(); 
			}
			return false;
	    });
	}
	
	if(jQuery(".wrapper-accordion").length>0){
		var max_items = jQuery(".accordion").length;
		var closed_width = "144px";
		var open_width = "684px";
		var opened = 2;
		for(var i=0; i<max_items; i++){
			jQuery(".accordion:eq("+i+") .content").hide();
			jQuery(".accordion:eq("+i+")").width(closed_width);
		}
		jQuery(".accordion:eq("+opened+")").width(open_width);
		jQuery(".accordion:eq("+opened+") .content").show();
		jQuery(".accordion").click(function() {
			if(jQuery(this).css("width") != open_width){
				for(var j=0; j<max_items; j++){
					if(jQuery(".accordion:eq("+j+")").css("width") == open_width){
						jQuery(".accordion:eq("+j+")").animate({
							width: closed_width
						}, 500, function() {
							// Animation complete.
						});
					}
				}
				
				jQuery(this).animate({
					width: open_width
				}, 500, function() {
					// Animation complete.
				});
				jQuery(".accordion .content").fadeOut(700).delay(300);
				jQuery(this).children(".content").fadeIn(700);
			}
			return false;
		});
	}
	
	/* LANDING SLIDER */
	jQuery(document).ready(function(){
		jQuery('#slideshow').fadeSlideShow({
	        width: '100%',
	        height: 483,
			speed: 'slow',
			interval: 10000,
			autoplay: true
	    });
	});
});		   
