﻿$(document).ready(function() {

    try
    {
    datetoday = new Date();
    timenow = datetoday.getTime();
    datetoday.setTime(timenow);
    thehour = datetoday.getHours();
    
     var theLoc = window.location.href;
     var thePos = theLoc.indexOf('london2012');
    
     if ( parseInt(thePos) == -1) // not london2012!
     {  

        if (thehour < 6)
        {
           $('body').addClass('nighttime');
        }
        else if(thehour >= 6 && thehour < 9 )
        {
           $('body').addClass('sunrise');
        }
        else if(thehour >= 9 && thehour < 17)
        {
           $('body').addClass('daytime');
        }
        else if(thehour >= 17 && thehour < 19)
        {
           $('body').addClass('sunrise');  
        }
        else 
        {
           $('body').addClass('nighttime');
        }
	
     }
      else //  london2012 - set london2012 class!
     {
       $('body').addClass('london2012');
     }
    
    $('.rays').innerfade({
        speed: 'slow',
        timeout: 1000,
        type: 'sequence',
        containerheight: '174px'
    });
    
    
    }
    catch(err) {}

    $("#main").tabs({ selected: 0 });
    $("#tabs1").tabs();
    $("#tabs2").tabs();
    $("#tabs3").tabs();

    $("#history").easySlider({
        auto: true,
        continuous: true,
        speed: 1,
        pause: 5000,
        numeric: true
    });

    $('fieldset').each(function(i) {

    if ($(this).find('.text').val() == '' || $(this).find('.searchField').val() == '') {
            $(this).addClass('default');
        }
    });

    $('.text, .searchField').click(function(e) {

        $(this).parent('fieldset').removeClass('default');

        if (this.tagName == "span") {
            if ($(this).siblings(".text")) {
                $(this).siblings(".text").focus();
            }
        }
    })

	.focus(function(e) {
	    $(this).parent('fieldset').removeClass('default');
	})

	.blur(function() {
	    if ($(this).val() == '')
	        $(this).parent('fieldset').addClass('default');
	});
});



function init() {
    man = new jsAnimManager();

    cm1 = man.createAnimObject("balloon3");
    cm4 = man.createAnimObject("balloon4");
    cm5 = man.createAnimObject("balloon5");
    cm6 = man.createAnimObject("balloon6");
    
    cm1.add({ property: Prop.top, from: 69, to: 64, duration: 1950, loop: -1, ease: jsAnimEase.bounceSmooth });
    cm4.add({ property: Prop.top, from: 94, to: 89, duration: 1750, loop: -1, ease: jsAnimEase.bounceSmooth });
    cm5.add({ property: Prop.top, from: 101, to: 96, duration: 1500, loop: -1, ease: jsAnimEase.bounceSmooth });
    cm6.add({ property: Prop.top, from: 89, to: 84, duration: 2200, loop: -1, ease: jsAnimEase.bounceSmooth });
}
