// JavaScript Document

	$(function() {		
		// hide links which are there for google and non-javascript visitors only
		$('.noscript').hide();

		// bind onchange and onkeyup event to category select box
		$('#input-category').bind('change', function() {
			var catId = this.options[this.selectedIndex].value; 
			if(catId != 0){ 
				window.location='/search/'+catId+'/'+urlencode($(this.options[this.selectedIndex]).html());
			}
		});	
		$('#input-category').bind('keyup', function() {
			var catId = this.options[this.selectedIndex].value; 
			if(catId != 0){ 
				window.location='/search/'+catId+'/'+urlencode($(this.options[this.selectedIndex]).html());
			}
		});			

		// text in search box clears when focussed for the first time
		$('#input-tags').bind('focus', function() {
			$(this).val('');
			$(this).removeClass('faded-font');
			$(this).unbind('focus');
		});
		$('#home-form').bind('submit', function() {
			$('#input-tags').focus();
			return true;
		});		
		
		/*
		$('#main-banner').bind('mouseout', function() {	
			$('#main-banner').bind('mouseover', function() {											 			
				$('#main-banner').stop().animate({"opacity": "0"}, 3000, function() {
					$(this).hide();	
				});				
			});												  
			$('#collection').bind('mouseover', function() {								
				$('#main-banner').stop().show().animate({"opacity": "1"}, 2000);
			});								
			$('#button-own-design').bind('mouseover', function() {								
				$('#main-banner').stop().show().animate({"opacity": "1"}, 2000);
			});											
		});							
		*/
	});
	
	// scroll to desired cardpage in topcards section
	function goToPage(clickedEl, pageNumber) {
		var pagenav = $(clickedEl).parent();
		var id = pagenav.attr('id').substr(0,pagenav.attr('id').indexOf('-pagenav'));
		var newLeft = pageNumber * 407 * -1;
		
		pagenav.find('a.active').removeClass('active');
		$('#'+id+'-pagewrapper').animate({'left': newLeft+'px'}, 1000); 
		$(clickedEl).addClass('active');
		
		return false;
	}	