$(function() {
    $('#location').change(function() {
        var x = $(this).val();
		if (x =='9' || x =='10' || x =='11') {
		$('#pageredirect').val('5');
		} else {
		$('#pageredirect').val('2');	
		}
    });
});
$(document).ready(function() {
    $("#formID").validationEngine();
	$("a.fancybox-form").fancybox({
		'titleShow'		: false
	});
	$("a.fancybox").fancybox({
		'titleShow'		: false
	});
	$("a.fancybox-iframe").fancybox({
		'type'				: 'iframe',
		'autoDimensions'	: false,
		'width'				: 400,
		'height'			: 600,
		'overlayOpacity'	: 0.7,
		'overlayColor'		: '#000',
		'hideOnOverlayClick' : false
	});
	$(".fancybox2").fancybox({
		'titlePosition' 	: 'inside',
		'height'			: '80%',
		'onComplete'	:	function() {
				$("#overlay-button").fancybox({
						'height'				: '100%',
						'scrolling'				: 'no',
						'hideOnOverlayClick'	: false,
						'titleShow'				: false,
						'onClosed'				: function() {
						    $(".formError").hide();
						}
				});
			},
		'titleFormat'		: formatTitle
	});
	$("#slider").easySlider({
        controlsBefore: '<p id="controls2">',
        controlsAfter: '</p>',
        prevId: 'prevBtn2',
        nextId: 'nextBtn2'
    });
	$('.scr-photo-home').not('.show-now2').find('img').css('opacity',0.7)
	$('.scr-photo-home').hover(function() {
	var loc = $(this).find('.real-thumbnail').attr("rel");
	$(this).addClass('show-now').find('img').stop().animate({"opacity": "1"}, "fast");
	$('div.real-thumbnails').find('div.scr-photo-home').not('.show-now').find('img').animate({"opacity": "0.7"}, "");
	$('#real-details-home').find('div.real-details').not('.hide-now').addClass('hide-now');
	$('#' + loc).removeClass('hide-now'); 
	},
	function() {
	$(this).removeClass('show-now');
	});
});
function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div class="fancy-consult"><span><a id="overlay-button" href="#form-holder"><img src="http://stage.sonobello.com/cms/wp-content/themes/sonobello/images/fancybox-free-consultation.jpg" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}
// JUST AN EXAMPLE OF VALIDATIN CUSTOM FUNCTIONS : funcCall[validate2fields]
function validate2fields() {
    if ($("#phone1").val() == "" || $("#phone2").val() == "" || $("#phone3").val() == "") {
        return true;
    } else {
        return false;
    }
}
function validatePhoneEmailfields() {
    if ($("#by_phone").val() == "" || $("#by_email").val() == "") {
        return true;
    } else {
        return false;
    }
}
function joinForm() {
	$("#specialnotes").val( $('#form-helper').val() + ' - ' + $("#notes").val());
}
$(function() {
	$('#chat-button').hover(function(){
		$(this).animate({width:'66px'},{queue:false,duration:200});
	}, function(){
		$(this).animate({width:'42px'},{queue:false,duration:400});
	});
	$('.hov-int').hover(function() {
		$(this).addClass('bg-hover');
	}, function() {
		$(this).removeClass('bg-hover');
	});
});
