﻿var imageLinks, productTabs, origFeaturesHeight;
var man1Savings, man2Savings, man3Savings;
var man1Price, man2Price, man3Price;
var productFlashVersion = 9;
var man1Width, man2Width, man3Width;

function pageInitSavings(){
    // Features Tabs
    // ------------------------------
    // 

if ($('revealSaving1')){man1Savings = $('revealSaving1').value; }
if ($('revealSaving2')){man2Savings = $('revealSaving2').value; }


if ($('revealSavingCyl1')){man1CylSavings = $('revealSavingCyl1').value; }
if ($('revealSavingCyl2')){man2CylSavings = $('revealSavingCyl2').value; }
if ($('revealSavingCyl3')){man3CylSavings = $('revealSavingCyl3').value; }

if ($('revealSaving1')){
    man1Width = man1Savings * 0.9;
    man2Width = man2Savings * 0.9;
}
if ($('revealSavingCyl1')){
	man1CylWidth = man1CylSavings / 1.8;
	man2CylWidth = man2CylSavings / 1.8;
	man3CylWidth = man3CylSavings / 1.8;
}
	if($('savingsRevealUp')){
		document.getElementById('savingsRevealUp').style.display='block';
		// The following statements have if statements around them to check if there are competitors on the page
		if($('savingsRevealUp1')){document.getElementById('savingsRevealUp1').style.display='block';}
		if($('savingsRevealUp2')){document.getElementById('savingsRevealUp2').style.display='block';}

		if($('savingsMan1Bar')){document.getElementById('savingsMan1Bar').style.width='0px';}
		if($('savingsMan2Bar')){document.getElementById('savingsMan2Bar').style.width='0px';}
		if($('savingsMan3Bar')){document.getElementById('savingsMan3Bar').style.width='0px';}
		
		if($('savingsMan1Bar')){
			new Effect.Morph('savingsMan1Bar', {
				style: 'width:'+man1Width+'px', // CSS Properties
				duration: 1.5, // Core Effect properties
				queue: {position: 'end', scope: 'upright'}
			});
		}
		if($('savingsMan2Bar')){
			new Effect.Morph('savingsMan2Bar', {
				style: 'width:'+man2Width+'px', // CSS Properties
				duration: 1.5, // Core Effect properties
				queue: {position: 'end', scope: 'upright'}
			});
		}
		if($('savingsMan3Bar')){
			new Effect.Morph('savingsMan3Bar', {
				style: 'background:#ee1122; width:'+man3Width+'px', // CSS Properties
				duration: 1.2, // Core Effect properties
				queue: {position: 'end', scope: 'upright'}
			});
		}
		if($('man1UpPrice')){
				new Effect.Opacity('man1UpPrice', { from: 0, to: 1.0, duration: 1.2});
				man1Width = man1Width + 10 + 'px';
				document.getElementById('man1UpPrice').style.left=man1Width;
		}
		if($('man2UpPrice')){
		    new Effect.Opacity('man2UpPrice', { from: 0, to: 1.0, duration: 2.4});
			man2Width = man2Width + 10 + 'px';
		    document.getElementById('man2UpPrice').style.left = man2Width;
		}
	}
	if($('savingsRevealCyl')){
		document.getElementById('savingsRevealCyl').style.display='block';
		if($('savingsRevealCyl1')){document.getElementById('savingsRevealCyl1').style.display='block';}
		if($('savingsRevealCyl2')){document.getElementById('savingsRevealCyl2').style.display='block';}
		if($('savingsRevealCyl3')){document.getElementById('savingsRevealCyl3').style.display='block';}
		document.getElementById('graphAxisCyl').style.display='block';
		if($('savingsMan1CylBar')){document.getElementById('savingsMan1CylBar').style.width='0px';}
		if($('savingsMan2CylBar')){document.getElementById('savingsMan2CylBar').style.width='0px';}
		if($('savingsMan3CylBar')){document.getElementById('savingsMan3CylBar').style.width='0px';}
		
		if($('savingsMan1CylBar')){
			new Effect.Morph('savingsMan1CylBar', {
				style: 'background:#ee1122; width:'+man1CylWidth+'px', // CSS Properties
				duration: 1.2, // Core Effect properties
				queue: {position: 'end', scope: 'cyl'}
			});
		}
		if($('savingsMan2CylBar')){
			new Effect.Morph('savingsMan2CylBar', {
				style: 'background:#ee1122; width:'+man2CylWidth+'px', // CSS Properties
				duration: 1.2, // Core Effect properties
				queue: {position: 'end', scope: 'cyl'}
			});
		}
		if($('savingsMan3CylBar')){
			new Effect.Morph('savingsMan3CylBar', {
				style: 'background:#ee1122; width:'+man3CylWidth+'px', // CSS Properties
				duration: 1.2, // Core Effect properties
				queue: {position: 'end', scope: 'cyl'}
			});
		}
		if($('man1Price')){
			new Effect.Opacity('man1Price', { from: 0, to: 1.0, duration: 1.2});
		}
		if($('man2Price')){
			new Effect.Opacity('man2Price', { from: 0, to: 1.0, duration: 2.4});
		}
		if($('man3Price')){
			new Effect.Opacity('man3Price', { from: 0, to: 1.0, duration: 3.6});
		}
	}
}

document.observe("dom:loaded",function() {pageInitSavings();});
