$(function() {
	
sitemap = [
	[{sec_no: '01', sec_main: 'Who We Are',		sec_sub: '',				sec_tri: '',			hash: ' ',		url: './pages/01_home.html'	}],
	[{sec_no: '01', sec_main: 'Who We Are',		sec_sub: '',				sec_tri: 'Introduction',	hash: 'who/intro',	url: './pages/01_intro.html'	}],
	[{sec_no: '02', sec_main: 'Capabilities',	sec_sub: '',				sec_tri: 'Capabilities',	hash: 'capabilities',	url: './pages/02_capab.html'	}],

// CASE STUDIES ----------------------------------------------------------------------------------------------------------------------------

	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'American Giant',		sec_tri: 'Overview',		hash: 'cs/ag/ov',	url: './pages/03_cs_ag_ov.html',	thumb: './images/thumbs/cs/tb_ag.jpg'}],

	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Wargaming',		sec_tri: 'Overview',		hash: 'cs/wg/ov',	url: './pages/03_cs_wg_ov.html',	thumb: './images/thumbs/cs/tb_wg.jpg'}],
	 
	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri: 'Overview',		hash: 'cs/redc/ov',	url: './pages/03_cs_redc_ov.html',	thumb: './images/thumbs/cs/redc.jpg'},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri: 'Challenge',		hash: 'cs/redc/ch',	url: './pages/03_cs_redc_ch.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri: 'Solution',		hash: 'cs/redc/so',	url: './pages/03_cs_redc_so.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri:  'Print',		hash: 'cs/redc/print',	url: './pages/03_cs_redc_print.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri:  'TShirt',		hash: 'cs/redc/shirt',	url: './pages/03_cs_redc_tshirt.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri:  'Twitter',		hash: 'cs/redc/twit',	url: './pages/03_cs_redc_twitter.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri: 'Interactive trailer',	hash: 'cs/redc/itrail',	url: './pages/03_cs_redc_trailer.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri:  'Website',		hash: 'cs/redc/web',	url: './pages/03_cs_redc_site.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Resident Evil',		sec_tri: 'Results',		hash: 'cs/redc/re',	url: './pages/03_cs_redc_re.html'	}],

	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Overview',		hash: 'cs/vind/ov',	url: './pages/03_cs_vind_ov.html',	thumb: './images/thumbs/cs/vin.jpg'},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Challenge',		hash: 'cs/vind/ch',	url: './pages/03_cs_vind_ch.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Solution',		hash: 'cs/vind/so',	url: './pages/03_cs_vind_so.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Print',		hash: 'cs/vind/print',	url: './pages/03_cs_vind_print.html'	},
	 //{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Banner',		hash: 'cs/vind/banner',	url: './pages/03_cs_vind_banner.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Trailer',		hash: 'cs/vind/trail',	url: './pages/03_cs_vind_trailer.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Vindictus',			sec_tri: 'Results',		hash: 'cs/vind/re',	url: './pages/03_cs_vind_re.html'	}],

	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri: 'Overview',		hash: 'cs/knl2/ov',	url: './pages/03_cs_knl_ov.html',	thumb: './images/thumbs/cs/knl.jpg'},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri: 'Challenge',		hash: 'cs/knl2/ch',	url: './pages/03_cs_knl_ch.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri: 'Solution',		hash: 'cs/knl2/so',	url: './pages/03_cs_knl_so.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri:  'Print',		hash: 'cs/knl2/print',	url: './pages/03_cs_knl_print.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri:  'Outdoor',		hash: 'cs/knl2/out',	url: './pages/03_cs_knl_outdoor.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri:  'Online',		hash: 'cs/knl2/web',	url: './pages/03_cs_knl_online.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Kane & Lynch 2: Dog Days',	sec_tri: 'Results',		hash: 'cs/knl2/re',	url: './pages/03_cs_knl_re.html'	}],

	[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri: 'Overview',		hash: 'cs/tomb/ov',	url: './pages/03_cs_tomb_ov.html',	thumb: './images/thumbs/cs/tomb.jpg'},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri: 'Challenge',		hash: 'cs/tomb/ch',	url: './pages/03_cs_tomb_ch.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri: 'Solution',		hash: 'cs/tomb/so',	url: './pages/03_cs_tomb_so.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri:  'GameSpot takeover',	hash: 'cs/tomb/gsp',	url: './pages/03_cs_tomb_gsp.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri:  '1UP banner',		hash: 'cs/tomb/1up',	url: './pages/03_cs_tomb_gsr.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri:  'IGN banner',		hash: 'cs/tomb/ign',	url: './pages/03_cs_tomb_ign.html'	},
	 {sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Tomb Raider: Underworld',	sec_tri: 'Results',		hash: 'cs/tomb/re',	url: './pages/03_cs_tomb_re.html'	}],

	//[{sec_no: '03', sec_main: 'Case Studies',	sec_sub: 'Just Cause 2',		sec_tri: 'Overview',		hash: 'cs/jc2/ov',	url: './pages/03_cs_jc2_ov.html',	thumb: './images/thumbs/prj/jc2.jpg'}],

// Projects --------------------------------------------------------------------------------------------------------------------------------

	[{sec_no: '04', sec_main: 'Projects',		sec_sub: '',				sec_tri: 'Projects',		hash: 'prj',		url: './pages/04_prj_intro.html'	}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Black Eyed Peas',			sec_tri: 'The Black Eyed Peas Experience',		hash: 'prj/bepx',	url: './pages/04_prj_bepx_ov.html',	thumb: './images/thumbs/prj/tb_bepx.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Acclarent',			sec_tri: 'Balloon Sinuplasty',		hash: 'prj/bsp',	url: './pages/04_prj_bsp_ov.html',	thumb: './images/thumbs/prj/tb_bsp.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Resident Evil',			sec_tri: 'R.E. Mercenaries 3D',		hash: 'prj/remerc',	url: './pages/04_prj_remerc_ov.html',	thumb: './images/thumbs/prj/tb_remerc.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: '76',				sec_tri: '76',			hash: 'prj/76',		url: './pages/04_prj_76_ov.html',	thumb: './images/thumbs/prj/76.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Pok&eacute;mon: Rumble Blast',		sec_tri: 'Pok&Eacute;mon: Rumble Blast',	hash: 'prj/prb',	url: './pages/04_prj_prb_ov.html',	thumb: './images/thumbs/prj/tb_prb.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Pok&eacute;mon: Zoroark',		sec_tri: 'Pok&Eacute;mon: Zoroark',	hash: 'prj/pkz',	url: './pages/04_prj_pkz_ov.html',	thumb: './images/thumbs/prj/pkz.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Slim Jim',			sec_tri: 'Slim Jim',		hash: 'prj/slj',	url: './pages/04_prj_slj_ov.html',	thumb: './images/thumbs/prj/slj.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'AB SCIEX',			sec_tri: 'AB SCIEX',		hash: 'prj/abs',	url: './pages/04_prj_abs_ov.html',	thumb: './images/thumbs/prj/abs.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Castlevania: L.O.S',		sec_tri: 'Castlevania',		hash: 'prj/cast',	url: './pages/04_prj_cas_ov.html',	thumb: './images/thumbs/prj/cas.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Call of Duty: Black Ops',	sec_tri: 'C.O.D - Black Ops',	hash: 'prj/cod',	url: './pages/04_prj_cod_ov.html',	thumb: './images/thumbs/prj/cod.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Dreyers: Snack Sizes',	sec_tri: 'Dreyer: Snack Sizes',	hash: 'prj/drey',	url: './pages/04_prj_dre_ov.html',	thumb: './images/thumbs/prj/dre.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'Lost Planet 2',		sec_tri: 'Lost Planet 2',	hash: 'prj/lp2',	url: './pages/04_prj_lp2_ov.html',	thumb: './images/thumbs/prj/lp2.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'trueAnthem',			sec_tri: 'trueAnthem',		hash: 'prj/tru',	url: './pages/04_prj_tru_ov.html',	thumb: './images/thumbs/prj/tru.jpg'}],
	[{sec_no: '04', sec_main: 'Projects',		sec_sub: 'US Cellular',			sec_tri: 'U.S. Cellular',	hash: 'prj/usc',	url: './pages/04_prj_usc_ov.html',	thumb: './images/thumbs/prj/usc.jpg'}],

// Labs ------------------------------------------------------------------------------------------------------------------------------------

	[{sec_no: '05', sec_main: 'Labs',		sec_sub: '',				sec_tri: 'Labs',		hash: 'labs',		url: './pages/05_labs_intro.html'}],
	[{sec_no: '05', sec_main: 'Labs',		sec_sub: 'HTML 5',			sec_tri: 'Particles',		hash: 'labs/parti',	url: './pages/05_labs_parti.html'}],
	//[{sec_no: '05', sec_main: 'Labs',		sec_sub: 'iPad',			sec_tri: 'iPong',		hash: 'labs/ipong',	url: './pages/05_labs_ipong.html'}],

// -----------------------------------------------------------------------------------------------------------------------------------------

	[{sec_no: '06', sec_main: 'Our Culture',	sec_sub: '',				sec_tri: 'Our Culture',		hash: 'culture',	url: './pages/06_cult1.html'}],
	[{sec_no: '06', sec_main: 'Our Culture',	sec_sub: 'Careers',			sec_tri: 'Careers',		hash: 'culture/jobs',	url: './pages/06_cult2.html'}],
	[{sec_no: '07', sec_main: 'Get In Touch',	sec_sub: '',				sec_tri: 'Now What?',		hash: 'contact',	url: './pages/07_cont.html'}]
];

var scrollIndexV = 	-1;
var scrollIndexH = 	0;
var busy = 		false;
var pageShow = 		null;
var pageBlur = 		null;

var mboxShow = 		null;
var mboxBlur = 		null;

var pageSpeed = 	750;
var tranDelay = 	150;
var pageEase = 		'easeInOutExpo';
var hoverSpeed = 	150;

var thumbsOpen = 	false;
var thumbsIndex =	null;

var nochromedelay = 	(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) ? 0:0; //0:50
var seenInstruct = 	false;

var menuHidden =	false;

/*var pageTracker = new Object()
pageTracker._trackEvent = function (info1, info2, info3) {
	document.title = info1 + " | " + info2 + " | " + info3 + " " + Math.random();
	return false;
}*/


if(navigator.platform.indexOf("iPad") > -1) {
	pageSpeed *= 	1.5;
	tranDelay *= 	1.5;
}

function fadeNavIn() {
	$('.hover', this).stop().animate({'width': '100%'}, hoverSpeed);
	//$('p', this).css({'color': '#000','opacity': 0}).animate({'opacity': 1},hoverSpeed);
}

function fadeNavOut() {
	$('.hover', this).stop().animate({'width': 0}, hoverSpeed);
	//$('p', this).css({'color': '#FFF','opacity': 1});
}

function getWindowSize() {
	var w = $(window).width();
	var h = $(window).height();

	if (navigator.platform.indexOf("iPad") > -1) {
		if (w < 768) w = 768;
		if (h < 550) h = 550;
	}else{
		if (w < 871) w = 871;
		//if (w < 768) w = 768;
		if (h < 605) h = 605;
	}
	

	return { width: w, height: h };
}

function resizeHandler() {

	for (var i = 0; i < 2; i++) {
		var winSize =  getWindowSize();
 
		$('#overall').width(winSize.width);
		$('#overall').height(winSize.height);

		$('#wrapper_pages').width(winSize.width);
		$('#wrapper_pages').height(winSize.height);
	}

	$('#carasoul').width(winSize.width);
	$('#carasoul').height(winSize.height);

	$('#pageA, #pageB, #tranA, #tranB, #tranC').width(winSize.width);
	$('#pageA, #pageB, #tranA, #tranB, #tranC').height(winSize.height);

	var bgratio = 4 / 3;

	if (winSize.width / winSize.height < bgratio) {
		var crop = -(winSize.height * bgratio - winSize.width) / 2 + "px";
		/*$('#bg').width(winSize.height * bgratio + "px" );
		$('#bg').height("100%");
		$('#bg').css('margin-left', crop);
		$('#bg').css('margin-top', "0");*/
		
		$('.innerbg').width(winSize.height * bgratio + "px" );
		$('.innerbg').height("100%");
		$('.innerbg').css('margin-left', crop);
		$('.innerbg').css('margin-top', "0");
	}else{
		var crop = -(winSize.width / bgratio - winSize.height) / 2 + "px";
		/*$('#bg').width("100%");
		$('#bg').height(winSize.width / bgratio + "px");
		$('#bg').css('margin-top', crop);
		$('#bg').css('margin-left', "0");*/
		
		$('.innerbg').width("100%");
		$('.innerbg').height(winSize.width / bgratio + "px");
		$('.innerbg').css('margin-top', crop);
		$('.innerbg').css('margin-left', "0");
	}
	//$('#menunav').css({top: ((winSize.height - $('#menunav_footer').height()) - $('#menunav').height()) / 2 });
	$('.textpage').vAlign(winSize.height);
	$('.case1_box .info').vAlign(winSize.height);
	$('.case2_box .info').vAlign(winSize.height);
	$('.innerPage .main').vAlign(winSize.height);
	
	if (navigator.platform.indexOf("iPad") > -1) {
		try {
			if (sitemap[scrollIndexV][scrollIndexH].hash == 'culture/jobs') {
				$('.blockinfo').css({'width': '248px'})
				$('.blockinfo .maintext2').css({'line-height': '25px'})
			}
		}catch (err) {}
	}
}


function doInstruction() {
	$('.instruct .inner').stop().each(
		function () {
			if ($('.device',this).text() == '' && !seenInstruct) {

				if (navigator.platform.indexOf("iPad") > -1) {
					$('.device',this).text('TouchSwipe');
				}else{
					$('.device',this).text('Use keyboard');
				}

				$(this).animate(
					{
						'margin-top': -64
					},{
						duration: pageSpeed, 
						easing: pageEase, 
						complete: function () {

						}
					}
				);
			}else{
				$(this).animate(
					{
						'margin-top': 0
					},{
						duration: pageSpeed, 
						easing: pageEase, 
						complete:  function(){
							//$(this).remove();
							$('.device',this).text('');
							seenInstruct = true;
						}
					}
				);
			}
		}
	);
}

function checkPokemon() {
  var pageHash = window.location.hash;
  
  if (pageHash.indexOf('pkz') != -1) {
    $('#menunav_footer').html('<div id="pokemon_legal">&copy; 2010 PIKACHU PROJECT.</div>'+
			'<a href="http://www.facebook.com/pages/JVST-Inc/106350829435663" target="_blank"><img src="./images/social_fb.png" /></a>'+
			'<a href="http://twitter.com/jvst" target="_blank"><img src="./images/social_tw.png" /></a>'+
		'<div>&copy; 2012 JVST AND OUR CLIENTS</div>');
  }
  else if (pageHash.indexOf('prb') != -1) {
    $('#menunav_footer').html('<div id="pokemon_legal">&copy; 2012 Pok&eacute;mon/Nintendo.</div>'+
			'<a href="http://www.facebook.com/pages/JVST-Inc/106350829435663" target="_blank"><img src="./images/social_fb.png" /></a>'+
			'<a href="http://twitter.com/jvst" target="_blank"><img src="./images/social_tw.png" /></a>'+
		'<div>&copy; 2012 JVST AND OUR CLIENTS</div>');
  }
  else {
    $('#menunav_footer').html('<a href="http://www.facebook.com/pages/JVST-Inc/106350829435663" target="_blank"><img src="./images/social_fb.png" /></a>'+
			'<a href="http://twitter.com/jvst" target="_blank"><img src="./images/social_tw.png" /></a>'+
		'<div>&copy; 2012 JVST AND OUR CLIENTS</div>');
  }
}

function scrollVBegin() {
	resizeHandler();
	attachNavInner();
	attachNavJobs();
	
	var colon = (sitemap[scrollIndexV][scrollIndexH].sec_sub.length > 0) ? ':&nbsp;': '';
	$('.crumbs_inner', pageBlur).html(
		sitemap[scrollIndexV][scrollIndexH].sec_no + 
		" " + 
		sitemap[scrollIndexV][scrollIndexH].sec_main + 
		colon + 
		'<span class="title">' +
		sitemap[scrollIndexV][scrollIndexH].sec_sub +
		'</span>'
	);
	$('h2', pageBlur).text(sitemap[scrollIndexV][scrollIndexH].sec_tri);
}

function fancyBoxApply() {
	if(navigator.platform.toLowerCase().indexOf("ipad") == -1) {
		$('a.fancybox').fancybox({
			'type'	:	'iframe',
			'width'	:	760,
			'height':	500
		});
	}
}

function ipadLinkApply() {
	try {
		if(navigator.platform.toLowerCase().indexOf("ipad") > -1) {
			$('a.medialink').each(
				function () {
					var ipadhref = $(this).attr('ipadhref');
					if (ipadhref.length > 0) {
						$(this).attr('href', ipadhref);
					}
				}
			);
		}
	}catch (err) {
		//alert(err.description);
	}
}

function scrollVDone()  {
	swapActiveBlur();
	pageBlur.css('visibility','hidden').css('display','none');
	pageBlur.html('');

	if ($.browser.msie) {
	 	pageShow.each(
			function() {
				this.style.removeAttribute('filter');
			}
		);
	}

	var hash = sitemap[scrollIndexV][scrollIndexH].hash;
	var sec_sub = sitemap[scrollIndexV][scrollIndexH].sec_sub;
	if (sec_sub != '') sec_sub = ' - ' + sec_sub;
	document.title = "JVST - " + sitemap[scrollIndexV][scrollIndexH].sec_main + sec_sub;

	if (hash == '') {
		document.location = "./#";
	}else{
		document.location = "./#" + hash;
	}
	pageTracker._trackEvent('Load Hash', hash);
	
	var sec_no = sitemap[scrollIndexV][scrollIndexH].sec_no - 1;
	$('#menunav a .caption').css({'background-color': 'transparent', 'color': '#FFF'});
	
	$('#menunav a .caption').eq(sec_no).css('background-color', '#000');
	if (scrollIndexV == 0) 			$('#pagenav #btn1').addClass('disabled'); else $('#pagenav #btn1').removeClass('disabled');
	if (scrollIndexV == sitemap.length -1 )	$('#pagenav #btn2').addClass('disabled'); else $('#pagenav #btn2').removeClass('disabled');
	
	$('.mbox .content a').click(
		function() {
			//alert('');
			pageTracker._trackEvent('Demo View', $(this).attr('href'));
		}
	);
	

	$('img.innerbg', pageShow).unbind('click').click(
		function () {
			toggleMenus();
		}
	);

	fancyBoxApply();
	ipadLinkApply();
	
	busy = false;
	if (menuHidden) toggleMenus();
	showLoader(0);
	doInstruction();
	
}

function toggleMenus() {
	if (!busy) {
		busy = true;
		showLoader(1);

		if (!menuHidden) {
			$('.mbox').animate({'left': -470}, hoverSpeed);
			$('#wrapper_menunav').animate(
				{'right': -170}, 
				{ 
					duration: hoverSpeed,
					complete: function() {
						busy = false;
						menuHidden = true;
						showLoader(0);
					}
				}
			);
		}else{
			$('.mbox').animate({'left': 0}, hoverSpeed);
			$('#wrapper_menunav').animate(
			
				{'right': 0}, 
				{ 
					duration: hoverSpeed,
					complete: function() {
						busy = false;
						menuHidden = false;
						showLoader(0);
					}
				}
			);
		}
	}
}

function swapMultiBox(inBox, inPage, callback) {
	
	var prevTitle = (scrollIndexH != 0) ? sitemap[scrollIndexV][scrollIndexH - 1].sec_tri:'';
	var nextTitle = (scrollIndexH + 1 < sitemap[scrollIndexV].length) ? sitemap[scrollIndexV][scrollIndexH + 1].sec_tri:'';

	$('.nav .thumbs',	inBox).html((new Array(sitemap[scrollIndexV].length + 1)).join('<a></a>'));
	$('.nav .thumbs a',	inBox).removeClass('current');
	$('.nav .thumbs a',	inBox).each(
		function (index) {
			$(this).unbind('click').click(
				function(){
					if (!busy) pageTracker._trackEvent('Menu Secondary', sitemap[scrollIndexV][index].hash);
					scrollH(index - scrollIndexH);
					return false;
				}
			);
		}
	);
	$('.nav .thumbs a',	inBox).eq(scrollIndexH).unbind('click').addClass('current');

	if(prevTitle != '') {
		$('.buttons .prev span',inBox).html(prevTitle);
		$('.buttons .prev',	inBox).css({'visibility': 'visible', 'display': 'block'});
		$('.buttons .prev a',	inBox).unbind('click').click(
			function(){
				if (!busy){
					pageTracker._trackEvent('Navigation', 'Click', 'Left');
					scrollH(-1);
				}
				return false;
			}
		);
		
	} else {
		$('.buttons .prev',inBox).css({'visibility': 'hidden', 'display': 'none'});
	}

	if(nextTitle != '') {
		$('.buttons .next span',inBox).html(nextTitle);
		$('.buttons .next',	inBox).css({'visibility': 'visible', 'display': 'block'});
		$('.buttons .next a',	inBox).unbind('click').click(
			function(){
				if (!busy){
					pageTracker._trackEvent('Navigation', 'Click', 'Right');
					scrollH(01);
				}
				return false;
			}
		);
	} else {
		$('.buttons .next',inBox).css({'visibility': 'hidden', 'display': 'none'});
	}
		

	//$('.content .section',inBox).fadeOut(100, function(){$(this).html($('.multipage_info .section',		inPage).html())}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});
	//$('.content .title',	inBox).fadeOut(100, function(){$(this).html($('.multipage_info .subject_name', 		inPage).html())}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});
	//$('.content h2',	inBox).fadeOut(100, function(){$(this).html($('.multipage_info .subject_section',	inPage).html())}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});

	$('.content .section',	inBox).fadeOut(100, function(){$(this).html(sitemap[scrollIndexV][scrollIndexH].sec_no + " " + sitemap[scrollIndexV][scrollIndexH].sec_main + ":&nbsp;")}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});
	$('.content .title',	inBox).fadeOut(100, function(){$(this).html(sitemap[scrollIndexV][scrollIndexH].sec_sub)		}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});
	$('.content h2',	inBox).fadeOut(100, function(){$(this).html(sitemap[scrollIndexV][scrollIndexH].sec_tri)		}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter');});
	$('.content .maintext',	inBox).fadeOut(100, function(){$(this).html($('.multipage_info .subject_detail',inPage).html())		}).fadeIn(100, function(){if ($.browser.msie) this.style.removeAttribute('filter'); if (callback) callback();});	
}

