// JavaScript Document


	var slide = 1;
	var timer = setInterval('inc()', 5000);
	
	function inc() {
		slide = slide + 1;
		if(slide > 5) {
			slide = 1;
		}
		transFade(slide);
	}
	
	function pauseTimer() {
		clearInterval(timer);
	}
	function startTimer() {
		timer = setInterval('inc()', 5000);
	}

	function transFade(id){
		if(id == 1){
			$('.feat1').fadeIn('slow');
			$('.feat2').fadeOut('slow');
			$('.feat3').fadeOut('slow');
			$('.feat4').fadeOut('slow');
			$('.feat5').fadeOut('slow');
		}
		if(id == 2){
			$('.feat1').fadeOut('slow');
			$('.feat2').fadeIn('slow');
			$('.feat3').fadeOut('slow');
			$('.feat4').fadeOut('slow');
			$('.feat5').fadeOut('slow');
		}
		if(id == 3){
			$('.feat1').fadeOut('slow');
			$('.feat2').fadeOut('slow');
			$('.feat3').fadeIn('slow');
			$('.feat4').fadeOut('slow');
			$('.feat5').fadeOut('slow');
		}
		if(id == 4){
			$('.feat1').fadeOut('slow');
			$('.feat2').fadeOut('slow');
			$('.feat3').fadeOut('slow');
			$('.feat4').fadeIn('slow');
			$('.feat5').fadeOut('slow');
		}
		if(id == 5){
			$('.feat1').fadeOut('slow');
			$('.feat2').fadeOut('slow');
			$('.feat3').fadeOut('slow');
			$('.feat4').fadeOut('slow');
			$('.feat5').fadeIn('slow');
		}
		slide = id;
	}
	

$(document).ready(function(){
			
				
				$('.sidebar_block1').animate({
					marginTop: "10px",
					opacity: 1
				  }, 300, function() {
					$('.sidebar_block2').animate({
					marginTop: "-50px",
					opacity: 1
					  }, 300, function() {
						$('.sidebar_block1_2').animate({
						marginTop: "-50px",
						opacity: 1
						  }, 300, function() {
							$('.sidebar_block3').animate({
							marginTop: "-50px",
							opacity: 1
							  }, 300, function() {
								
								$('.sidebar_inner1').animate({
								opacity: 1
								  }, 200, function() {
									$('.sidebar_inner2').animate({
									opacity: 1
									  }, 200, function() {
										$('.sidebar_inner1_2').animate({
										opacity: 1
										  }, 200, function() {
											$('.sidebar_block3_top h2').animate({
											opacity: 1
											  }, 200, function() {
																						
												  });	
														$('.sidebar_inner3').animate({
														opacity: 1
												  }, 200, function() {
																						
											  });								
										  });										
									  });
									
								  });
								
							  });
						  });
					  });
				  });
				
				$("ul.topnav li").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $(this).find("ul.children").fadeIn('fast');
				}, function() {
					$(this).data("timeout", setTimeout($.proxy(function() {
						$(this).find("ul.children").fadeOut();
					}, this), 500));
				});
				$(document).click(function() {
					$('ul.children:visible').fadeOut();
				});
				
				
				$(".nav_visitors").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_visitors').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_visitors').fadeOut();
					}, this), 500));
				});
				
				$(".nav_visitors2").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_visitors2').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_visitors2').fadeOut();
					}, this), 500));
				});
				
				$(".nav_exhibitors").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_exhibitors').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_exhibitors').fadeOut();
					}, this), 500));
				});
				
				$(".nav_competitors").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_competitors').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_competitors').fadeOut();
					}, this), 500));
				});
				
				$(".nav_society").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_society').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_society').fadeOut();
					}, this), 500));
				});
				
				/*
				$(".nav_contact").hover(function() {
				  var timeout = $(this).data("timeout");
				  if(timeout) clearTimeout(timeout);
				  $('.dropdown_contact').fadeIn();
				}, function() {
					
					$(this).data("timeout", setTimeout($.proxy(function() {
						$('.dropdown_contact').fadeOut();
					}, this), 500));
				});
				*/
				
				
				
				$(document).click(function() {
					$('.dropdown_visitors').fadeOut();
				});
});


