
function thumb(thumb)
{
	$("#thumbLinks a").removeClass('on');
	$("#tl"+thumb).addClass('on');
	$.get('work.php', { offset: thumb }, function(data) {
		$('#workThumbContainer').hide();
		$('#workThumbContainer').html(data);
		$('#workThumbContainer').fadeIn('slow');
	});
}

function spotlight(id) 
{
	//alert(id);
  //get the position of the placeholder element
  var pos = $(id).offset();  
  var width = $(id).width();
  //show the menu directly over the placeholder
  $("#thumbSpotlight").css( { "left": (pos.left - 320) + "px", "top": (pos.top - 120) + "px" } );
  $("#thumbSpotlight").html($(id).html());
  $("#thumbSpotlight").show();
}

//preload nav bgs
// counter
var i = 0;

// create object
imageObj = new Image();

// set image list
images = new Array();
images[0]	=	"/vdz/images/navServices.png"
images[1]	=	"/vdz/images/navWork.png"
images[2]	=	"/vdz/images/navContact.png"
images[3]	=	"/vdz/images/navAbout.png"
images[4]	=	"/vdz/images/workLeftOn.png"
images[5]	=	"/vdz/images/workRightOn.png"


// start preloading
for(i = 0; i <= 5; i++) 
{
	imageObj.src=images[i];
}


//services toggle
var sectionCur = 'consult';
var sectionState = 'open';

function services(sectionNew) 
{
		if (sectionCur != sectionNew)
		{
			$('#'+sectionCur+'Img').attr({src: '/vdz/images/'+sectionCur+'Plus.png'});
			$('#'+sectionNew+'Img').attr({src: '/vdz/images/'+sectionNew+'Minus.png'});
			$('#'+sectionNew).show('fast');
			$('#'+sectionCur).hide('fast');
			sectionState = 'open';
		}
		else if (sectionCur == sectionNew)
		{
			if (sectionState == 'open')
			{
				$('#'+sectionNew+'Img').attr({src: '/vdz/images/'+sectionNew+'Plus.png'});
				sectionState = 'close';
			}
			else
			{
				$('#'+sectionNew+'Img').attr({src: '/vdz/images/'+sectionNew+'Minus.png'});
				sectionState = 'open';
			}
			$('#'+sectionNew).toggle('fast');
		}
		sectionCur = sectionNew;
}



//function to check hash to send to new section
$(function(){

  // Bind the event.
  $(window).hashchange( function(){
    // Alerts every time the hash changes!
    //alert( location.hash );
		setPage(location.hash);
  })

  // Trigger the event (useful on page load).
  $(window).hashchange();

});


//get location
function what()
{
	var pos = $("#content").position();
	alert(pos.left + " " + pos.top);
}

//main nav to sections
var bgTop;
var bgLeft;
var navImage;
var section;
var sectionMain;
var sectionSub = 'xxx';

function setPage(section)
{
	
	//section = location.hash;
	
	sectionMain = section.split('/',3)[0];
	sectionSub = section.split('/',3)[1];
	
	if (section == '') sectionMain = '#gohome';
		
	if (sectionMain == '#gohome')
	{
		bgTop = '0px';
		bgLeft = '0px';
		navImage = 'navBlank.gif';
	}
	else if (sectionMain == '#gowork')
	{
		bgTop = '-1487px';
		bgLeft = '0px';
		navImage = 'navWork.png';
	}
	else if (sectionMain == '#goservices')
	{
		bgTop = '0px';
		bgLeft = '-1290px';
		navImage = 'navServices.png';
	}
	else if (sectionMain == '#gocontact')
	{
		bgTop = '-1467px';
		bgLeft = '-1290px';
		navImage = 'navContact.png';
	}
	else if (sectionMain == '#goabout')
	{
		bgTop = '-2700px';
		bgLeft = '-1290px';
		navImage = 'navAbout.png';
	}
	
	$('#navImage').attr('src','/vdz/images/'+navImage);
			
	$('#content').animate({
		left: bgLeft, 
		top: bgTop}, {
		duration: 1000, 
		easing: 'easeOutBack', 
		complete: workItOut()}
	);
		
}

//drop in 18 thumbs for work section
var wt = 1;
function setWork()
{
	if (sectionMain == '#gowork' && wt <= 18)
	{
		$('#wt'+wt).switchClass('wtAni', 'wtStatic', 400);	
		wt++;
		setTimeout("setWork('#gowork')", 100);
	}
	
	//if (sectionSub != 'xxx') workSet(sectionSub);
}

function workItOut()
{
	
	if (sectionSub != 'xxx')
	{
		workSet(sectionSub);
	}
	
	setWork();
}

//load work thumbs
function loadThumbs(offset)
{
	$.get('/vdz/work.php', { workOffset: offset }, function(data) {
		$('#workThumbContainer').hide();
		$('#workThumbContainer').html(data);
		$('#workThumbContainer').fadeIn('slow');
	});
	//alert(offset);
}

function workSet(set)
{
	$.get('/vdz/workSet.php', { set: set }, function(data) {
		$('#workContent').html(data);
		
		//re init with new div content
		$('#workContent').cycle({
			fx:     'fade',
			speed:  'fast',
			timeout: 0,
			next:   '#workRight',
			prev:   '#workLeft'
		});
	});
}