function scrollHDone(callback)  {
	swapMultiBox(mboxShow, pageBlur, callback);
}

function scrollV(delta, forceH) {
	delta = parseInt(delta);
	
	if (busy || scrollIndexV + delta < 0 || scrollIndexV + delta >= sitemap.length) return;
	busy = true;
	
	//var prevmulti = (sitemap[((scrollIndexV != -1) ? scrollIndexV:0)].length > 1);

	var prevmulti = false;
	var prevHash = sitemap[((scrollIndexV != -1) ? scrollIndexV:0)][scrollIndexH].hash;

	if (prevHash.indexOf('cs/') == 0 || prevHash.indexOf('prj/') == 0 || prevHash.indexOf('labs/') == 0) {
		prevmulti = true;
		//alert("prevHash: " + prevHash);	
	}


	scrollIndexV += delta;
	
	if (forceH != undefined) {
		scrollIndexH = forceH;
	}else{
		scrollIndexH = 0;
	}

	if (scrollIndexV < 0) {
		scrollIndexV += sitemap.length;
	} else if (scrollIndexV >= sitemap.length) {
		scrollIndexV -= sitemap.length;
	}
	
	if (Math.abs(delta) > 0) {
		showLoader(1);
		pageBlur.unbind('load').load(sitemap[scrollIndexV][scrollIndexH].url,
			function (){
				//alert('html loaded');
				var bgLoadedFunc = function () {
					//alert('transition');
					var direc = (delta > 0) ? 1 : -1;
					var pageDelay = 0;
					if (Math.abs(delta) > 1) {
						pageDelay = 1
						$('#tranA, #tranB, #tranC').css({
							'visibility': 'visible',
							'display': 'block',
							'left': 0
						});
						$('#tranA').delay(tranDelay * 0).css({top: getWindowSize().height*direc}).animate(
							{ top: -getWindowSize().height*direc },
							{ duration: pageSpeed, easing: pageEase }
						);
						$('#tranB').delay(tranDelay * 1).css({top: getWindowSize().height*direc}).animate(
							{ top: -getWindowSize().height*direc },
							{ duration: pageSpeed, easing: pageEase }
						);
						$('#tranC').delay(tranDelay * 2).css({top: getWindowSize().height*direc}).animate(
							{ top: -getWindowSize().height*direc },
							{ duration: pageSpeed, easing: pageEase,
								complete: function(){ $('#tranA, #tranB, #tranC').css('visibility','hidden').css('display','none'); }
							}
						);
					}else{
						$('#tranA, #tranB, #tranC').css('visibility','hidden').css('display','none');
					}

					pageBlur.delay(tranDelay * 0 * pageDelay).show(0,
						function() {
							//var multi = (sitemap[scrollIndexV].length > 1);

							var multi = false;
							var currentHash = sitemap[scrollIndexV][scrollIndexH].hash;
							if (currentHash.indexOf('cs/') == 0 || currentHash.indexOf('prj/') == 0 || currentHash.indexOf('labs/') == 0) {
								multi = true;
								//alert("currenthash: " + currentHash);	
							}
							
							if (multi) {	//PREPOSITION
								mboxBlur.css({visibility: 'visible', display: 'block', top: getWindowSize().height * direc});
								swapMultiBox(mboxBlur,pageBlur);
							}
							
							
							if (multi) {	//ANIMATE IN
								mboxBlur.delay(tranDelay * 2 * pageDelay).animate(
									{top: 0},
									{
										duration: pageSpeed, 
										easing: pageEase, 
										complete: function () {
											swapBoxBlur();
											mboxBlur.css({'visibility': 'hidden'}).css('display','none');
										}
									}
								);
							}
							if (prevmulti){ //ANIMATE OUT
								mboxShow.delay(nochromedelay).animate(
									{top: -getWindowSize().height*direc},
									{duration: pageSpeed,easing: pageEase, 
										complete: function () {
											$(this).css({'visibility': 'hidden'}).css('display','none');
										}
									}
								);
							}
							
							scrollVBegin();
							pageBlur.css({visibility: 'visible', display: 'block', top: getWindowSize().height * direc, left: 0});
							pageBlur.delay(tranDelay * 2 * pageDelay).animate(			// PAGE ENTERING
								{top: 0, left: 0},
								{duration: pageSpeed, easing: pageEase}
							);
							pageShow.delay(tranDelay * 1 * pageDelay).animate(			// PAGE LEAVING
								{top: -getWindowSize().height * direc},
								{duration: pageSpeed, easing: pageEase, complete: scrollVDone}
							);
						}
					);
				}
				/*$('.layer', pageBlur).each(
					function () {
						var bgurl = $(this).attr('rel'); 

						$(this).css({
							"background-image": "url(" + bgurl + ")",
							"background-position": "center",
							"background-repeat": "no-repeat"
						});

					}
				);*/
				var blurThis = this;
				if ($('.innerbg', this).eq(0).attr('rel') != undefined) {
					var imgurl = $('.innerbg', this).eq(0).attr('rel');
					$('.innerbg', this).eq(0)
					.attr('selectable', 'false')
					.unbind('load')
					.unbind('mousedown')
					.unbind('mousemove')
					.mousedown(
						function(event) {
							event.preventDefault();
							return false;
						}
					)
					.mousemove(
						function(event) {
							event.preventDefault();
							return false;
						}
					).load(
						function() {
							//alert('bg done');
							bgLoadedFunc.apply(blurThis);
						}
					).attr('src', imgurl);
				}else{
					//alert('bg');
					bgLoadedFunc.apply(blurThis);
				}
			}
		);
	}else{
		busy = false
		return;
	}
}