var filter = ":not(:submit,:radio,:checkbox,:hidden)";
var errors = false;
var selected = false;

$(function(){

	$('input' + filter + ', textarea').each(function(){
		if($(this).attr('placeholder-text')!='' && $(this).attr('placeholder-text')!=undefined)
			$(this).after('<span class="placeholder" onclick="$(this).parent().find(\'input,textarea\').focus();">'+$(this).attr('placeholder-text')+'</span>');
		if($(this).val()!='')
			$(this).next().hide();
	});
	
	$('input' + filter + ', textarea').focus(function(){
		if($(this).val()==''){
			$(this).parent().find('span.placeholder').fadeTo(100, 0.5);
		}
	});
	$('input' + filter + ', textarea').blur(function(){
		if($((this)).val()==''){
			$(this).parent().find('span.placeholder').fadeTo(100, 1);
		}
		else
		{
			$(this).parent().find('span.placeholder').hide();
		}
		$('.error-tip').fadeOut('fast', function(){
			$(this).remove();
		});
	});
	
	$('input' + filter + ', textarea').keyup(function(){
		if($((this)).val()==''){
			$(this).parent().find('span.placeholder').fadeTo(100, 1);
		}
		else
		{
			$(this).parent().find('span.placeholder').hide();
		}
	});
	
	$('a.ui-state-default').click(function(){
		$('input' + filter + ', textarea').each(function(){
			if($(this).val()!='')
				$(this).parent().find('span.placeholder').hide();
		});
	});

});
 
function validateForm(formClass){
	
	$('form.'+formClass).submit(function(){
		
		$('.error-tip').remove();
		
		errors = false;
		selected = false;
		
		$('form.'+formClass + ' input' + filter + ', form.'+formClass + ' textarea').each(function(){
			
			if($(this).attr('required-field')=="required" && $(this).val()==''){
				errors = true;
				
				if($(this).attr('error-message')!=undefined)
					$(this).after('<span class="error-tip" style="display:none;">'+$(this).attr('error-message')+'</span>');
				else
					$(this).after('<span class="error-tip" style="display:none;">This field is required</span>');
				$('.error-tip').fadeIn('fast');
				
				if(selected == false){
					$(this).focus();
					selected = true;
					return false
				}
			}
			
		});
		
		if(errors==false && selected == false){
			
			/*$('form.'+formClass + ' input' + filter + ', form.'+formClass + ' textarea').each(function(){
				if($(this).val()==$(this).attr('placeholder-text')){
					$(this).val('');
				}
			});*/
			
			$('form.'+formClass).submit();
		}
		
		return false;
		
	});
	
	return false;
	
}

function validateFormAjax(formClass){
	
	//$('form.'+formClass).submit(function(){
		
		$('.error-tip').remove();
		
		errors = false;
		selected = false;
		
		$('form.'+formClass + ' input' + filter + ', form.'+formClass + ' textarea').each(function(){
			
			if($(this).attr('required-field')=="required" && $(this).val()==''){
				errors = true;
				
				$(this).after('<span class="error-tip" style="display:none;">This field is required</span>');
				$('.error-tip').fadeIn('fast');
				
				if(selected == false){
					$(this).focus();
					selected = true;
					return false
				}
			}
			
		});
		
		if(errors==false && selected == false){
			
			/*$('form.'+formClass + ' input' + filter + ', form.'+formClass + ' textarea').each(function(){
				if($(this).val()==$(this).attr('placeholder-text')){
					$(this).val('');
				}
			});*/
			
			$('form.'+formClass).submit();
		}
		
		return false;
		
	//});
	
	//return false;
	
}
