$(document).ready(function(){
	// mailto replacer <span class="mailto">ashin at webfirm dot com.au</span>
	$("span.mailto").each(function(){
		var addr = $(this).text().replace(/ at /,"@").replace(/ dot /g,".");
		var link = ($(this).attr('title') == "") ? addr : $(this).attr('title');
				
		$(this).after('<a href="mailto:'+addr+'">'+ link + '</a>');
		$(this).remove();
	})
	// external links can be accessed by rel="external"
	$('A[rel="external"]').click( function() {
	  window.open( $(this).attr('href') );
	  return false;
	});
	$("#navigation ul li a").append('<span><!-- --></span>');
	
	// click and hover functions for the products
	$('ul#star-signs li:not(".heading")').click(function(){
		 window.location=$(this).find("a").attr("href"); return false;
	});
			
	$('ul#star-signs li:not(".heading")').hover(function(){
		$(this).css("background-position", "0 -120px");
		$(this).css("cursor", "pointer");
		return false;
	},
		function()
	{
		$(this).css("background-position", "0 0");
	});
	$('table tr:even').css("background","#fceafc")
	
	// secondary navigation slide menu
	$("#secondary ul li ul").hide();
	$("#secondary ul li:has(ul)").hoverIntent(function(){
		$(this).children("ul").slideToggle(300);
		return false;
	},
		function()
	{
		$(this).children("ul").slideToggle(100);
	});
	  
  $('.date-pick').datepicker({
    clickInput:true, 
    minDate:new Date(1900, 1, 1),
    changeMonth: true,
    changeYear: true,
    yearRange: '1900:2009',
    dateFormat: 'dd-mm-yy'
    });
  
  $("#newsletter").validate();
  $("#contact-form").validate();
  
  //compatability
  $('div#results').hide();
  $("button#go").click(function(){
    $('div#results').hide();
    $.post("/astro_compatibility/result",
        { user_bday_day : $("#user_bday_day").val(),
          user_bday_month : $("#user_bday_month").val(),
          user_bday_year : $("#user_bday_year").val(),
          lover_bday_day : $("#lover_bday_day").val(),
          lover_bday_month : $("#lover_bday_month").val(),
          lover_bday_year : $("#lover_bday_year").val(),
          authenticity_token : $("#authenticity_token").val()
      }, function(data){
        $('div#results').html(data);
        $('div#results').show('fast');
    });

    return false;
  });
})
