//Initiating jQuery to work with Prototype;
//var $ = jQuery.noConflict(); located inside jquery-1.3.2.min.js file

$(document).ready(function() { onDocumentLoad(); });
$(window).load(function() { onWindowLoad(); });

//Global Variables

/*
 * Standard page loading functions for prototype / jQuery
 */
function onDocumentLoad(){

	//removes the last li tag in the footer menu to remove the last |
	$('#footerMenu li:last').hide();
	$('#footerMenu li:not(:last)').show();//doing this so it loads nicer

	startList('mainMenuUl');

	/*$('#bannerFlash').html(flashBanner);*/

	if($("#headerFlashViewFinder").length > 0){
		$('#headerFlashViewFinder').html(flashHeaderVF);
	}

	if($("#headerFlash").length > 0){
		$('#headerFlash').html(flashHeader);
	}

	$('#googleHeader').css({'width':'0px','height':'0px'});

	$('#bannerFlashImage').fadeIn('slow');

}

//Stuff put into this function doesnt run until the entire document is loaded flash and all
function onWindowLoad(){
	//Updates the show home count based on the quantity of showhomes //Not being used
	/*if($('.showhomes').length >= 2) {
		$('#showhomeWrap h2').html($('.showhomes').length+' Impressive show homes');
	} else if ($('.showhomes').length == 1) {
		$('#showhomeWrap h2').html('Impressive<br />show home');
	}*/

	$('a.external').attr('target','_blank');
	$('a.nolink').attr('href','javascript:void(0)');

	if($.trim($('#advertisingWrap ul li').html()) == "_"){
		$('#advertisingWrap').html('');
	} else {
		$('#advertisingWrap').css({'height':'44px','margin-top':'30px'});
		$('#coopersCrossingLogo').css({'margin-top':'-110px'});
		$('#advertisingWrap').removeClass( 'advertisingWrap' );
	}

	$('#advertisingWrap li:not(:last)').show();//doing this so it loads nicer

	if($('#advertisingWrap li:not(.adDiamond)').size() == 1||$('#advertisingWrap li:not(.adDiamond)').size() == 2){
		$('#advertisingWrap li:last').show();
		$('#advertisingWrap li:last').clone().prependTo("#advertisingWrap ul");
		if ($('#advertisingWrap li:not(.adDiamond)').size() == 1) {
				$('#advertisingWrap').css({ 'width': '798px', 'height': '44px', 'margin': '0px', 'margin-top': '30px'});
		}
	}

	if(window.location.hash == '#active'){
		 $('#view-lot-info').trigger('click');
	}
	//$('#mainContentWrap').fadeOut(100).delay(500).slideDown('slow');
	//window.setTimeout("$('#mainContentWrap').slideDown('slow')", 1000);
	//$('#mainContentWrap').fadeIn('slow');
}

startList = function(name)
{
	var navId = name;

	if ( document.all && document.getElementById ) {
		navRoot = document.getElementById( navId );

		for ( i = 0; i < navRoot.childNodes.length; i++ ) {
			node = navRoot.childNodes[i];

			if ( node.nodeName == 'LI' && node.className.indexOf('level1') != -1 ) {
				node.onmouseover = function() {
					this.className+=" hover";
				}

				node.onmouseout = function() {
					this.className=this.className.replace( ' hover', '' );
				}
			}

		}
	}
}

function printViewfinderPDF() {
	window.open (viewfinderPDF,"viewfinderPDF");
}