function scrollH(delta) {
	if (sitemap[scrollIndexV].length < 2) {
		return;
	}

	if (busy || scrollIndexH + delta < 0 || scrollIndexH + delta >= sitemap[scrollIndexV].length) 
		return;

	if (Math.abs(delta) > 0) {

		busy = true;
		
		scrollIndexH += delta;
		if (scrollIndexH < 0) {
			scrollIndexH += sitemap[scrollIndexV].length;
		} else if (scrollIndexH >= sitemap[scrollIndexV].length) {
			scrollIndexH -= sitemap[scrollIndexV].length;
		}
		showLoader(1);
		pageBlur.unbind('load').load(sitemap[scrollIndexV][scrollIndexH].url,
			function (){
				var bgLoadedFunc = function() {
					var direc = (delta > 0) ? 1 : -1;
					var pageDelay = 0;
					if (Math.abs(delta) > 1) {
						pageDelay = 1
						$('#tranA, #tranB, #tranC').css({ 'visibility': 'visible', 'display': 'block', 'top': 0 });
						$('#tranA').delay(tranDelay * 0).css({left: getWindowSize().width*direc}).animate(
							{ left: -getWindowSize().width*direc },
							{ duration: pageSpeed, easing: pageEase }
						);
						$('#tranB').delay(tranDelay * 1).css({left: getWindowSize().width*direc}).animate(
							{ left: -getWindowSize().width*direc },
							{ duration: pageSpeed, easing: pageEase }
						);
						$('#tranC').delay(tranDelay * 2).css({left: getWindowSize().width*direc}).animate(
							{ left: -getWindowSize().width*direc },
							{ duration: pageSpeed, easing: pageEase,
								complete: function(){ $('#tranA, #tranB, #tranC').css('visibility','hidden').css('display','none'); }
							}
						);
					}else{
						$('#tranA, #tranB, #tranC').css('visibility','hidden').css('display','none');
					}
					
					pageBlur.delay(tranDelay * 1 * pageDelay).show(0,
						function() {
							scrollVBegin();
							pageBlur.css({visibility: 'visible', display: 'block', left: getWindowSize().width * direc, top:  0});
							pageBlur.delay(tranDelay * 1 * pageDelay).animate(
								{ top: 0,left: 0 },
								{ duration: pageSpeed, easing: pageEase }
							);
							pageShow.delay(tranDelay * 0 * pageDelay).animate(
								{ left: -getWindowSize().width * delta },
								{ duration: pageSpeed, easing: pageEase, complete: function(){scrollHDone(scrollVDone);} }
							);
						}
					);
				};

				var blurThis = this;

				if ($('.innerbg', this).eq(0).attr('rel') != undefined) {
					var imgurl = $('.innerbg', this).eq(0).attr('rel');
					$('.innerbg', this).eq(0)
					.attr('selectable', 'false')
					.unbind('load')
					.unbind('mousedown')
					.unbind('mousemove')
					.mousedown(
						function(event) {
							event.preventDefault();
							return false;
						}
					)
					.mousemove(
						function(event) {
							event.preventDefault();
							return false;
						}
					).load(
						function() {
							//alert('bg done');
							bgLoadedFunc.apply(blurThis);
						}
					).attr('src', imgurl);
				}else{
					//alert('bg');
					bgLoadedFunc.apply(blurThis);
				}
			}
		);
	}else{
		showLoader(0);
		return;
	}
}

