//Set jQuery into no conflict mode

var $jq = jQuery.noConflict();

		
$jq(function(){

	// This is the CUFON FONT replacement. All elements targeted individually for complete control.
	
   Cufon.replace('#homepage-featured  h2, .profile-post h1, a.cta-button, .homepage-box h3, a.calc-button, .footer-widgets h4, #bread-crumb, #left-content  h1, .sidebar-widget h3, #left-content h2 , #left-content h3 ' , {hover: true});

});


$jq(function() {
	
	//Starts Cycle on the Homepage Featured Area
	
    $jq('#cycle-home').cycle({ 
	
    fx:    'fade', 
	
    speed:  1000,
	
	timeout:  15000,
	
	pager:  '.cycle-pager-featured'
	
	});
    
});


$jq(function() {

	//Starts Cycle on the Case Studies Area

    $jq('#case-study-cycle').cycle({ 
	
    fx:    'scrollDown', 
	
    speed:  1000,
	
	timeout:  27000,
	
	pager:  '#case-study-pager'
	
	});
    
});


$jq(document).ready(function() {	
	
	//Navigation Dropdown Animation
	
	$jq('#navigation ul li').hover(	
	
		function(){		
		
			$jq(this).children('ul').stop(true,true).fadeIn(150);},		
			
		function(){	
			
			$jq(this).children('ul').animate({opacity: '+=0'}, 50).fadeOut(150); 		
			
	}); 	
	
	// Adds colourbox to all #left-content images bar blogroll 
	
	$jq('#left-content img').parent().addClass('colourbox-image');
	
	$jq('a.strip-classes').removeClass('colourbox-image');
	
	$jq('p').removeClass('colourbox-image'); 
	
	$jq('div.comment-person').removeClass('colourbox-image');
		
});


$jq(document).ready(function(){	
	
	//The Colourbox Modal Window is initiated here 	
	
	$jq(".colourbox-image").colorbox();	
	
	$jq(".homepage-modal-anchor").colorbox({iframe:true, innerWidth:590, innerHeight:450});
	
});

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

	//Heat Pump Calculator 
	
	// Declare Variables
	
	var A = "";
	var B = "";
	var E = "";
	var K = ""; 
	
	var X = "35";	// Sleeping
	var Y = "50";	// Living
	var Z = "200";	// Hotwater
	
	// Reset Input Fields
	
	$jq(".hc-step2a-1, .hc-step2a-2, .hc-step2a-3, .hc-step2b-1, .hc-step2b-2, .hc-step2b-3, .es-input").val("0");
	
	// Narrative Steps
	
	$jq(".hc-step1a-btn").click(function(){
		
		$jq(".hc-step-1").slideUp(300);
		
		$jq(".hc-step-2a").slideDown(300);
	
	});
	
	$jq(".hc-step1b-btn").click(function(){
		
		$jq(".hc-step-1").slideUp(300);
		
		$jq(".hc-step-2b").slideDown(300);
	
	});
	
	$jq(".heat-calculate-a").click(function(){
		
		$jq(".hc-step-2a, .hc-step-2b").slideUp(300);
		
		$jq(".hc-result").slideDown(300);
	
	});
	
	// Calculate Via Meters Squared
	
	$jq(".heat-calculate-b").click(function(){
		
		A = $jq("input.hc-step2b-1").val();
		B = $jq("input.hc-step2b-2").val();
		E = $jq("input.hc-step2b-3").val();
		
		k = ( A * Y ) + ( B * X ) + ( E * Z );
		
		K = ( k / 1000 );
		
		Result = Math.round(K*2)/2;
		
		$jq(".hc-step-2a, .hc-step-2b").slideUp(300);
		
		$jq(".hc-result").slideDown(300);
		
		if(!isNaN(Result)) {$jq("span.hc-result-text").text(Result.toFixed(2));}
		else{$jq("span.hc-result-text").text('Error: Please enter numerals only');}
	
	});
	
	// Calculate Via Squared Feet 
	
	$jq(".heat-calculate-a").click(function(){
		
		A = $jq("input.hc-step2a-1").val();
		B = $jq("input.hc-step2a-2").val();
		E = $jq("input.hc-step2a-3").val();
		
		a = ( A / 10.764 );
		b = ( B / 10.764 );
	
		
		k = ( a * Y ) + ( b * X ) + ( E * Z );
		
		K = ( k / 1000 );
		
		Result = Math.round(K*2)/2;
		
		$jq(".hc-step-2a, .hc-step-2b").slideUp(300);
		
		$jq(".hc-result").slideDown(300);
		
		if(!isNaN(Result)) {$jq("span.hc-result-text").text(Result.toFixed(2));}
		else{$jq("span.hc-result-text").text('Error: Please enter numerals only');}
	
	});
	
	

});


