$(document).ready(function(){
	
	/*
	----------------------------------------------------------
	GENERAL
	---------------------------------------------------------- */
	//HOME BANNER
	$('#panel').cycle({ 
		fx:     'fade', 
		speed:   500, 
    	timeout: 0
	});
	
	$('.tab1 a').click(function() { 
		$('#panel').cycle(2); 
		return false; 
	}); 
	 
	$('.tab2 a').click(function() {  
		$('#panel').cycle(1);  
		return false;  
	});
	
	$('.tab3 a').click(function() {  
		$('#panel').cycle(0);  
		return false;  
	});
	
	
	//ISOTOPE FILTERING

	var $container = $('#shopitems');
	

	$('#filters input').click(function(){
		
	  the_filter = "";
			 
      op1 = false;
	  op5 = false;
	  
	  if ($('#opt1').attr('checked')){ the_filter = the_filter + ".op1"; op1=true;	}
	  if ($('#opt5').attr('checked')){ the_filter = the_filter + ".op5"; op5=true;	}

	  	  	  	  	  
	  var selector = the_filter;
	 // window.alert(the_filter);
	
	  // Set cookie
	  //$.cookie("shopitem-sort", selector, { expires : 90, path: '/' });	  
	
      $container.isotope({ filter: selector });

             var t=setTimeout('setChecks(op1,op5)',100);

      return false;
      
    });
	
	// FANCYBOX
	$("a#fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'fade',
		'speedIn'		:	200, 
		'speedOut'		:	200
	});
	
	
	// FORM ERROR MESSAGES
	$("ul.errors").hide();
	
	
	
	// CLEAR VALUE ON FOCUS
	$('.labelvalue').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = default_value;
	        }
	    });
	});
	
	
	
	// EXTERNAL WINDOWS
	$('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });



	// MAKE ENTIRE AREA CLICKABLE
	$("div.highlight").click(function(){
		if($(this).find("a").attr("rel") == "external") {
		    window.open($(this).find("a").attr("href"))
		} else{
		    window.location=$(this).find("a").attr("href"); return false;
		    return;
		}
	});
	
	
	// MONCUR LOGO ANIM
	$("#moncur a").hover(function() {
		$(this).next("span").animate({opacity: "show"}, "slow");
	}, function() {
		$(this).next("span").animate({opacity: "hide"}, "fast");
	});
	
		
});


function setChecks(op1,op5){
     
            //window.alert("here2")
             if (op1 == true) { document.getElementById('opt1').checked = true;}  else {document.getElementById('opt1').checked = false;}    
            if (op5 == true) { document.getElementById('opt5').checked = true;}   else {document.getElementById('opt5').checked = false;}       
     
     }
     
function setTab(tab){

document.getElementById('seasoning-info').style.display = 'none';
document.getElementById('soup-info').style.display = 'none';
document.getElementById('rice-info').style.display = 'none';
document.getElementById('seasoning-items').style.display = 'none';
document.getElementById('soup-items').style.display = 'none';
document.getElementById('rice-items').style.display = 'none';

document.getElementById('rice-img').src = '/assets/img/tab_ricemixes-off.png';
document.getElementById('soup-img').src = '/assets/img/tab_soupmixes-off.png';
document.getElementById('seasoning-img').src = '/assets/img/tab_seasonings-off.png';

document.getElementById(tab + '-info').style.display = 'block';
document.getElementById(tab + '-items').style.display = 'block';

if (tab == 'seasoning'){document.getElementById('seasoning-img').src = '/assets/img/tab_seasonings-on.png';}
if (tab == 'soup'){document.getElementById('soup-img').src = '/assets/img/tab_soupmixes-on.png';}       
if (tab == 'rice'){document.getElementById('rice-img').src = '/assets/img/tab_ricemixes-on.png';}       

}


    
/*
----------------------------------------------------------
COOKIES
---------------------------------------------------------- */
function readCookie(name,delimit)
{


  if (document.cookie == '')
  {
    return false;
  }
  else
  {
    var fC,lC;
    var mcookie = unescape(document.cookie);
    fC = mcookie.indexOf(name);
    var ph = fC + name.length;
    if ((fC != -1) && (mcookie.charAt(ph) == '='))
    {
      fC += name.length + 1;
      lC = mcookie.indexOf(delimit,fC);
      if (lC == -1) lC = mcookie.length;
      return unescape(mcookie.substring(fC,lC));
    }
    else
    {
      return false;
    }
  }
}




