$(document).ready( function() {
   
    // open external link in new tab/window
    // use rel="external" instead of target="_blank"
    $('a[rel="external"]').click( function() {
        this.target = "_blank";
    });
    
    //email replacement
   	$("span.mailto").each(function(){
   	  exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
   	  match = exp.exec($(this).text());
   	  addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
   	  emaillink = match[2] ? match[2] : addr;
   	  subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
       $(this).after('<a href="mailto:'+addr+subject+'">'+ emaillink + '</a>');
   		$(this).remove();
   	});
   	$('ul#banners').cycle({
   	});
   	$('#feature_photos ul').cycle({ 
        prev:   '#back', 
        next:   '#forward', 
        timeout: 0
    });
    
    // sign up default value
    $("#newsletter form input").focus(function() {
     	if( this.value == this.defaultValue ) {
     	  this.value = "";
     	}
    }).blur(function() {
     	if( !this.value.length ) {
     		this.value = this.defaultValue;
     	}
    });
    //validate no-default
    jQuery.validator.addMethod("defaultInvalid", function(value, element) {
      return value != element.defaultValue;
    }, "This can't be left blank");
    $("#newsletter form").validate();
    
		
		$(".colorbox").colorbox();
		$('.colorbox-frame').colorbox({width: "610px", height: "390px", iframe:true}); 
		
		
		$(".month ul.event:odd").addClass("odd");
		
		
	//hide email and add the hidden email_To on submit
	$("#contact-form").submit(function() {
		var s1 = 'info';
		var s2 = '@';
		var s3 = 'mindariemarina.com.au';
		$(this).append('<input type="hidden" name="Email_To" value="' + s1 + s2 + s3 + '" />');
	});	
	
		//EVENTS CALENDAR SHOW/HIDE
		
		$(".selected-event").hide();
		$("#event-11-12-09").show();
		
		$("#date-11-12-09").click(function() {
			$(".selected-event").hide();
			$("#event-11-12-09").show();
		});
		
		$("#date-12-12-09").click(function() {
			$(".selected-event").hide();
			$("#event-12-12-09").show();
		});
		
		$("#date-13-12-09").click(function() {
			$(".selected-event").hide();
			$("#event-13-12-09").show();
		});
		
		$('ul.sf-menu').superfish(); 
     
		
});