/* Simplessus.com JavaScripts */

$(document).ready(function() {
	if(!$.browser.msie) {
		$(".btn_blur_holder a").hover(function() {
			$(this).next("em").animate({opacity: "show"}, "slow");
		}, function() {
			$(this).next("em").animate({opacity: "hide"}, "slow");
		});
	} else {
		if($.browser.version < 7) $('img[@src$=.png]').ifixpng();
	}
	
	$("#search_words").autocomplete("/?remote_service=cms_search_autosuggest&cms_search[mode]=1", {
		width: 260,
		selectFirst: false,
		matchContains: true,
		autoFill: true,
		cacheLength: 10
	});

	$(".topnavilink").hover(function() {
		$(this).animate({ color: "#BBBBBB" }, 500);
	},function() {
	 	$(this).animate({ color: "#FFFFFF" }, 500);
	});
	
	$(".product").hover(function() {
		$(this).addClass('productover');
	},function() {
	 	$(this).removeClass('productover');
	});
	
	simp_slide("#sliding-navigation", 15, 10);
	
	$('.gallery a').lightBox();
	
	$("input.text").focus(function() {
		$(this).css('border', '1px solid #6AC625');
	});
	
	$("input.text").blur(function() {
		$(this).css('border', '1px solid #cecece');
	});

	$("select").focus(function() {
		$(this).css('border', '1px solid #6AC625');
	});
	
	$("select").blur(function() {
		$(this).css('border', '1px solid #cecece');
	});

	$("textarea").focus(function() {
		$(this).css('border', '1px solid #6AC625');
	});
	
	$("textarea").blur(function() {
		$(this).css('border', '1px solid #cecece');
	});
	
	$('textarea.resizable:not(.processed)').TextAreaResizer();
	
	$('.defaulttable tr:odd').addClass('odd');
	$('.defaulttable tr:even').addClass('even');
	
	// Homepage
	$('ul#portfolio').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '214px'
	});
	
	// Product page
	install_teaser_buttons();
	
	// Grayscale images
	grayscale($('.grayscale'));
	
	$('.grayscale').hover(function() {
		grayscale.reset($(this));
	},function() {
	 	grayscale($(this));
	});

});

function simp_slide(navigation_id, pad_out, pad_in) {
	// creates the target paths
	var list_elements = navigation_id + " li.sliding-element";
	var link_elements = list_elements + " a";
	

	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i)
	{
		$(this).hover(
		function()
		{
			$(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			$(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
}

function install_teaser_buttons() {
	$("#teaserbutton1").hide();
	
	$("#teaserbutton1").click(function() {
		$("#teaserbutton2").fadeIn();
		$(this).fadeOut();

		$("#teasercontent2").slideUp();
		$("#teasercontent1").slideDown();
	});

	$("#teaserbutton2").click(function() {
		$("#teaserbutton1").fadeIn();
		$(this).fadeOut();
				
		$("#teasercontent1").slideUp();
		$("#teasercontent2").slideDown();
	});

}