(function( $ ){

	var $this = this;
	$.fn.initJS = function() {
		
		this.hideAll();
	  
	};
	
	$.fn.hideAll = function() {
		
		$("*").each(function() {
			
			if(this != "[object HTMLBodyElement]" && this != "[object HTMLHtmlElement]" ) {
				
				$(this).hide();
				
			}
			
		});
		
	};
	
	$.fn.showAll = function() {
		
		try {
		
			$("*").each(function() {
				
				if(this != "[object HTMLScriptElement]" && this != "[object HTMLTitleElement]" && this != "[object HTMLStyleElement]" ) {
					$(this).show();
				}
				
			});
		
		}
		catch(error) {
			
			alert(error);
			
		}
	};
	
	$.fn.resiseElementToBrowser = function() {
		
		try {
			
			var $orgW = 1560;
			var $orgH = 1100;		
			
			var $crntW = window.innerWidth;
			var $crntH = window.innerHeight;
			
			var $siteH = $crntH;
			var $siteW = ($orgW*$siteH)/$orgH;
			
			$(this).css("width", ($siteW-10)+"px" );
			$(this).css("height", ($siteH-10)+"px" );
			
			$("#contentWrapper").css("height", ($("#bodyWrapper").height()-$("#headerWrapper").height()-$("#footerWrapper").height()-50)+"px");
			
			$(this).centerToBrowser(this);
			$(this).setPreviewImgHeight();
			
		}
		catch(error) {
			
			alert(error);
			
		}

	}
	
	$.fn.centerToBrowser = function($elem) {
		
		$($elem).css("margin-left", "auto");
		$($elem).css("margin-right", "auto");
		
	}
	
	$.fn.setPreviewImgHeight = function() {
		
		try {
			
			var $orgW=0;
			var $orgH=0;
			var $avgH=0;
			
			var loc = window.location;
		    var page = loc.pathname.substring(loc.pathname.lastIndexOf('/')+1, loc.pathname.length);
			page=page.substring(0, page.lastIndexOf('.'));
			
			this.showAll();

			if(page=="" || page=="index") {
				
				$orgW=1326;
				$orgH=879;
				
				$("#previewImg").css("width", ($("#contentLeft").width())-20);
				$avgH = ($orgH * $("#previewImg").width())/$orgW;
				
				$("#contentLeft").css("height", $avgH+20);
				
				
				$("#logoImg").css("margin-top", $("#contentLeft").height()-$("#logoImg").height());
			}
			else if(page=="home") {
				
				$orgW=595;
				$orgH=804;
				
				$("#previewImg").css("width", ($("#contentLeft").width()/2)-10);
				$avgH = ($orgH * $("#previewImg").width())/$orgW;
				
				$("#contentLeft").css("height", $avgH+20);				
				
				$orgW=149;
				$orgH=166;
				var $avgW=120;
				var $avgH=0;
				
				$avgH=($orgH*$avgW)/$orgW;
				
				$("#mainLogo").css("height", $avgH)
				
				var $mT = ($("#contentLeft").height()/2)-($("#mainLogo").height()/2);
				var $mL = ($("#contentLeft").width()/4)-($("#mainLogo").width()/2);
				
				$("#mainLogo").css("margin-top", $mT);
				$("#mainLogo").css("margin-left", $mL);				
				
			}
			else if(page=="photoindex") {
				
				$orgW=1190;
				$orgH=789;
				
				$("#previewImg").css("width", ($("#contentLeft").width())-20);
				$avgH = ($orgH * $("#previewImg").width())/$orgW;
				
				$("#contentLeft").css("height", $avgH+20);
				$("#tsv_container").css("height", $("#contentLeft").height());
				
				$(this).setThumbnailScroller();
				
			}
			else if(page=="video") {
				
				$(this).setThumbnailScroller();
			}
			else if(page=="contact" || page=="clients") {
				
				$orgW=595;
				$orgH=804;
				
				$("#previewImg").css("width", ($("#contentLeft").width()/2)-10);
				$avgH = ($orgH * $("#previewImg").width())/$orgW;
				
				$("#contentLeft").css("height", $avgH+20);				
				
				var $marginT=$("#contentLeft").height()-$("#contentPara").height();
				$("#contentPara").css("margin-top", $marginT-10);					
				
			}

		}

		catch(error) {
			
			alert(error);
			
		}
		
	}
	
	$.fn.setThumbnailScroller = function() {
		 	
		var $imgPadding = 8;
		var $showThumbs = 5;
		
		var $thumbs = $("#tsv_container img");
		
		var $thumbsHeight = ($("#tsv_container").height()/$showThumbs)-$imgPadding;


		$thumbs.each(function() {
			
			$(this).css("height", $thumbsHeight);
			$(this).css("margin-bottom", ($imgPadding+2));
			
		});
		
		ThumbnailScroller("tsv_container","vertical","next","prev",$showThumbs, $thumbs.length,0,200,"easeOutCirc",0.4,500);
				
	}
	
	$.fn.randomImgs = function( $imgs ) {
		
		var $rImgs = Math.floor(Math.random() * $imgs.length);
		if( $rImgs == 0) $rImgs = 3;
		
		document.getElementById("previewImg").src = $imgs[$rImgs];
		//$("#previewImg").css( "src", $imgs[$rImgs] );
		
	}
	

})( jQuery );




