// Page Init;


function pageValidate(){
	// Open correct page
	var hashTag = (window.location.hash);
	var locid = hashTag.split('?');
	$("#content").find(".link").removeClass("active");
	$('input.validate').val(locid);
	if(locid[0] == '#casestudies' && locid[1] == 'main') {
		$(".home, .services, .people, .blog").hide();
		$(".casestudies, #menuarea").show();
		$(".casebutton").addClass("active");
		clearAll();
	};
	if(locid[0] == '#services') {
		$(".home, .casestudies, .people, .blog").hide();
		$(".services, #menuarea").show();
		$(".servbutton").addClass("active");
	};
	if(locid[0] == '#blog') {
		$(".home, .casestudies, .people, services").hide();
		$(".blog, #menuarea").show();
		$(".blogbutton").addClass("active");
	};
	if(locid[0] == '#people') {
		$(".people, #menuarea").show();
		$(".peopbutton").addClass("active");
		$(".home, .services, .casestudies, .blog").hide();
	}; 
	if (locid[0] == '#home') {
		$(".services, .casestudies, .people, #menuarea, .blog").hide();
		$(".home").show("500");
	};
	if (locid[0] == '#casestudies' && locid[1] != 'main') {
			$(".home, .services, .people, .blog").hide();
			$(".casestudies, #menuarea").show();
			$(".casebutton").addClass("active");
			var $thisExpandW = $(".casewrapper["+locid[1]+"]");
				$thisExpandW.slideDown();			
				$(".returnCase", $thisExpandW).fadeIn();
			$("#caseMenu").slideUp();
	};
	
}

function clearAll(){
	var hashTagClear = (window.location.hash);
	var locidClear = hashTagClear.split('?');
	if (locidClear[0] == '#casestudies'){ window.location.hash = "#casestudies?main" };
	$("body").find(".tooltip").hide();
	$('body').find("div.peopClass").next().next().slideUp();
	$('body').find("div.peopClass").removeClass('active');
	$('body').find("div.returnCase").fadeOut();
	$(".casewrapper").slideUp();
	$("#caseMenu").slideDown();
	var $contact = $('body').find("#location");
	$contact.animate({
		"height": "0",
		"width": "0",
		"left": "50%",
		"top": "50%"
		}, 200, function(){
		$contact.hide();
		});
}

$(document).ready(function() {
  $(".services, .casestudies, .people, #menuarea, .blog").hide();
	var locid = (window.location.hash);
	if (locid == '') {
		window.location.hash = "#home";
	};
	pageValidate();
});

// Faux Center
function centerIncr(){
	var winW = $(window).width();
	var divW = (winW - (626))/2;
	if (divW > 0){
		var modW = Math.floor(divW / 126);
	}
	else {
	var finW = 0
	var modW = 0
	}
	var finW = 126 * modW;
	$('#homelink').stop().animate({ 'margin-left': finW }, 450);
	$('#contentWrapper').stop().animate({ 'margin-left': finW }, 500);
	$('#footerContent').stop().animate({ 'margin-left': finW - 50 }, 550);
	if (modW <= 0){
		$('#footerContent').stop().animate({ 'margin-left': finW }, 550);
	}
};

function centerZero(){

	$('#homelink').stop().animate({ 'margin-left': 0 }, 450);
	$('#contentWrapper').stop().animate({ 'margin-left': 0 }, 500);
	$('#footerContent').stop().animate({ 'margin-left': 0 }, 550);
};






// CrossSlider Definitions;
$(document).ready(function() {
	$('#placeholder').crossSlide({
	  fade: 1
	}, [
	  {
		src:  'pics/imgIndep.jpg',
		from: '50% 50% .5x',
		to:   '50% 10% .75x',
		time: 3
	  }, {
		src:  'pics/imgTele.jpg',
		from: '0% 80% .75x',
		to:   '80% 0% 1x',
		time: 2
	  }, {
		src:  'pics/imgInfra.jpg',
		from: '100% 80% .75x',
		to:   '80% 0% .5x',
		time: 2
	  }, {
		src:  'pics/imgDesign.jpg',
		from: '100% 50% .5x',
		to:   '30% 45% .8x',
		time: 2
	  }
	]);
});

function ImgError(source){
	source.onerror = "";
    source.src = "pics/people/bioNA.jpg";
    return true;
}

	$('#textcycle').cycle({ 
		cleartype:  false, // disable cleartype corrections 
		delay: 0,
		speed: 1200,
		timeout: 8000,
		pause: 1
	});



