/* this sets values for the slideshow plugin */


var Set_Carousels  = {


	main_win: jQuery("#images"),
	left_win: jQuery("#left-images"),
	
	initialize: function() {
	  		var self = this;

      		self.main_win.innerfade({
      		speed: 3000,
      		timeout: 6500,
      		type: 'sequence',
      		containerheight: '300px'
  			});
  			
      		self.left_win.innerfade({
		    speed: 3000,
      		timeout: 9000,
      		type: 'sequence',
      		containerheight: '140px'
  			});
      }

}
  
Set_Carousels.initialize();



/* this populates the search box with an initial value */

var Search_Box = {

	form: jQuery("#search-form"),
	input: jQuery("#search-text"),
	
	initialize: function() {
		var self = this;
                self.input.val(self.input.attr("title"));
                self.input.addClass("placeholder");
		self.search_focus();
		self.search_blur();
		self.search_submit();
	},
	
	search_focus: function() {
		var self = this;
		self.input.focus(function() {
                        self.input.removeClass("placeholder");
			if (this.value == this.title) {
				this.value = "";
			}
		});
	},
	
	search_blur: function() {
		var self = this;
		self.input.blur(function() {
                        self.input.addClass("placeholder");
			if (this.value == "") {
				this.value = this.title;
			}
		});
	},
	
	search_submit: function() {
		var self = this;
		self.form.submit(function() {
			if (self.input.attr("value") == self.input.attr("title") || self.input.attr("value") == "") {
				return false;
			} 
			else {
				return true;
			}
		});
	}

}

Search_Box.initialize();
  	
/* Text resize - style switcher */

var Text_Resize = {

	small_link: jQuery("#small a"),
	large_link: jQuery("#large a"),
        style_sheet_url: jQuery("link[title='larger-text']").attr("href"),
	
	initialize: function() {
	
		var self = this;
		
		self.small_link.click(function() {
			jQuery("link[title='larger-text']").attr("disabled", "true").remove();
			jQuery("a").each(function() {
				this.href = this.href.replace("/text-large", "");
			});
			jQuery("form").each(function() {
				this.action = this.action.replace("/text-large", "");
			});
			return false;
		});
		
		self.large_link.click(function() {
			jQuery("link[title='larger-text']").remove();
                        jQuery("head").append('<link media="screen" title="larger-text" type="text/css" rel="stylesheet" href="' + self.style_sheet_url + '"/>');
                        jQuery("head").append('<link media="print" title="larger-text" type="text/css" rel="stylesheet" href="' + self.style_sheet_url + '"/>');
			jQuery("a").each(function() {
				this.href = this.href.replace("/text-large", "").replace(location.host, location.host + "/text-large");
			});
			jQuery("form").each(function() {
				this.action = this.action.replace("/text-large", "").replace(location.host, location.host + "/text-large");
			});
			return false;
		});
	
	}

}

Text_Resize.initialize();
	

