/*

Scripts written by Alex Dickson for Acura Multimedia (http://www.acura.com.au)

All scripts leverage the jQuery framework (http://www.jquery.com) by John Resig (http://www.ejohn.org)

*/



// on DOM ready

$(document).ready(function(){

	$('html').addClass('dom-loaded');


       
    $('a[rel*=external],#content a[href^=http://]:not([href*=' + location.hostname + '])"').newWindow();
    
    
    
    
    // Menu
    if ($('body').hasClass('home')) {
	   $('#header ul li a').anchorAnimate();
    };
    

    
	// Contact Form
	
	$('#contact #bot').hide();
	
	$('#input-bot').val('Leonie');    
	    
    $('#contact').validate({
              rules: {
                  name: {
                      required: true
                  },
                  email: {
                      required: true,
                      email: true
                  },
                  enquiry: {
                      required: true
                  }
              },

              errorPlacement: function(error, element) {
                 var $parent = element.parent();
                 $parent.attr('title', error.text() );
                 $parent.addClass('error');
               }
          });          

	          
	
	    
    
   $('#input-enquiry').inputLabel({ defaultLabel: 'your message' });
   
   if ($('body').hasClass('our-gourmet-tours')) {
        
        // set up lightbox        
        $('.gallery ul li a.gallery-image').prettyPhoto();
        
        
        $('.gallery').each(function() {
        
            $(this).find('ul li:first').addClass('big-link');
            
        });
        
      
        
   };

			
    
});


// on window loaded



$(window).load(function(){  // window load

	$('html').addClass('window-loaded');

	//google analytics

	try {

		var pageTracker = _gat._getTracker('UA-693909-48');

		pageTracker._trackPageview();

	} catch(err) {}

});



// Open links in new window

 (function($){  
  $.fn.newWindow = function(options) {   
    var defaults = {
		titleText: 'Link opens in a new window'
	};	
	var options = $.extend(defaults, options);   
     return this.each(function() {  
	   var obj = $(this);
       if ( ! obj.is('a')) {
           return;
       };
	   if (options.titleText != '') {   
		   if (obj.attr('title')) {
				var newTitle = obj.attr('title') + ' (' + options.titleText + ')';
		   } else {
				var newTitle = options.titleText;   
		   };		   
		   obj.attr('title', newTitle);   
	   };
	   obj.click(function(event) {
	   	  event.preventDefault();  
		  var newBlankWindow = window.open(obj.attr('href'), '_blank');
		  newBlankWindow.focus();
		}); 
	   });
  };  
 })(jQuery); 
 
 
 /*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
	
 
jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
 
 
 
 // inputlabel
 
 eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(6($){$.m.2=6(1){4 c={8:\'\',7:\'n\',d:\'l-k\'};4 1=$.h(c,1);f e.j(6(){4 0=$(e);5(!0.p(\':g, :v, w\')){f};5(1.8==\'\'&&0.a(\'b\')){4 2=0.a(\'b\');4 2=$(\'r[s=\'+2+\']\').9(1.d).g()}q{4 2=1.8};5(!0.3()||0.3()===2){0.9(1.7);0.3(2)};0.t(6(){5(0.3()==2){0.u(1.7);0.3(\'\')}});0.o(6(){5($.i(0.3())==\'\'){0.9(1.7);0.3(2)}})})}})(x);',34,34,'obj|options|inputLabel|val|var|if|function|dullClass|defaultLabel|addClass|attr|id|defaults|labelClass|this|return|text|extend|trim|each|use|in|fn|dulled|blur|is|else|label|for|focus|removeClass|password|textarea|jQuery'.split('|'),0,{}));

// hover intent

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
