$(document).ready(function(){
	banner_slider = $('#banner_slider');
	var slido_timer;
	slider_construct = banner_slider.children();
	img_item = slider_construct.children();
	navigator_item = $('.banner_navigator').children();
	slider_construct.width(img_item.length*banner_slider.width());
	for(i=0;i<img_item.length;i++){
		$(navigator_item[i]).bind('click',i,function(c){
			x = c.data;
			banner_slider.animate({
											scrollLeft:x*banner_slider.width()
										},'slow',function(){
											clearInterval(slido_timer);
											slido_timer = setInterval(function(){
													if(banner_slider.scrollLeft() == banner_slider.width()*(img_item.length-1)){
														banner_slider.animate({
																						scrollLeft:0
																					},'slow');
													}else{
														banner_slider.animate({
																						scrollLeft:"+="+banner_slider.width()
																					},'slow');
													}
											},4000);
										});
		});
	}
	
	slido_timer = setInterval(function(){
			if(banner_slider.scrollLeft() == banner_slider.width()*(img_item.length-1)){
				banner_slider.animate({
												scrollLeft:0
											},'slow');
			}else{
				banner_slider.animate({
												scrollLeft:"+="+banner_slider.width()
											},'slow');
			}
	},4000);
});

function slideMenu(menu,me){
	menus = $('.sub_menu');
	$menu = $(menu);
	if(menu.css('display') == 'none'){
		menus.slideUp();
		menu.slideDown();
	}
	$active_menus = $('.activemenu');
	$active_menus.attr('class','');
	$(me).attr('class','activemenu');
}

function show_panel(container,position,callback){
	var hider = $('.hider');
	fWidth = $(window).width();
	fHeight = $(window).height();
	nWidth = $(container).width();
	nHeight = $(container).height();
	LeftSpace = (fWidth-nWidth)/2;
	TopSpace = (fHeight-nHeight)/2;
	if(position == 'bottom'){
		hider.fadeIn();
		$(container).css({zIndex:'999',position:'fixed',bottom:'2px',left:LeftSpace+'px'})
		.fadeIn('fast',function(){
			if(callback){
				setTimeout(callback+"()",300);
			}																																																							
		});
		hider.click(function(){
			$(container).fadeOut('fast',function(){
				hider.hide();
			});
		});
	}
	if(position == 'free'){
		hider.show();
		$(container).fadeIn();
		hider.click(function(){
			$(container).fadeOut('fast',function(){
				hider.hide();
			});
		});
	}else{
		gheight = (nHeight-fHeight)/2;
		scrollHeight = $(window).scrollTop()-gheight;
		hider.show();
		$(container).css({zIndex:'999',position:'absolute',top:scrollHeight+'px',left:LeftSpace-50+'px'}).fadeIn('fast',function(){
			if(callback){
				setTimeout(callback+"()",300);
			}																																																							
		});
		hider.click(function(){
			$(container).fadeOut('fast',function(){
				hider.hide();
			});
		});
	}
}


function form_loader(form,result){
	 target = $(form);
	$(result).html('loading...');
	 $.ajax({
		 type: "GET",
		 url: target.attr('action'),
		 data: target.serialize(),
		 success: function(msg){
			 $(result).html(msg);
		 }
 	});
}



function Form1_Validator(theForm){
  if (theForm.firstname.value == ""){
	alert("Please insert first name!");
	theForm.firstname.focus();
	return (false);
  }

  if (theForm.lastname.value == ""){
	alert("Please insert last name!");
	theForm.lastname.focus();
	return (false);
  }	

  if (theForm.telephone.value == ""){
	alert("Please insert your address!");
	theForm.telephone.focus();
	return (false);
  }

  if (theForm.address.value == ""){
	alert("Please insert your city!");
	theForm.address.focus();
	return (false);
  }

  if (theForm.city.value == ""){
	alert("Please insert your postcode/zip!");
	theForm.city.focus();
	return (false);
  }

  if (theForm.postcode.value == ""){
	alert("Please insert your Phone number.");
	theForm.postcode.focus();
	return (false);
  }

  if (theForm.email.value == ""){
	alert("Please insert your Email Address.");
	theForm.email.focus();
	return (false);
  }
  
  if (theForm.email2.value != theForm.email.value){
	alert("Email addresses do not match - please re-enter!");
	theForm.email2.focus();
	return (false);
  }
  
}
