/*///////////////////////////////////////////////////////////
//	GLOBALS
///////////////////////////////////////////////////////////*/
var domLoaded	=	false,
	fontsLoaded	=	false;
/*///////////////////////////////////////////////////////////
//	LOAD GOOGLE FONTS
///////////////////////////////////////////////////////////*/
/*google.load("webfont", "1");

google.setOnLoadCallback(function() {
	WebFont.load({
		google	:	{
			families	:	[
				"Cuprum",
				"Tangerine",
				"Arimo"
			]
	  	},
		active		:	function() {
			fontsLoaded = true;
			if(domLoaded) {
				fitNav.init([
					$("#nav").children("ul"),
					$("#socialBox").children("ul")
				]);
			};
		}
	});
});*/
/*///////////////////////////////////////////////////////////
//	FIT NAV ITEMS - ROMAN PACHECO
///////////////////////////////////////////////////////////*/
var fitNav	=	{
	init		:	function(n) {
		n = !$.isArray(n) ? [n] : n;
		$.each(n,function(i,nav) {
			var navWidth	=	parseFloat(nav.innerWidth()),
				items		=	nav.children("li");
			if($.browser.mozilla) {
				navWidth -= 2;
			};
			while(fitNav.tallyWidth(items) < navWidth) {
				var activeItem,
					activeSide;
				
				// ADD 1 TO LEFT PADDING
				$.each(items,function(i,e) {
					if(fitNav.tallyWidth(items) < navWidth) {
						activeItem = $(e);
						activeSide = "left";
						var aTag = $(e).children("a");
						aTag.css({
							paddingLeft	:	parseInt(aTag.css("padding-left")) + 1
						});
					} else {
						return false;
					};
				});
				
				// ADD 1 TO RIGHT PADDING
				$.each(items,function(i,e) {
					if(fitNav.tallyWidth(items) < navWidth) {
						activeItem = $(e);
						activeSide = "right";
						var aTag = $(e).children("a");
						aTag.css({
							paddingRight	:	parseInt(aTag.css("padding-right")) + 1
						});
					} else {
						return false;
					};
				});
				
				// IF WE'RE DONE, BACK IT UP ONE
				if(fitNav.tallyWidth(items) == navWidth) {
					activeItem.css("padding-" + activeSide,activeItem.css("padding-" + activeSide) - 1);
				};
			};
		});
	},
	tallyWidth	:	function(items) {
		var totalWidth	=	0;
		$.each(items,function(i,item) {
			totalWidth += $(item).outerWidth(true);
		});
		return totalWidth;
	}
};
$(function() {
	/*domLoaded = true;
	if(fontsLoaded) {*/
		fitNav.init([
			$("#nav").children("ul"),
			$("#socialBox").children("ul")
		]);
	/*};*/
	$("#socialBox")
		.tabs({
			disabled	:	[2,3,4,5]
		})
		
		// HACKERY, BUT IT WORKS
		.find("a[target='_blank']")
		.bind("click",function() {
			var href	=	$(this).attr("href"),
				target	=	href.replace(/#/,"");
			window.open(target,"_blank");
		});
});
/*///////////////////////////////////////////////////////////
//	PLACEHOLDER PLUGIN v1.1
///////////////////////////////////////////////////////////*/
(function($){var phClass="placeholder",pluginName="html5Forms",fieldsToCheck="input[type='text'], input[type='email'], input[type='search'], input[type='tel'], input[type='url'], input[type='password'], textarea",methods={init:function(o,callback){return this.each(function(){var $this=$(this),data=$this.data(pluginName);if(!data){var fieldTypes=$this.find(fieldsToCheck),settings={placeholderClass:phClass,alertText:"test this mutha"};if(o){$.extend(settings,o);};$.each(fieldTypes,function(i,f){var ph=$(f).attr("placeholder"),parent=$(f).parents("form:first");if(ph==$(f).val()||$.trim($(f).val())==""){$(f).val(ph).addClass(phClass);};$(f).bind("focus",function(){methods.fieldFocus.call($(this),ph);});$(f).bind("blur",function(){methods.fieldBlur.call($(this),ph);});$(f).bind("submit",function(){methods.clearValue.call($(this),ph);});});var instanceObj={settings:settings};$this.data(pluginName,instanceObj);};if(typeof callback!="undefined"){callback();};});},fieldFocus:function(ph){return this.each(function(){var $this=$(this);$this.removeClass(phClass);methods.clearValue.call($this,ph);});},fieldBlur:function(ph){return this.each(function(){var $this=$(this);if($.trim($this.val())==""){$this.addClass(phClass).val(ph);};});},clearValue:function(ph){return this.each(function(){var $this=$(this);if($this.val()==ph){$this.val("");};});}};$.fn.html5Forms=function(m){var fakeInput=document.createElement("input"),isNative=!!("placeholder"in fakeInput);if(!isNative){if(methods[m]){return methods[m].apply(this,Array.prototype.slice.call(arguments,1));}else if(!m||typeof m=="object"){return methods.init.apply(this,arguments);}else{$.error("Invalid method passed");};};}})(jQuery);
/*///////////////////////////////////////////////////////////
//	TNT IMAGE ROTATION v1.2 - ROMAN PACHECO
///////////////////////////////////////////////////////////*/
(function($){var pluginName="tnt_imageRotation",activeImgClass=pluginName+"_active",nextImgClass=pluginName+"_next",methods={init:function(o,callback){return this.each(function(){var $this=$(this),data=$this.data(pluginName);if(!data){var settings={effect:"fadeIn",speed:1000,delay:4000,startImg:0,enableBg:false,bgColor:"#fff"},images=$this.find("img"),container={width:0,height:0};if(o){$.extend(settings,o);};if(settings.effect=="dissolve"){settings.enableBg=false;};if($this.css("position")!="relative"&&$this.css("position")!="absolute"){$this.css({position:"relative"});}else{$this.css({position:$this.css("position")});};$this.css({display:"block",width:"0px",height:"0px",overflow:"hidden"});if(settings.enableBg){$this.css({backgroundColor:settings.bgColor});};$.each(images,function(i,e){$(e).show();container.width=Math.max(container.width,$(e).width());container.height=Math.max(container.height,$(e).height());$(e).css({display:"none",position:"absolute",top:"0px",left:"0px",margin:"0px",padding:"0px",border:"none",zIndex:"1"}).addClass(pluginName+"_"+i);});$.each(images,function(i,e){$(e).css({marginLeft:(container.width-parseFloat($(e).width()))/2,marginTop:(container.height-parseFloat($(e).height()))/2});});$this.css({width:container.width,height:container.height});if(settings.enableBg){var overlay=$("<div />",{css:{position:"absolute",display:"block",top:"0px",right:"0px",bottom:"0px",left:"0px",margin:"0px",padding:"0px",width:"auto",height:"100%",backgroundColor:settings.bgColor,zIndex:"9"}});$this.prepend(overlay);$.extend(settings,{overlay:overlay});};$this.data(pluginName,settings);};methods.rotate.call($this);});},rotate:function(o){return this.each(function(){var $this=$(this),data=$this.data(pluginName);if(data){var delayTime=data.delay,overlay=data.overlay;if(o){$.extend(data,o);};if(typeof data.activeImg!="number"){data.nextImg=data.startImg;delayTime=0;}else{var activeImg=$this.find("."+pluginName+"_"+data.activeImg);};if(!$this.find("."+pluginName+"_"+data.nextImg).length){data.nextImg=0;};var nextImg=$this.find("."+pluginName+"_"+data.nextImg);if(overlay){overlay.css({display:"none"});};nextImg.siblings("img").css({zIndex:1});if(activeImg&&data.effect=="dissolve"){activeImg.delay(delayTime).fadeOut(data.speed);};nextImg.css({zIndex:10}).delay(delayTime).fadeIn(data.speed,function(){nextImg.siblings("img").hide();data.activeImg=data.nextImg;data.nextImg=parseInt(data.nextImg+1);methods.rotate.call($this);});if(overlay){overlay.delay(delayTime).fadeIn(data.speed);};}});}};$.fn.tnt_imageRotation=function(m){if(methods[m]){return methods[m].apply(this,Array.prototype.slice.call(arguments,1));}else if(!m||typeof m=="object"){return methods.init.apply(this,arguments);}else{$.error("Invalid method passed");};};})(jQuery);
$(function() {
	$("#topPics").tnt_imageRotation({
		delay	:	8000
	});
});
/*///////////////////////////////////////////////////////////
//	SCROLLING FORM PAGES - ROMAN PACHECO
///////////////////////////////////////////////////////////*/
$(function() {
	var questionsForm	=	$("#questionsForm");
	questionsForm
		.tnt_pages()
		.find(".button_next")
		.bind("click",function() {
			questionsForm.tnt_pages("next");
			return false;
		})
		.end()
		.find(".button_prev")
		.bind("click",function() {
			questionsForm.tnt_pages("prev");
			return false;
		})
		.end()
		.find(".button_submit")
		.bind("click",function() {
			if(!$(this).hasClass("disabled")) {
				questionsForm.submit();
				$(this)
					.addClass("disabled")
					.html("Sending...");
			};
			return false;
		})
		.end()
		.html5Forms();
	
});
(function($){
	var pluginName	=	"tnt_pages",
		_v			=	{
			cssProps	:	{
				active	:	{
					marginLeft	:	"0%"
				},
				hiddenR	:	{
					marginLeft	:	"100%"
				},
				hiddenL	:	{
					marginLeft	:	"-100%"
				}
			}
		},
		_s			=	{
			speed			:	500,
			pages			:	".formPage",
			startingPage	:	0
		},
		_m			=	{
			init	:	function(o) {
				return this.each(function() {
					var $this	=	$(this),
						data	=	$this.data(pluginName);
					if(!data) {
						var s =	$.extend(true,{},_s);
						s = o ? $.extend(true,s,o) : s;
						$.extend(true,s,{
							pageList	:	[],
							currentPage	:	s.startingPage,
							targetPage	:	false
						});
						$.each($(s.pages),function(i,e) {
							if(i == s.startingPage) {
								$(e).css(_v.cssProps.active);
							} else {
								$(e).css(_v.cssProps.hiddenR);
							};
							s.pageList.push($(e));
						});
						$this.data(pluginName,s);
						data = $this.data(pluginName);
					};
				});
			},
			next	:	function() {
				return this.each(function() {
					var $this	=	$(this),
						data	=	$this.data(pluginName);
					if(data && data.pageList[data.currentPage]) {
						data.targetPage = data.pageList[data.currentPage + 1] ? data.currentPage + 1 : 0;
						_m.animate.left.call($this);
					};
				});
			},
			prev	:	function() {
				return this.each(function() {
					var $this	=	$(this),
						data	=	$this.data(pluginName);
					if(data && data.pageList[data.currentPage]) {
						data.targetPage = data.pageList[data.currentPage - 1] ? data.currentPage - 1 : data.pageList.length - 1;
						_m.animate.right.call($this);
					};
				});
			},
			animate	:	{
				left	:	function() {
					return this.each(function() {
						var $this	=	$(this),
							data	=	$this.data(pluginName);
						if(data && data.pageList[data.currentPage] && data.pageList[data.targetPage]) {
							data.pageList[data.targetPage].css(_v.cssProps.hiddenR);
							data.pageList[data.currentPage].animate(_v.cssProps.hiddenL,data.speed);
							data.pageList[data.targetPage].animate(_v.cssProps.active,data.speed);
							data.currentPage = data.targetPage;
						};
					});
				},
				right	:	function() {
					return this.each(function() {
						var $this	=	$(this),
							data	=	$this.data(pluginName);
						if(data && data.pageList[data.currentPage] && data.pageList[data.targetPage]) {
							data.pageList[data.targetPage].css(_v.cssProps.hiddenL);
							data.pageList[data.currentPage].animate(_v.cssProps.hiddenR,data.speed);
							data.pageList[data.targetPage].animate(_v.cssProps.active,data.speed);
							data.currentPage = data.targetPage;
						};
					});
				}
			}
		};
	$.fn[pluginName] = function(m) {
		m = !m ? "init" : m;
		if(typeof _m[m] != "undefined") {
			return _m[m].apply(this,arguments);
		};
	};
})(jQuery);
/*///////////////////////////////////////////////////////////
//	jQuery SWFObject v1.1.1 MIT/GPL @jon_neal
//	http://jquery.thewikies.com/swfobject
///////////////////////////////////////////////////////////*/
(function(f,h,i){function k(a,c){var b=(a[0]||0)-(c[0]||0);return b>0||!b&&a.length>0&&k(a.slice(1),c.slice(1))}function l(a){if(typeof a!=g)return a;var c=[],b="";for(var d in a){b=typeof a[d]==g?l(a[d]):[d,m?encodeURI(a[d]):a[d]].join("=");c.push(b)}return c.join("&")}function n(a){var c=[];for(var b in a)a[b]&&c.push([b,'="',a[b],'"'].join(""));return c.join(" ")}function o(a){var c=[];for(var b in a)c.push(['<param name="',b,'" value="',l(a[b]),'" />'].join(""));return c.join("")}var g="object",m=true;try{var j=i.description||function(){return(new i("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}()}catch(p){j="Unavailable"}var e=j.match(/\d+/g)||[0];f[h]={available:e[0]>0,activeX:i&&!i.name,version:{original:j,array:e,string:e.join("."),major:parseInt(e[0],10)||0,minor:parseInt(e[1],10)||0,release:parseInt(e[2],10)||0},hasVersion:function(a){a=/string|number/.test(typeof a)?a.toString().split("."):/object/.test(typeof a)?[a.major,a.minor]:a||[0,0];return k(e,a)},encodeParams:true,expressInstall:"expressInstall.swf",expressInstallIsActive:false,create:function(a){if(!a.swf||this.expressInstallIsActive||!this.available&&!a.hasVersionFail)return false;if(!this.hasVersion(a.hasVersion||1)){this.expressInstallIsActive=true;if(typeof a.hasVersionFail=="function")if(!a.hasVersionFail.apply(a))return false;a={swf:a.expressInstall||this.expressInstall,height:137,width:214,flashvars:{MMredirectURL:location.href,MMplayerType:this.activeX?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}}attrs={data:a.swf,type:"application/x-shockwave-flash",id:a.id||"flash_"+Math.floor(Math.random()*999999999),width:a.width||320,height:a.height||180,style:a.style||""};m=typeof a.useEncode!=="undefined"?a.useEncode:this.encodeParams;a.movie=a.swf;a.wmode=a.wmode||"opaque";delete a.fallback;delete a.hasVersion;delete a.hasVersionFail;delete a.height;delete a.id;delete a.swf;delete a.useEncode;delete a.width;var c=document.createElement("div");c.innerHTML=["<object ",n(attrs),">",o(a),"</object>"].join("");return c.firstChild}};f.fn[h]=function(a){var c=this.find(g).andSelf().filter(g);/string|object/.test(typeof a)&&this.each(function(){var b=f(this),d;a=typeof a==g?a:{swf:a};a.fallback=this;if(d=f[h].create(a)){b.children().remove();b.html(d)}});typeof a=="function"&&c.each(function(){var b=this;b.jsInteractionTimeoutMs=b.jsInteractionTimeoutMs||0;if(b.jsInteractionTimeoutMs<660)b.clientWidth||b.clientHeight?a.call(b):setTimeout(function(){f(b)[h](a)},b.jsInteractionTimeoutMs+66)});return c}})(jQuery,"flash",navigator.plugins["Shockwave Flash"]||window.ActiveXObject);

/*///////////////////////////////////////////////////////////
//	GALLERY
///////////////////////////////////////////////////////////*/
var tnt_gallery	=	function(o) {
	return $.each(this,function() {
		var $this		=	$(this),
			scroller	=	$("<div />",{
				"class"	:	"scroller"
			}),
			detailView	=	$("<div />",{
				"class"	:	"detailView"
			}),
			thumb		=	$("<a />",{
				"class"	:	"galleryThumb",
				text	:	"&nbsp;"
			}),
			allThumbs	=	[];
		$this.html("");
		
		// ADD ELEMS
		$this
			.append(scroller)
			.append(detailView);
		
		// CREATE THUMBS
		$.each(o,function(i,obj) {
			var newThumb	=	thumb.clone(),
				thumbObj	=	{
					thumb	:	newThumb
				};
			newThumb
				.css({
					backgroundImage	:	"url(" + obj.thumb + ")"
				})
				.attr("href",obj.image);
			
			// PRELOAD IMAGE
			var thisImg	=	$("<img />",{
				src	:	obj.image
			});
			thumbObj.image = thisImg;
			allThumbs.push(thumbObj);
			scroller.append(newThumb);
		});
		
		// INIT SCROLLER
		scroller.tnt_scroll({
			cssPos		:	"absolute"
		});
			
		$.each(allThumbs,function(i,thumbObj) {
			
			// BIND CLICK
			thumbObj.thumb.bind("click",function(e) {
				e.stopPropagation();
				if(!detailView.hasClass("animating")) {
					detailView.addClass("animating");
					detailView
						.fadeOut("fast",function() {
							$(this)
								.html(thumbObj.image)
								.fadeIn("slow",function() {
									detailView.removeClass("animating");
								});
						});
				};
				return false;
			});
		
		});
		$(allThumbs[0].thumb).trigger("click");
	});
};