function swapActiveBlur() {
	var temp = pageShow;
	pageShow = pageBlur;
	pageBlur = temp;
}

function swapBoxBlur() {
	var temp = mboxShow;
	mboxShow = mboxBlur;
	mboxBlur = temp;
}

function showLoader(visible) {
	checkPokemon();
	if (visible) 
		$('#pagenav_keys #ani').fadeIn(200);
	else
		$('#pagenav_keys #ani').fadeOut(200);
}

function thumbsToggle(callback, ignoreBusy) {
	if (busy && !ignoreBusy) return;
	busy = true;
	showLoader(1);
	var targetWidth = ($('#wrapper_thumbs').outerWidth() != 0) ? 0:590;
	if (targetWidth == 0) {
		$('.overlay_thumbs').fadeOut(pageSpeed);
	}else{
		$('.overlay_thumbs').css({opacity: 0}).show().animate({opacity: 0.75}, {duration: pageSpeed, easing: pageEase});
	}
	$('#wrapper_thumbs').animate(
		{
			width: targetWidth
		}, 
		{
			duration: pageSpeed,
			easing: pageEase,
			complete: function() { 
				thumbsOpen = (targetWidth > 0);
				if(callback) {
					callback();
				}
			}
		}
	);
}

function thumbsNavToggle() {
	var contenty = $('#wrapper_thumbs .scroll-content').position().top;
	var contentbottom = contenty + $('#wrapper_thumbs .scroll-content').outerHeight();
	var wrapHeight = $('#wrapper_thumbs .scroll-wrap').outerHeight();
	if (contenty == 0) {
		$('.thumbs_nav a').eq(0).hide();
	}else{
		$('.thumbs_nav a').eq(0).show();
	}
	
	if (contentbottom <= wrapHeight) {
		$('.thumbs_nav a').eq(1).hide();
	}else{
		$('.thumbs_nav a').eq(1).show();
	}
	busy = false;
}

