function changeZ(isOn)
{
	el = document.getElementById('contact');
	if(isOn)
	{
		el.style.zIndex=1;
	} else
	{
		el.style.zIndex=1000;
	}
}
function show_div(which) {
	
	$('#content div.current').removeClass('current').addClass("hidden");
	$('#content div#'+which).toggleClass("hidden").addClass("current");

	setSubnav(which, true);
	goToByScroll("top");
	return false;
}
function show_photos() {
	
	$('#content div.current').removeClass('current').addClass("hidden");
	$('#content div#photos').toggleClass("hidden").addClass("current");
	$('ul.thumbnails').toggleClass('hidden');
	setSubnav("photos", true);
	goToByScroll("top");
	return false;
}
function toggle_el(el, caller, id)
{
	var o = $(el+"[id^="+id+"]");
	o.removeClass("hidden");
	
	$(el+"[id^="+caller.id+"]").siblings().each(function(index){
		if(this.nodeName=="DIV")
		{
			$(this).addClass("hidden");	
		}
	});	
	$('#subsub li a').each(function(index)
	{
		if($(this).hasClass("current"))
		{
			$(this).toggleClass("current");
		}
	});
	$('#subsub li a#'+id).toggleClass("current");
	//$(caller).toggleClass("current");
	
}
function setSubnav(which, addCaret){
	
	if($('#subnav a.current'))
	{
		$('#subnav a.current').text($('#subnav a.current').text().replace(" >", ""));
	}
	$('#subnav a.current').removeClass("current");
	$('#subnav a#'+which).addClass("current");
	if(addCaret)
	{
		$('#subnav a#'+which).append(" >");
	}
}
// ==============
// = SLIDE HERE =
// ==============
function goToByScroll(id){
     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
// ================
// = TALKERS HERE =
// ================
$(document).ready(function() {
	$("a.talker").talkerEvent();
	$("a.tn").thumb();
	$("a.code_words").code_words();
});

jQuery.fn.talkerEvent = function() {
	hideBios();
	return this.each(function(){
		var caller = this;
		var elem = "#code_talkers a#"+caller.id;
		var htm = $(elem).text();
		var curHtm;
		$(caller).hover(
			function () {
				if( $(elem).hasClass("current") )
				{
					return false;
				} else
				{
					$(elem).toggleClass("active").append(" >");
				}
            },
            function() {
				$(elem).toggleClass("active");
				if( $(elem).hasClass("current") )
				{
					return false;
				} else
				{
					$(elem).text(htm);
				}
            }
		);
		$(caller).click(function (event) {	
			if($(caller).hasClass("current")){}else{
				//$(caller).text().replace(" >", ""));
				revealBio(caller.id);
			}
			return false;
		})
	})
}
function hideBios()
{
	$('div.bio').fadeOut("fast");
}
function revealBio(which, addCaret)
{
	setSubnav(which, false);
	//$('#subsub a#bio').addClass("current");
	var div = "div#talker-"+which;
	
	if($("div.active").length>0)
	{
		$("div.active").fadeOut("normal");//.removeClass("active").addClass("hidden");
		$(div).removeClass("hidden").addClass("active").fadeIn("normal");
	} else
	{
		$("#talkers").fadeOut("normal");
		$(div).removeClass("hidden").addClass("active").fadeIn("normal");
	}
}
// =========================
// = THUMBNAIL PHOTOS HERE =
// =========================
jQuery.fn.thumb = function() {
	return this.each(function(){
		var caller = this;
		$(caller).click(
			function (event) {	
				revealImg(caller.id);
				return false;
			}
		)
	})
}
function revealImg(id)
{
	var img = $('div#img-'+id);
	if($(img).hasClass("current"))
	{
		$(img).toggleClass('hidden').removeClass("current");//.css("padding", "8px 7px 5px 7px");
	} else
	{
		$(img).toggleClass('hidden').addClass("current");//.css("padding", "8px 7px 5px 7px");
	}
	$('ul.thumbnails').toggleClass('hidden');
}
function hide_div(el)
{
	var p = $(el).parent().get(0).id;
	$('div#'+p).toggleClass('hidden');
	$('ul.thumbnails').toggleClass('hidden');//.css("padding", "0");;
}

// ===================
// = CODE WORDS HERE =
// ===================

jQuery.fn.code_words = function() {
	return this.each(function(){
		var caller = this;
		var word = $(caller).text();
		var code = $(caller).attr("title");
		
		$(caller).hover(
			function () {
				$(caller).text(code);
            },
            function() {
				$(caller).text(word);
            }
		);
	})
}
// ============================
// = BLANK INPUT TEXT DEFAULT =
// ============================

function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
