// JavaScript Document


jQuery(document).ready(function(){
					
					
					// STOP IE6 FLICKER
	if ($.browser.msie && $.browser.version.substr(0,1)<7) { 
		document.execCommand('BackgroundImageCache', false, true);
		
	};

					
	jQuery('#viewport').carousel('.simplePrevious', '.simpleNext');
	jQuery('#viewport2').carousel('.simplePrevious2', '.simpleNext2');  
	

	$('#preview1').slideUp('slow');
	
	
	$('.Hover').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	


	$('#Signup').click(function () {
			$('#preview1').slideDown('slow');					 
								 
	});
					   
	$('#CloseSignup').click(function () {
								 
			$('#preview1').slideUp('slow');		 
								 
	});

	$(function () {
				
		$('ul.spy').simpleSpy();
		
	});

	$('.ImageHold').hover(
				
				function(){ 
					//console.log('over');
					$(this).find('.ImageTop').animate({ paddingTop: '0px'}, 500 );
				},
				function(){ 
					//console.log('out');
					$(this).find('.ImageTop').animate({ paddingTop: '90px'}, 500);
				}
						 
	);
	


});




(function ($) {
    
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 3;
    interval = interval || 8000;
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = $list.find('> li:first').height();
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
        $list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function spy() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 1;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);

/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container get's applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        		'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  '285px',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}
// JavaScript Document

$(document).ready(function(){
	
	$('.fade').innerfade({ speed: 'slow', timeout: 5500, type: 'sequence'}); 

});

$(function() {
$.simpleWeather({
location: 'bury, united kingdom',
unit: 'c',
success: function(weather) {  
$("#weatherhold").append('<h4><strong>Keep Up To Date With The Weather In '+weather.city+', '+weather.region+' '+weather.country+'</strong></h4><div id="weather"  style="background:url(/images/Content_Film2.png) repeat-x scroll 0 -5px transparent;"><div class="weatherleft"><strong>Today\'s High</strong>: '+weather.high+'&deg; '+weather.units.temp+' <br /><strong>Today\'s Low</strong>: '+weather.low+'&deg; '+weather.units.temp+' <br /><strong>Current Temp</strong>: '+weather.temp+'&deg; '+weather.units.temp+'<br /><br /><strong>Wind</strong>: '+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+'<br /><strong>Wind Chill</strong>: '+weather.wind.chill+'<br /><strong>Currently</strong>: '+weather.currently+'<br clear="all" /></div><div class="weathermid" style="background:url('+weather.image+') right 10px no-repeat;"><strong>Forecast</strong>: '+weather.forecast+'<br /><strong>Humidity</strong>: '+weather.humidity+'<br /><strong>Pressure</strong>: '+weather.pressure+'<br /><strong>Rising</strong>: '+weather.rising+'<br /> <strong>Visibility</strong>: '+weather.visibility+'<br /><strong>Sunrise</strong>: '+weather.sunrise+'<br /><strong>Sunset</strong>: '+weather.sunset+'<br /></div><div class="weatherright"><strong>Tomorrow\'s Date</strong>: '+weather.tomorrow.day+' '+weather.tomorrow.date+'<br /><strong>Tomorrow\'s High/Low</strong>: '+weather.tomorrow.high+'/'+weather.tomorrow.low+'<br /><strong>Tomorrow\'s Forecast</strong>: '+weather.tomorrow.forecast+'<br /><br /><br /><br /><span style="font-size:11px; font-style:italic; padding:5px 15px 15px 5px; color:#CCC; ">Last updated: '+weather.updated+'&nbsp;-&nbsp;<a href="'+weather.link+'">View Forecast &raquo;</a></span></div><br clear="all" /></div>');


},
error: function(error) {
$("#weatherhold").html('<p>'+error+'</p>');
}


});


	
	

});