function attachNav() {
	$('.pagenav_btn #btn1').unbind('click').click(
		function(){
			if (!busy){
				if (scrollIndexV != 0) pageTracker._trackEvent('Navigation', 'Click', 'Up');
				scrollV(-1);
			}
			return false;
		}
	);
	$('.pagenav_btn #btn2').unbind('click').click(
		function(){
			if (!busy){
				if (scrollIndexV != sitemap.length - 1) pageTracker._trackEvent('Navigation', 'Click', 'Down');
				scrollV(01);
			}
			return false;
		}
	);  
	$('#menunav .hover').css({'background-color': '#006e69', 'opacity': 0.75, 'width': 0});
	$('#menunav #title').unbind('click').click(function () {$('#menunav .btn a').eq(0).trigger('click');});
	$('#menunav .btn a').each(
		function(index) {
			for (var i = 0; i < sitemap.length; i++){
				if (parseInt(sitemap[i][0].sec_no - 1) == index) {
					$(this).attr('href', "#" + sitemap[i][0].hash);
					break;
				}
			}
		}
	).click(
		function(i) {
			//alert('click');
			if (busy) {
				return false;
			}
			var clickIndex = $(this).parent().index();
			var foundScrollIndex = null;
			for (var j = 0; j < sitemap.length; j++) {
				if (parseInt(sitemap[j][0].sec_no) == clickIndex) {
					foundScrollIndex = (j-scrollIndexV);
					break;
				}
			}
			if (foundScrollIndex != null) {
				if (!thumbsOpen) {
					if (Math.abs(foundScrollIndex)) {
						pageTracker._trackEvent('Menu Primary', sitemap[j][0].hash);
						scrollV(foundScrollIndex);
					}
				}else{
					thumbsToggle(
						function () {
							busy = false;
							if (Math.abs(foundScrollIndex)) {
								pageTracker._trackEvent('Menu Primary', sitemap[j][0].hash);
								scrollV(foundScrollIndex);
							}else{
								showLoader(0);
							}
						}
					);						
				}
			}
			return false;
		}
	);
	
	$('#menunav .btn a').each(
		function(index){
			if (index != 2 && index != 3) return;
			$('#menunav .btn a').eq(index).unbind('click').click(
				function() {
					if (busy) { return false; }
					thumbsIndex = index - 2;
					if (thumbsOpen) {
						thumbsToggle(
							function() {
								updateThumbs();
								pageTracker._trackEvent('Gallery', 'Open', (thumbsIndex == 0) ? 'Case Studies': 'Projects');
								thumbsToggle(function (){busy = false; showLoader(0)}, true);
							}
						);
					}else{
						updateThumbs();
						pageTracker._trackEvent('Gallery', 'Open', (thumbsIndex == 0) ? 'Case Studies': 'Projects');
						thumbsToggle(function (){busy = false; showLoader(0)});
					}
					return false;
				}
			);
		}
	);
	
	$('#keys').unbind('click').click(
		function () {
			seenInstruct = false;
			doInstruction();
		}
	);

	$('#menunav_footer a').unbind('click');
	$('#menunav_footer a').eq(0).click(function() {pageTracker._trackEvent('Link Out', 'Facebook')});
	$('#menunav_footer a').eq(1).click(function() {pageTracker._trackEvent('Link Out',  'Twitter')});
	
	if (navigator.platform.indexOf("iPad") == -1 && navigator.platform.indexOf("iPod") == -1 && navigator.platform.indexOf("iPhone") == -1) {
		$('#menunav .btn a').unbind('hover').hover(
			function() {
				fadeNavIn.apply(this);
			}, 
			function() {
				var el = this;
				setTimeout(function() {
					if (!el.open) fadeNavOut.apply(el);
				}, 10);
			}
		);
	}else{
		$('#pagenav .notouch').removeClass('notouch');
	}
}

