$(document).ready(function() {
  $('.banners ul').cycle({
	fx: 'fade',
	speed: 2000,
	timeout: 2000
  });
	
  $('#promo').cycle({
	fx: 'fade',
	speed: 2500,
	timeout: 2000,
	next: '#promo-prev',
	prev: '#promo-next'
  });

  $('#content-show').cycle({
	fx:     'scrollHorz', 
	speed:  2000,
	timeout:0,
	cleartype:  1,
	easeIn:  'easeOutExpo', 
	easeOut: 'easeOutExpo', 
	next:   '#slider-next', 
	prev:   '#slider-prev'
  });

  $('#banners').cycle({
	  fx: 'fade',
	  speed: 2000,
	  timeout: 2000
  });

  $(".zoom").fancybox({
	'zoomSpeedIn': 600,
	'zoomSpeedOut': 600,
	'overlayShow': false,
	'easingIn': 'easeOutBack',
	'easingOut': 'easeInBack'
  });

  $(".promos a").fancybox({
	'showCloseButton': true,
	'zoomSpeedIn': 600,
	'zoomSpeedOut': 600,
	'overlayShow': false,
	'easingIn': 'easeOutBack',
	'easingOut': 'easeInBack',
	'titlePosition': 'inside'
  });  

    $('.tipped').formtips({
        tippedClass: 'tipped'
    });

  $("#contactform").validationEngine();

  function checkThisEmail(data) {
	var html = $.ajax({
	  type: 'POST',
	  url: "config/add_newsletter.php",
	  data: "mail="+ data,
	  async: false
	 }).responseText;
	
	return html;
  }

  $("#top_newsletter").validationEngine({
	success : function() { $("#top_newsletter").html(checkThisEmail($('#top_newsletter_email').val())); }
  })

  $("#top_newsletter_foot").validationEngine({
	success : function() { $("#top_newsletter_foot").html(checkThisEmail($('#top_newsletter_email_foot').val())); }
  });
	
		
  $('img.hover').hover(
	function()
	{ this.src = this.src.replace("-off", "-on"); },
	function()
	{ this.src = this.src.replace("-on", "-off"); }
  );
  $('a.hover').hover(
	function()
	{ $('img', this).attr('src', $('img', this).attr('src').replace("-off", "-on")); },
	function()
	{ $('img', this).attr('src', $('img', this).attr('src').replace("-on", "-off")); }
  );
});

(function($){
	
	$.fn.formtips = function(options) {
	
		// handle options
		var settings = jQuery.extend({
			tippedClass: "tipped"
		}, options);
	
		return this.each(function() {
			
			// prepare input elements an textareas
			var e = $(this);
			
			// do not apply form tips to inputs of type file, radio or checkbox
			var type = $(e).attr('type');
			if(type != 'file' && type != 'checkbox' && type != 'radio') {
		
				// handle focus event
				$(e).bind('focus', function() {
					var lv = $(this).attr('title');
					if($(this).val() == lv) {
						$(this).val('').removeClass(settings.tippedClass);
					}
					return true;
				});
		
				// handle blur event
				$(e).bind('blur', function() {
					var lv = $(this).attr('title');
					if($(this).val() == '') {
						$(this).val(lv).addClass(settings.tippedClass);
					}
					return true;
				});
		
				// handle initial text
				var lv = $(e).attr('title');
				if($(e).val() == '' || $(e).val() == $(this).attr('title')) {
					$(e).val(lv).addClass(settings.tippedClass);
				} else {
					$(e).removeClass(settings.tippedClass);
				}
			
				// handle removal of default value
				$(e).parentsUntil('form').parent().submit(function() {
					var lv = $(e).attr('title');
					if($(e).val() == lv) {
						$(e).val('').removeClass(settings.tippedClass);
					}
				});
			
			}
		
		});
	};

})(jQuery);

