function checkTopImage(){
 var currentID = $('.img_changer a.selected').attr("rel");
 currentID = parseInt(currentID);
 nextID = currentID+1;
	if (nextID == 5){
	nextID =1;
	}
 $('.image_holder .image').fadeOut(1000);
 $('.image_holder .'+nextID).fadeIn(1000);
 $('.img_changer a.selected').removeClass('selected');
 $('.img_changer a[rel='+nextID+']').addClass('selected');
}

theinterval = window.setInterval('checkTopImage()', 10000);

$(document).ready(function(){
	$('#seat_count').change(function() {
		var count = $(this).val();
		var input_base = document.createElement('input');
		var jcontainer = $('#delegate_list');
		input_base.className = 'validate[required]';
		input_base.type = 'text';
		for(var i = $('#delegate_list section').length + 1; i < count; ++i) {
			var rand = Math.floor(Math.random() * 32767);
			var container = document.createElement('section');
			var input_title = input_base.cloneNode(false);
			var input_firstname = input_base.cloneNode(false);
			var input_surname = input_base.cloneNode(false);
			var input_address1 = input_base.cloneNode(false);
			var input_address2 = input_base.cloneNode(false);
			var input_postcode = input_base.cloneNode(false);
			var input_telephone = input_base.cloneNode(false);
			var input_mobile = input_base.cloneNode(false);
			var input_email = input_base.cloneNode(false);
			var heading = document.createElement('h3');
			heading.className = 'cufon';
			heading.innerHTML = 'Delegate ' + (i + 1).toString();
			input_title.id = 'title' + rand;
			input_firstname.id = 'firstname' + rand;
			input_surname.id = 'lastname' + rand;
			input_address1.id = 'address1' + rand;
			input_address2.id = 'address2' + rand;
			input_postcode.id = 'postcode' + rand;
			input_telephone.id = 'telephone' + rand;
			input_mobile.id = 'mobile' + rand;
			input_email.id = 'email' + rand;
			
			input_title.name = 'title[]';
			input_firstname.name = 'firstname[]';
			input_surname.name = 'lastname[]';
			input_address1.name = 'address1[]';
			input_address2.name = 'address2[]';
			input_postcode.name = 'postcode[]';
			input_telephone.name = 'telephone[]';
			input_mobile.name = 'mobile[]';
			input_email.name = 'email[]';
			
			input_title.value = 'Title:';
			input_firstname.value = 'First Name:';
			input_surname.value = 'Last Name:';
			input_address1.value = 'Address 1:';
			input_address2.value = 'Address 2:';
			input_postcode.value = 'Postcode:';
			input_telephone.value = 'Telephone:';
			input_mobile.value = 'Mobile:';
			input_email.value = 'E-Mail:';
			
			container.appendChild(heading);
			container.appendChild(input_title);
			container.appendChild(input_firstname);
			container.appendChild(input_surname);
			container.appendChild(input_address1);
			container.appendChild(input_address2);
			container.appendChild(input_postcode);
			container.appendChild(input_telephone);
			container.appendChild(input_mobile);
			container.appendChild(input_email);
			
			jcontainer.append(container);
		}
		$("form").validationEngine();
		formprompt();
	});
	$("form").validationEngine();
			

$('table.zebra td:odd').addClass('color');
 $('a[href=#]').click(function(){
	    return false;
	    });
		
		$('a[href=#top]').click(function(){
	    $('html, body').animate({scrollTop:0}, 'slow');
	    return false;
	    });
		
		
		$('.dropdown#sports li ul').jScrollPane();
		$('.dropdown#sports li div.jScrollPaneContainer').css('margin-top', '6px');
		$('.dropdown#sports li div.jScrollPaneContainer').hide();
		
	$('#top_menu li').hover(function(){
		$(this).children('ul').stop().show();
  }, 
  function () {
		$(this).children('ul').stop().hide();
	});
	
  $('ul.dropdown li').hover(function(){
		$(this).children('ul').stop(true,true).show();
		$(this).children('div').stop(true,true).slideDown();

		
  }, 
  function () {
		$(this).children('div').stop(true,true).slideUp();

	});
	
$('#events_tab').click(function(){
$(this).addClass('selected');
$('#news_tab').removeClass('selected');
$('.whitetabs #news').fadeOut(function(){
$('.whitetabs #events').fadeIn();
});
});

$('#news_tab').click(function(){
$(this).addClass('selected');
$('#events_tab').removeClass('selected');
$('.whitetabs #events').fadeOut(function(){
$('.whitetabs #news').fadeIn();
});
});

$('.image_holder .image').hide();
$('.image_holder .1').attr('style', 'display:block');







$('.img_changer a').click(function(){
clearInterval(theinterval);
 var theID = $(this).attr('rel');
 $('.img_changer a.selected').removeClass('selected');
 $(this).addClass('selected');
 $('.image_holder .image').fadeOut(1000);
 $('.image_holder .'+theID).fadeIn(1000);
 theinterval = window.setInterval('checkTopImage()', 10000);

});


});

