/* ---------------------
title: LDF site specific Jquery
author: Simon Tweedale
created: 07/11/11
--------------------- */


/* --------------------- initiates fancybox --------------------- */

$(document).ready(function() {
		
	$("a.inline, .leftcol a, .rightcol a, .product-list a, .zoom ").fancybox({
		'speedIn'		:	400, 
		'speedOut'		:	400, 
		'overlayOpacity' : 0.9,
		'overlayColor' : '#000',
		'autoDimensions' : true
	});

});


/* --------------------- jquery analog clock --------------------- */

$(document).ready(function() {

      setInterval( function() {
      var seconds = new Date().getSeconds();
      var sdegree = seconds * 6;
      var srotate = "rotate(" + sdegree + "deg)";

      $("#sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate});

      }, 1000 );

      setInterval( function() {
      var hours = new Date().getHours();
      var mins = new Date().getMinutes();
      var hdegree = hours * 30 + (mins / 2);
      var hrotate = "rotate(" + hdegree + "deg)";

      $("#hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate});

      }, 1000 );

      setInterval( function() {
      var mins = new Date().getMinutes();
      var mdegree = mins * 6;
      var mrotate = "rotate(" + mdegree + "deg)";

      $("#min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate});

      }, 1000 );
});

/* --------------------- gets the latest weather --------------------- */

$(function() {
			$.simpleWeather({
				location: 'Kendal, united kingdom',
				unit: 'f',
				success: function(weather) {		
					html = '<img src="/assets/img/weather/'+weather.code+'.png">';
					html += '<p>'+weather.currently+'</p>';
					html += '<p style="font-size:26px;"> '+weather.tempAlt+'<span style="font-family:Arial;font-size:16px;">&deg;c</span> </p>';
					$("#weather").html(html);
				},
				error: function(error) {
					$("#weather").html('<p>'+error+'</p>');
				}
			});
		});

/* --------------------- fade items on page load --------------------- */

$(document).ready(function(){	
	$('.widgets').css("display","none");
	$('.widgets').delay(900).fadeIn(1000);
});

$(document).ready(function(){
	$('.map, .product-list, .discussion-list').css("display","none");	
	$('.map, .product-list, .discussion-list').fadeIn(1000);
});

/* --------------------- fades items on hover --------------------- */

$(document).ready(function(){
	$("h4 a").fadeTo("fast", 0.85); 
	$("h4 a").hover(function(){
	$(this).fadeTo("fast", 1); 
	},function(){
	$(this).fadeTo("fast", 0.85); 
	});
});

/* --------------------- toggles show/hide --------------------- */

$(document).ready(function () {
	$('.products').find('.list').live('click', function () {
		$('.product-list img,.product-list p').hide();
		$(this).removeClass('list').addClass('longlist').text('Product List');
	});
	$('.products').find('.longlist').live('click', function () {
		$('.product-list img,.product-list p').show();
		$(this).removeClass('longlist').addClass('list').text('Quick List');
	});
});
 
 /* --------------------- clears form field on focus --------------------- */
 
 $(document).ready(function() {
    $(".members ul input,.warning input,#membership-signup form div input").focus(function(srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).removeClass("defaulttext");
            $(this).val("");
        }
    });
    
    $(".members ul input,.warning input,#membership-signup form div input").blur(function() {
        if ($(this).val() == "") {
            $(this).addClass("defaulttext");
            $(this).val($(this)[0].title);
        }
    });
    
    $(".members ul input,.warning input,#membership-signup form div input").blur();        
});


/* initiates feature panel cycle */
/* requires jquery.cycle.js */

$(document).ready(function() {
    var $featurePanel = null;
    var $navigationArrows = null;
    $featurePanel = $('.frontpanels');
    $navigationArrows = $('.frontpanels a.fade');
    if ($featurePanel.length) {
        $featurePanel.css("overflow", "hidden");
       
        $("ul.panels").cycle({
            fx: 'fade',
            pause: 1,
            prev: '#prev',
            speed:  '1000',
            timeout:  6000,
            next: '#next'
        });
       
        $featurePanel.hover(function() {
            $navigationArrows.fadeIn();
          },
              function() {
            $navigationArrows.fadeOut();
          });
    }
    $navigationArrows.fadeOut();
});