function updateThumbs() {
	if (thumbsIndex == 0) {
		$('#wrapper_thumbs .title').text('Case Studies');
	}else{
		$('#wrapper_thumbs .title').text('Projects');			
	}
	
	$('#wrapper_thumbs .scroll-content').css({top: 0});	
	//'<div class="item"><a href="#"><img src="" /><p class="caption">Popmarket</p></a></div>'
	var hashParent = (thumbsIndex == 0) ? 'cs/' : 'prj/';
	var items = '';
	for (var i = 0; i < sitemap.length; i++) {
		if (sitemap[i][0].thumb != undefined && sitemap[i][0].hash.indexOf(hashParent) == 0) {
			items = items + '<div class="item"><a href="#' + sitemap[i][0].hash + '" rel="' + i + '"><img src="' + sitemap[i][0].thumb + '" /><p class="caption">' + sitemap[i][0].sec_sub + '</p></a></div>';
		}
	}
	$('#wrapper_thumbs .scroll-content .items').html(items);
	
	thumbsNavToggle();
	
	$('#wrapper_thumbs .scroll-content .items .item a').click(
		function () {
			var deltaIndex =  parseInt($(this).attr('rel')) - scrollIndexV;
			//alert('scrollIndexV: ' + scrollIndexV  + "\n" + 'rel: ' + parseInt($(this).attr('rel')) + "\n");
			thumbsToggle(
				function(){
					busy = false;
					if (deltaIndex != 0) {
						pageTracker._trackEvent('Gallery', 'Item View', sitemap[scrollIndexV + deltaIndex][0].hash);
						scrollV(deltaIndex);
					}else{
						showLoader(0);
					}
				}
			);
			return false;
		}
	);
}

