/*----------------------------------------------------------------------
HIDES IPHONE URL BAR
----------------------------------------------------------------------*/
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) {
    setTimeout(function() {
        window.scrollTo(0, 1);
    });
}

/*----------------------------------------------------------------------
PAGE BUILDING ANIMATIONS
----------------------------------------------------------------------*/
$(document).ready(function() {

    $('#elevator').css({'width': '100%'});
    $('#subNav').css({'right': '0px'});
    $('.content').css({'opacity': '0'});
    $('.mortgageTable').css({'opacity': '0'});
    $('#landTransTitle').css({'opacity': '0'});
    
    setTimeout(function() {
        $('#elevator').animate({
            'width': '0%'
        }, {'duration': 1200, 'easing': 'easeInOutSine'});
    }, 100);

    setTimeout(function() {
        $('#subNav').animate({
            'right': '400px'
        }, {'duration': 1200, 'easing': 'easeInOutSine'});
    }, 300);
    
    setTimeout(function() {
        $('.landTransfer').animate({
            'left': '0px'
        }, {'duration': 700, 'easing': 'easeInOutSine'});
    }, 600);

    setTimeout(function() {
        $('#landTransTitle').animate({
            'opacity': '1'
        }, 600);
        $('.mortgageTable').animate({
            'opacity': '1'
        }, 600);
        $('.content').animate({
            'opacity': '1'
        }, 600);
    }, 1160);
    
    $('#navHome').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'default.cfm';}, 1200);
    });
    $('#navHome2').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'default.cfm';}, 1200);
    });
    $('#navListings').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'listings.cfm';}, 1200);
    });
    $('#navAbout').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'about.cfm';}, 1200);
    });
    $('#navAbout2').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'about.cfm';}, 1200);
    });
    $('#navTestimonials').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'testimonials.cfm';}, 1200);
    });
    $('#navBuyers').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'buyers.cfm';}, 1200);
    });
    $('#navBuyers2').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'buyers.cfm';}, 1200);
    });
    $('#navSellers').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'sellers.cfm';}, 1200);
    });
    $('#navContact').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'contact.cfm';}, 1200);
    });
    $('#navContact2').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'contact.cfm';}, 1200);
    });
    $('#navMortgage').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'mortgage.cfm';}, 1200);
    });
    $('#navNewsletters').click(function() {
        $('#elevator').animate({'width': '100%'}, {'duration': 1200, 'easing': 'easeInOutSine'});
        setTimeout(function() {window.location.href = 'newsletters.cfm';}, 1200);
    });
    
});

/*----------------------------------------------------------------------
SUB NAVIGATION ANIMATIONS
----------------------------------------------------------------------*/
$(document).ready(function() {

    $('#pg1Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeIn(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg2Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeIn(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeOut(500);
        $('#pg2BG').fadeIn(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg3Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeIn(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeOut(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeIn(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg4Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeIn(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeOut(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeIn(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg5Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeIn(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeOut(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeIn(500);
    });
    $('#pg6Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeIn(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg7Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeIn(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg8Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeIn(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg9Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeIn(500);
        $('.pg10').fadeOut(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });
    $('#pg10Nav').click(function() {
        $(this).parent().parent().find('a').removeClass('active');
        $(this).addClass('active');
        $('.pg1').fadeOut(500);
        $('.pg2').fadeOut(500);
        $('.pg3').fadeOut(500);
        $('.pg4').fadeOut(500);
        $('.pg5').fadeOut(500);
        $('.pg6').fadeOut(500);
        $('.pg7').fadeOut(500);
        $('.pg8').fadeOut(500);
        $('.pg9').fadeOut(500);
        $('.pg10').fadeIn(500);
        $('#pg1BG').fadeIn(500);
        $('#pg2BG').fadeOut(500);
        $('#pg3BG').fadeOut(500);
        $('#pg4BG').fadeOut(500);
        $('#pg5BG').fadeOut(500);
    });

});

