/* sni-kitchens - Thu, 16 Jul 2009 13:29:16 -0400 */

if( typeof(SNI.kitchens) == "undefined" ) {
	SNI.kitchens = {};
}

SNI.kitchens.ANIMATION_SPEED = 150;

kitchensApplicationConfig.prototype=new SNI.UR.ApplicationConfig();function kitchensApplicationConfig(){kitchensApplicationConfig.prototype=new 
SNI.UR.ApplicationConfig();function urVersion(){return 1;}}
if(typeof SNI.Community=='undefined'){SNI.Community={};}
SNI.Community.UR={init:function(){if((SNI.Community.siteName==undefined)||(SNI.Community.siteName==null)){SNI.Community.UR.urUser=new SNI.UR.UrUser(new kitchensApplicationConfig());if(SNI.Community.UR.urUser.isLoggedIn==true){SNI.Community.UR.ViewingUserId=SNI.Community.UR.urUser.getUserId();SNI.Community.UR.ViewingUserName=SNI.Community.UR.urUser.getEmail();SNI.Community.UR.ViewingUserDisplayName=SNI.Community.UR.urUser.getUserName();if((SNI.Community.UR.ViewingUserDisplayName==undefined)||(SNI.Community.UR.ViewingUserDisplayName==null)||(SNI.Community.UR.ViewingUserDisplayName=='')){if((SNI.Community.UR.ViewingUserName!=null)){if(SNI.Community.UR.ViewingUserName.indexOf("@")==-1){SNI.Community.UR.ViewingUserDisplayName=SNI.Community.UR.ViewingUserName;}else{SNI.Community.UR.ViewingUserDisplayName=SNI.Community.UR.ViewingUserName.substring(0,SNI.Community.UR.ViewingUserName.indexOf("@"));}}}
SNI.Community.UR.ViewingUserPostalCode=SNI.Community.UR.urUser.getPostalCode();SNI.Community.UR.logged_in='true';}else{}}
else if((SNI.Community.UR.ViewingUserName!=undefined)&&(SNI.Community.UR.ViewingUserName!=null)){if((SNI.Community.UR.ViewingUserDisplayName==undefined)||(SNI.Community.UR.ViewingUserDisplayName==null)||(SNI.Community.UR.ViewingUserDisplayName=='')){if(SNI.Community.UR.ViewingUserName!=null){if(SNI.Community.UR.ViewingUserName.indexOf("@")==-1){SNI.Community.UR.ViewingUserDisplayName=SNI.Community.UR.ViewingUserName;}else{SNI.Community.UR.ViewingUserDisplayName=SNI.Community.UR.ViewingUserName.substring(0,SNI.Community.UR.ViewingUserName.indexOf("@"));}}}
SNI.Community.UR.logged_in='true';}},logout:function(){var destURL=document.location;document.location="http://my.kitchens.com/redirectors/logout_redirector.jsp?DEST_URL="+escape(destURL);}};
jQuery.dpl={init:function(type,config){return this.each(function(i){if(this.id){}
else{this.id=type+"-"+new Date().getTime();}
try{document.execCommand('BackgroundImageCache',false,true);}catch(e){}
var init=$.dpl[type];if($.isFunction(init)){init(this,config);}});},carousel:function(ele,config){config=$.extend({pause:null,scroll:1,animation:"slow",auto:0,wrap:null,pagelink:null,pagetext:null,start:1},config);var crsl_itemFirstInCallback=function(carousel,item,idx,state){if(config["pagelink"]=="text"){var tmpText=config["pagetext"];tmpText=tmpText.replace(/_current/ig,idx);tmpText=tmpText.replace(/_total/ig,carousel["options"]["size"]);carousel.container.find(".jcarousel-pagetext").html(tmpText);}else if(config["pagelink"]=="image"){jQuery(ele).find('.jcarousel-pageimg a.current').removeClass("current");link=jQuery(ele).find('.jcarousel-pageimg a')[idx-1];jQuery(link).addClass("current");}};var crsl_initCallback=function(carousel,state){if((config["pagelink"]=="text")||(config["pagelink"]=="both")){carousel.container.append('<div class="jcarousel-pagetext"></div>');}else if((config["pagelink"]=="image")||(config["pagelink"]=="both")){var imgLinks="";for(var i= 1;i<=carousel["options"]["size"];i++){imgLinks+='<a href="#'+i+'">'+i+'</a>';}
carousel.container.append('<div class="jcarousel-pageimg"></div>');jQuery(ele).find(".jcarousel-pageimg").append(imgLinks);jQuery(ele).find('.jcarousel-pageimg a').bind('click',function(){carousel.scroll(jQuery.jcarousel.intval(jQuery(this).html()));return false;});}};$(ele).find('.crsl').jcarousel({scroll:config["scroll"],animation:config["slow"],auto:config["auto"],wrap:config["wrap"],itemFirstInCallback:crsl_itemFirstInCallback,initCallback:crsl_initCallback,start:config["start"]});},dynlead:function(ele,config){config=$.extend({delay:15000,loops:0,showThumbnails:false,widthThumbails:130,pause:null},config);var _timeout;var currentSlide=0;var slides=$(ele).find(".dl-content li");var pageLinks=$(ele).find(".dl-menu");var maxSlides=slides.length;var countLoop=0;$(".video-cn").hide();$(ele).find(".videolink").click(function(){clearTimeout(_timeout);$(this).hide();$(this).parent().find(".video-cn").show();});var play=true;if(config["pause"]!=null){$(ele).find("."+config["pause"]).click(function(){txt=($(this).html()=="PAUSE")?"PLAY":"PAUSE";$(this).html(txt);if(play){clearTimeout(_timeout);play=false;}
else{nextSlide(ele,config);play=true;}});}
slides.not(":first").hide();pageLinks.find("ul > li:first-child").addClass("active");pageLinks.find("ul > li").each(function(i){var $this=$(this);if(config["showThumbnails"]){var thPreviewID=ele.id+"-cn-th-"+i;$this.attr({"rel":"#"+thPreviewID});$this.next(".content-th").attr({"id":thPreviewID});$this.cluetip({width:config["widthThumbails"],cluezIndex:6,cluetipClass:'content-th',local:true,showTitle:false,sticky:true,mouseOutClose:true,closePosition:'title',closeText:'',topOffset:6,leftOffset:-($this.parent().width()),positionBy:'fixed',dropShadow:false,cursor:'hand',titleAttribute:'',waitImage:false});$this.hover(function(e){height=$("#cluetip-inner").outerHeight();$('#cluetip').hide();opt={margin:true,padding:true,border:true,scroll:true};anchorPos=$(this).offset({scroll:true,margin:true,padding:true,border:true});_top=parseInt(anchorPos["top"])-parseInt(height);$('#cluetip').css('top',_top);$('#cluetip').show();},function(){if($('#cluetip').is(':visible')){$('#cluetip').hover(function(){$('#cluetip').show();},function(){$('#cluetip').hide();});$('#cluetip').hide();}});}
$this.click(function(){clearTimeout(_timeout);currentSlide=i;nextSlide(ele,config);});});var nextSlide=function(ele,config){clearTimeout(_timeout);var currentID=ele.id;var currentPage=slides[currentSlide];$(ele).find("li.active").removeClass("active");pageLinks.find("ul > li:eq("+currentSlide+")").addClass("active");$(currentPage).fadeIn('slow').siblings().not(":hidden").fadeOut('slow');if(currentSlide==(maxSlides-1)){currentSlide=0;countLoop++;}
else{currentSlide++;}
if((countLoop<config["loops"])&&(config["loops"]>0)){_timeout=setTimeout(function(){nextSlide(ele,config);},config["delay"]);}};if((config["loops"]>0)){_timeout=setTimeout(function(){nextSlide(ele,config);},config["delay"]);}},accordion:function(el,config){config=$.extend({autoheight:true,header:'.acco-link',animated:($.browser.msie?false:'easeOutSine')},config);jQuery(el).accordion(config);},tabs:function(el,config){jQuery(el).tabs(config);},collapser:function(el,config){config=$.extend({programguide:false,videochannels:false},config);if(config["programguide"]==true){var today=new Date();var current_time=today.getHours();var current_minutes=today.getMinutes();var dayofweek=today.getDay();var weekend=false;if(dayofweek==0||dayofweek==6){weekend=true;}
togglelist.each(function(){var $this=$(this);var target=$this.find("h4");if(!$this.hasClass("active")){$this.find(".crsl-w").hide();};target.click(function(){if($this.hasClass("active")){$this.removeClass("active");$this.find(".crsl-w").hide(250);}else{$this.addClass("active");$this.find(".crsl-w").show(250);}});});};if(config["videochannels"]!=true){$(el).children(":first").each(function(){var $this=$(this);$this.click(function(){$this.parent().toggleClass("active");});});};}};jQuery.fn.dpl=jQuery.dpl.init;
$.ui=$.ui||{};$.fn.extend({dropdown:function(options,data){var args=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof options=="string"){var dropdown=$.data(this,"ui-dropdown");dropdown[options].apply(dropdown,args);}else if(!$(this).is(".ui-dropdown")){$.data(this,"ui-dropdown",new $.ui.dropdown(this,options));}});}});$.ui.dropdown=function(container,options){this.element=$(container);this.options=options=$.extend({},$.ui.dropdown.defaults,options);this.options.title=this.options.title||this.element.find('option.select-title').text();this.element.addClass("ui-dropdown");this.list=buildList(this.element,this.options);this.element.after(this.list);this.css={position:this.element.css('position'),left:this.element.css('left')};this.element.hide();if(this.element.attr('disabled')){this.disable();}else{this.enable();}};$.extend($.ui.dropdown,{defaults:{title:'',disabled:false}});$.ui.dropdown.prototype={enable:function(){var element=this.element;var list=this.list;this.options.disabled=false;this.element.removeAttr('disabled');this.list.find('.disabled').removeClass('disabled');var handle=this.list.find('dt a');handle.mousedown(function(){hideDropDowns();list.find('dd').show();$(this).parent('dt').addClass('active');$('body').bind("mousedown",bodyClicked);return false;});return element;},disable:function(){this.options.disabled=true;this.element.attr('disabled','disabled');this.list.find('dt').addClass('disabled');var handle=this.list.find('dt a');handle.unbind('mousedown');return this.element;},destroy:function(){this.list.remove();this.element.show();this.element.removeClass("ui-dropdown");$.removeData(this.element,"ui-dropdown");},reset:function(){this.list.remove();this.options.title=this.element.find('option.select-title').text();this.list=buildList(this.element,this.options);this.element.after(this.list);},select:function(){select=this.element.get(0);option=select.selectedIndex>-1?select[select.selectedIndex]:false;if(option){this.list.find('dt a').html(option.text+'<em></em>');}},activate:function(event){dropdown=event&&event.data?event.data.dropdown:this;if(!dropdown.options.disabled){hideDropDowns();dropdown.list.find('dd').show();dropdown.list.find('dt').addClass('active');}}};function buildList(element,options){select=element.get(0);option=select.selectedIndex>-1?select[select.selectedIndex]:false;var selected=option?option.text:'';var ddList='<dl class="dd-list">';ddList+=options.disabled?'<dt class="dd-dt disabled">':'<dt class="dd-dt">';ddList+='<a>'+selected+'<em></em></a></dt>';ddList+='<dd style="display: none;">';ddList+='<div class="dd-hd"></div>';ddList+='<div class="dd-bd">';if(options.title){ddList+='<h3>'+options.title+'<a class="close"></a></h3>';}
ddList+='</div>';ddList+='<div class="dd-ft"></div>';ddList+='</dd>';ddList+='</dl>';ddList=$(ddList);ddList.find('.close').click(function(){hideDropDowns();return false;});var list=$('<ul class="dd-ul"></ul>');element.children('option:not(.select-title)').each(function(i){var link=$('<a href="#">'+$(this).text()+'</a>');link.click(function(){ddList.find('dt a').html($(this).text()+'<em></em>');element.find('option:not(.select-title)')[i].selected=true;hideDropDowns();element.trigger('change');return false;});var item=$('<li class="dd-li"></li>').append(link);list.append(item);});ddList.find('.dd-bd').append(list);return ddList;}
function hideDropDowns(event){if(event&&$.browser.mozilla&&$(event.target).hasClass('dd-ul')){return true;}
$('.dd-list dd').hide();$('.dd-list .active').removeClass('active');$('body').unbind("mousedown",bodyClicked);return true;}
function bodyClicked(event){var element=$(event.target);if(element.parents().is('.dd-list')){return false;}else{hideDropDowns();}}
$.ui=$.ui||{};$.fn.extend({dependent_dropdowns:function(options,data){var args=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof options=="string"){var dependent_dropdowns=$.data(this,"ui-dependent-dropdowns");dependent_dropdowns[options].apply(dependent_dropdowns,args);}else if(!$(this).is(".ui-dependent-dropdowns")){$.data(this,"ui-dependent-dropdowns",new $.ui.dependent_dropdowns(this,options));}});}});$.ui.dependent_dropdowns=function(container,options){this.element=$(container);this.options=options=$.extend({},$.ui.dependent_dropdowns.defaults,options);this.dropdowns=this.options.dropdowns||this.element.find('select');this.data=this.options.data;this.element.addClass("ui-dependent-dropdowns");var dd=this;$.each(this.dropdowns,function(i,val){$(val).dropdown();$(val).bind("change",function(){index=$.inArray(this,dd.dropdowns);if(index!=-1){dd._updateValues(index+1);}});});this.enable();};$.ui.dependent_dropdowns.prototype={enable:function(){this._updateValues(0);this.defaults();},disable:function(){},destroy:function(){$.each(this.dropdowns,function(key,value){$(value).destroy();});this.element.removeClass("ui-dependent-dropdowns");$.removeData(this.element,"ui-dependent-dropdowns");},defaults:function(){if(this.data.defaults){var now=new Date();var hours=now.getHours()<10?'0'+now.getHours():now.getHours();var minutes=now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes();var time=hours.toString()+minutes.toString();var dd=this;$.each(this.data.defaults,function(key,values){times=key.split('-');if(dd._checkTime(times[0],times[1],time)){index=0;$.each(values,function(k,v){if(select=dd.dropdowns[index]){$(select).find('option').each(function(){if($(this).val()==v){this.selected=true;$(select).dropdown('select');$(select).trigger('change');}});}
index++;});}});}},_updateValues:function(index){if(index==null){index=0;}
if(dropdown=this.dropdowns[index]){values=this._findValues(this.data.values,0,index);previous_value=$(dropdown).val()||false;if(this.data.titles&&this.data.titles[index]){options='<option value="" class="select-title">'+this.data.titles[index]+'</option>';}else{options='';}
if(values){$.each(values,function(key,val){options+='<option value="'+key+'"';if(previous_value&&previous_value==key){options+=' selected="selected"';}
options+='>'+val.label+'</option>';});}
if(!values){$(dropdown).dropdown('disable');}
$(dropdown).html(options);$(dropdown).dropdown('reset');if(values){$(dropdown).dropdown('enable');}
this._updateValues(index+1);}},_findValues:function(values,start_index,end_index){if(start_index==end_index){return values;}else{values=values[$(this.dropdowns[start_index]).val()];if(values){return this._findValues(values.values,start_index+1,end_index);}else{return null;}}},_updateDropdown:function(dropdown){if(index=$.inArray(dropdown,this.dropdowns)){this._updateValues(index+1);}},_checkTime:function(from_time,to_time,time){if(to_time<from_time){if(time>=from_time&&time<2400){return true;}else if(time<to_time&&time>=0){return true;}}else if(time>=from_time&&time<to_time){return true;}
return false;}};