$jq(document).ready(function(){	
	
	// Energy Bill Saver 
	
	// Declare Variables 
	
	var A;		// Input for Oil
	var B;		// Input for Storage Heater
	var C;		// Input for Natural Gas
	var D; 	// Input for LPG
	var E; 	// Input for Coal	
	var F; 	// Input for Wood Pellets
	var G; 	// Input for Number of Occupants	
	var J;		
	var K;
	var H;
	var I;
	
	// Declare Constants 
	
	var a = 0.0816;	// Rate for Oil
	var b = 0.0963;	// Rate for NightRate
	var c = 0.0558;	// Rate for Gas
	var d = 0.1579; 	// Rate for LPG
	var e = 0.121; 	// Rate for Coal
	var f = 0.0828; 	// Rate for Pellets
	var g = 0.02675; 	// Rate for Heat Pump
	
	var x = 1226.4; 
	 
	 
	// Splittin up I to avoid error	
	
	var S1; // Splitting up the calcuation for I
	var S2; // Splitting up the calcuation for I
	var S3; // Splitting up the calcuation for I
	var S4; // Splitting up the calcuation for I
	var S5; // Splitting up the calcuation for I
	var S6; // Splitting up the calcuation for I
	
	
	
	// Calculate H (Ground Sourced Heat Pump)
	
	$jq(".es-calculate").click(function(){
	
	
		$jq(".es-result-wrap").slideDown(300);
	
	
		A = parseFloat( $jq("input.es-oil").val() );
		B = parseFloat( $jq("input.es-storage").val() );
		C = parseFloat( $jq("input.es-gas").val() );
		D = parseFloat( $jq("input.es-lpg").val() );
		E = parseFloat( $jq("input.es-coal").val() );
		F = parseFloat( $jq("input.es-pellets").val() );
		G = parseFloat( $jq("input.es-occupants").val() );
	
	
		J = ( A / a ) + ( B / b ) + ( C / c ) + ( D / d ) + ( E / e ) + ( F / f ) ;
		
		H = A + B + C + D + E + F - ( J * g ) ;
		
		K = ( G * x ) ;
		
		
		if ( A !== 0 ) { S1 = ( ( ( A / a ) / J ) * K * a ) ; }
		else { S1 = 0 ; }
		
		if ( B !== 0 ) { S2 = ( ( ( B / b ) / J ) * K * b ) ; }
		else { S2 = 0 ; }
		
		if ( C !== 0 ) { S3 = ( ( ( C / c ) / J ) * K * c ) ; }
		else { S3 = 0 ; }
		
		if ( D !== 0 ) { S4 = ( ( ( D / d ) / J ) * K * d ) ; }
		else { S4 = 0 ; }
		
		if ( E !== 0 ) { S5 = ( ( ( E / e ) / J ) * K * e ) ; }
		else { S5 = 0 ; }
		
		if ( F !== 0 ) { S6 = ( ( ( F / f ) / J ) * K * f ) ; }
		else { S6 = 0 ; }
		
		
		I = S1 + S2 + S3 + S4 + S5 + S6 ;
		
		
		if(!isNaN(H)) {$jq("span.es-result-span-h").text(H.toFixed(2));}
		else{$jq("span.es-result-span-h").text('Error: Please enter numerals only');}
		
		if(!isNaN(I)) {$jq("span.es-result-span-i").text(I.toFixed(2));}
		else{$jq("span.es-result-span-i").text('Error: Please enter numerals only');}
	
	});
	
});

