$(document).ready(function() {



$.ajax({
		type: "GET",
		url: "/ThePonds/info/hfi/home_flash_images.flash_images.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('Attributes').each(function(){
				var mainbannerTitle = $(this).find('mainbannerTitle').text();
				var bannerTitle = $(this).find('bannerTitle').text();
				var bannerText = $(this).find('bannerText').text();
				var bannerUrlText = $(this).find('bannerUrlText').text();
				var bannerUrl = $(this).find('bannerUrl').text();
				var bannerUrlTarget = $(this).find('bannerUrlTarget').text();
				
				
				var mainbannerTitlehtml = '<div>' + mainbannerTitle + '</div>';
				var bannerTitlehtml = '<div>' + bannerTitle + '</div>';
				var bannerTexthtml = '<div>' + bannerText + '</div>';
				var bannerButtonTexthtml = '<span class="class1"><div><a href="' + bannerUrl + '" target="' + bannerUrlTarget + '">'+ bannerUrlText +'</a>';
				
				$('#introText').append($(mainbannerTitlehtml));
				$('#bannerTitle').append($(bannerTitlehtml));
				$('#bannerText').append($(bannerTexthtml));
				$('#bannerButtonText').append($(bannerButtonTexthtml));
			
	
				
			});
		}
	});



$.ajax({
		type: "GET",
		url: "/ThePonds/info/hfi/home_flash_images.flash_images.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('images').each(function(){

				var heroImage = $(this).find('heroImage').text();

				var img = new Image();
			
				var html = '<div><img alt="" src="' + heroImage + '" /></div>';

				$('#photoShow').append($(html));
				//alert(heroImage);
				
				
				$(img).load(function () {
					$(this).hide();
					$('#container').removeClass('loading').append(this);
					$(this).fadeIn(100);
					}).error(function () {
					}).attr('src', heroImage).attr('class', 'bgImage');
								
				
			});
		}
	});





$("#introText").fadeIn(1000);

setInterval( function() {
		rotateImages();
	}, 5000 );


setTimeout( function() {
		$("#photoShow").fadeIn(1000);
	}, 6000 );


setTimeout( function() {
$("#photoShow div.current").fadeIn(1000);
	}, 6000 );




setTimeout( function() {
		slideLEFT();
	}, 6000 );

setTimeout( function() {
		$("#introText").fadeOut(1000);
	}, 3500 );
setTimeout( function() {
		$('#introText').css('text-align','right');
		$("#introText").animate({right: "10", top: "0"}, 500, "swing");
	}, 5000 );
setTimeout( function() {
		$("#introText").fadeIn('slow');
	}, 6000 );

$('#moveLeft').click(function() {

	slideLEFT();
});

$('#moveRight').click(function() {

	slideRIGHT();
});
	
$('#bannerButtonTextClose').click(function() {	
	slideRIGHT();
});	



	
function slideLEFT(){
	//alert ("left");
	$("#moveLeft").hide();
	$("#movingBanner").animate({right: "-200"}, 1000, "swing");
	$("#moveRight").show();
	$('#movingButton').unbind('click');
}


function slideRIGHT(){
	$("#moveRight").hide();
	$("#movingBanner").animate({right: "-708"}, 1000, "swing");
	$("#moveLeft").show();
	$('#movingButton').unbind('click');
	}
	
function rotateImages(){
	var oCurPhoto = $("#photoShow div.current");
	var oNxtPhoto = oCurPhoto.next();
	
	$("#photoShow div:first").show();
	$("#photoShow div:previous").show();
	$("#photoShow div:curent").show();
	
	if (oNxtPhoto.length == 0)
		oNxtPhoto = $("#photoShow div:first");
		
	oCurPhoto.removeClass('current').addClass('previous');
	oNxtPhoto.css({opacity:0.0}).addClass('current').animate({opacity:1.0},1000,
		function(){
		oCurPhoto.removeClass('previous');
		});
	}
});




