﻿/*

**** ORC requires jQuery! ****

new ORC(a)
a = (string) unique identifier for ORC controls - string modifier should make control ids unique on page

ORC.CustomizeSelectors(a, b) - Change Empty/Full images for the rotator selectors
a = (string) path to "empty" version of selector image (do not include '.' or file extension)
b = (string) path to "full" version of selector image (do not include '.' or file extension)

ORC.CustomizeArrows(a, b) - Change Previous and Next arrow images
a = (string) path to previous arrow image (do not include '.' or file extension)
b = (string) path to next arrow image (do not include '.' or file extension)

ORC.Load(a,b,c,d,e)
a = (string) wrapper div that controls will be appended into
b = (int) total number of options to cycle between
c = (int) delay in milliseconds between auto-cycle, enter 0 to disable auto-cycle
d = (int) start index(1-based), enter 0 for random (empty/out-of-range/NaN default to 1)
e = (string) name of javascript update function to call on each cycle - do not include '()'
*/


var hero_option_num = 1;
var rl_option_num = 1;
var cs_campaign_num = 0;

if (typeof cs_cid_passed != 'undefined') { cs_campaign_num = cs_cid_passed; }
if(cs_campaign_num > 4 || cs_campaign_num < 1) { cs_campaign_num = 0; }
if (typeof cs_hero_passed != 'undefined') { hero_option_num = cs_hero_passed; }
if(hero_option_num > 4 || hero_option_num < 1) { hero_option_num = 1; }

$(document).ready(function(){
    
    // Hero Option Rotator
    var orc_hero = new ORC('or_hero')
    orc_hero.Load('picController', 4, 8000, hero_option_num, 'orc_hero_update');
    
    // Recipe List Option Rotator
    var orc_recipe_list = new ORC('or_rl')
    // Customize
    orc_recipe_list.CustomizeSelectors('/Images/Products/PieCrusts/Paging-Transparent','/Images/Products/PieCrusts/Paging-SelectedTransparent')
    orc_recipe_list.CustomizeArrows('/Images/Products/PieCrusts/Paging-PreviousTransparent','/Images/Products/PieCrusts/Paging-NextTransparent')
    orc_recipe_list.force_gif = true;
    // Load Recipe List Rotator
    orc_recipe_list.Load('recipe_pager', 4, 0, rl_option_num, 'orc_rl_update');
    
});

// Hero Update Function
function orc_hero_update(newOpt)
{   
    hero_option_num = newOpt;
    
    $('#heroImage')
        .attr('src',detail_array[newOpt-1][0])
        .attr('alt', detail_array[newOpt-1][1]);
    $('#coupon_link').attr('href',detail_array[newOpt-1][2]);
    $('#hero_rec_link').attr('href',detail_array[newOpt-1][3]);
    $('#heroImageLink').attr('href',detail_array[newOpt-1][3]);
}

// Hero Option Details
// [0] = Hero Image Src 
// [1] = Hero Image Alt Text
// [2] = Coupon Link Href
// [3] = Get Recipe Button Link Href

// Mummy Dogs
var cs_mummy_dogs = new Array('/Images/Products/crescentsMS/hero_mummy_dogs.jpg','Mummy Dogs','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=16015');

// Layer Bars
var cs_layer_bars = new Array('/Images/Products/crescentsMS/hero_layer_bars.jpg','Layer Bars','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=15485');

// Layer Bars (Holiday)
var cs_layer_bars_holiday = new Array('/Images/Products/crescentsMS/hero_layer_bars_holiday.jpg','Layer Bars','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=15485');

// Pizza Pinwheels
var cs_pizza_pinwheels = new Array('/Images/Products/crescentsMS/hero_pizza_pinwheels.jpg','Pizza Pinwheels','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=15520');

// Turkey Cranberry Pinwheels
var cs_tcran_pinwheels = new Array('/Images/Products/crescentsMS/hero_tcran_pinwheels.jpg','Turkey Cranberry Pinwheels','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=45544');

// Bacon Cheese Tartlets
var cs_bc_tartlets = new Array('/Images/Products/crescentsMS/hero_bc_tartlets.jpg','Bacon Cheese Tartlets','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=46242');

// Bacon Cheese Tartlets (Holiday)
var cs_bc_tartlets_holiday = new Array('/Images/Products/crescentsMS/hero_bc_tartlets_holiday.jpg','Bacon Cheese Tartlets','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=46242');

// Mini-Crescent Dogs
var cs_mini_cdogs = new Array('/Images/Products/crescentsMS/hero_mini_cdogs.jpg','Mini Crescent Dogs','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=9898');

// Holiday Appetizer Tree
var cs_hol_apptree = new Array('/Images/Products/crescentsMS/hero_hol_apptree.jpg','Holiday Appetizer Tree','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=39519');

// Crescent Wrapped Brie
var cs_wrap_brie = new Array('/Images/Products/crescentsMS/hero_wrap_brie.jpg','Wrapped Brie','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=9907');

// Mini-Crescent Dogs
var cs_veggie_pizza = new Array('/Images/Products/crescentsMS/hero_veggie_pizza.jpg','Easy Veggie Pizza','http://bricks.coupons.com/bstart.asp?o=59328&ci=1&c=GM&p=FNa9bC4Q','/Recipes/ShowRecipe.aspx?rid=9897');


var campaign_array1 = new Array(cs_mummy_dogs, cs_layer_bars, cs_pizza_pinwheels, cs_bc_tartlets);
var campaign_array2 = new Array(cs_tcran_pinwheels, cs_bc_tartlets, cs_mini_cdogs, cs_pizza_pinwheels);
var campaign_array3 = new Array(cs_hol_apptree, cs_wrap_brie, cs_bc_tartlets_holiday, cs_layer_bars_holiday);
var campaign_array4 = new Array(cs_layer_bars, cs_veggie_pizza, cs_pizza_pinwheels, cs_mini_cdogs);

// Default rotation - currently #4, but may change to most popular campaign
var campaign_array0 = new Array(cs_layer_bars, cs_veggie_pizza, cs_pizza_pinwheels, cs_mini_cdogs);

var detail_array = eval("campaign_array" + cs_campaign_num);


// Recipe List Update Function
function orc_rl_update(newOpt)
{   
    rl_option_num = newOpt;
    $('div.recipe_list').load("/Products/handlers/RecipeListHandler.ashx?style=lrb_bo&rids=" + rl_array[rl_option_num-1]);
}

// Option Details

var rl_array = new Array("21726,13725,11507","9907,11550,11580","15495,9898,9897","15519,17558,14465");