ITVM=window.ITVM||{};ITVM.UI=(function($){function setupNavigations(){$("#main-navigation > ul > li").hover(function(){$(this).find(".subnav").show();}),function(){$(this).find(".subnav").hide();}}function setupTabs(){$('#page .tabbed-content > div').addClass('copyarea');$('#page .tabbed-content .tabs li a').click(function(e){var parent=$(this).parent();var target=$(this).attr('href');parent.siblings().removeClass('selected');$('#page .tabbed-content .copyarea').removeClass('selected');parent.addClass('selected');$(target).addClass('selected');if(ITVM.UI.postProcessTabsIE){ITVM.UI.postProcessTabsIE();}e.preventDefault();});$('#page .tabbed-content .tabs li.last a').unbind('click').click(function(e){e.preventDefault();});$('#page .tabbed-content .tabs li:first-child a').click();}function changeVideo(sender,container){$("#"+container).html("");$("#"+container).flash({src:'/common/modules/net.johnhenry.website/flash/video_player/flash/output/video_player.swf',width:300,height:240,wmode:'transparent',flashvars:{video_url:$(sender).val(),skin_url:"/common/modules/net.johnhenry.website/flash/video_player/flash/output/skin/SteelExternalAll.swf"}},{expressInstall:true});}function expandVideo(video_url,video_title,client_id){var addVideoFunction=function(container){$(container).html("");$(container).flash({id:client_id,src:'/common/modules/net.johnhenry.website/flash/video_player/flash/output/video_player.swf',width:836,height:550,wmode:'transparent',flashvars:{video_url:video_url,skin_url:"/common/modules/net.johnhenry.website/flash/video_player/flash/output/skin/SteelExternalAll.swf",in_markup_id:client_id}},{expressInstall:true});}var params=$.extend(ITVM.UI.Dialog.presets.EXPAND_VIDEO,{content:addVideoFunction,title:video_title});ITVM.UI.Dialog.show(params);}function showLoginDialog(e){var d=ITVM.UI.Dialog;var dlg=$.extend(true,{},d.presets.LOGIN);dlg.content=document.getElementById('login-field-container');d.show(dlg);e.preventDefault();}function showForgottenLoginDialog(e){var d=ITVM.UI.Dialog;var dlg=$.extend(true,{},d.presets.LOGIN);dlg.content=document.getElementById('login-forgotten-container');d.show(dlg);e.preventDefault();}function setupLogin(){$('#login-button,.login-surrogate').click(showLoginDialog);}function setupForgottenLogin(){$('#login-field-container').find('.forgotten').click(showForgottenLoginDialog);}return{setupTabs:setupTabs,setupLogin:setupLogin,setupForgottenLogin:setupForgottenLogin,changeVideo:changeVideo,expandVideo:expandVideo};}(jQuery));ITVM.UI.Dialog=(function($){var contentParentNode;var presets={PP_ADDED_TO_BASKET:{customClasses:'buying d-added-to-basket',title:'That\'s done',content:'<p>Added to:</p><div class="basket-name">[ Orange, New Animal Package ]</div>',buttons:[{label:'Close',action:'close',placement:'left'},{label:'Go to campaign',action:'template_planner_3.shtml',placement:'right'}]},PP_ADD_TO_NEW_BASKET:{customClasses:'buying d-add-to-new-basket',title:'New campaign',content:'<p>Your campaign should be labelled as &lt;client name&gt;,&lt;campaign&gt;<br />eg. DFS, Spring Sale</p><div class="basket-name"><label for="newname">Campaign name:</label><input type="text" id="newname" name="newname" value="" /></div>',buttons:[{label:'Cancel',action:'close',placement:'left'},{label:'Create &amp; add to new campaign',action:'submit',placement:'right'}]},LOGIN:{customClasses:'login',title:'Login',buttons:[{label:'Cancel',action:'close',placement:'left'}]},EXPAND_VIDEO:{customClasses:'expanded_video',title:'Expanded video',button:[{action:'close',placement:'right'}]}};function buttonise(button){var anchor=$('<a href="#">'+button.label+'</a>').get();if($.isFunction(button.action)){$(anchor).click(function(ev){button.action();ev.preventDefault();});}else{switch(button.action){case'close':$(anchor).click(function(ev){close();ev.preventDefault();});break;case'submit':break;default:$(anchor).attr({href:button.action});}}return $(anchor).wrap('<div class="button '+button.placement+'"></div>').parent('div').get();}function show(params){close();var i,panelHeight,dialogHeight;var defaults={modal:true,close:true,customClasses:'',title:'default title',content:'default content',buttons:[],x:'auto',y:'auto'};var options=$.extend(defaults,params);$('#dialog-panel').toggleClass('modal',options.modal);$('#dialog-panel').toggleClass('non-modal',!options.modal);$('#dialog-panel .dialog').addClass(options.customClasses);$('#dialog-panel .dialog h3').text(options.title);switch(typeof options.content){case'string':$('#dialog-panel .dialog .content').html(options.content);break;case'object':contentParentNode=options.content;$('#dialog-panel .dialog .content').html('<div></div>');$(contentParentNode).children().insertAfter('#dialog-panel .dialog .content > div');$('#dialog-panel .dialog .content > div:first-child').remove();break;case'function':options.content($('#dialog-panel .dialog .content'));break;}if(options.close){$('<span class="close">X</span>').appendTo('#dialog-panel .dialog h3').click(close);}if(!options.modal){$('#dialog-panel').css({top:options.y,left:options.x});}if(options.buttons.length){for(i=0;i<options.buttons.length;i++){$('#dialog-panel .buttons').append($(buttonise(options.buttons[i])));}$('#dialog-panel .buttons').show();}else{$('#dialog-panel .canvas').addClass('no-buttons');$('#dialog-panel .buttons').hide();}if(options.modal){$('#dialog-panel-cover').show();}$('#dialog-panel').show();if(options.modal){panelHeight=$('#dialog-panel').innerHeight();dialogHeight=$('#dialog-panel .dialog').height();if($('#dialog-panel-cover').length){$('#dialog-panel .dialog').css({'margin-top':($(window).scrollTop()+200)});}else{$('#dialog-panel .dialog').css({'margin-top':(Math.floor(panelHeight/2)-Math.floor(dialogHeight/2))});}}}function close(){$('#dialog-panel.non-modal').removeAttr('style');$('#dialog-panel .dialog').removeAttr('style').attr({'class':'dialog'});$('#dialog-panel .canvas').removeAttr('style');$('#dialog-panel').removeClass('modal non-modal').hide();$('#dialog-panel-cover').hide();$('#dialog-panel .buttons').empty();if(contentParentNode){$(contentParentNode).html('<div></div>');$('#dialog-panel .dialog .content').children().insertAfter('#'+contentParentNode.id+' div');$('#'+contentParentNode.id+' > div:first-child').remove();contentParentNode=null;}$("#dialog-panel").find("embed").each(function(){var node=$(this).parent();var content=node.html();node.html("");node.html(content);});}return{presets:presets,show:show,close:close};})(jQuery);ITVM.UI.Search=(function(){function testCriterion(e,findCriterion){if(findCriterion.slice(0,1)=='.'){return NETJOHNHENRY.dom.hasClass(e,findCriterion.slice(1));}else
{return e.nodeName.toLowerCase()==findCriterion.toLowerCase();}}function toggleGroup(e,findCriterion){var ev,target,sib;ev=NETJOHNHENRY.normaliseEvent(e);target=NETJOHNHENRY.normaliseEventTarget(e);if(hasClass(target,'expandhint')){target=target.parentNode;}sib=target.nextSibling;while(sib&&(sib.nodeType==3||!testCriterion(sib,findCriterion))){sib=sib.nextSibling;}if(sib!==null){switch(sib.style.display){case'none':sib.style.display='block';break;case'block':default:sib.style.display='none';}if(ev.preventDefault){ev.preventDefault();}else
{ev.returnValue=false;}}}return{toggleGroup:toggleGroup}})();jQuery(ITVM.UI.setupNavigations);jQuery(ITVM.UI.setupTabs);jQuery(ITVM.UI.setupLogin);jQuery(ITVM.UI.setupForgottenLogin);
