$(document).ready(function() {                
	//Focus on the first input on the page
	$("input:first").focus();
	
	
	/*email protect*/
	$("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,".");
		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();
	});    



	// Open links in new window when rel="external" is applyed to a tag
	$('a[@rel="external"]').click(function(){
		this.target = "_blank";
	});
	

									
		$('.mover').hide();								
		
		$("a.pusher").click(function() {
			var toshow = $(this).attr('href');

			$(toshow).slideToggle("fast");
			return false;
		});
		
		
		$('#flash').cycle({ 
			 fx:     'fade', 
			 speed:  3000, 
			 timeout: 3000, 
			 next:   '#next2', 
			 prev:   '#prev2' 
		});

		$('#flash2').cycle({ 
					fx:    'fade', 
					speed:  1000 
			});

		/*on focus for input boxes*/
	$.fn.search = function() {
		return this.focus(function() {if( this.value == this.defaultValue ) {this.value = "";}})
		.blur(function() {if( !this.value.length ) {this.value = this.defaultValue;}});};

		//on the click of the search input, clear string
		if($("input#sFilter").val() == "enter keywords...")
		{
			$("input#sFilter").search();
		}
    
	/* on the search form submit */
	$("form#filter").submit(function(){
		//if the user submits search our products, clear string
		if($("input#sFilter").val() == "enter keywords...")
		{
			$("input#sFilter").val("");
		}

		//get the length of the string
		var searchLength = $("input#sFilter").val().length;

		//if the search string is less than 3 characters alert the user
		if(searchLength >= 1 && searchLength < 3)
		{
			alert("You must place at least three characters");
			$("input#sFilter").focus();
			return false;
		}
	});

});
