function resetFields(whichform) {

	var url = window.location.href;

	if(url.indexOf("do=send")<0) {

		for (var i=0; i<whichform.elements.length; i++) {
			var element = whichform.elements[i];

			if(element.type == "submit") continue;
			if(element.type == "radio") continue;
			if(element.type == "checkbox") continue;
			if(!element.defaultValue) continue;

			element.onfocus = function() {
				if(this.value == this.defaultValue) this.value = "";
			}
			element.onblur = function() {
				if(this.value == "") this.value = this.defaultValue;
			}
		}
	}
}
function prepareForms() {
	for(var i=0; i<document.forms.length; i++) {
		resetFields(document.forms[i])
	}
}

function defeatFocusRects() {
	a = document.getElementsByTagName("a");
	al = a.length;
	while(al--) {
		a[al].onfocus = function() {
			this.blur();
		}
	}
}

$(document).ready(function() {
	$('#visual img').removeClass("h");
	$('#layer').fadeOut(6000);
	$('#metanav a:last').css("background-image","none");
	$('.textbox p:last').css("margin-bottom", "0");
	$('.more').each(function(){
		tp = $(this).prev();
		ta = $(this).find("a");
		$(tp).append(ta);
		$(this).remove();
	});
	$(window).scroll(function () { 
	      $('#backtotop').removeClass("h"); 
	});
	$("#pikachoose").PikaChoose();
	//$("ul#pikachoose").hide();
	function resetThumbs() {
		$('#thumbs img').each(function(){
			src = $(this).attr("src");
			src = src.replace("_on","");
			$(this).attr("src",src);
		});
	}
	$('.detail').hide();
	$('#tc_1').show();
	$('#thumbs').removeClass("h");
	$('#thumbs img').click(function(){
		resetThumbs();
		src = $(this).attr("src");
		bid = src.replace("th_","");
		src = src.replace(".jpg","_on.jpg");
		$(this).attr("src",src);
		$('#team_big').attr("src",bid);
		tid = $(this).attr("id");
		tid = tid.replace("h","c");
		tid = "#"+tid;
		$('.detail').hide();
		$(tid).show();
	});
	
	
	$("a[href^=http]").each(
	   function(){
		  if(this.href.indexOf(location.hostname) == -1) { 
	      $(this).attr('target', '_blank');
	    }
	});
	$("a[href*=pdf]").each(
	   function(){
	      $(this).attr('target', '_blank');
	});
	
	prepareForms();
	defeatFocusRects();
});




