
$.fn.fullScreen = function(settings) {
	settings = $.extend({
		logoHorOffset: 75,
		page:'index',
		vertical_center: 0
		}, settings);


		var container = $(this);


if (settings.page == "") { settings.page = 'index'};







	//var resize
/*	$("#fullsize img").load( function() {

		 $('.lr_img').fadeOut("slow");

	});*/
	

	//Define image ratio
	var ratio = $('#fullsize img').height()/$('#fullsize img').width();
	///alert('ratio'+ratio+" : "+$('#fullsize img').height()+" : "+$('#fullsize img').width());
	//	$('#fullsize').css("overflow","hidden");
	//	$('body').css("overflow","hidden");

	var imagewidth = $('#fullsize img').width();
	var imageheight = $('#fullsize img').height();
	var browserwidth = $(window).width();
	var browserheight = $(window).height();
	
//alert('imagewidth = '+imagewidth+'imageheight = '+imageheight+'browserwidth = '+browserwidth+'browserheight = '+browserheight);
	
	var offset;
	//var vertical_center = 0;
	var minWidth = $("#container").width()+300;
	var minHeight = $("#container").outerHeight()+($('.logo_back').height()+(settings.logoHorOffset/2));
	var scrollOnceHor = true;
	var scrollOnceVer = true;
//	var page = 'index';

	var timerOn = false;
	
	function reseizeImage() { 
		
			timerOn = false;	
		//Gather browser and current image size
		imagewidth = $('#fullsize img').width();
		imageheight = $('#fullsize img').height();
		browserwidth = $(window).width();
		browserheight = $(window).height();




		//Reset scroll bars if needed
		if (scrollOnceVer == true && $(document).scrollTop() != 0){
			scrollOnceVer = false;

			$('html,body').animate({scrollTop: 0}, 300, function() {

				scrollOnceVer = true;

			});


		}

		if (scrollOnceHor == true && $(document).scrollLeft() != 0){
			scrollOnceHor = false;
			$('html,body').animate({scrollLeft: 0}, 300, function() {

				scrollOnceHor = true;

			});
		}
		
		
		

	
		function setIndexMenu() { 
		if (settings.page == 'index') {
	
				$(".container_text").width($('#fullsize').width());

				$(" #container ul li").width($('#fullsize').width()/2);
				$(" #container ul li").css('margin-top', $('#fullsize').height()/2-$(" #container ul li img").height());
				
				
				$('#red_line1').css('left', ($('#fullsize').width()*0.5)-4);
					$('#red_line1').css('top', $('#fullsize').height()*0.5-33);
			//	$('#red_line1').height(60);
				
				$('.weddings_link .index_back').css('left', -10+$('#fullsize').width()*0.25-$("#weddings_link_img").width()/2);
				$('.commercial_link .index_back').css('left', -10+$('#fullsize').width()*0.25-$("#commercial_link_img").width()/2);
				}
			};
		


		if (browserheight > minHeight && browserwidth > minWidth) {
			$('#fullsize').css("overflow","hidden");
			$('body').css("overflow","hidden");
			browserwidth = $(window).width();
			browserheight = $(window).height();
			setImage();

			$('#fullsize').children().css('left', (browserwidth - $('#fullsize').width())/2);
			if (settings.vertical_center == 1) {
				$('#fullsize').children().css('top', (browserheight - $('#fullsize').height())/2);
			}

			$('#fullsize').height($(window).height());
			//----------------------------------- 
			//TESTING NUMBER 
			//$(".text").text('1'); 

			//MOVE LOGO TO BASE OF CONTENT DIV
			var position = $('#container').position();
			$('.logo_wrap').css("top","auto");
			$('.logo_wrap').css("bottom","60");
			
			$('.logo_wrap').css("left", "auto");
				$('#container').css("margin-left", "auto");
			if ($('#container').height() >= 550) {
				$('.logo_wrap').css("top",$('#container').height()+position.top-($('#container').height()-$('#container_background').height())+settings.logoHorOffset);
			}
			
			if ($('#container').height() >= $('.logo_wrap').height() && settings.page != 'index') {
				$('.logo_wrap').css("top",$('#container').height()+position.top-($('#container').height()-$('#container_background').height())+settings.logoHorOffset);
			}
			
				setIndexMenu();	

		} else if (browserheight < minHeight && browserwidth > minWidth) {

			browserheight = minHeight+50;

			setImage();


			browserwidth = $(window).width();
			$('#fullsize').children().css('left', (browserwidth - $('#fullsize').width())/2);

			if (settings.vertical_center == 1) {	
				$('#fullsize').children().css('top', (browserheight - $('#fullsize').height())/2);	

			}

			$('#fullsize').width( browserwidth);
			$('#fullsize').height(browserheight);

			$('#fullsize').css("overflow","hidden");
			$('body').css("overflow","visible");
						//----------------------------------- TESTING NUMBER 
					//	$(".text").text('2');
						
						
				setIndexMenu();	

			//MOVE LOGO TO BASE OF CONTENT DIV
		var position = $('#container').position();
		if (settings.page != 'index') {	$('.logo_wrap').css("top",$('#container').height()+position.top-($('#container').height()-$('#container_background').height()));
	} else {
	$('.logo_wrap').css("top",$('#container').height());	
	}
		
			$('.logo_wrap').css("left", "auto");
				$('#container').css("margin-left", "auto");
			
		}

		else if (browserwidth < minWidth && browserheight > minHeight) {
			browserwidth = minWidth;

			setImage();
			browserheight = $(window).height();
		
			
				var position = $('#container').position();

			$('#fullsize').children().css('left', (browserwidth - $('#fullsize').width())/2);
			if (settings.vertical_center == 1) {
				$('#fullsize').children().css('top', (browserheight - $(document).height())/2);
			}
			$('#fullsize').width(minWidth);
			$('#fullsize').height(browserheight);
			$('#fullsize').css("overflow","hidden");
			$('body').css("overflow","visible");
			
						//----------------------------------- TESTING NUMBER
			//$(".text").text('3');
				setIndexMenu();	
				//MOVE LOGO TO BASE OF CONTENT DIV
					var position = $('#container').position();
					$('.logo_wrap').css("top","auto");
					$('.logo_wrap').css("bottom","60");

					$('.logo_wrap').css("left", "auto");
					if (settings.page != 'index') {
					$('#container').css("margin-left", "150px");
				}
					if (settings.page != 'index') {	$('.logo_wrap').css("top",$('#container').height()+position.top-($('#container').height()-$('#container_background').height())+settings.logoHorOffset);
				
}				
				
				$('.logo_wrap').css("left", $('#container').width()+100);



		} else if (browserwidth < minWidth && browserheight < minHeight) {
		
					//----------------------------------- TESTING NUMBER
		//	$(".text").text('4');
			browserwidth = minWidth;
			browserheight = minHeight+40;
			
			setImage();


			$('#fullsize').children().css('left', (browserwidth - $('#fullsize').width())/2);
			if (settings.vertical_center == 1) {
				$('#fullsize').children().css('top', (browserheight - $('#fullsize').height())/2);
			}
			$('#fullsize').width(minWidth);
			$('#fullsize').height(browserheight);
			$('#fullsize').css("overflow","hidden");
			$('body').css("overflow","visible");
			
			
					//MOVE LOGO TO BASE OF CONTENT DIV

						var position = $('#container').position();
//						$('.logo_wrap').css("top",$('#container').height()+position.top-100);
						setIndexMenu();	
							if (settings.page != 'index') {
	$('#container').css("margin-left", "150px");

	

					$('.logo_wrap').css("top",$('#container').height()+position.top-($('#container').height()-$('#container_background').height()));
					
				} else {
				$('.logo_wrap').css("top",$('#container').height());	
				}			
					$('.logo_wrap').css("left", $('#container').width()+100);

		}

//var position = $('#container').position();

//$('#weddings_menu').css("top",$('#container').height()-$('#container_background').height()+position.top);
//	$(".text").text(browserheight+' '+(minHeight+$('.logo_back').height()+settings.logoHorOffset));

	};
	function setImage() { 
		if ((browserheight/browserwidth) > ratio){
			$('#fullsize').height(browserheight);
			$('#fullsize').width(browserheight / ratio);
			$('#fullsize').children().height(browserheight);
			$('#fullsize').children().width(browserheight / ratio);


		} else {
			$('#fullsize').width(browserwidth);
			$('#fullsize').height(browserwidth * ratio);

			$('#fullsize').children().width(browserwidth);
			$('#fullsize').children().height(browserwidth * ratio);

		}



	
	};








/*$('#next_img').click(function(){
//	alert("hello");
$('.current_img').animate( { left:$('#fullsize').width() }, 1500);	
	});*/









	reseizeImage();
	
		$("#fullsize").find("img").each(function(z) {

				reseizeImage();
				//alert("");

		

		});
	

	$(window).resize(function() {
		// do something in 2 seconds
		if (timerOn == false) {
			$.doTimeout( 500, function(){
				
				timerOn = true;
reseizeImage();
			});



		}
		

	

	});

		}

