$(document).ready(function(){

	

	$(".toggle_container").hide();



	$("h2.trigger").click(function(){

		$(this).toggleClass("active").next().slideToggle("slow");

	});





});





$(document).ready(function(){

    $('.toggle-content').hide();



    $('.toggle').click(function(){

        $('.toggle-content').hide();

        $(this).children('.toggle-content').toggle();

    })

})





$(document).ready(function(){



$("ul.tabs").tabs("div > div.tab_content");

	});

	

var $j = jQuery.noConflict();

	$j(function() { 				

    $j('#slideshow').cycle({ 

        fx:     'fade', 

        timeout: 4000,

		pause:1,

		 speed:  1200,

        pager:  '#nav', 

        before: function() {  

       $j('#caption').html(this.alt); 

        } 

    }); 

}); 



$j(document).ready(function(){

    $('.tip').tooltip({

        	// place tooltip on the right edge

	position: "bottom center",



	// a little tweaking of the position

	offset: [-2, 10],



	// use the built-in fadeIn/fadeOut effect

	effect: "fade",



	// custom opacity setting

	opacity: 0.7

    })

});



$j(document).ready(function(){

    $('#valuationform').submit(function(){



        var hasError = false;



		jQuery('.required').each(function() {

			if(jQuery.trim(jQuery(this).val()) == '') {

				var labelText = jQuery(this).prev('label').text();

				//jQuery(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');

				jQuery(this).addClass('inputError');

				hasError = true;

			} else if(jQuery(this).hasClass('email')) {

				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

				if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {

					var labelText = jQuery(this).prev('label').text();

					//jQuery(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');

					jQuery(this).addClass('inputError');

					hasError = true;

				}

			} else if(jQuery(this).hasClass('website')){

                            if(jQuery.trim(jQuery(this).val()) === 'http://'){

                                var labelText = jQuery(this).prev('label').text();

                                jQuery(this).addClass('inputError');

                                hasError=true;

                            }

                        } else {

                            jQuery(this).removeClass('inputError');

                        }

		});



		if(!hasError) {

			jQuery('.more-info').fadeOut('normal', function() {

				if ( jQuery(this).hasClass("in_footer") ) {

					jQuery('.loadingImgWidgetFt').css({display:"block"});

				}else{

					jQuery('.loadingImgWidgetSb').css({display:"block"});

				}

			});

                        jQuery('#submitted').replaceWith('<img src="/images/qlbloading.gif" alt="loading" />');

			var formInput = jQuery(this).serialize();

			jQuery.post('/wp-content/plugins/capsule-crm/valuation.php',formInput, function(data){

                            window.location = '/valuation-request-received/';

				jQuery(this).delay(1500,function() {

				jQuery('form.more-info').fadeOut('fast', function() {

					jQuery(this).before('<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent.</p>');

					});

				});

			});

		}



		return false;



        return false;

    })

})



$j(document).ready(function(){

    $('#more-info').submit(function(){

        var hasError = false;



		jQuery('.required').each(function() {

			if(jQuery.trim(jQuery(this).val()) == '') {

				var labelText = jQuery(this).prev('label').text();

				//jQuery(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');

				jQuery(this).addClass('inputError');

				hasError = true;

			} else if(jQuery(this).hasClass('email')) {

				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

				if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {

					var labelText = jQuery(this).prev('label').text();

					//jQuery(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');

					jQuery(this).addClass('inputError');

					hasError = true;

				}

			} else {

                            jQuery(this).removeClass('inputError');

                        }

		});



		if(!hasError) {

//			jQuery('.more-info').fadeOut('normal', function() {

//				if ( jQuery(this).hasClass("in_footer") ) {

//					jQuery('.loadingImgWidgetFt').css({display:"block"});

//				}else{

//					jQuery('.loadingImgWidgetSb').css({display:"block"});

//				}

//			});

                        jQuery('#more-info-button').replaceWith('<img src="/images/qlbloading.gif" alt="loading" />');

			var formInput = jQuery(this).serialize();

                        if ( jQuery('input:[name="subscribe"]').is(':checked') ){

                            var redirect = '/listing-inquiry-notify/';

                        } else {

                            redirect = '/listing-inquiry/';

                        }

			jQuery.post('/wp-content/plugins/capsule-crm/more-info.php',formInput, function(data){

                            window.location = redirect;

////				jQuery(this).delay(1500,function() {

//////				jQuery('form.more-info').fadeOut('fast', function() {

//////					jQuery(this).before('<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent.</p>');

//////					});

////				});

			});

		}



		return false;



        return false;

    })

})



	$j(function() { 

    $j('#slideshow2').cycle({ 

        fx:     'fade', 

        timeout: 4000,

		pause:1,

		 speed:  1200,

        pager:  '#nav2', 

        before: function() {  

       $j('#caption2').html(this.alt); 

        } 

    }); 

}); 

	

$j(function() { 

    $j('#testimonial').cycle({ 

        fx:     'scrollDown', 

        timeout: 4000,

		pause:1,

		 speed:  1200,

        pager:  '', 

        before: function() {  

       $j('').html(this.alt); 

        } 

    }); 

}); 

	

	

Cufon.replace('h1,h3,h4,th,.frontpage-desc, .jqueryslidemenu ul:first > li > a',

					  {

		 hover: true



});

	

// If the HTML document is ready to be manipulated

$j(document).ready(function(){

	// Add the hover handler to the link

	$j("ul.social-icons li a").hover(

		function(){

			$j(this).find("img").animate({top : '-6px'}, 200);

		},

		function(){ 

			$j(this).find("img").animate({top : '0px'}, 200);

		}

	);

});



$j("input.focus:last").focus();



$j(document).ready(function(){

	$j("a[rel^='prettyPhoto']").each(function() {	

		var $jimage = $j(this).contents("img");

			$jhoverclass = 'hover_video';



	if($j(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) 

	$jhoverclass = 'hover_image';

		

	if ($jimage.length > 0)

	{	

		var $jhoverbg = $j("<span class='"+$jhoverclass+"'></span>").appendTo($j(this));

		

			$j(this).bind('mouseenter', function(){

			$jheight = $jimage.height();

			$jwidth = $jimage.width();

			$jpos =  $jimage.position();		

			$jhoverbg.css({height:$jheight, width:$jwidth, top:$jpos.top, left:$jpos.left});

		});

	}



});	



$j("a[rel^='prettyPhoto']").contents("img").hover(function() {

		$j(this).stop().animate({"opacity": "0.2"}, 400);

		},function() {

		$j(this).stop().animate({"opacity": "1"},400);

	});

});




