﻿//JQuery scripts
$(document).ready(function(){

  	/*$("#cross-site-links").load("/pages/cross-site-links.html .cross-site-links");*/

    //this is the script that handles manually swapping lists in recipe finder module on FC home page
    $('.home .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.recipe-finder div div').hide();
        
            $('div#' + listname + '-list').show();
    
        });
        
    });

    //this is the script that handles manually swapping lists in recipe finder module on recipe home page
    $('.recipes .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.list-rotator').cycle('stop');
            $('.list-rotator div').css({'opacity': '0'});
			$('.list-rotator div').hide();
        
            $('.list-rotator div#' + listname + '-list').show()
            $('.list-rotator div#' + listname + '-list').css({'opacity': '1'});    
        });
        
    });
    
    //this is the script that handles manually swapping lists in recipe finder module on drinks home page
    $('.drink_recipes .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.list-rotator').cycle('stop');
            $('.list-rotator div').css({'opacity': '0'});  
			$('.list-rotator div').hide();
        
            $('.list-rotator div#' + listname + '-list').show()
            $('.list-rotator div#' + listname + '-list').css({'opacity': '1'});    
        });
        
    });
    
     //this is the script that handles manually swapping lists in recipe finder module on baking home page
    $('.baking .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.list-rotator').cycle('stop');
            $('.list-rotator div').css({'opacity': '0'});  
			$('.list-rotator div').hide();
        
            $('.list-rotator div#' + listname + '-list').show()
            $('.list-rotator div#' + listname + '-list').css({'opacity': '1'});    
        });
        
    });
    
        //this is the script that handles manually swapping lists in recipe finder module on mit home page
    $('.dinner_recipes .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.list-rotator').cycle('stop');
            $('.list-rotator div').css({'opacity': '0'});  
			$('.list-rotator div').hide();
        
            $('.list-rotator div#' + listname + '-list').show()
            $('.list-rotator div#' + listname + '-list').css({'opacity': '1'});    
        });
        
    });
    
    //this is the script that handles manually swapping lists in recipe finder module on drinks home page
    $('.healthy_recipes .index .recipe-finder .categories a').each(function(){
        
        $(this).click(function(){
	        $('.recipe-finder .categories a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('.list-rotator').cycle('stop');
            $('.list-rotator div').css({'opacity': '0'});  
			$('.list-rotator div').hide();
        
            $('.list-rotator div#' + listname + '-list').show()
            $('.list-rotator div#' + listname + '-list').css({'opacity': '1'});    
        });
        
    });

    
    //this is the script that handles swapping lists in recipe toggle module
    $('#recipe-toggle .categories li').each(function(){
        
        $(this).click(function(){
	        $('#recipe-toggle .categories li').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('#recipe-toggle div#searched-list').hide();
            $('#recipe-toggle div#favorites-list').hide();
            $('#recipe-toggle div#rated-list').hide();
        
            $('div#' + listname + '-list').show();
        });
        
    });
	
	     //this is the script that handles swapping content on CYOM My Favorites display view
    $('.cyom .tabs a').each(function(){
        
        $(this).click(function(){
	        $('.cyom .tabs a').removeClass('selected');
        	$(this).addClass('selected');
            
            var listname = $(this).attr('rel');
            
            //hide all tabs first
            $('#menu-sections div#courses').hide();
			$('#menu-sections div#shopping-list').hide();
            $('#menu-sections div#instructions').hide();

            $('div#' + listname).show();
			//$('.cyom .print-type').html('<link rel="stylesheet" href="/styles/myfinecooking_shoplist_print.css" media="print" />');
        });
        
    });
   
});

/*not jquery but since this file is referenced on all pages its best to put these here*/
function roll(img_name1, img_src1)
   {
   document[img_name1].src = img_src1;
   }
   
function popitup(url) {
   newwindow=window.open(url,'name','height=272,width=400,top=50,left=50');
   if (window.focus) {newwindow.focus()}
   return false;
}
