$(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.safemail").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();
   	});
   
   $('#secondary li a:odd').addClass('alt');
   $('#secondary li a').fadeTo("fast", 0.8)
   $('#secondary li a').hover(function() {
    $(this).fadeTo("fast", 1)   
   }, function() {
     $(this).fadeTo("fast", 0.8)
   });
   
   $('body#p-retailer li.item:last').css('border-bottom', 'none');
   
   $('ul.squared li.item').hover(function() {
     $(this).css('background', '#3A4960')
   }, function() {
     $(this).css('background', 'none')
   });
   
   	// Slideshow (fade in/out)
	$('#pics').cycle({ 
			fx:    'fade', 
			speed:  4000
	 });
   
   //add the hidden email_To on submit
   $("form.uniForm").submit(function() {
     var s1 = 'cale.woodley';
     var s2 = '@';
     var s3 = 'webfirm.com';
     $(this).append('<input type="hidden" name="Email_To" value="' + s1 + s2 + s3 + '" />');
   });

   
});