$(document).ready(function(){ 
	$(".sf-menu").superfish(); 
	
	$('#news').innerfade({
		speed: 1000,
		timeout: 7000,
		type: 'sequence',
		containerheight: '108px'
	});
	
	$( "#top" ).scrollFollow({
		offset: 20,
		relativeTo: 'bottom'
	});
	
	$("img.image").dropShadow({
			left: 6,
			top: 6,
			opacity: .5,
			color: 'black'
	});
	
	/*
	$("#category").selectbox({debug: true});
	$("#title").selectbox({debug: true});
	$("#artist").selectbox({debug: true});
	$("#technique").selectbox({debug: true});
	$("#pricerange").selectbox({debug: true});
	$("#size").selectbox({debug: true});
	$("#offer").selectbox({debug: true});
	$("#search").checkbox({checked: "media/images/checkbox-checked.gif", unchecked: "media/images/checkbox-unchecked.gif"});
	*/
	
	 // initialize scrollable  
    $("div.scrollable").scrollable({ 
        items: '#thumbs',
		hoverClass: 'hover',
		size: 1,
		interval: 7000,
		speed: 2000,
		easing: 'swing',
		loop: true,
		
		next: '#next', 
    	prev: '#prev' 
    }); 
	
	$.fn.clearForm = function() {
		return this.each(function() {
		$(':input', this).each(function() {
			var type = this.type, tag = this.tagName.toLowerCase();
			if (type == 'text' || type == 'password' || tag == 'textarea')
				this.value = '';
			else if (type == 'checkbox' || type == 'radio')
				this.checked = false;
			else if (tag == 'select')
				this.selectedIndex = -1;
			});
		});
	};

	$("a[href^='javascript']").each(function (index) {
		var object = $(this);
		var link = object.attr('href').replace(/javascript:location.href=/,"");
		var parts = link.split("+");
		$.each(parts, function (index,data) {
			parts[index] = trim(data,"'");
		});
		parts[1] = (eval(parts[1]));
		var link = parts.join("");
		object.attr({
			href: link
		});
		object.html(parts[1]);
	});
	
});

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
