function goTo(page){
	window.location = page;
}


function calculateHeight(){
	$header = $(".header");
	$next = $header.next();
	$nextNext = $next.next();
	$content = $nextNext.next();
	$rightNav = $content.next();
	var windowHeight = $(window).height();
	var headerHeight = $header.height();
	var nextHeight = $next.height();
	var nextNextHeight = $nextNext.height();
	var footerHeight = $(".footer").height();
	var footerMargin = 20;
	var fineTune = 21;
	var contentHeight = windowHeight - headerHeight - nextHeight - nextNextHeight - footerHeight - footerMargin - fineTune;
	if(contentHeight < $rightNav.height())
	    contentHeight = $rightNav.height();
	$content.css("minHeight", contentHeight.toString() + "px");
}
//round corners for buttons and anything else.
DD_roundies.addRule('#mediaTypeNav li a', '5px 5px 0px 0px', true);

$(document).ready(function(){
	$(".searchBar").formfocus();
	
	//Remove Img if it's empty
 $('.siteWrapper img').each(function(){
  var imgSrc = $(this).attr("src");
  if(imgSrc == "")
   $(this).remove();
 });
	
        //convert richtext popup images to fancybox images
    $(".intContent a").each(function(){
        var href = $(this).attr("href");
       if(href != undefined){
            var index = href.indexOf("viewImage");
            if(index > -1){
               href = href.replace("javascript:viewImage('", "");
               href = href.replace("')","");
               $(this).attr("href", href);
               $(this).addClass("single_image"); 
            }
        }
    });
    $("a.single_image").fancybox();
    //end convert richtext popup images to fancybox images
	
	
	$('td.nextPrevious a:first').addClass('leftArrow');
	$('td.nextPrevious a:last').addClass('rightArrow');
        //first level hover
	    $('.aNavName').hover(
	        function()
	        {
		        $(this).children(".menus").stop().css({'display':'block', 'top':'36px'}).animate(
		        {
			        opacity: 1,
			        left: 0
			        //children hover
		        }, "fast").children().hover(
		            
		            function()
		            {
		                $(this).parent().css({'filter':'none'});
		                $(this).addClass('navItemHover');
		                $(this).children('.menuExtra').stop().css({'display':'block', 'top':'0px'}).animate({
			                opacity: 1,
			                left: 0
		                }, "fast");
		            },
		            //children hover out
                    function(){
                        $(this).removeClass('navItemHover');
                        $(this).children('.menuExtra').stop().animate({
	                        opacity: 1,
	                        left: 0
                        }, "fast").animate({
	                        top: -1000
                        }, 2);
                    }
                    //end children hover out
                );
                //end children hover
	        },
	        //first level hover out
	        function(){
		        $(this).children(".menus").stop().animate({
			        opacity: 0,
			        left: 0
		        }, "fast").animate({
			        top: -1000
		        }, 2);
	        }
	        //end first level hover out
	    );
	    //end first level hover	
	
	//Home Fader
	$('#features').jshowoff({ 
		controls: false,
		links: true,
		hoverPause: false,
		changeSpeed: 1200,
		speed: 5000
	});
	
	
	//Contact Fader
	$('#contactSlider').jshowoff({ 
		controls: false,
		autoPlay: false,
		links: false,
		hoverPause: false,
		changeSpeed: 1200,
		speed: 5000
	}); 
	
	
	//Interior Fader
	$('#InteriorFeature').jshowoff({ 
		controls: false,
		links: false,
		hoverPause: false,
		changeSpeed: 1200,
		speed: 5000
	});
	
    //sitemap popup
    $("#siteMapPop").fancybox({
		'width'				: 750,
		'height'			: 400,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	//privacy policy
    $("#PrivacyPolicy").fancybox({
		'width'				: 575,
		'height'			: 600,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	//disclaimer
    $("#disclaimer").fancybox({
		'width'				: 575,
		'height'			: 600,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	//documents
    $("#documents").fancybox({
		'width'				: 380,
		'height'			: 291,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
  	//ACCORDION
	$('.accordionButton').click(function() {
		$('.accordionButton').removeClass('on');
	 	$('.accordionContent').slideUp('fast');
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('on');
			$(this).next().slideDown('normal');
		 } 
	 });
	  
	$('.accordionButton').mouseover(function() {
		$(this).addClass('over');
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	$('.accordionContent').hide();
	
	//$('.accordionButton').append('<img src="/images/arrow.png" />');
	
	$('ul#mediaTypeNav li a:first').css('background-image','none');

	
	//Contact Form Slide
	$('#nextBtn').click(function(){
		$('#formPanel1').css('display','block');
	});
	

	$('#nextBtn').click(function() {
		$('#formPanel1').hide();
		$('#prevBtn').show();
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	
	calculateHeight();
	$(window).resize(function(){
	    calculateHeight();
	});
});
