$(document).ready(function() {                
	
	
	
	/*email protect*/
	$("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,".");
		link = match[2] ? match[2] : addr;
		subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
		$(this).after('<a href="mailto:'+addr+subject+'">'+ link + '</a>');
		$(this).remove();
	});    

  // on focus for input boxes*/
    $.fn.resetValue = function() {
     return this.focus(function() {if( this.value == this.defaultValue ) {this.value = "";}})
     .blur(function() {if( !this.value.length ) {this.value = this.defaultValue;}});
    };
  // $('.search-form input').resetValue();


	// Open links in new window when rel="external" is applyed to a tag
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	
	
  //hide email and add the hidden email_To on submit
  $("#enquiryform").submit(function() {
    var s1 = 'admin';
    var s2 = '@';
    var s3 = 'sitechwa.com.au';
    $(this).append('<input type="hidden" name="Email_To" value="' + s1 + s2 + s3 + '" />');
  });

	$('.baseform').validate();
	
	$('.nav li').append('/');
	
	$('body#p-products div.image').append('<div class="overlay"></div>');

	$('body#p-news ul#news-items li').addClass('clearfix');
	$('body#p-testimonials ul#testimonials-items li').addClass('clearfix');
	$('body#p-projects ul#projects-items li').addClass('clearfix');
	$('body#p-careers ul#careers-items li').addClass('clearfix');
	
	$('div#content ul#products li:odd').addClass('alt');
	$('div#content ul#testimonials-items li:odd').addClass('alt');
	$('div#content ul#careers-items li:odd').addClass('alt');

});

