(function(window,undefined) { //if (eval("typeof window.History.getState() != 'function'")) return false; if (typeof window['History']['getState'] !== 'function') { return false;} var History = window.History,State = History.getState(); History.Adapter.bind(window, 'hashchange', function(){ var State = History.getState(); var mod = (State.data.back) ? '-' : ''; $.ajax({ type: "GET", url: State.url+'?_suid='+new Date().getTime(), dataType: 'html', error: function(req,text) { var html = req.responseText; var height = $('#container').height(); if ($('#container .contentHolder').length) $('#container').empty(); // fix for back/forward buttons not hitting site.load rollover.hideFast();rolloverbottom.hideFast(); $('
'+html+'
').appendTo('#container'); $('.contentHolder', '#container').animate({marginTop:0},500, 'easeOutQuart', function(){ if (typeof window.pagerun == 'function') { window.pagerun(); if (typeof window.pagerun == 'function') { delete window.pagerun; } }}); }, success: function(html) { var height = $('#container').height(); if ($('#container .contentHolder').length) $('#container').empty(); // fix for back/forward buttons not hitting site.load rollover.hideFast();rolloverbottom.hideFast(); $('
'+html+'
').appendTo('#container'); $('.contentHolder', '#container').animate({marginTop:0},500, 'easeOutQuart', function(){ if (typeof window.pagerun == 'function') { window.pagerun(); if (typeof window.pagerun == 'function') { delete window.pagerun; } }}); } }); }); History.Adapter.bind(window, 'statechange', function(){ if ($.browser.msie) return; var State = History.getState(); var mod = (State.data.back) ? '-' : ''; $.ajax({ type: "GET", url: State.url+'?_suid='+new Date().getTime(), dataType: 'html', error: function(req,text) { var html = req.responseText; var height = $('#container').height(); if ($('#container .contentHolder').length) $('#container').empty(); // fix for back/forward buttons not hitting site.load rollover.hideFast();rolloverbottom.hideFast(); $('
'+html+'
').appendTo('#container'); $('.contentHolder', '#container').animate({marginTop:0},500, 'easeOutQuart', function(){ if (typeof window.pagerun == 'function') { window.pagerun(); if (typeof window.pagerun == 'function') { delete window.pagerun; } }}); }, success: function(html) { var height = $('#container').height(); if ($('#container .contentHolder').length) $('#container').empty(); // fix for back/forward buttons not hitting site.load rollover.hideFast();rolloverbottom.hideFast(); $('
'+html+'
').appendTo('#container'); $('.contentHolder', '#container').animate({marginTop:0},500, 'easeOutQuart', function(){ if (typeof window.pagerun == 'function') { window.pagerun(); if (typeof window.pagerun == 'function') { delete window.pagerun; } }}); } }); }); })(window); var site = { timerStart : null, timerCurrent : null, timerInterval : undefined, init : function() { form.label($('#search-box')); // and do it again just for laughs (there is a reason behind this) $(window).load(function(){ form.label($('#search-box')); }); rollover.attachhide(); rolloverbottom.attachhide(); searcher.ac(); }, top : function(handler) { $("html,body").animate({ scrollTop: 0 }, 750, 'easeInOutQuart'); return false; }, to : function(handler, callback) { if ($(window).scrollTop() < 1) { if (typeof callback == "function") callback();return false; } var top = (typeof handler != 'undefined' && $(handler).length) ? $(handler).offset().top : 0; $("html,body").animate({ scrollTop: top }, 750, 'easeInOutQuart'); setTimeout(function(){ typeof callback == "function" && callback(); },750); return false; }, load : function(url, back, cls) { // first check if we are on careers page and bust out of it if (window.location.pathname == '/careers' || window.location.pathname == '/contact/careers') return true; //if (url == window.location.href) return site.top(); if (typeof url == "object"){ //console.log($(url).is('a')); $('li a', '#links ul').removeClass('active'); $('li a', '#blinks ul').removeClass('active'); if ($(url).is('a') && $(url).parent().parent().is('ul') && !cls) { if ($(url).parent().parent().parent().attr('id') == 'links') { var parent = $(url).parent().attr('id'); $('a', '#b'+parent).addClass('active'); } else { var parent = $(url).parent().attr('id'); parent = parent.substring(1); $('a', '#'+parent).addClass('active'); } $(url).addClass('active'); //$('li a', $(url).parent().parent()).removeClass('active'); //$(url).addClass('active'); } else if ($(url).is('a') && ($(url).parent().parent().attr('id') == 'services-bottom-expand' || $(url).parent().parent().attr('id') == 'services-expand')) { $('li a', '#links ul').removeClass('active'); $('li a', '#blinks ul').removeClass('active'); $('a', '#blink-services').addClass('active'); $('a', '#link-services').addClass('active'); } url = $(url).attr('href'); } History.pushState({back: back,rand:Math.random()},false,url); //if (cls && cls.length > 0) site.cls(cls); $('#content').addClass('loading').empty(); //site.timer('start'); return false; }, cls : function(myclass) { if ($('body').attr('class').length > 0 && $('body').attr('class') != myclass) { $('body').switchClass($('body').attr('class'),myclass,0); site.ss(myclass); } }, ss : function(myclass) { switch (myclass) { case 'suppliers' : $('#ui-css').attr('href','/media/css/ui/suppliers/ui.css');break; case 'stock' : $('#ui-css').attr('href','/media/css/ui/stock/ui.css');break; case 'reports' : $('#ui-css').attr('href','/media/css/ui/reports/ui.css');break; case 'orders' : $('#ui-css').attr('href','/media/css/ui/orders/ui.css');break; } }, timer : function(wut) { if (wut == 'start') { site.timerStart = new Date().getTime(); $('#ticker').remove(); if (!$('#ticker').length) { var w = ($(window).width() / 2) - (25 / 2); $('
').appendTo('#content'); } site.timer('update'); } else if (wut == 'update') { if (typeof site.timerInterval == 'undefined') site.timerInterval = setInterval(function(){site.timer('update');}, 10); site.timerCurrent = (new Date().getTime() - site.timerStart) / 1000; site.timerCurrent = (Math.round(site.timerCurrent*100)/100).toFixed(2); $('#ticker').text(site.timerCurrent); } else if (wut == 'end') { clearInterval(site.timerInterval); site.timerInterval = undefined; if (site.timerCurrent < 1) { $('#ticker').remove(); return false;} //var text = $('#ticker').text(); //$('#ticker').text('Loaded in '+text+' seconds'); if ($('#ticker').length) { $('#ticker').hide(); setTimeout(function(){ $('#ticker').show(); $('#ticker').animate({top:'155px',fontSize:24+'px'},500, function(){ $('#ticker').fadeOut(500, function(){$('#ticker').remove();}); }); },250); } } return false; } }; var test = { init : function() { $('#slideshow-testimonials .testimonial').each(function() { $(this).hide(); }); $('#slideshow-testimonials .testimonial:first').show(); // hide controls if theres just one testimonial if ($('#slideshow-testimonials .testimonial').length == 1) $('#testimonial-controls').hide(); }, change : function(state) { if ($('#slideshow-testimonials .testimonial:animated').length > 0) return false; if (state == 'up') { var current = $('#slideshow-testimonials .testimonial:visible'); if (current.length > 1) current = current[1]; var next = $('#slideshow-testimonials .testimonial:visible').next('.testimonial'); if (!next.length) next = $('#slideshow-testimonials .testimonial:first'); // setup next var height = $(current).height(); $('#testimonial-up').addClass('on'); $(next).css({display:'block',opacity:1,top:height+'px'}); $(current).animate({opacity:0,top: '-'+height+'px'}, 750,'easeOutCubic',function(){$(current).css({display:'none'});$('#testimonial-up').removeClass('on');}); $(next).animate({top: '0px'}, 750,'easeOutCubic'); } else { var current = $('#slideshow-testimonials .testimonial:visible'); if (current.length > 1) current = current[0]; var next = $('#slideshow-testimonials .testimonial:visible').prev('.testimonial'); if (!next.length) next = $('#slideshow-testimonials .testimonial:last'); // setup next var height = $(current).height(); $('#testimonial-down').addClass('on'); $(next).css({display:'block',opacity:1,top:'-'+height+'px'}); $(current).animate({opacity:0,top: height+'px'}, 750,'easeOutCubic',function(){$(current).css({display:'none'});$('#testimonial-down').removeClass('on');}); $(next).animate({top: '0px'}, 750,'easeOutCubic'); } return false; } }; var slide = { init : function() { if (!$('#slideshow-quote').length && !$('#slideshow-image').length) return false; $('#slideshow-quote .quote').each(function(){ $(this).hide(); }); $('#slideshow-quote .quote:first').show(); $('#controls-bottom ul').empty(); $('#slideshow-image img').each(function(i,v){ //$('#controls-bottom ul').append('
  • '); $('#controls-bottom ul').append('
  • '); $(this).hide(); }); $('#controls-bottom ul li:first a').addClass('active'); $('#slideshow-image img:first').show(); //$('#slideshow-image img:first').load(function(){$(this).fadeIn('250','easeOutCubic');}); /*if ($('#slideshow-image img:first').data('doneanim') != 1) { $('#slideshow-image img:first').fadeIn('250','easeOutCubic').data('doneanim', 1); } else { $('#slideshow-image img:first').show(); }*/ if ($('#slideshow-image img').length == 1 || $('#slideshow-quote .quote').length == 1) { $('#controls-bottom').hide(); $('#controls-right').hide(); } }, go : function(no) { var imgIndex = $('img').index($('#slideshow-image img.active')) - 1; if (no >= imgIndex) { var count = 35; for (;imgIndex<=no;imgIndex++) { //setTimeout(function(){slide.change('up', 35);},count); slide.change('up', 35, function() {slide.change('up', 35);}); //count+=35; } } else { for (;no<=imgIndex;no++) { slide.change('down', 125); } } return false; }, change : function(state, speed) { if (!speed) speed = 750; if ($('#slideshow-quote .quote:animated').length > 0) return false; if (state == 'up') { var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[1]; var next = $('#slideshow-quote .quote:visible').next('.quote'); if (!next.length) next = $('#slideshow-quote .quote:first'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[1]; var nextImage = $('#slideshow-image img:visible').next('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:first'); $('#slideshow-arrow-up').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: height+'px'}); $(nextImage).addClass('active').css({display:'block', top: heightImage+'px'}); $(current).animate({opacity:1,top:'-'+height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-up').removeClass('on');}); $(currentImage).removeClass('active').animate({top:'-'+(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } else if (state == 'down') { var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[0]; var next = $('#slideshow-quote .quote:visible').prev('.quote'); if (!next.length) next = $('#slideshow-quote .quote:last'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[0]; var nextImage = $('#slideshow-image img:visible').prev('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:last'); $('#slideshow-arrow-down').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: '-'+height+'px'}); $(nextImage).addClass('active').css({display:'block', top: '-'+heightImage+'px'}); $(current).animate({opacity:1,top:height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-down').removeClass('on');}); $(currentImage).removeClass('active').animate({opacity:1,top:(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } else if (typeof state == 'number') { // the offset var imgIndex = $('img').index($('#slideshow-image img.active')) - 1; if (state > imgIndex) { speed = 200; var times = state - imgIndex; var count = 1; console.log('state: '+state+' imgIndex: '+imgIndex+' times: '+times); // do it one time var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[1]; var next = $('#slideshow-quote .quote:visible').next('.quote'); if (!next.length) next = $('#slideshow-quote .quote:first'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[1]; var nextImage = $('#slideshow-image img:visible').next('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:first'); $('#slideshow-arrow-up').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: height+'px'}); $(nextImage).addClass('active').css({display:'block', top: heightImage+'px'}); $(current).animate({opacity:1,top:'-'+height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-up').removeClass('on');}); $(currentImage).removeClass('active').animate({top:'-'+height+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); var interval = setInterval(function(){ count++; console.log('setInterval: '+count); if (count >= times) { clearInterval(interval);return false;} var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[1]; var next = $('#slideshow-quote .quote:visible').next('.quote'); if (!next.length) next = $('#slideshow-quote .quote:first'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[1]; var nextImage = $('#slideshow-image img:visible').next('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:first'); $('#slideshow-arrow-up').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: height+'px'}); $(nextImage).addClass('active').css({display:'block', top: heightImage+'px'}); $(current).animate({opacity:1,top:'-'+height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-up').removeClass('on');}); $(currentImage).removeClass('active').animate({top:'-'+height+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); },200); } else { speed = 200; var times = imgIndex; var count = 1; console.log('state: '+state+' imgIndex: '+imgIndex+' times: '+times); // do it one time var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[0]; var next = $('#slideshow-quote .quote:visible').prev('.quote'); if (!next.length) next = $('#slideshow-quote .quote:last'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[0]; var nextImage = $('#slideshow-image img:visible').prev('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:last'); $('#slideshow-arrow-down').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: '-'+height+'px'}); $(nextImage).addClass('active').css({display:'block', top: '-'+heightImage+'px'}); $(current).animate({opacity:1,top:height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-down').removeClass('on');}); $(currentImage).removeClass('active').animate({opacity:1,top:height+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); var interval = setInterval(function(){ count++; console.log('setInterval: '+count); if (count >= times) { clearInterval(interval);return false;} var current = $('#slideshow-quote .quote:visible'); if (current.length > 1) current = current[0]; var next = $('#slideshow-quote .quote:visible').prev('.quote'); if (!next.length) next = $('#slideshow-quote .quote:last'); var currentImage = $('#slideshow-image img:visible'); if (currentImage.length >1) currentImage = currentImage[0]; var nextImage = $('#slideshow-image img:visible').prev('img'); if (!nextImage.length) nextImage = $('#slideshow-image img:last'); $('#slideshow-arrow-down').addClass('on'); var height = $(current).height(); var heightImage = $(currentImage).height(); $(next).css({display:'block', opacity: 1, top: '-'+height+'px'}); $(nextImage).addClass('active').css({display:'block', top: '-'+heightImage+'px'}); $(current).animate({opacity:1,top:height+'px'}, speed, 'easeOutCubic', function(){$(current).css({display:'none'});$('#slideshow-arrow-down').removeClass('on');}); $(currentImage).removeClass('active').animate({opacity:1,top:height+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});}); $(next).animate({top: '0px'}, speed, 'easeOutCubic'); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-image img.active')); $('#controls-bottom ul li a').removeClass('active'); $('#controls-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); },200); } } return false; } }; var slidemini = { init : function() { if (!$('#slideshow-mini-image').length) return false; $('#controls-mini-bottom ul').empty(); $('#slideshow-mini-image img').each(function(i,v){ //$('#controls-bottom ul').append('
  • '); $('#controls-mini-bottom ul').append('
  • '); $(this).hide(); }); //$('#slideshow-mini-image img:first').fadeIn('250','easeOutCubic'); $('#slideshow-mini-image img:first').show(); if ($('#slideshow-mini-image img').length == 1) { $('#controls-mini-bottom').hide(); $('#controls-mini-right').hide(); } else { $('#controls-mini-bottom ul li:first a').addClass('active'); } }, change : function(state, speed) { if (!speed) speed = 750; if ($('#slideshow-mini-image img:animated').length > 0) return false; if (state == 'up') { var currentImage = $('#slideshow-mini-image img:visible'); if (currentImage.length >1) currentImage = currentImage[1]; var nextImage = $('#slideshow-mini-image img:visible').next('img'); if (!nextImage.length) nextImage = $('#slideshow-mini-image img:first'); $('#slideshow-arrow-mini-up').addClass('on'); var heightImage = $(currentImage).height(); $(nextImage).addClass('active').css({display:'block', top: heightImage+'px'}); $(currentImage).removeClass('active').animate({top:'-'+(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});$('#slideshow-arrow-mini-up').removeClass('on');}); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-mini-image img.active')); $('#controls-mini-bottom ul li a').removeClass('active'); $('#controls-mini-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } else if (state == 'down') { var currentImage = $('#slideshow-mini-image img:visible'); if (currentImage.length >1) currentImage = currentImage[0]; var nextImage = $('#slideshow-mini-image img:visible').prev('img'); if (!nextImage.length) nextImage = $('#slideshow-mini-image img:last'); $('#slideshow-arrow-mini-down').addClass('on'); var heightImage = $(currentImage).height(); $(nextImage).addClass('active').css({display:'block', top: '-'+heightImage+'px'}); $(currentImage).removeClass('active').animate({opacity:1,top:(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});$('#slideshow-arrow-mini-down').removeClass('on');}); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('img').index($('#slideshow-mini-image img.active')); $('#controls-mini-bottom ul li a').removeClass('active'); $('#controls-mini-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } return false; } }; var slidemedia = { init : function() { if (!$('#slideshow-media-image').length) return false; $('#controls-media-bottom ul').empty(); $('#slideshow-media-image div').each(function(i,v){ //$('#controls-bottom ul').append('
  • '); $('#controls-media-bottom ul').append('
  • '); $(this).hide(); }); //$('#slideshow-mini-image img:first').fadeIn('250','easeOutCubic'); $('#slideshow-media-image div:first').show(); if ($('#slideshow-media-image div').length == 1) { $('#controls-media-bottom').hide(); $('#controls-media-right').hide(); } else { $('#controls-media-bottom ul li:first a').addClass('active'); } }, change : function(state, speed) { if (!speed) speed = 750; if ($('#slideshow-media-image div:animated').length > 0) return false; if (state == 'up') { var currentImage = $('#slideshow-media-image div:visible'); if (currentImage.length >1) currentImage = currentImage[1]; //$('iframe', currentImage).get(0).api_pause(); var nextImage = $('#slideshow-media-image div:visible').next('div'); if (!nextImage.length) nextImage = $('#slideshow-media-image div:first'); $('#slideshow-media-arrow-up').addClass('on'); var heightImage = $(currentImage).height(); $(nextImage).addClass('active').css({display:'block', top: heightImage+'px'}); $(currentImage).removeClass('active').animate({top:'-'+(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});$('#slideshow-arrow-media-up').removeClass('on');}); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('div').index($('#slideshow-media-image div.active')); $('#controls-media-bottom ul li a').removeClass('active'); $('#controls-media-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } else if (state == 'down') { var currentImage = $('#slideshow-media-image div:visible'); if (currentImage.length >1) currentImage = currentImage[0]; //$('iframe', currentImage).get(0).api_pause(); var nextImage = $('#slideshow-media-image div:visible').prev('div'); if (!nextImage.length) nextImage = $('#slideshow-media-image div:last'); $('#slideshow-media-arrow-down').addClass('on'); var heightImage = $(currentImage).height(); $(nextImage).addClass('active').css({display:'block', top: '-'+heightImage+'px'}); $(currentImage).removeClass('active').animate({opacity:1,top:(heightImage/4)+'px'}, speed, 'easeOutCubic', function(){$(currentImage).css({display:'none'});$('#slideshow-arrow-media-down').removeClass('on');}); $(nextImage).animate({top: '0px'}, speed, 'easeOutCubic'); var imgIndex = $('div').index($('#slideshow-media-image div.active')); $('#controls-media-bottom ul li a').removeClass('active'); $('#controls-media-bottom ul li:eq('+(--imgIndex)+') a').addClass('active'); } return false; } }; var modal = { box : null, settings: {draggable:false,modal:true,resizable:false,autoOpen:false,hide: "explode",show:'',title:'Loading...'}, init : function() { if (modal.box != null) $(modal.box).dialog( "destroy" ); modal.box = $('').dialog(modal.settings).dialog('open').bind('dialogclose',function(event,ui){ $(event.target).remove(); }); }, message : function(message, buttons) { buttons = $.extend({}, buttons, {Okay: function() {modal.box.dialog('close');}}); modal.init(); $(modal.box).removeClass('modal-loading').html('

    '+message+'

    ').dialog({ resizable: false, modal: true, title: 'For your information', buttons: buttons }).dialog('open'); return false; }, close : function() { if (modal.box != null) modal.box.dialog("close"); //setTimeout(function(){$('.ui-dialog').remove();},1000); } }; var conv = { feetormetres : function(handler) { if ($('#conv-feetormetres option:selected').val() == 'feet') { $('#label-entry').text('Feet'); $('#label-result').text('Metres'); } else { $('#label-entry').text('Metres'); $('#label-result').text('Feet'); } conv.convert($('#conv-entry')); }, convert : function(handler) { var value = parseFloat($(handler).val().replace(/[^0-9\.]/g, '')); var result = 0; if ($('#conv-feetormetres option:selected').val() == 'feet') { result = parseFloat(value * 0.3048); var actual = result.toFixed(2); var remainder = (actual + "").split('.'); if (remainder[1] == 0) actual = Math.round(actual); if (!isNaN(actual)) { (value == 1) ? $('#label-entry').text('Foot') : $('#label-entry').text('Feet'); $('#conv-result').val(actual); var size = ((actual+'').length) - 8; if (size > 0) { var wut = (18 - size) > 8 ? (18 - size) : 9; $('#conv-result').css({fontSize:wut+'px'}); } else { $('#conv-result').css({fontSize:'18px'}); } } else { $('#conv-result').val(''); } } else { result = parseFloat(value * 3.2808399); var actual = result.toFixed(2); if (!isNaN(actual)) { (value == 1) ? $('#label-entry').text('Metre') : $('#label-entry').text('Metres'); $('#conv-result').val(actual); var size = ((actual+'').length) - 8; if (size > 0) { var wut = (18 - size) > 8 ? (18 - size) : 9; $('#conv-result').css({fontSize:wut+'px'}); } else { $('#conv-result').css({fontSize:'18px'}); } } else { $('#conv-result').val(''); } } } }; var searcher = { vals : [], toggle : function(handler) { if ($('#search-box').is(':hidden')) { $(handler).addClass('active'); $('#search-line').show(); $('#search-box').slideDown(500,'easeOutCubic'); form.label($('#search-box')); } else { $(handler).removeClass('active'); $('#search-box').slideUp(500,'easeOutCubic', function(){$('#search-line').hide();}); } return false; }, ac : function() { $('#search-go').autocomplete({ minLength : 0, source: searcher.vals, focus: function(event,ui) { return false; }, select : function(event,ui){ $('#search-go').val(''); site.load(ui.item.link); searcher.toggle($('#link-search a')); return false; } }).data("autocomplete")._renderItem = function(ul, item) { return $("
  • ").data("item.autocomplete", item).append(''+item.label+''+item.desc+'').appendTo(ul); }; } }; var login = { toggle : function(handler) { if ($('#login-box').is(':hidden')) { $(handler).addClass('active'); $('#login-box').show(); $('#login-box').slideDown(500,'easeOutCubic'); form.label($('#login-box')); } else { $(handler).removeClass('active'); $('#login-box').slideUp(500,'easeOutCubic', function(){$('#login-box').hide();}); } return false; } }; var form = { holder : null, submit: function(formid, holder, callback) { if (!holder) holder = 'content'; form.holder = holder; var url = $(formid).attr('action'); var data = ($(formid).length) ? $(formid).serialize() : formid; data += '&ajax=1'; $.ajax({ type: "POST", url: url, data: data, dataType: 'json', error: function(req) { var message = 'Error: '+req.status+ '

    There was an error loading the following URL:

    '+url+'

    Please try again or if this persists contact james@brandfour.com with this error log.

    '; alert(message); //modal.message(message, {}); return false; }, success: function(json) { if (typeof json != 'object') return false; if (json.worked == 1) { //console.log(typeof callback); //typeof callback == "function" && callback(); if (typeof callback == "function") { callback(); } } var html = json.html; if (html && $(form.holder).length) $(form.holder).html(html); return false; } }); return false; }, jsonsubmit: function(formid) { var url = $(formid).attr('action'); var data = ($(formid).length) ? $(formid).serialize() : formid; // add loader to the submit button $('input[type=submit]',formid).addClass('loading'); data += '&ajax=1'; $.ajax({ type: "POST", url: url, data: data, dataType: 'json', error: function(req) { $('input[type=submit]',formid).removeClass('loading'); var message = 'Error: '+req.status+ '

    There was an error loading the following URL:

    '+url+'

    Please try again or if this persists contact james@brandfour.com with this error log.

    '; //alert(message); //modal.message(message, {}); return false; }, success: function(json) { $('input[type=submit]',formid).removeClass('loading'); if (typeof json != 'object') return false; if (json.worked == 1) { form.thanks(formid); } else { var message = json.message; var error = $(formid).find('div.form-error'); $('.form-error', formid).animate({opacity:0},50).html(message).addClass('on').animate({opacity:1},250); } return false; } }); return false; }, thanks : function(formid) { var thanks = $('

    Thank you for filling out our online form. A member of our team will get back to you shortly.
    ').insertBefore(formid); $(thanks).hide(); $(formid).animate({height:0,opacity:0},950, function(){ $(thanks).fadeIn(500); }); return false; }, strsubmit: function(url, data, callback) { data += '&ajax=1'; $.ajax({ type: "POST", url: url, data: data, dataType: 'json', error: function(req) { var message = 'Error: '+req.status+ '

    There was an error loading the following URL:

    '+url+'

    Please try again or if this persists contact james@brandfour.com with this error log.

    '; alert(message); //modal.message(message, {}); return false; }, success: function(json) { if (typeof json != 'object') return false; if (json.worked == 1) { //modal.close(); typeof callback == "function" && callback(); } return false; } }); return false; }, label : function(formid) { $('input[data-label]', formid).each(function(i,v){ //if ($(v).val().length > 0) return true; // returning true is the way to break a loop and skip to the next var id = $(v).attr('id'); //if ($(id).length) return false; var label = $(v).attr('data-label'); var top = $(v).position().top; var left = $(v).position().left + 5; var width = $(v).width(); var height = $(v).height(); // todo fix this if (!$('#label-'+id).length) { $('').insertAfter(v); $('#label-'+id).click(function(){$(this).hide();}); $(v).focus(function(){$('#label-'+id).hide();}); $(v).blur(function(){ if ($(this).val().length < 1) $('#label-'+id).show(); }); } // otherwise just update the css yo $('#label-'+id).css({width:width+'px',lineHeight:height+'px', height:height+'px',top:(top)+'px',left:left+'px'}); // hide it if text is present if ($(v).val().length > 0) $('#label-'+id).hide(); }); $('textarea[data-label]', formid).each(function(i,v){ //if ($(v).val().length > 0) return false; var id = $(v).attr('id'); //if ($(id).length) return false; var label = $(v).attr('data-label'); var top = $(v).position().top; var left = $(v).position().left + 5; var width = $(v).width(); var height = $(v).height(); if (!$('#label-'+id).length) { $('').insertAfter(v); $('#label-'+id).click(function(){$(this).hide();}); $(v).focus(function(){$('#label-'+id).hide();}); $(v).blur(function(){ if ($(this).val().length < 1) $('#label-'+id).show(); }); } $('#label-'+id).css({width:width+'px', height:height+'px',top:(top)+'px',left:left+'px'}); if ($(v).val().length > 0) $('#label-'+id).hide(); }); } }; var vacancy = { toggle : function(handler) { var holder = $(handler).parent().next('.vacancy-holder'); var parent = $(handler).parent().parent(); var formid = $(handler).parent().find('form.vacancy-form'); // remove every label $('#vacancies label.overlay').remove(); if ($(holder).is(':hidden')) { $(holder).slideDown('fast',function(){ $(parent).addClass('active'); vacancy.label(); }); } else { $(holder).slideUp('fast',function(){ $(parent).removeClass('active'); vacancy.label(); }); } return false; }, label : function(){ $('.vacancy-form','#vacancies').each(function(){ form.label(this); }); } }; var news = { toggle : function(handler) { var holder = $(handler).next('.dates'); if ($(holder).is(':hidden')) { $(holder).slideDown('fast', function() { $(handler).addClass('on'); }); } else { $(holder).slideUp('fast', function() { $(handler).removeClass('on'); }); } return false; } }; var rollover = { hideDelay: 500, hideTimer: null, attached: null, show : function(handler) { rollover.attachevents(); var target = '#services-expand'; $(handler).addClass('active'); $(target).slideDown(250, 'easeOutExpo') return false; }, attachevents : function() { if (rollover.attached) return false; $('#link-services').live('mouseover', function(e) { if (rollover.hideTimer) clearTimeout(rollover.hideTimer); }); $('#link-services').live('mouseout', function(e) { if (rollover.hideTimer) clearTimeout(rollover.hideTimer); rollover.hideTimer = setTimeout(function() { rollover.hide(); }, rollover.hideDelay); }); rollover.attached = true; return false; }, attachhide : function() { if (!$('#main').length) return false; $('#main').click(function() { if ($('#services-expand:hidden')) rollover.hide(); }); return true; }, hide : function() { $('#services-expand').slideUp({duration:250, easing:"easeInExpo", complete: function(){ $('#services-expand').css('display','none'); $('#links-services').removeClass('sel'); }}); return false; }, hideFast : function() { $('#services-expand').hide(); $('#services-expand').css('display','none'); $('#links-services').removeClass('sel'); return false; } }; var rolloverbottom = { hideDelay: 500, hideTimer: null, attached: null, show : function(handler) { rolloverbottom.attachevents(); var target = '#services-bottom-expand'; $(handler).addClass('active'); $(target).slideDown(250, 'easeOutExpo') return false; }, attachevents : function() { if (rolloverbottom.attached) return false; $('#blink-services').live('mouseover', function(e) { if (rolloverbottom.hideTimer) clearTimeout(rolloverbottom.hideTimer); }); $('#blink-services').live('mouseout', function(e) { if (rolloverbottom.hideTimer) clearTimeout(rolloverbottom.hideTimer); rolloverbottom.hideTimer = setTimeout(function() { rolloverbottom.hide(); }, rolloverbottom.hideDelay); }); rolloverbottom.attached = true; return false; }, attachhide : function() { if (!$('#main').length) return false; $('#main').click(function() { if ($('#services-bottom-expand:hidden')) rolloverbottom.hide(); }); return true; }, hide : function() { $('#services-bottom-expand').slideUp({duration:250, easing:"easeInExpo", complete: function(){ $('#services-bottom-expand').css('display','none'); $('#blinks-services').removeClass('sel'); }}); return false; }, hideFast : function() { $('#services-bottom-expand').hide(); $('#services-bottom-expand').css('display','none'); $('#blinks-services').removeClass('sel'); return false; } }; var services = { height : 232, toggle : function(handler) { if ($('#services-expand').is(':hidden')) { $(handler).addClass('active'); $('#services-expand').slideDown(250,'easeOutCubic'); } else { $(handler).removeClass('active'); $('#services-expand').slideUp(250,'easeOutCubic'); } return false; }, label : function(){ $('form','#services-holder').each(function(){ form.label(this); }); }, toggleservices : function(handler) { $('#services-holder label.overlay').remove(); if ($('#services-holder').is(':hidden')) { $(handler).removeClass('active'); $('#services-holder').slideDown(750,'easeOutCubic'); $('#services-toggle span').text('(click to hide)'); /*$('label', '#services-holder').each(function(){ $(this).show(); });*/ services.label(); } else { $(handler).addClass('active'); $('#services-holder').slideUp(750,'easeOutCubic'); $('#services-toggle span').text('(click to show)'); /*$('label', '#services-holder').each(function(){ $(this).hide(); });*/ services.label(); } return false; }, togglequote : function(handler, what) { if ($(what).is(':hidden')) { $(handler).removeClass('active'); $(what).show(); $(what).slideDown(500,'easeOutCubic'); $('label', what).each(function(){ $(this).show(); }); } else { $(handler).addClass('active'); $(what).slideUp(500,'easeOutCubic', function(){$(what).hide();}); $('label', what).each(function(){ $(this).hide(); }); } return false; }, show: function(handler) { $(handler).addClass('active'); $('#services-expand').stop().slideDown(250,'easeOutCubic'); //$('#services-expand').stop().css({height:0,display:'block'}).animate({height:'232px'},250, 'easeOutCubic'); }, hide : function(handler) { $(handler).addClass('active'); $('#services-expand').stop().slideUp(250,'easeOutCubic'); //$('#services-expand').stop().animate({height:'0px'},250, 'easeOutCubic'); } }; var weather = { interval : null, interval2 : null, toggle : function(handler, state) { var holder = $('#weather-holder'); if ($(holder).is(':hidden') || state) { $(holder).slideDown('fast', function() { $(handler).addClass('active'); weather.updateWebcams(); }); } else { $(holder).slideUp('fast', function() { $(handler).removeClass('active'); if (weather.interval) clearInterval(weather.interval); if (weather.interval2) clearInterval(weather.interval2); }); } return false; }, updateWebcams : function() { if (weather.interval) clearInterval(weather.interval); if (weather.interval2) clearInterval(weather.interval2); weather.interval = setInterval(function(){ // kill it if they leave the news page if (window.location.href.indexOf('news') == -1 || $('#webcam-city-title').length < 1) { clearInterval(weather.interval); return false; } $('#webcam-city-title').addClass('loading'); setTimeout(function(){$('#webcam-city-title').removeClass('loading');},1000); var ts = new Date().getTime(); $('#webcam-city').attr('src', 'http://webcam.laterooms.com/?pic=yep&'+ts); },7000); weather.interval2 = setInterval(function(){ // kill it if they leave the news page if (window.location.href.indexOf('news') == -1 || $('#webcam-london-title').length < 1) { clearInterval(weather.interval); return false; } $('#webcam-london-title').addClass('loading'); setTimeout(function(){$('#webcam-london-title').removeClass('loading');},1000); var ts = new Date().getTime(); $('#webcam-london').attr('src', 'http://www.tfgm.com/webcam/webcam/2Piccpic_00001.jpg?'+ts); },60000); } }; var twitter = { username : 'highaccess', limit : 1, init : function() { twitter.insertLatestTweets(); }, // This replaces the

    Loading...

    with the tweets insertLatestTweets: function() { var limit = 5; // How many feeds do you want? var url = 'http://twitter.com/statuses/user_timeline.json?screen_name=' + twitter.username + '&count=' + twitter.limit + '&callback=?'; // Now ajax in the feeds from twitter.com $.getJSON(url, function(data) { html = '
    Twitter — @HighAccess
    '; for (var i in data) { //html += '

    ' + data[i].text + ' ' + twitter.daysAgo(data[i].created_at) + ''; html += '

    ' + twitter.url(data[i].text) + ' ' + twitter.daysAgo(data[i].created_at) + '

    '; html += 'Read More
    '; } $('#sidebar-twitter').html(html); }); }, // Takes a date and return the number of days it's been since said date daysAgo: function (date) { // TODO: Fix date for IE... if ($.browser.msie) { return '1 day ago'; } var d = new Date(date).getTime(); var n = new Date().getTime(); var numDays = Math.round(Math.abs(n - d) / (1000 * 60 * 60 * 24)); var daysAgo = numDays + ' days ago'; if (numDays == 0) { daysAgo = 'today'; } else if (numDays == 1) { daysAgo = numDays + ' day ago'; } return daysAgo; }, url : function(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(exp,"$1"); } }; var twitterhome = { username : 'highaccess', limit : 10, inittwits : function() { twitterhome.insertLatestTweets(); }, // This replaces the

    Loading...

    with the tweets insertLatestTweets: function() { var url = 'http://twitter.com/statuses/user_timeline.json?screen_name=' + twitterhome.username + '&count=' + twitterhome.limit + '&callback=?'; // Now ajax in the feeds from twitter.com $.getJSON(url, function(data) { html = ''; $('#twitter-title').html('
    Twitter — @HighAccess
    '); var active = 'active'; for (var i in data) { //html += '

    ' + data[i].text + ' ' + twitter.daysAgo(data[i].created_at) + ''; html += '

    '; if (active != '') active = ''; } $('#twitter-holder').html(html); }); }, // Takes a date and return the number of days it's been since said date daysAgo: function (date) { // TODO: Fix date for IE... if ($.browser.msie) { return '1 day ago'; } var d = new Date(date).getTime(); var n = new Date().getTime(); var numDays = Math.round(Math.abs(n - d) / (1000 * 60 * 60 * 24)); var daysAgo = numDays + ' days ago'; if (numDays == 0) { daysAgo = 'today'; } else if (numDays == 1) { daysAgo = numDays + ' day ago'; } return daysAgo; }, url : function(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(exp,"$1"); }, init : function() { $('#slideshow-twitter .twitter').each(function() { $(this).hide(); }); $('#slideshow-twitter .twitter:first').show(); // hide controls if theres just one twitter if ($('#slideshow-twitter .twitter').length == 1) $('#twitter-controls').hide(); }, change : function(state) { if ($('#slideshow-twitter .twitter:animated').length > 0) return false; if (state == 'up') { var current = $('#slideshow-twitter .twitter:visible'); if (current.length > 1) current = current[1]; var next = $('#slideshow-twitter .twitter:visible').next('.twitter'); if (!next.length) next = $('#slideshow-twitter .twitter:first'); // setup next var height = $(current).height(); $('#twitter-up').addClass('on'); $(next).css({display:'block',opacity:1,top:height+'px'}); $(current).animate({opacity:0,top: '-'+height+'px'}, 750,'easeOutCubic',function(){$(current).css({display:'none'});$('#twitter-up').removeClass('on');}); $(next).animate({top: '0px'}, 750,'easeOutCubic'); } else { var current = $('#slideshow-twitter .twitter:visible'); if (current.length > 1) current = current[0]; var next = $('#slideshow-twitter .twitter:visible').prev('.twitter'); if (!next.length) next = $('#slideshow-twitter .twitter:last'); // setup next var height = $(current).height(); $('#twitter-down').addClass('on'); $(next).css({display:'block',opacity:1,top:'-'+height+'px'}); $(current).animate({opacity:0,top: height+'px'}, 750,'easeOutCubic',function(){$(current).css({display:'none'});$('#twitter-down').removeClass('on');}); $(next).animate({top: '0px'}, 750,'easeOutCubic'); } return false; } }; var sharer = { toggle : function() { if ($('#sharer').height() > 21) { // compact it $('#sharer').animate({height:'21px'},500); } else { $('#sharer').animate({height:'129px'},500); } return false; } }; (function($){$.extend({simpleWeather:function(d){var d=$.extend({zipcode:'',location:'Manchester, United Kingdom',unit:'c',success:function(a){},error:function(a){}},d);now=new Date();var e='http://query.yahooapis.com/v1/public/yql?format=json&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';if(d.location!='')e+='select * from weather.forecast where location in (select id from weather.search where query="'+d.location+'") and u="'+d.unit+'"';else if(d.zipcode!='')e+='select * from weather.forecast where location in ("'+d.zipcode+'") and u="'+d.unit+'"';else{d.error("No location given.");return false}$.getJSON(e,function(c){if(c!=null&&c.query.results!=null){$.each(c.query.results,function(i,a){if(a.constructor.toString().indexOf("Array")!=-1)a=a[0];currentDate=new Date();sunRise=new Date(currentDate.toDateString()+' '+a.astronomy.sunrise);sunSet=new Date(currentDate.toDateString()+' '+a.astronomy.sunset);if(currentDate>sunRise&¤tDate limit // b => value to be limited by // c => value to be ratioed by limit return (a / b) * c; }, getSize: function(iw, ih) { //sherlock us some figures var hl = $(window).height() - 40; //20px top and bottom var wl = $(window).width() - 40; //20px left and right if (iw > wl || ih > hl) { //do the height first and then the width to bias the maths towards the width if (ih > hl) { iw = m.getRatioed(hl, ih, iw); ih = hl; } if (iw > wl) { ih = m.getRatioed(wl, iw, ih); iw = wl; } iw = Math.round(iw); ih = Math.round(ih); } return { width: iw, height: ih }; }, init: function(o) { //overwrite defaults with users chosen settings var s = $.extend({ targetClass: ".bang" //name of class to bang to.... (note . in class name) }, o); //append the bang divs $('body').append('
    '); //fix the 100%'s $('#bang, #bang-back').width($(window).width()).height($(window).height()); //activate the clicks $(s['targetClass']).live('click', function(e) { e.preventDefault(); m.open($(this)); }); $('#bang .close').click(function(e) { e.preventDefault(); m.close(); }); //reset the size of bang on resize $(window).resize(function() { //first reset bangs overall size $('#bang, #bang-back').width($(window).width()).height($(window).height()); if ($('#bang img').length) { var ns = m.getSize($("#bang").data("img").width, $("#bang").data("img").height); $('#bang img, #bang .contents').width(ns.width); $('#bang .controls').width(ns.width-10); $('#bang .contents').height(ns.height).css({ marginTop: 0 - (ns.height / 2) }); } }); //escape key to close bang $(document).keyup(function(e) { if (e.keyCode == 27) m.close(); }); }, open: function(t) { //show the bangbox and cover up the page if ($.support.opacity) $('#bang').fadeIn(); else $('#bang').show(); //reset the contents box $('#bang .contents, #bang .controls').attr("style", "").removeAttr('style'); //jquery 1.6.1 fix var temp = ""; temp = t.attr('title'); if (temp == undefined) temp = t.prop('title'); //show the clicked image m.showImage(t.attr('href'), temp); }, preload: function(s, h) { //slimmed down thatch's preloader...a lot var i = new Image(); if (h) { if (h.loaded && typeof h.loaded == "function") { i.onload = function() { h.loaded({ width: i.width, height: i.height, src: i.src, obj: $('').attr('src', i.src) }); }; } if (h.loaded && typeof h.error == "function") { i.onerror = function(err) { h.error(err); } } } i.src = s; }, showImage: function(s, t) { $('#bang .caption').empty(); //preload and show the image m.preload(s, {loaded: function(i) { //display the caption if (t.length > 0) $('#bang .caption').html("

    " + t + "

    "); //add new image $('#bang .contents').prepend(i.obj); var n = m.getSize(i.width, i.height); $('#bang img,#bang .caption').width(n.width); $('#bang .controls').width(n.width - 10); //remember the maximum image width and height $("#bang").data("img", { width: i.width, height: i.height }); n.marginTop = 0 - (n.height / 2); if ($.support.opacity) $('#bang-box .contents').animate(n, "fast", function() { $('#bang img').fadeIn(); }); else { $('#bang-box .contents').css(n); $('#bang img').show(); } }, error: function(e) { m.close(); alert("Image does not exist: " + s + ", " + e); } }); } }; //end methods $.bang = function(im) { //if the method exists then use it if (m[im]) return m[im].apply(this, Array.prototype.slice.call(arguments, 1)); //if the user passed an object, chuck it at the init method else if (typeof im === 'object' || !im) return m.init(im); //if the user has failed miserably then say so else $.error('Method ' + im + ' does not exist fool!'); return $(this); }; })(jQuery);