// JavaScript Document

	function showPic (whichpic, id) {
		if (document.getElementById) {
			document.getElementById('placeholder').src = whichpic.href;
			var x=document.getElementsByName("thumbs");
			for(var i = 0; i < x.length; i++){
				x[i].removeAttribute("class");
			}
			document.getElementById(id).setAttribute("class", "active");
		  return false;
		}
	}

	function colorSelect (id, cValue) {
		if (document.getElementById) {
			$("#aajdee1_1").removeClass("active");
			$("#aajdee1_2").removeClass("active");
			$("#aajdee1_3").removeClass("active");
			$("#aajdee1_4").removeClass("active");
			$("#"+id).addClass("active");
			if(id == "aajdee1_2"){
				$("#pImg").html("<img src='../images/product_item_aajdee1a.png'>");
				$("#colorName").html("nežna oliva");
			}
			else if (id == "aajdee1_3"){
				$("#pImg").html("<img src='../images/product_item_aajdee1d.png'>");
				$("#colorName").html("strašna vijolična");
			}
			else if (id == "aajdee1_4"){
				$("#pImg").html("<img src='../images/product_item_aajdee1c.png'>");
				$("#colorName").html("nabrita oranžna");
			}
			else {
				$("#pImg").html("<img src='../images/product_item_aajdee1a.png'>");
				$("#colorName").html("nežna oliva");
			}
			$("#colorValue").val(cValue);
			$("#productID").val(cValue);
				
		  return false;
		}
	}
	
	function sizeSelectBigabaga (id, cValue, pID, price) {
		if (document.getElementById) {
			$("#small").removeClass("active");
			$("#medium").removeClass("active");
			$("#large").removeClass("active");
			$("#"+id).addClass("active");
			$("#sizeValueB").val(cValue);
			$("#productID").val(pID);
			$("#price").val(price);
				
		  return false;
		}
	}
	
	function sizeSelectCopaCopa (id, cValue, pID) {
		if (document.getElementById) {
			$("#c01").removeClass("active");
			$("#c02").removeClass("active");
			$("#c03").removeClass("active");
			$("#c04").removeClass("active");
			$("#c05").removeClass("active");
			$("#c06").removeClass("active");
			$("#c07").removeClass("active");
			$("#c08").removeClass("active");
			$("#"+id).addClass("active");
			$("#sizeValueC").val(cValue);
			$("#productID").val(pID);
				
		  return false;
		}
	}
	
	function submitform(myForm){
		$('form#'+myForm).attr('action','?t=add').submit();		 
	}
	
	function showInfoChart(){
		$('#mojakosara').slideDown('slow');		 
	}
	
	function hideInfoChart(){
		$('#mojakosara').hide();		 
	}
	
	function removeItem(obj) {
		$(obj).parent().attr('action','?t=remove').submit();
	}

	$(document).ready(function() {  
  	$('a[href=#top]').click(function(){  
    	$('html, body').animate({scrollTop:0}, 'slow');  
      return false;  
   	});  
	}); 
	
	$(document).ready(function()
{
	// main menu
	$('#infoChart').hover(	    
    function(){ $('div', this).show();  }, 
    function(){ $('div', this).hide();  }
  );

	// tabs
  $('div.activities ul.tabNavigation a').click(function () {
  		var tabContainers = $('div.activities > div:not(#clearer)');		    		
      tabContainers.hide().filter(this.hash).fadeIn("normal");        	        
      tabContainers.filter(this.hash+'_add').fadeIn("normal");

      return false;
  });
}); 

	var featItemAnimate = function(cur,nex)
	{
		fiWrapper.filter(cur).fadeOut(3000);
		fiWrapper.filter(nex).addClass('curImg').fadeIn(3000);
	}		
						
	var featItemRun = function()
	{						
		fiCurentImg++;	
		fiCurentImg = fiCurentImg > fiCount ? 1 : fiCurentImg;
		
		featItemAnimate('.curImg','#mainPicture'+fiCurentImg);
	
		// Update navigation buttons
		$('div.galleryNavigation a').removeClass('active');
		$('div.galleryNavigation a#i'+fiCurentImg).addClass('active');
	}			
						
	var featItemInit = function() 
	{		
		fiWrapper = $('.galleryContainer > div');				
		fiCurentImg = 1
		fiCount = fiWrapper.size();
																																		
		// Show first image	
		fiWrapper.filter(':first').show().addClass('curImg');						
		
		// Run slide show
		fiInterval = setInterval("featItemRun()",5000);
		
		// Set navigation buttons onclick	
		$('div.galleryNavigation a').click(function () 
		{
			clearInterval(fiInterval);								
			if (this.className.indexOf('active') == -1) 
			{
				featItemAnimate('.curImg',this.hash);								
				$('div.galleryNavigation a').removeClass('active');
				$(this).addClass('active');
			}
			return false;
		});		
	}
