/*
$(document).ready(function() {
	
});*/











//// METHODS //////

function playSlideshow()
{
	
	$.get("video/slideshow_container.html", function(data){
			// create a modal dialog with the data
			
			$(data).modal({
				opacity:80,
				overlayCss: {backgroundColor:"#000000"},
				close:true,
				closeHTML: "<a href ='' id='modal-close' >CLOSE X</a>",
				overlayClose:true,
				onOpen:animopen
			
			});

		});
}


function launchVideo(num)
{
		var src = "";
	
		if(num==1){
			src = "2003_Showhomes.html"
		}else{
			src = "1990_Showhomes.html"
		}
	
		// load the contact form using ajax
		$.get("video/" + src, function(data){
			// create a modal dialog with the data
			
			$(data).modal({
				opacity:80,
				overlayId: 'video-overlay',
				containerId: 'video_container',
				close:true,
				closeHTML: "<a href ='' id='modal-close' >CLOSE</a>",
				overlayClose:true,
				onOpen:animopen
			
			});

		});
}


function animopen(dialog)
{
	dialog.overlay.fadeIn(200, function () {
		dialog.container.fadeIn(200, function () {
			dialog.data.fadeIn(200);
		});
	});
}
		

function resizeWindow()
{
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight );
	}
	
function showhomes_window(w)
{
	if(w =="one")
	{
		window.open("showhomes/southern.html","_blank","width =990, scrollbars = yes, resizable = yes");
	}else{
			window.open("showhomes/anniversary.html","_blank","width =990, scrollbars = yes,resizable = yes");
	}
}



function playHTMLVideo(src)
{
	$("#theater").show();

	$("#theater video").attr("src",src);

	//console.log($("#theater video").attr("src"));
}

function closeHTMLVideo()
{
	$("#theater").hide();
	$("#theater video").attr("src","");
	$("#theater #player").get(0).pause();
}



/* NO FLASH GALLERY*/
var gallerycount = 0;
var galleryimg;


function initGallery()
{
			

			

	galleryimg = $("#gallery_img_display");
	
	loadImage(gallerycount);

	


	$("#gallery_next_btn").click(function(e){
					e.preventDefault();
					if(gallerycount<img_arr.length-1){
						gallerycount++;
					}else{
						gallerycount = 0;
					}
				
				
					loadImage(gallerycount);
		});

		$("#gallery_prev_btn").click(function(e){
			e.preventDefault();
		
			if(gallerycount>0){
				gallerycount--;
			}else{
				gallerycount = 19;
			}

			loadImage(gallerycount);
		});
	

		
}

function loadImage(num)
{

	//console.log(num);
	
	$(galleryimg)
		// once the image has loaded, execute this code
		.load(function () {
		// set the image hidden by default    
		$(this).hide();

		// with the holding div #loader, apply:
		$('#loader')
		// remove the loading class (so no background spinner), 
		.removeClass('loading')
		// then insert our image
		.append(this);

		// fade our image in to create a nice effect
		$(this).fadeIn();
		})

		// if there was an error loading the image, react accordingly
		.error(function () {
		// notify the user that the image could not be loaded
		})

		// *finally*, set the src attribute of the new image to our image
		.attr('src', img_arr[num]);

}






