var touch = function(){
	// 
	var workTypes = new Array(["identity",["0,1","0,2","1,2"]],["print",["0,1","1,2","0,1"]],["digital",["0,2","1,2","0,1"]]);
	var sitePath = "/touch/includes/themes/touch/";
	return {
		init : function() {	
		 
			$('#page_effect').fadeIn(1000);
			$('.header').fadeIn(1000);
			// add a check for ie
			//alert($.browser.msie);
			if ($.browser.msie) {
				//touch.checkResolutionForIE();
			}
			// font rendering
			try{Typekit.load();}catch(e){}
			// animate scroll
			$('a[href=#top]').click(function(){
				$('html, body').animate({scrollTop:0}, 'slow');
				return false;
			});
			
			jQuery.reject({
				imagePath: sitePath+'images/',
				closeESC: true, // Allow closing of window with esc key  
				closeCookie: true, // If cookies should be used to remmember if the window was closed (see cookieSettings for more options)  
				// Cookie settings are only used if closeCookie is true  
				cookieSettings: {  
					path: '/', // Path for the cookie to be saved on (should be root domain in most cases)  
					expires: 0 // Expiration Date (in seconds), 0 (default) means it ends with the current session  
				}  
			});
			
			var pageId = $("body").attr("id");
			
			switch (pageId) {
				// setup homepage
				case "work":
					touch.setupWork();
					break;
			}
			
			// highlight work is url hash is passed 
			touch.highlightWork(unescape(self.document.location.hash.substring(1)));
	
		},
		checkResolutionForIE : function() {
			if ((screen.width<1100)) {
				$("link[rel=stylesheet]:last").attr({href : sitePath+"css/900_pixels.css"}); 
			} else if ((screen.width>1400)) {
				$("link[rel=stylesheet]:last").attr({href : sitePath+"css/1000_pixels.css"}); 
			} 

		},
		resetWork : function() {
			$(".work").removeClass("active");
			$(".work").removeClass("inactive");
			$(".nav_main a").removeClass("highlight");
		},
		highlightWork : function(workType) {
			// remove all active classes 
			$(".work").removeClass("active");
			
			for (var x=0;x<workTypes.length;x++) {
				if (workType.toLowerCase()==workTypes[x][0].toLowerCase()) {
					$("."+workTypes[x][0]+"-project").addClass("active");
					// set current highlight
					$("."+workTypes[x][0]).addClass("highlight");
				} else {
					// remove current highlights
					$("."+workTypes[x]).removeClass("highlight");
					if (workType.length!=0) {
						$("."+workTypes[x][0].split(" ")[0]+"-project").addClass("inactive");
					}
				}
			}
		},
		setupWork : function() {
			
			$('.slideshow1').css('display','block');
			$('.slideshow-biggest-box').css('display','block');
			$('.slideshow-wide').css('display','block');
			$('.slideshow-tall').css('display','block');
			$('.slideshow-big-box').css('display','block');
			$('.slideshow-big-box-wide').css('display','block');
			$('.work .highlight-image').css('display','block');
			
			for(var x=0;x<workTypes.length;x++) {
				$(".sub-nav ."+workTypes[x][0]).click(function() {
					touch.highlightWork(this.className.split(" ")[0]);
				});
			
			}
			
			// homepage animations
			$('.slideshow1').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
			$('.slideshow-biggest-box').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
			$('.slideshow-wide').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
			$('.slideshow-tall').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
			$('.slideshow-big-box').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
			$('.slideshow-big-box-wide').slideshow({playhover:true,playframe:false,effecttime:2000,time:300,title:false,panel:false,width:'100%',height:'100%'});
		}
	}
}();
$(document).ready(touch.init);
