var tab = [];
var tab_index = 0;
var title = "JSV3D.COM";

function content(mytitle, mytitle_src, myicon_src, mytab_src, mycontent_src)
{
	this.title 			= mytitle;
	this.title_src 		= mytitle_src;
	this.icon_src 		= myicon_src;
	this.tab_src 		= mytab_src;
	this.content_src 	= mycontent_src;
}

function initialize()
{
	//tab.push(new content('home','img/font/blank.png','img/buttons/home.png','img/tabs/home.png','content/home.html'));
	tab.push(new content('3d','img/font/3d.png','img/buttons/3d.png','img/tabs/3d.png','content/3d/3d.html'));
	tab.push(new content('reel','img/font/reel.png','img/buttons/reel.png','img/tabs/reel.png','content/reel/reel.html'));
	tab.push(new content('toys','img/font/toys.png','img/buttons/toys.png','img/tabs/toys.png','content/toys/toys.html'));
	tab.push(new content('decks','img/font/decks.png','img/buttons/decks.png','img/tabs/decks.png','content/decks/decks.html'));
	tab.push(new content('drawings','img/font/drawings.png','img/buttons/drawings.png','img/tabs/drawings.png','content/traditional/traditional.html'));
	tab.push(new content('vector','img/font/vector.png','img/buttons/vector.png','img/tabs/vector.png','content/vector/vector.html'));
	tab.push(new content('photo','img/font/photo.png','img/buttons/photo.png','img/tabs/photo.png','content/photo/photo.html'));
	tab.push(new content('resume','img/font/resume.png','img/buttons/resume.png','img/tabs/resume.png','content/resume/resume.html'));
	tab.push(new content('contact','img/font/contact.png','img/buttons/contact.png','img/tabs/contact.png','content/contact/contact.html'));

	//tab.push(new content('tutorials','img/font/blank.png','img/buttons/tutorials.png','img/tabs/tutorials.png','content/tutorials/tutorials.html'));
	//tab.push(new content('fun','img/font/fun.png','img/buttons/fun.png','img/tabs/fun.png','content/indev/indev.html'));

	tab.push(new content('links','img/font/links.png','img/buttons/links.png','img/tabs/links.png','content/links/links.html'));
}

function load_anchor()
{
	var hash = window.location.hash.substr(1);
	
	for(var i=0;i<tab.length;i++)
	{
		if(hash==tab[i].title)
		{
			tab_index = i;
			set_tab();
			return;
		}
	}
}

function set_tab()
{
	if (!document.getElementById) 
		return true;
		
	document.getElementById('selection').src 		= tab[tab_index].tab_src;
	document.getElementById('selection').title 		= tab[tab_index].title;
	document.getElementById('title').src 			= tab[tab_index].title_src;
	document.getElementById('title').title 			= tab[tab_index].title;
	window.location.hash = tab[tab_index].title;
	fetch_content(tab[tab_index].content_src);
	
	document.title = title + " | " + tab[tab_index].title.toUpperCase();
}

function set(hash)
{
	for(var i=0;i<tab.length;i++)
	{
		if(hash==tab[i].title)
		{
			tab_index = i;
			set_tab();
			return;
		}
	}
	set_tab();
}


function next_tab(obj)
{
	if (tab_index >= tab.length)
		tab_index = 0;
	else
		tab_index++;	

	set_tab();
}

function prev_tab(obj)
{
	if (tab_index <= 0)
		tab_index = tab.length;
	else 
		tab_index--;

	set_tab();
}

function fetch_content(src)
{
	if (window.XMLHttpRequest)
		xmlhttp=new XMLHttpRequest();
	else
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		document.getElementById("content").innerHTML=xmlhttp.responseText;
		initLightbox();
	}
	xmlhttp.open("GET",src,true);
	xmlhttp.send();
	document.getElementById('content').innerHTML = "<div style='padding-top:200px'><img src='img/loading.gif' title='loading content' /><br />loading...</div>";
	
	}

function load_thumb(obj)
{
	if (!document.getElementById) 
		return true;
		
	var url = obj.src.toString().replace("t-","p-");
	var url = url.toString().replace(".png",".jpg");
	
	document.getElementById('focus').src = obj.src;
	document.getElementById('focus_link').href = url;
	
}
