/* Global Variable NOTE: I know it's not enice to cloud the global namespace! */ var enlarged = false; var curScreenshot = 1; var nav_btns = new Array(); animation=false; /*Tabs8*/ function tabsReset () { $$('.recipe div').each(function(el) { el.style.display='none'; }); }; function chagePage(showPage) { if($defined($("recipeNav"))) { tabsReset (); } $$('.active').removeClass("active"); var tabName = showPage+'Tab'; $(tabName).addClass('active'); $(showPage).style.display='block'; }; /* get informed page */ function changeSectionWithDropDown(_select) { for(var i = 0; i < _select.options.length; i++) { $(_select.options[i].value).style.display = "none"; } $(_select.options[_select.selectedIndex].value).style.display="block"; } /* products panes */ function changePane(pane,tab) { var tabs = $$("#productCatTabs img"); for(var i = 0; i < tabs.length; i++) { tabs[i].src = tabs[i].src.replace(/\.on/g,'.off'); } $(tab).src = $(tab).src.replace(/\.off/g,'.on'); var panes = $$("#productsContainer div"); for(var i = 0; i < panes.length; i++) { panes[i].style.display='none'; } $(pane).style.display='block'; //console.log($(pane)); } /* Screen shots */ function screenshotScroller () { var width = 0; var screenshots = $('screenShots'); var newLeft = 0; var aspectRatio = "null"; if(aspectRatio == "standard") { var deltaLeft = 476; } else if(aspectRatio == "widescreen"){ var deltaLeft = 649; } else { var deltaLeft = 262; } var totalItems = $$('.screenShot').length - 1; $$('.screenShot').each(function (el) { width += deltaLeft; }); screenshots.setStyle('width', width); var slide = new Fx.Style(screenshots, 'left', { duration: 700 }); $ES('.next').addEvent('click',function (event) { if (Math.abs(screenshots.getStyle('left').toInt() - deltaLeft*totalItems) >= screenshots.getStyle('width').toInt()) { //at end screenshots.getFirst().injectAfter(screenshots.getLast()); screenshots.setStyle('left', (screenshots.getStyle('left').toInt()+deltaLeft)+"px"); startPos = screenshots.getStyle('left').toInt(); endPos = startPos - deltaLeft; } else { startPos = screenshots.getStyle('left').toInt(); endPos = startPos - deltaLeft; } /* for tracking current screenshot being viewed */ if(curScreenshot > totalItems) { curScreenshot = 1; } else { curScreenshot += 1; } slide.start(startPos, endPos); }); $ES('.back').addEvent('click',function (event) { if (screenshots.getStyle('left').toInt() == 0 || screenshots.getStyle('left').toInt() == -1) { //at start screenshots.getLast().injectBefore(screenshots.getFirst()); screenshots.setStyle('left', (-deltaLeft)+"px"); startPos = -deltaLeft; endPos = 0; } else { startPos = screenshots.getStyle('left').toInt(); endPos = startPos + deltaLeft; } /* for tracking current screenshot being viewed */ if(curScreenshot < 2) { curScreenshot = 3; } else { curScreenshot -= 1; } slide.start(startPos, endPos); }); } /* launch smoothbox */ function screenshotEnlarger() { var enlargeButton = $('enlargeButton'); if($defined(enlargeButton)) { enlargeButton.addEvent('click',function(event) { var event = new Event(event); event.preventDefault(); var imgs = $$("#screenShots img"); var imgPrefix = imgs[0].src.split(/\//).pop().split(/\./)[0]; if($defined($('aspectRatio'))) { var aspectRatio = $('aspectRatio').value; } else { var aspectRatio = "widescreen"; } var url = this.href + "?current=" + curScreenshot + "&count=" + imgs.length + "&imgprefix=" + imgPrefix + "&aspectRatio=" + aspectRatio + "&KeepThis=true&TB_iframe=true&height=385&width=620"; TB_show("", url, null); }); } } function videoTB() { $$('.videoTB').addEvent('click', function(event) { var event = new Event(event); event.preventDefault(); TB_show("Isabelle Racicot", "../video.jsp?&KeepThis=true&TB_iframe=true&height=400&width=596", null); }); } Window.onload = function(){ if ($defined($('learnMoreSelect'))) { $('learnMoreSelect').selectedIndex=0; } $$('.btn').each(function (el) { nav_btns[el.id] = new NavButton(el); }); /*pickUpandPlay scroller*/ puapScroller(); /*Image Preloading*/ var contextPath = '/fr/images/'; var preLoadedImages = [ contextPath + 'nav.item1.on.gif', contextPath + 'nav.item2.on.gif', contextPath + 'nav.item3.on.gif', contextPath + 'nav.item4.on.gif', contextPath + 'nav.item5.on.gif', contextPath + 'nav.item6.on.gif', contextPath + 'sub.nav.item1.on.gif', contextPath + 'sub.nav.item2.on.gif', contextPath + 'sub.nav.item3.on.gif', contextPath + 'sub.nav.item4.on.gif', contextPath + 'sub.nav.item5.on.gif', contextPath + 'sub.nav.item6.on.gif' ]; new Asset.images(preLoadedImages, { onComplete: function() { /*subnave*/ $$('li.liParents').addEvent('mouseover', function(){ if($('subNav'))$('subNav').style.display='block'; if($('subNav-false')) { $('subNav-prod').style.display='none'; $('subNav-false').style.display='block'; } }); $$('li.liParents').addEvent('mouseout', function(){ if($('subNav'))$('subNav').style.display='none'; if($('subNav-false')) { $('subNav-prod').style.display='block'; $('subNav-false').style.display='none'; } }); $$('li.liProd').addEvent('mouseover', function(){ if($('subNav-prod'))$('subNav-prod').style.display='block'; if($('subNav-prod-false')) { $('subNav').style.display='none'; $('subNav-prod-false').style.display='block'; } }); $$('li.liProd').addEvent('mouseout', function(){ if($('subNav-prod'))$('subNav-prod').style.display='none'; if($('subNav-prod-false')) { $('subNav').style.display='block'; $('subNav-prod-false').style.display='none'; } }); $$('li.liWl').addEvent('mouseover', function(){ $('subNav-wl').style.display='block'; }); $$('li.liWl').addEvent('mouseout', function(){ $('subNav-wl').style.display='none'; }); /*Mouse overs*/ $$('img.navItem').addEvent('mouseover', function(event){ var event = new Event(event); event.target.src = event.target.src.replace(/\.off/g,'.on'); }); $$('img.navItem').addEvent('mouseout', function(event){ var event = new Event(event); event.target.src = event.target.src.replace(/\.on/g,'.off'); }); /*Wishlist effects*/ $$('input.wlds').addEvent('click', function(event) { if(this.checked) { this.nextSibling.firstChild.style.border='5px #f6b35f solid'; this.nextSibling.firstChild.style.padding='0px'; } else { this.nextSibling.firstChild.style.border='none'; this.nextSibling.firstChild.style.padding='5px'; } }); $$('input.wlwii').addEvent('click', function(event) { if(this.checked) { this.nextSibling.firstChild.style.border='5px #bae2f2 solid'; this.nextSibling.firstChild.style.padding='0px'; } else { this.nextSibling.firstChild.style.border='none'; this.nextSibling.firstChild.style.padding='5px'; } }); } }); /*scroller init*/ if ($defined($('screenShots'))) { screenshotScroller(); screenshotEnlarger(); } /*tool tips*/ var tTip = new Tips($$('.toolTip'), { offsets: {'x': -10, 'y': 20}, fixed: true, className: 'fr' }); /* iron ons popup pattern switcher */ $$('.pattern').each(function($el) { $el.addEvent('mouseover',function() { $$('.patternShirt').setStyle('display','none'); $('patternShirt' + this.title).setStyle('display','block'); }); }); playControl(); wii_acc(); videoTB(); }; function puapScroller() { if($defined($('sliderFrame'))){ maxSlides = 1; distance= 225; scrollBox = $('slider'); var scroll = makeScroller(); }; } function makeScroller() { var scroll = scrollEffect().addEvent('onStart', function(){ animation = true; }).addEvent('onComplete', function(){ animation = false; }); $('rightBtn').addEvent('click', function() { if(animation) return; var pos = scrollRight(); scroll.start(pos[0], pos[1]); }); $('leftBtn').addEvent('click', function() { if(animation) return; var pos = scrollLeft(); scroll.start(pos[0], pos[1]); }); return scroll; } function scrollRight() { scrollBox.getFirst().injectAfter(scrollBox.getLast()); scrollBox.setStyle('left', (scrollBox.getStyle('left').toInt()+distance)+"px"); var startPos = scrollBox.getStyle('left').toInt(); var endPos = startPos - distance; return new Array(startPos,endPos); } function scrollLeft() { scrollBox.getLast().injectBefore(scrollBox.getFirst()); scrollBox.setStyle('left', (scrollBox.getStyle('left').toInt()-distance)+"px"); var startPos = scrollBox.getStyle('left').toInt(); var endPos = startPos + distance; //console.log(startPos+ ' '+endPos); return new Array(startPos,endPos); } function scrollEffect() { var scroll = new Fx.Style('slider', 'left', { duration: 1500, transition: Fx.Transitions.Quad.easeInOut }); return scroll; } function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName] } else { return document[movieName] } } function playMovie(movieFile, top) { $('flashToolTip').style.top='0'; $('flashToolTip').style.left='0'; $('flashToolTip').style.width='100%'; $('flashToolTip').style.height='100%'; $('flashToolTip').style.textAlign='center'; $('flashToolTip').style.padding=top+'px 0 0 0'; var movie = thisMovie("flashTip"); movie.startMovie(movieFile); } function closeMovie() { $('flashToolTip').style.padding='0'; $('flashToolTip').style.width='1px'; $('flashToolTip').style.height='1px'; movie.dumpMovie(); } /*mouse over*/ var NavButton = new Class({ initialize: function(el){ this.el = el; ref = this; this.src = el.getProperty('src'); el.addEvent('mouseover', function (e) { e = new Event(e); el.setProperty('src',this.src.replace(/.off/,'.on')); }.bind(ref)); el.addEvent('mouseout', function (e) { e = new Event(e); el.setProperty('src',this.src); }.bind(ref)); } }); /* display contact us pop up */ function displayPopUp(url,width,height,scroll) { if($defined(scroll)) { window.open(url,"","chrome=yes,scrollbars="+scroll+",width="+width+",height="+height+""); }else{ window.open(url,"","chrome=yes,width="+width+",height="+height+""); }; } function showSwf(el,name,width,height) { var so = new SWFObject("/swf/"+name, "mymovie", width, height, "8", "#ffffff"); so.addParam("wmode", "transparent"); so.write(el); } function playControl() { $$('.game').addEvent('mouseover', function () { $(this).setOpacity(1); }); $$('.game').addEvent('mouseout', function () { $(this).setOpacity(0.5); }); $ES('.game').addEvent('click', function () { var featured = $$('.featured').getProperty('src'); var src = this.getProperty('src').split('.')[0].split('/'); var length = src.length; var game = src[length - 1]; var old = this; $$('#game_content div').setStyle('display', 'none'); var featureFadeIn = new Fx.Style($E('.featured'), 'opacity', { duration: 350 }); var featureFadeOut = new Fx.Style($E('.featured'), 'opacity', { duration: 350 }); var contentFadeIn = new Fx.Style($(game), 'opacity', { duration: 350 }); var contentFadeOut = new Fx.Style($(game), 'opacity', { duration: 350 }); contentFadeOut.start(1,0).addEvent('onComplete', function() { featureFadeIn.start(0,1).addEvent('onComplete', function () { $(game).setStyle('display', 'block'); $$('.copy').setStyle('display', 'block'); contentFadeIn.start(0,1); }); }); featureFadeOut.start(1,0).addEvent('onComplete', function() { $E('.featured').setProperty('src', old.getProperty('src').toString().replace('.small.', '.big.')); old.setProperty('src', featured[0].toString().replace('.big.', '.small.')); featureFadeIn.start(0,1).addEvent('onComplete', function () { }); }); /* var gameFade = new Fx.Style(this, 'opacity', { duration: 350 }); var gameFade2 = new Fx.Style(this, 'opacity', { duration: 350 }); gameFade.start(1,0).addEvent('onComplete', function() { old.setProperty('src', featured[0].toString().replace('.big.', '.small.')); gameFade2.start(0,1); }); */ }); $$('#playcontrols .buynow').addEvent('mouseover', function () { $ES('#playcontrols .buynow_popup').setStyle('display', 'block'); $ES('#playcontrols .stores').setStyle('display', 'block'); }); $ES('#playcontrols .buynow_popup').addEvent('mouseleave', function () { $ES('#playcontrols .buynow_popup').setStyle('display', 'none'); }); } function wii_acc() { $$('.wiiacc-tout .buynow').addEvent('mouseover', function () { $(this).getNext().setStyle('display', 'block'); $$('.wiiacc-tout .stores').setStyle('display', 'block'); }); $ES('.wiiacc-tout .buynow_popup').addEvent('mouseleave', function () { $ES('.wiiacc-tout .buynow_popup').setStyle('display', 'none'); }); }