$(document).ready(function() {
	var initList = $('#thumb a');
	var initListI = $('#thumb a img');
	var P = 0;
	var photoImg = $('#photo img');
	var prevState; activeState(0);
	var navlist = $('li'); var tab = $('#tabcontent');
	var info = $('.info'); var tabs = $('#tabs');
	var height = info.eq(0).height();
	tabs.css({'height' : height});
	info.each(function() { if (info.index(this) == 0) return; $(this).css('visibility','hidden'); });
	$('#a a').addClass('current'); var i = 8; var t = 10;
	$('#thumb').css({'height':'60px','padding':'0','margin':'0'});
	
	initList.each(function() { $(this).css('padding','0');
		if (initList.index(this) ==10) { i=8;t=60;$('#thumb').css('height','120px'); };
		$(this).css({'position':'absolute','left':i,'top':t}); i+=61;
	});

	makeWimpyPlayer();
	makeWimpyPlayer2();
	
	var runInitSource = window.setInterval(runInit, 5000);
	var runIniti = 1;
	function runInit() {
		if (runIniti > initList.length - 1) runIniti = 0;
		P = runIniti;
		var swap = initList[P];
		photoImg.attr('src',swap);
		activeState(P);
		runIniti++;
	};
	
	initList.mouseenter(function() {
		window.clearInterval(runInitSource);
		P = initList.index(this);
		var swap = $(this).attr('href');
		photoImg.attr('src',swap);
		activeState(P);
	});
	
	initList.click(function(e) {
		e.preventDefault();
	});

	navlist.click(function(e) {
		var index = navlist.index(this);
		if (index == 5) return;
		if (index == 6) index = 5;
		var w = $('.info').width();
		var pos = index * -w;
		height = info.eq(index).height();
		e.preventDefault();
		$('a.current').removeClass('current');
		$(this).children().addClass('current');
		for (var i=0;i<=5;i++) {
		info.eq(i).css('visibility','visible');
		}
		tabs.stop().animate({'height' : height});
		tab.stop().animate({ 'left' : pos},function() {info.not(info.eq(index)).css('visibility','hidden');});
		if (index == 2) {
			document.getElementById('wimpy').js_wimpy_stop();
		} else {
			document.getElementById('wimpy2').js_wimpy_stop();
		}
	});
		
	$('#bname').focus(function() {
		if ($(this).attr('value') == 'Name') $(this).attr('value','');
	}).blur(function() {if ($(this).attr('value') == '') $(this).attr('value','Name');});
	
	$('#bphone').focus(function() {
		if ($(this).attr('value') == 'Phone') $(this).attr('value','');
	}).blur(function() {if ($(this).attr('value') == '') $(this).attr('value','Phone');});
	
	$('#bemail').focus(function() {
		if ($(this).attr('value') == 'Email') $(this).attr('value','');
	}).blur(function() {if ($(this).attr('value') == '') $(this).attr('value','Email');});
	
	var temp;
	$('#links a img').hover(function() { $(this).stop().animate({"width":"80","marginLeft":"-20","top":"-=10"},100) }
		,function() { var value = temp; $(this).stop().animate({"width":"57","marginLeft":"0","top":"0"},100) });

function activeState(a) {
/****Changes border around active Image****************/
	if (a == prevState) return;
	var b = initListI.eq(prevState);
	var c = initListI.eq(prevState+1);
	var d = initListI.eq(prevState-1);
	var e = initListI.eq(a);
	var f = initListI.eq(a+1);
	var g = initListI.eq(a-1);
	b.stop().animate({'width' : '50px', 'marginTop' : '0','marginLeft':'0px'},100);
	
	prevState = a;
	e.stop().animate({'width' : '62px', 'marginTop' : '-4px','marginLeft':'-7px'},100);
	
}

$(function() {
$('#submit').click(function() {	var name = $('#name').val(); var email = $('#email').val(); var message = $('#message').val(); var Err1 = $('label[for="name"]'); var Err2 = $('label[for="email"]'); var Err3 = $('label[for="message"]');if (name == "" || email == "" || message.length < 15) {	if (name == "") {Err1.html('<span class="red">Please enter your name.</span>');} else {Err1.html('Your Name:');}if (email == "") {Err2.html('<span class="red">Please enter your Email address.</span>');} else {Err2.html('Your Email Address:');}if (message.length < 15) {Err3.html('<span class="red">Please enter a more detailed message.</span>');} else {Err3.html('Your Message:');}return false;} else {
$('.red').text('');return true;}});});

$(function() {
$('#bsubmit').click(function() {
	var name = $('#bname').val();
	var phone = $('#bphone').val();
	var email = $('#bemail').val();
	var details = $('#bdetails').val();
	var message = 'Please fill out the form completely before submitting.';
	if (name == '' || name == 'Name') {alert(message);return false;}
	if (email == '' || email == 'Email') {alert(message);return false;}
	if (details == '') {alert(message);return false;}
}); });
});