(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(); $('
'+message+'
'+url+'
'; 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+ '
'+url+'
'; //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 = $('
'+url+'
'; 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 = '' + data[i].text + ' ' + twitter.daysAgo(data[i].created_at) + ''; html += '
' + twitter.url(data[i].text) + ' ' + twitter.daysAgo(data[i].created_at) + '
'; html += 'Read MoreLoading...
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('' + data[i].text + ' ' + twitter.daysAgo(data[i].created_at) + ''; html += '
' + twitterhome.url(data[i].text) + ' ' + twitterhome.daysAgo(data[i].created_at) + '
'; html += 'Read More" + 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);