function attachNavThumbs(){
	$('.thumbs_nav a').each(
		function(index) {
			$(this).unbind('click').click(
				function() {
					if (busy) return;
					busy = true;
					var itemHeight = $('#wrapper_thumbs .item').eq(0).outerHeight();
					var content = $('#wrapper_thumbs .scroll-content');
					var direc = '-=';
					if (index == 0) direc = '+=';
					content.animate(
						{
							top: direc + itemHeight
						}, thumbsNavToggle
					);
					return false;
				}
			);
		}
	); 
	
	$('#wrapper_thumbs .closebtn a, .overlay_thumbs').unbind('click').click(
		function() {
			if (!busy) {
				pageTracker._trackEvent('Gallery', 'Close');
			}
			thumbsToggle(function (){busy = false; showLoader(0)});
			return false;
		}
	);
	$('#wrapper_thumbs .holder').mousewheel(
		function(e, delta) {
			if (delta > 0){
				if ($('.thumbs_nav a').eq(0).is(":visible"))
					$('.thumbs_nav a').eq(0).trigger('click');
			}else if (delta < 0) {
				if ($('.thumbs_nav a').eq(1).is(":visible"))
					$('.thumbs_nav a').eq(1).trigger('click');
			}
		}
	);


	$('#wrapper_thumbs .holder').touchwipe({
		noPageWipeUp: function () {
			if ($('.thumbs_nav a').eq(0).is(":visible"))
				$('.thumbs_nav a').eq(0).trigger('click');
		},
		noPageWipeDown: function () {
			if ($('.thumbs_nav a').eq(1).is(":visible"))
				$('.thumbs_nav a').eq(1).trigger('click');
		},
		preventDefaultEvents: true
	});
}

function attachNavInner(){
	$('.info .nav .keys #a a').unbind('click').click(
		function(){
			if (!busy){
				pageTracker._trackEvent('Navigation', 'Click', 'Left');
				scrollH(-1);
			}
			return false;
		}
	);
	$('.info .nav .keys #b a').unbind('click').click(
		function(){
			if (!busy){
				pageTracker._trackEvent('Navigation', 'Click', 'Right');
				scrollH(01);
			}
			return false;
		}
	);  
}


