var currentPage;
var portfolioPage;

function switchPage(sClass)
{
	/*
	 * Toggle text on each page except Portfolio
	 */
	 
	 if(currentPage == sClass) {
		return false;
	 }
	 
	 if(sClass == "portfolio") {
		sClass = "web";
	 }
	 
	 if(sClass == "directions") {
		sClass = "contact";
	 }
	 
	 $("#" + currentPage).css("display", "none");
	 
	var contents = $("#" + sClass).html();
	$(".text-block").css("width", "460px");
	if(sClass === "portfolio" || sClass === "web" || sClass === "print" || sClass === "branding" || sClass === "video") {
		$(".text-block").css("display", "none");
		
		$("#" + sClass).css("display", "block");
		$(".tabs").tabs().tabs("rotate", 4000); // Switch tab every 4 seconds
		
	}else if(sClass === "index") {
		$(".text-block").css("width", "220px");
		$(".text-block").css("display", "block").html(contents);
	} else {
		$(".text-block").css("display", "block").html(contents);
	}
	
	currentPage = sClass;
	
	if(currentPage == "company" || currentPage == "quickfacts") {
		$(".quickfacts").css("display", "block");
	}else {
		$(".quickfacts").css("display", "none");
	}
	
	if(currentPage == "contact" || currentPage == "directions") {
		$(".directions").css("display", "block");
	}else {
		$(".directions").css("display", "none");
	}
	
	if(currentPage == "portfolio" || currentPage == "web" || currentPage == "print" || currentPage == "branding" || currentPage == "video") {
		$(".web,.print,.branding,.video").css("display", "block");
	}else {
		$(".web,.print,.branding,.video").css("display", "none");
	}
	
}

function pageLoad() 
{
	/*
	 * Start of displaying no content
	 * See what hash is in URL, if none load Services
	 * otherwise load the text from the same element ID
	 */
	
	//alert(currentPage);
	
	$("#services, #portfolio, #company, #index, #contact, #careers, #quickfacts, #web, #print, #video, #branding").css("display", "none");

	//currentPage = page;
	switchPage("index");
}

$(document).ready(function() {

	pageLoad();

	$("#menu a").click(function() {
		switchPage($(this).attr('title'));
		//alert(currentPage);
	});
	
	$('#bg').jqFancyTransitions({
		width: 600,
		height: 300,
		effect: 'wave',
		position: 'bottom',
		delay: 3000,
	});
	
});


$(function(){
	// Soloy
	$(".video1").videopopup({
		'videoid' : '27451284',
		'videoplayer' : 'vimeo', 
		'autoplay' : 'true',
		'width' : '615',
		'height' : '355'
	});
	// Kla Ha Ya Days
	$(".video2").videopopup({
		'videoid' : '27450780',
		'videoplayer' : 'vimeo',
		'autoplay' : 'true',
		'width' : '615',
		'height' : '355'
	});
	// Orbit
	$(".video3").videopopup({
		'videoid' : '27447186',
		'videoplayer' : 'vimeo', 
		'autoplay' : 'true',
		'width' : '615',
		'height' : '392'
	});
	// Acrowood
	$(".video4").videopopup({
		'videoid' : '22720708',
		'videoplayer' : 'vimeo',
		'autoplay' : 'true',
		'width' : '620',
		'height' : '470'
	});
});