function attachNavJobs(){
	$('#job_details').slideUp(0);
	$('.joblink').each(
		function(){
			$(this).unbind('click').click(
				function(){
					if (busy) return;
					busy = true;
					pageTracker._trackEvent('JobView', $(this).text());
					showLoader(1);
					$('#job_details .ajax_holder').unbind('load').load($(this).attr('href'),
						function(){

							/*
							var addthisscript = document.createElement("script");
							addthisscript.type = "text/javascript";
							addthisscript.src = "http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5b347712cdd750";
							$('.applyshare',this).append(addthisscript);
							*/

							$('#job_details .ajax_holder').jScrollPane();
							$('#job_details').slideDown(pageSpeed / 2,
								function() {
									busy = false;
									showLoader(0);
									$('#job_details .ajax_holder').each(function(){if ($.browser.msie) {this.style.removeAttribute('filter')}}).jScrollPane();
									$('.jScrollPaneContainer').touchwipe({
										min_move_y: 	1,
										moveXY: function (dx, dy) {
											if (dy > 0) {
												$.jScrollPane.wheelFunc(null, -1);
											} else if (dy < 0) {
												$.jScrollPane.wheelFunc(null, 1);
											}
										},
										preventDefaultEvents: true 
									});
								}
							);
						}
					);
					return false;
				}
			);
		}
	);
	$('#job_details .back').unbind('click').click(
		function(){
			$('#job_details').slideUp(pageSpeed/2);
			return false;
		}
	);
}

function scrollHash() {
	if (document.location.href.indexOf('#') == -1) {
		scrollV(1);
		return;
	}else{
		for (var i = 0; i < sitemap.length; i++) {
			for (var j = 0; j < sitemap[i].length; j++) {
				if (document.location.href.split('#')[1] == sitemap[i][j].hash ) {
					scrollV(i+1, j);
					return;
				}
			}
		}
	}
	scrollV(1);
}

function init() {
	$(document).keydown(
		function(e){
			var ar = new Array(33,34,37,38,39,40,32);
			var key = /*e.charCode ? e.charCode :*/ e.keyCode ? e.keyCode : 0;
			if($.inArray(key,ar) > -1) {
				e.preventDefault();
				if (key == 33 || key == 38) {		if (!busy){ if (scrollIndexV != 0)					pageTracker._trackEvent('Navigation', 'Keyboard', 'Up'); 	scrollV(-1);}} 
				else if (key == 34 || key == 40) {	if (!busy){ if (scrollIndexV != sitemap.length - 1)			pageTracker._trackEvent('Navigation', 'Keyboard', 'Down'); 	scrollV(01);}} 
				else if (key == 37) {			if (!busy){ if (scrollIndexH != 0) 					pageTracker._trackEvent('Navigation', 'Keyboard', 'Left');	scrollH(-1);}} 
				else if (key == 39) {			if (!busy){ if (scrollIndexH != sitemap[scrollIndexV].length - 1)	pageTracker._trackEvent('Navigation', 'Keyboard', 'Right');	scrollH(01);}}
				else if (key == 32) { toggleMenus(); }
				return false;
			}
			return true;
		}
	);
	$(document).touchwipe({
		wipeUp: 	function(){ if (!busy){ if (scrollIndexV == 0) 					return; pageTracker._trackEvent('Navigation', 'Swipe', 'Up');   } scrollV(-1); },
		wipeDown: 	function(){ if (!busy){ if (scrollIndexV == sitemap.length - 1)			return; pageTracker._trackEvent('Navigation', 'Swipe', 'Down'); } scrollV(01); },
		wipeRight: 	function(){ if (!busy){ if (scrollIndexH == 0)					return;	pageTracker._trackEvent('Navigation', 'Swipe', 'Left'); } scrollH(-1); },
		wipeLeft: 	function(){ if (!busy){ if (scrollIndexH == sitemap[scrollIndexV].length - 1)	return;	pageTracker._trackEvent('Navigation', 'Swipe', 'Right');} scrollH(01); },
		preventDefaultEvents: true
	});
	
	/*
	wipeDown: 	function () {if (!busy){ pageTracker._trackEvent('Wipe', 'Down'); 	scrollV(01);}},
	wipeUp: 	function () {if (!busy){ pageTracker._trackEvent('Wipe', 'Up'); 	scrollV(-1);}},
	wipeRight: 	function () {if (!busy){ pageTracker._trackEvent('Wipe', 'Left'); 	scrollH(-1);}},
	wipeLeft: 	function () {if (!busy){ pageTracker._trackEvent('Wipe', 'Right');	scrollH(01);}},
	*/
	
	$(window).resize(resizeHandler);
	$('.bg').mousedown(
		function (e) { 
			e.preventDefault();
		}
	);

	resizeHandler(false);
	$(document).mousewheel(
		function (e, delta) {
			var obj = $(e.target)
			var objPath = '';
			var nopage = false;
			while(1) {
				objPath = obj[0].tagName + "|" + obj.attr('id') + '|' + obj.attr('class') + ' > ' + objPath;
				if (objPath.indexOf('nopage') > -1){
					nopage = true;
					break;
				}
				obj = obj.parent();
				if (!obj[0]) break;
				if (obj[0].tagName.toLowerCase() == 'body') break;
				
			}
			if (nopage) {
				//alert(objPath);
			}else{
				if (!busy) {
					if (!(scrollIndexV == 0 && delta > 0) && !(scrollIndexV == sitemap.length - 1 && delta < 0)) {
						pageTracker._trackEvent('Navigation', 'MouseWheel', (delta > 0) ? 'Up': 'Down');
					}
					scrollV(-delta);
				}
			}
		}
	);

	pageShow = $('#pageA');
	pageBlur = $('#pageB');
	mboxShow = $('#mboxA');
	mboxBlur = $('#mboxB');
	attachNav();
	attachNavThumbs();
	scrollHash();
}
init();
});
