/*

Savage-Orphanage.js
(c) Savage Media Pty Ltd


Usage:

void	SavageOrphanage ( element TextObject , pixels MaxPadding ) 
	: Called with an object with text inside it. 
	: If it finds an orphan it plays with the CSS until the orphan is removed.
	: As a last resort pushes the second last word down to the next line.
	

Changes:

1.01 - Improved IE line break detection.
1.02 - If no text nodes found ignore object.
1.03 - Changed DOM handling for GetStyle
1.04 - Documentation
1.05 - bug fixes
1.06 - fix bug when not enough words.
1.07 - Speed up.
1.08 - Double line fix.
1.09 - DOM error fix.

*/

var SavageOrphanage = function ( TextObject , MaxPadding ) {
	// Also be sure this paragraph is long enough for this method.
	var TextContent = ( typeof ( TextObject.textContent ) != "undefined" ) ? TextObject.textContent : TextObject.innerText;
	if ( TextContent.split ( " " ).length < 4 ) {
		return;
	}
	
	var TextNode = null;
	var TextNodeSibling = null;
	
	var FindLastTextNode = function ( ThisObject ) {
		// Grab last node.
		ThisObject = ThisObject.lastChild;
		
		// Keep going till we run out of nodes.
		while ( ThisObject ) {
			// Found it?
			if ( ThisObject.nodeName == "#text" ) {
				TextNode = ThisObject;
			}
			
			// Children?
			if ( ThisObject.lastChild ) {
				ReturnedObject = FindLastTextNode ( ThisObject );
				if ( ReturnedObject.nodeName == "#text" ) {
					TextNode = ReturnedObject;
				}
			}
			
			// Get previous
			TextNodeSibling = ThisObject;
			ThisObject = ThisObject.previousSibling;	
		}
		
		// Nothing found
		return false;
	};
	
	// Grab last 
	FindLastTextNode ( TextObject );
	
	// Ignore tags without text
	if ( ! TextNode ) {
		return;
	}
	
	// Save InnerText for later.
	var InnerText = TextNode.nodeValue;

	// Break up into words.
	var WordsArray = InnerText.split ( " " );
	
	if ( WordsArray.length < 3 ) {
		return;
	}
	
	var CheckEnd = WordsArray.pop ( );
	if ( CheckEnd.trim ( ) !== "" ) { 
		WordsArray.push ( CheckEnd );
	}
	
	// Clear it.
	TextNode.nodeValue = "";
	
	
	// Wrapper for all spans
	var ContainerSpan = document.createElement ( "span" );
	
		
	// Break apart everything per words.
	for ( var i = WordsArray.length - 1; i >= 0; i -- ) {
		if ( i ) {
			WordsArray [ i ] = " " + WordsArray [ i ];
		}
		
		// Rewrite word into object.
		var NewSpan = document.createElement ( "span" );
		var NewText = document.createTextNode ( WordsArray [ i ] );
				
		// Put back into object.
		NewSpan.appendChild ( NewText );
		ContainerSpan.insertBefore ( NewSpan , ContainerSpan.firstChild );
	}
	
	// Rewrite word into object.
	if ( TextNodeSibling !== null ) {
		// When there are things on the end.
		TextObject.insertBefore ( ContainerSpan , TextNodeSibling );
		
	} else {
		// When this IS the end object.
		TextObject.appendChild ( ContainerSpan );
	}
	
	
	// Grab words again, now split by objects
	var SpansArray = ContainerSpan.getElementsByTagName ( "span" );

	// Scope
	var Pixels;
	
	// Don't keep adding more.
	if ( TextObject.OrphanagePixels ) {
		// Reload
		Pixels = TextObject.OrphanagePixels;
	} else {
		// Loop adding padding to the right of the object till the orphan is gone.
		Pixels = TextObject.GetStyle ( "padding-right" );
	}
	
	// Be sure to save.
	TextObject.OrphanagePixels = Pixels;
	
	var EndPixels = Pixels + MaxPadding;
	var Orphaned = false;
	while ( Pixels <= EndPixels ) {
		// Not found till found. OMG really?
		Orphaned = false;
		
		// Check Y value and Height between to check if this text has an orphan.
		if ( ! BrowserVersion.isMSIE ) {
			// Normal browsers
			// SpansArray [ SpansArray.length - 1 ].offsetLeft == 0
			if ( SpansArray [ SpansArray.length - 2 ].offsetTop != SpansArray [ SpansArray.length - 1 ].offsetTop ) {
				Orphaned = true;
			}
		} else {
			// IE of course
			if ( SpansArray [ SpansArray.length - 2 ].offsetHeight < SpansArray [ SpansArray.length - 1 ].offsetHeight ) {
				Orphaned = true;
			}
		}
			 
		// Fix Orhpans or break loop 
		if ( Orphaned ) {			
			// Orphaned. Increase padding and try again.
			Pixels ++;
			TextObject.style.paddingRight = Pixels + "px";
		} else {
			// Exit loop, this is fixed.
			break;
		}		
	}
	
	// Destroy Spans
	TextObject.removeChild ( ContainerSpan );
	
	// After the padding was the orphan killed? 
	if ( Orphaned ) {
		// Reset
		TextObject.style.paddingRight = TextObject.OrphanagePixels + "px";

		// Create break		
		var NewBreak = document.createElement ( "br" );
		TextObject.insertBefore ( NewBreak , TextNode.nextSibling );
		
		// Create last line.
		var LastWords = document.createTextNode ( WordsArray [ WordsArray.length - 2 ] + " " + WordsArray [ WordsArray.length - 1 ] );
		TextObject.insertBefore ( LastWords , NewBreak.nextSibling );		

		// Trash the last two words in previous text node
		WordsArray = WordsArray.slice ( 0 , WordsArray.length - 2 );
		InnerText = WordsArray.join ( " " ); 
	}	

	// Return text
	TextNode.nodeValue = InnerText;
};


/*

Savage-Helpers.js v1.35
(c) Savage Media Pty Ltd (http://www.savagemedia.com.au/)

Objects:

// Simple yet effective browser detection.
// Obviously shouldn't be used for function detection,
// and only for times where a specific result is required
// for 'x' browser.
boolean BrowserVersion.isMSIE : Is Microsoft IE
boolean BrowserVersion.isMSIE6 : Is Microsoft IE 6.x
boolean BrowserVersion.isFirefox : Is Mozilla Firefox
boolean BrowserVersion.isSafari : Is Apple Safari


Functions:

object	DOMObject ( string ID | object Object )
	: Returns the element with many helper function built in.		
	object	object.Show ( ) : Simple show style change	
	object	object.Hide ( ) : Simple hide style change
	object	object.Render ( css Kind ) : Simple display style change supply with "none" "inline" "block" etc.
	boolean object.Visible ( ) : Detects if the object is rendered
	object	object.UpdateXY ( ) : Find the exact positioning of this object and update object with "x" and "y" properties
	object	object.Detach ( ) : Remove from the DOM
	object	object.InsertHTML ( string HTML , boolean Append ) : W3C compliant HTML insertion. Call with Append as true to simply insert at the end of the element.
	string	object.GrabXHTML ( ) : W3C compliant XHTML collection. 
	object	object.SetEvent ( string Kind , function Func ) : W3C complaint event setter
	object	object.RemoveEvent ( string Kind , function Func ) : W3C complaint event remover
	boolean object.HasClass ( string Class ) : Test className list for Class
	object	object.AddClass ( string ClassAdd ) : Add a class to the className list
	object	object.RemoveClass ( string ClassRemove ) : Remove a class to the className list
	array	object.GetElementsByClass ( string Needle ) : Find all child elements with a class set of Needle.
	pixels	object.GetStyle ( string CssRule ) : Grab calculated style in pixels
	
void	PreventDefault ( event ) : Stops any default action the brwoser might take. ie a href click
void	CancelBubble ( event ) : Stops the default bubble of events. 
int CountProperties ( object ) : Count the number of properties an object has. 
return	SingleEvent ( ScopeFunction ,  event ) : Reduces events to only orginator of single event. 
ratio	PixelsToEMs ( object ) : All browser Pixel to EM ratio detection
sting	EntityDecode ( string ) : Convert entities into UTF-8
pixels	ConvertToPixelValue ( element Object , css Value ) : Convert the value ie "100em" to a pixel number "250"
boolean FindInArray ( array Variable , mixed Value ) : Find the {Value} in an Array
string	AustralianFormattedTime ( date Time ) : Return a formatted time of either now or supplied time.


Prototypes:

function ScopeFunction ( object Scope , function Command , array Arguments , const Flags ) 
	: Create scope and closure and allow passing of event and arguments. Event is passed as last arg.
	const	ScopeFunction_PREVENTDEFAULT : Call PreventDefault after command is processed
	const	ScopeFunction_CANCELBUBBLE : Call CancelBubble after command is processed
	const	ScopeFunction_NOARGUMENTS : Disable parsing of arguments via array. Also event parsing.


Changes:

1.03 - added GetStyle
1.04 - RemoveEvent, inArray
1.05 - little improvements
1.06 - append InsertHTML + full replace
1.07 - Render style
1.08 - MSIE6 detect
1.09 - improved detection of browsers
1.10 - ScopeFunction
	 - Improved PreventDefault
	 - Improved UpdateXY
1.11 - InsertHTML bug fix
1.12 - ScopeFunction bug fix for events
	 - Flags for ScopeFunction
1.13 - Documentation
1.14 - Added Detach
1.15 - Improved GetStyle to handle strings
1.16 - Added SingleEvent
1.17 - ScopeFunction_NOARGUMENTS
1.18 - Added trim ()
1.19 - PixelsToEMs
1.20 - InsertHTML fix.
1.21 - RemoveEvent fix.
1.22 - Improved RemoveEvent to handle false Func values
1.23 - InsertHTML IE append fix.
1.24 - HasClass
1.25 - EntityDecode ()
1.26 - object.Visible ()
1.27 - Firefox UpdateXY bug.
1.28 - IE EntityDecode bug fix.
1.29 - CountProperties ()
1.30 - Errors only when console available.
1.31 - IE error catch on offsetParent
1.32 - GrabXHTML ()
1.33 - Bug fix, PixelsToEMs (images)
1.34 - ?
1.35 - Chrome detection

*/


/*global window, document, navigator, DOMParser, XPathResult, _ */

// Simple yet effective browser detection.
// Obviously shouldn't be used for function detection,
// and only for times where a specific result is required
// for 'x' browser.
var BrowserVersion = {
	// Detect browser.
	isMSIE : ( navigator.userAgent.indexOf ( 'MSIE' ) > -1 ),
	isMSIE6 : ( navigator.userAgent.indexOf ( 'MSIE' ) > -1 && parseFloat ( navigator.appVersion.split ( "MSIE" ) [ 1 ] ) == 6 ),
	isMSIE7 : ( navigator.userAgent.indexOf ( 'MSIE' ) > -1 && parseFloat ( navigator.appVersion.split ( "MSIE" ) [ 1 ] ) == 7 ),
	isMSIE8 : ( navigator.userAgent.indexOf ( 'MSIE' ) > -1 && parseFloat ( navigator.appVersion.split ( "MSIE" ) [ 1 ] ) == 8 ),
	isFirefox : ( navigator.userAgent.indexOf ( 'Firefox' ) > -1 ),
	isSafari : ( navigator.userAgent.indexOf ( 'Safari' ) > -1 ),
	isChome : ( navigator.userAgent.indexOf ( 'Chrome' ) > -1 )
};


// Stop the default event a tag might have.
var PreventDefault = function ( Event ) {
	// For IE which leaves the event in the window object
	if ( ! Event ) {
		Event = window.event; 
	}
	
	// Which style?
	Event.returnValue = false;
	if ( Event.preventDefault ) {
		Event.preventDefault ( );
	}
	
	// Makes use cleaner.
	return false;
};


// Stop a bubble of events.
var CancelBubble = function ( Event ) {
	// For IE which leaves the event in the window object
	if ( ! Event ) {
		Event = window.event; 
	}
	
	// Which style?
	Event.cancelBubble = true;
	if ( Event.stopPropagation ) {
		Event.stopPropagation ( );
	}
};


// Limit an event to just the single event we want.
var SingleEvent = function ( Action ,  Event ) {	
	// Grab this mouseout.
	var MainObject = ( Event.srcElement ) ? Event.srcElement : Event.target;

	// Can't accept objects that aren't even inside this element.
	while ( MainObject && MainObject != this ) {			
		// Grab next parent
		MainObject = MainObject.parentNode;
	}
	
	// Be sure we stopped at the object and not the window
	if ( MainObject != this ) {
		return;
	}
	
	
	// Grab the object we moved to.
	var RelatedObject = ( Event.relatedTarget ) ? Event.relatedTarget : Event.toElement;

	// This better not be inside the main element.
	while ( RelatedObject && RelatedObject != MainObject ) {			
		// Grab next parent
		RelatedObject = RelatedObject.parentNode;
	}
	
	// If it is inside the element then forget it, it's not important.
	if ( RelatedObject == MainObject ) {
		return;
	}
	
	
	// Take action.
	return Action ( Event );
};


// Convert all entities into UTF-8 strings
var EntityDecode = function ( HTML ) {
	var Root;
	
	// Normal browsers
	if ( ! BrowserVersion.isMSIE && typeof DOMParser != "undefined" ) {
		// Build parser
		var Parser = new DOMParser ( );
		var Doc = Parser.parseFromString ( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"><body>" + HTML + "</body></html>" , 'application/xhtml+xml' );
		
		// Grab body tag
		Root = Doc.documentElement.getElementsByTagName ( "body" ) [ 0 ];
		
	} else {
		// Make temp element
		Root = document.createElement ( 'div' );
		
		// Old school way (IE of course)
		Root.innerHTML = HTML;
	}

	
	// Return only the text.
	return (Root.textContent ? Root.textContent : Root.innerText);
};


// Change a scope of a function, use a closure.
var ScopeFunction_PREVENTDEFAULT = 1;
var ScopeFunction_CANCELBUBBLE = 2;
var ScopeFunction_NOARGUMENTS = 4;
function ScopeFunction ( Scope , Command , Arguments , Flags ) {	
	// Clean up args
	if ( ! Arguments ) {
		Arguments = [ ];
	}

	// Return Closured function
	return function ( Event ) {
		var Returned;
	
		if ( ScopeFunction_NOARGUMENTS & Flags ) {
			// Simply parse normal arguments.
			Returned = Command.apply ( Scope , arguments );
		
		} else {
			// Collect for IE
			if ( ! Event && window.event ) {
				Event = window.event;
			}
			
			// Handle event parsing
			if ( Event ) {
				Arguments.push ( Event );
			}
		
			// Execute
			Returned = Command.apply ( Scope , Arguments );
		
			// Handle event parsing
			if ( Event ) {
				Arguments.pop ( );
			}
		}
		
		// Prevent standard event functionality?
		if ( ScopeFunction_PREVENTDEFAULT & Flags ) {
			PreventDefault ( Event );
		}
		
		// Stop the event bubble?
		if ( ScopeFunction_CANCELBUBBLE & Flags ) {
			CancelBubble ( Event );
		}
		
		// Clear out.
		return Returned;
	};
}


// All browser Pixel to EM ratio detection
var PixelsToEMs = function ( TestObject ) {
	// Stylise a temporary DIV to workout the ratio of EM to PX
	var TemporaryObject = document.createElement ( "div" );
	TemporaryObject.style.height = "1em"; 
	TemporaryObject.style.position = "absolute"; 
	TemporaryObject.style.backgroundColor = "#ff0000"; 
	
	var Ratio;
	if ( TestObject.nodeName.toLowerCase ( ) === 'img' ) {
		// Add, find actual height, remove.
		TestObject.parentNode.appendChild ( TemporaryObject ); 
		Ratio = TemporaryObject.offsetHeight / 1;
		TestObject.parentNode.removeChild ( TemporaryObject );
	} else {
		// Add, find actual height, remove.
		TestObject.appendChild ( TemporaryObject ); 
		Ratio = TemporaryObject.offsetHeight / 1;
		TestObject.removeChild ( TemporaryObject );
	}
		
	// And we have a winrar!
	return Ratio;
};


// IE specific EM to Pixel conversion
var ConvertToPixelValue = function ( TestObject , Value ) {
	var PIXEL = /^\d+(px)?$/i;
	
	// Already px?
	if ( PIXEL.test ( Value ) ) {
		return parseInt ( Value , 10 );
	}
	
	// Save for later.
	var TestStyle = TestObject.style.left;
	var RuntimeStyle = TestObject.runtimeStyle.left;
	
	// Set a new value
	TestObject.runtimeStyle.left = TestObject.currentStyle.left;
	TestObject.style.left = Value || 0;
	
	// Collect pixel value
	Value = TestObject.style.pixelLeft;
	
	// Reset
	TestObject.style.left = TestStyle;
	TestObject.runtimeStyle.left = RuntimeStyle;
	
	// Return value converted to px.
	return Value;
};


// Cross browser event set
var SetEvent = function ( Object , Kind , Func ) {
	if ( window.attachEvent ) {
		Object.attachEvent ( "on" + Kind , Func );
	} else if ( window.addEventListener ) {
  		if (Kind == 'mousewheel') {
	  		Kind = 'DOMMouseScroll';
  		}
  		
		Object.addEventListener ( Kind , Func , false );
	}
};


// Count object properties
var CountProperties = function ( Object ) {
	var Count = 0;

	for ( var Property in Object ) {
		if ( Object.hasOwnProperty ( Property ) ) {
			Count ++;
		}
	}
	
	return Count;
};


// DOM helper, similar to $ in prototype
function DOMObject ( ID ) {
	// Scope
	var Object;

	// If it's a string grab the object.
	if ( typeof ID == "string" ) {
		// Grab object.
		Object = document.getElementById ( ID );
		
		// Help debug
		if ( ! Object ) {
			if ( typeof ( _ ) === 'function' ) {
				// Let the coder know
				_( "[ DOMObject ] ID not found: " + ID );
			}
						
			// Don't bother
			return false;
		}
	} else {
		// This is simply an object already
		Object = ID;
	}
	
	// Nothing found?
	if ( ! Object ) {
		return false;
	}
	
	// Simple show style change 
	Object.Show = function ( ) {
		this.style.visibility = "visible";	
		return this;
	};
	
	// Simple hide style change
	Object.Hide = function ( ) {
		this.style.visibility = "hidden";
		return this;
	};
	
	// Simple display style change	
	Object.Render = function ( Kind ) {
		this.style.display = Kind;	
		return this;
	};
	
	// Detect visiblity (to the user)
	Object.Visible = function ( ) {
		// Default to visible
		var Visible = true;

		// css visibility
		Visible = Visible && (this.GetStyle ( 'visibility' ) != 'hidden');
		
		// css display
		Visible = Visible && (this.GetStyle ( 'display' ) != 'none');
		
		// Let the caller know what we found
		return Visible;
	};
	
	
	// Find the exact positioning of this object
	Object.UpdateXY = function ( ) {
		var x = 0;
		var y = 0;

		// Start with "this" and work up
		var ThisObject = this;


		// Loop till find the top most parent
		try {
			while ( ThisObject ) {
				// Add positioning
				x += ThisObject.offsetLeft - ThisObject.scrollLeft;
				y += ThisObject.offsetTop - ThisObject.scrollTop;
				
				// Grab next parent
				ThisObject = ThisObject.offsetParent;
			}
		} catch (e) {
			// OMG IE IS $@#! 
		}
		
		// IE8 adds the window scroll to the offset.
		if ( ! BrowserVersion.isMSIE8 && ! BrowserVersion.isFirefox ) {
			x = x + ( document.documentElement.scrollLeft || document.body.scrollLeft);
			y = y + ( document.documentElement.scrollTop || document.body.scrollTop);
		}
				
		// Update local vars
		this.offsetX = x;
		this.offsetY = y;
		
		// And single line mode
		return this;
	};
	
	// Remove from the DOM	
	Object.Detach = function ( ) {
		this.parentNode.removeChild ( this );	
		return this;
	};
	
	// XHTML Compliant innerHTML;
	Object.InsertHTML = function ( HTML , Append ) {	
		// Normal browsers
		if ( ! BrowserVersion.isMSIE && typeof DOMParser != "undefined" ) {
			if ( ! Append ) {
				// Remove everything
				while ( this.firstChild ) {
					this.removeChild ( this.firstChild );		 
				} 
			}
			
			// Create a minimal doc and then use it to collect nodes.
			var Parser = new DOMParser ( );
			var Doc = Parser.parseFromString ( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"><body>" + HTML + "</body></html>" , 'application/xhtml+xml' );
			var Root = Doc.documentElement.getElementsByTagName ( "body" ) [ 0 ];
			
			// Loop inserting nodes
			for ( var InsertNode = 0 ; InsertNode < Root.childNodes.length ; InsertNode ++ ) {
				this.appendChild ( document.importNode ( Root.childNodes [ InsertNode ] , true ) );
			}
		} else {
			if ( ! Append ) {
				// Old school way (IE of course)
				this.innerHTML = HTML;
			} else {
				// Old school way (IE of course)
				this.innerHTML = this.innerHTML + HTML;
			}
		}
		
		// Single line mode.
		return this;
	};
	
	// DOM to XHTML;
	Object.GrabXHTML = function ( ) {
		// Recursively grabs nodes etc	
		var GrabXHTMLNodes = function ( Nodes ) {
			var CleanXHTML = '';
			var CleanTag = '';
			var CleanAttributes = '';
			
			var TagName = '';
			var TagValue = '';
			var TagAttributes = null;
			var TagNodes = null;
			
			var AttributeName = '';
			var AttributeValue = '';
			
			
			// Run backwards for speed reasons.
			for ( var Node = Nodes.length - 1; Node > -1; Node -- ) {
				// Reset
				CleanTag = '';
				CleanAttributes = '';
				
				// Simplify
				TagName = Nodes [ Node ].nodeName.toLowerCase ( );
				TagNodes = Nodes [ Node ].childNodes;
				TagValue = Nodes [ Node ].nodeValue;
				TagAttributes = Nodes [ Node ].attributes;
				
				// When there are attributes...
				if ( TagAttributes ) {
					// Run backwards to speed up
					for ( var Attribute = TagAttributes.length - 1; Attribute > -1; Attribute -- ) {
						// Simplify
						AttributeName = TagAttributes [ Attribute ].nodeName.toLowerCase ( );
						AttributeValue = TagAttributes [ Attribute ].nodeValue;
						
						// Only useful attributes.
						if ( AttributeValue && AttributeValue != 'null' ) {
							// Order is not important
							CleanAttributes = CleanAttributes + ' ' + AttributeName + '="' + AttributeValue + '"'; 
						}
					}
				}
				
				// Some tags are different.
				switch ( TagName ) {
					// Text node
					case '#text' :
						CleanTag = TagValue;
					break;
					
					// Unclosed tag
					case 'br' :
						CleanTag = '<' + TagName + CleanAttributes + ' />';
					break;
					
					// Typical tag
					default:				
						CleanTag = '<' + TagName + CleanAttributes + '>';					
						CleanTag = CleanTag + GrabXHTMLNodes ( TagNodes );						
						CleanTag = CleanTag + '</' + TagName + '>';
				}
				
				// Add backwards
				CleanXHTML = CleanTag + CleanXHTML;
			}
			
			// All complete.
			return CleanXHTML;
		};
		
		// Return XHTML
		return GrabXHTMLNodes ( this.childNodes );
	};
	
	// Cross browser event set
	Object.SetEvent = function ( Kind , Func ) {
		if ( window.attachEvent ) {
			this.attachEvent ( "on" + Kind , Func );
		} else if ( window.addEventListener ) {
	  		if (Kind == 'mousewheel') {
		  		Kind = 'DOMMouseScroll';
	  		}
	  		
			this.addEventListener ( Kind , Func , false );
		}
		
		// Single line mode.
		return this;
	};
	
	// Cross browser event remove
	Object.RemoveEvent = function ( Kind , Func ) {
		if ( ! Func ) {
			// Single line mode.
			return this;
		}
		
		if ( window.detachEvent ) {
			this.detachEvent ( "on" + Kind , Func );
		} else if ( window.removeEventListener ) {
			this.removeEventListener ( Kind , Func , false );
		}
		
		// Single line mode.
		return this;
	};
	
	// Insert className
	Object.HasClass = function ( Class ) {
		// Break apart Classes by whitespace
		var ClassArray = this.className.split ( " " );
		var ClassFound = false;
	
		// Search for same class definition
		for ( var ClassCount = 0; ClassCount < ClassArray.length; ClassCount ++ ) {
			if ( ClassArray [ ClassCount ] == Class ) {
				// Found
				ClassFound = true;
				
				// No need to keep looping
				break;
			}
		}
		
		return ClassFound;
	};
	
	// Insert className
	Object.AddClass = function ( ClassAdd ) {
		// Break apart Classes by whitespace
		var ClassArray = this.className.split ( " " );
		var ClassFound = false;
	
		// Search for same class definition
		for ( var ClassCount = 0; ClassCount < ClassArray.length; ClassCount ++ ) {
			if ( ClassArray [ ClassCount ] == ClassAdd ) {
				// Found
				ClassFound = true;
				
				// No need to keep looping
				break;
			}
		}
	
		// Not found so add
		if ( ! ClassFound ) {
			// Just shove onto the end of array
			ClassArray.push ( ClassAdd );
			
			// Put back to string and apply
			this.className = ClassArray.join ( " " );
		}
	
		// Return this for single line mode.
		return this;
	};
	
	// Remove className
	Object.RemoveClass = function ( ClassRemove ) {
		// Break apart Classes by whitespace
		var ClassArray = this.className.split ( " " );
	
		// Search for class definition and delete
		for ( var ClassCount = 0; ClassCount < ClassArray.length; ClassCount ++ ) {
			if ( ClassArray [ ClassCount ] == ClassRemove ) {
				// Found so delete
				 ClassArray.splice ( ClassCount , 1 );
				
				// Technically no need to keep looping, however if some twat
				//	does something dumb like "class1 class1"...
			}
		}
	
		// Put back to string and apply
		this.className = ClassArray.join ( " " );
	
		// Return this for single line mode.
		return this;
	};	
	
	// Grab any child elements by what class they have set.
	Object.GetElementsByClass = function ( Needle ) {
		// Return array.
		var Collection = [ ];	
		var Element;
		var Result;
	
		// Fast or crappy IE way? DISABLED
		if ( document.evaluate && XPathResult && false ) {
			// Run XPath search
			Result = document.evaluate ( "//*[@class='" + Needle + "']" , this , null , XPathResult.ANY_TYPE , null );
			
			// Place into nice array.
			do {
				// Grab
				Element = Result.iterateNext ( );
				
				// Stack
				Collection.push ( Element );
			} while ( Element );
		
		// crappy way
		} else {
			// Grab everything here.	
			Result = this.getElementsByTagName ( "*" );

			// Search for classes
			var SearchPattern = new RegExp ( "(^|\\s)" + Needle + "(\\s|$)" );
			
			// Place into a nice array
			for ( var Node = Result.length - 1; Node >= 0; Node -- ) {
				// Grab
				Element = Result [ Node ];
				
				// Test
				if ( SearchPattern.test ( Result [ Node ].className ) ) {
					Collection.push ( Element );
				}
			}
		}
		
		// And give back array.
		return Collection;
	};
	
	// Grab calculated style 
	Object.GetStyle = function ( CssRule ) {
		// Default to empty.
		var Value = "";
		
		// What DOM?
		if ( document.defaultView && document.defaultView.getComputedStyle ) {
			Value = document.defaultView.getComputedStyle ( this , "" ).getPropertyValue ( CssRule );
		} else if ( this.currentStyle ) {
			CssRule = CssRule.replace ( /\-(\w)/g , function ( Match , Text ) { return Text.toUpperCase ( ); } );
			Value = this.currentStyle [ CssRule ];
		}
		
		// String or number?
		if ( isNaN ( parseInt ( Value , 10 ) ) ) {
			return Value;
		} else {
			// For IE we have to convert EMs.
			if ( BrowserVersion.isMSIE ) {
				Value = ConvertToPixelValue ( this , Value );
			}
			
			// Return without px etc.
			return parseInt ( Value , 10 );
		}
	};


	// Return with helpers attached.
	return Object;
}


// Ah yay.
var FindInArray = function ( Variable, Value ) {
	for ( var Row in Variable ) { 
		if ( Variable [ Row ] === Value ) {
			return Row;
		}
	}
	return -1;
};


// Why doesn't js do this kind of thing?
var AustralianFormattedTime = function ( Time ) {
	// If not supplied then use the current time.
	if ( ! Time ) {
		Time = new Date ( );
	}
	
	// get just the hours.
	var Hours = Time.getHours ( );
	
	// get just the minutes and make it two digits.
	var Minutes = Time.getMinutes ( );
	if ( Minutes < 10 ) {
		Minutes = "0" + Minutes;
	}
	
	// get just the seconds and make it two digits.
	var Seconds = Time.getSeconds ( );
	if ( Seconds < 10 ) {
		Seconds = "0" + Seconds;
	}
	
	// AM or PM, and convert hours
	var TimeOfDay;
	if ( Hours < 12 ) {
		TimeOfDay = "am";
	} else {
		// negate 12 hours
		Hours = Hours - 12;
		TimeOfDay = "pm";
	}	

	// 0 hour is actually 12
	if ( Hours === 0 ) {
		Hours = 12;
	}
	
	// return it put together
	return Hours + ":" + Minutes + "." + Seconds + TimeOfDay;
};


// Why isn't this native??
String.prototype.trim = function ( ) {
	var a = this.replace ( /^\s+/ , '' );
	return a.replace ( /\s+$/ , '' );
};


/* !REQUIRE Savage-Helpers.js

Cross-browser AJAX Library v1.11 
Created by Lloyd Bottomley of Savage Media
http://www.savagemedia.com.au/

Usage: 

var TestAJAX = new SavageAJAX ( );
TestAJAX.UploadVars.push ( { Name : "TEST", Value : "VALUE" } );


Methods:

TestAJAX.XMLRequest ( function CallBackFunction ( XML , Text ) );


Changes:

1.10 - Documentation, tidy
1.11 - XML and Text reply now.

*/
function SavageAJAX ( ) {
	// global vars.
	this.UploadVars = [ ];
	this.ObjectCallBack = null;
	

	// ********************************************
	// Send an XML Request.
	// ********************************************
	this.XMLRequest = function ( ObjectCallBack ) {
		// Save the callback function
		this.ObjectCallBack = ObjectCallBack;
		
		// default to fail.
		var XMLHttp = false;
		// native XMLHttpRequest object
		if ( window.XMLHttpRequest ) {
			try {
				XMLHttp = new XMLHttpRequest ( );
			} catch ( Error0 ) {
				XMLHttp = false;
			}
		
		// IE/Windows ActiveX version
		} else {
			try {
				XMLHttp = new ActiveXObject ( "Msxml2.XMLHTTP" );
			} catch ( Error1 ) {
				try {
					XMLHttp = new ActiveXObject ( "Microsoft.XMLHTTP" );
				} catch ( Error2 ) {
					XMLHttp = false;
				}
			}
		}
	
		// actually send
		if ( XMLHttp ) {
			// nothing to send by default
			var PostData = '';
			
			// loop the vars and add to the post data.
			for ( var i = 0 ; i < this.UploadVars.length ; i ++ ) {	
				PostData += this.UploadVars [ i ].Name + '=' + encodeURIComponent ( this.UploadVars [ i ].Value );
				if ( i < this.UploadVars.length - 1 ) {
					PostData += "&";
				}
			}
			
			// Start a request.
			XMLHttp.open ( "POST" , "./" , true );
	
			// Tell the it what we are doing
			XMLHttp.setRequestHeader ( "Content-type" , "application/x-www-form-urlencoded" );
			
			// Unsafe header for Safari.
			if ( ! BrowserVersion.isSafari ) {
				XMLHttp.setRequestHeader ( "Content-length" , PostData.length ); 
				XMLHttp.setRequestHeader ( "Connection" , "close" );
			}
	
			// Handle the reply
			XMLHttp.onreadystatechange = ScopeFunction ( this , function ( ) {
				// when we have a reply...
				if ( XMLHttp.readyState == 4 && XMLHttp.status == 200 ) {
					// Call back to function.
					this.ObjectCallBack ( XMLHttp.responseXML , XMLHttp.responseText );
				} 
			} );
			
			// Send request.
			XMLHttp.send ( PostData );
		} else {
			alert ( "Browser Unsupported" );
		}
	};
}



/* !REQUIRE Savage-Helpers.js, Savage-Ajax.js

Savage.js 
(c) Savage Media Pty Ltd

1.10 - rewritten using better object notation
1.11 - requirements
1.12 - tidy
1.13 - bug fixes.
1.14 - disabled auto-lightbox for ie6
1.15 - FileLink a href.
1.16 - Error management.
1.17 - Only Taipan errors.
1.18 - Reenabled Taipan error reporting.

*/

// Error management.
window.onerror = function ( Message , URL , Line ) { 
	// Run our Taipan if installed
	if ( typeof ( Taipan ) == "object" ) {
		// New AJAX
		var ErrorAJAX = new SavageAJAX ( ); 
		
		// Send these vars to PHP...
		ErrorAJAX.UploadVars.push ( { Name : "SavageErrorURL", Value : URL } );
		ErrorAJAX.UploadVars.push ( { Name : "SavageErrorMessage", Value : Message } );
		ErrorAJAX.UploadVars.push ( { Name : "SavageErrorLine", Value : Line } );
		ErrorAJAX.UploadVars.push ( { Name : "SavageErrorBrowser", Value : navigator.userAgent } );
	
		// Closured request
		ErrorAJAX.XMLRequest ( function ( ) { } );
		
		
		// Let Taipan know.
		Taipan.WindowError ( );
	}
};

// Attach Onload events
SetEvent ( window , "load" , function ( ) { 

	// Set up BODY classes
	var bodyTag = DOMObject ( document.getElementsByTagName ( 'body' ).item ( 0 ) );
	if ( BrowserVersion.isMSIE ) {
		bodyTag.AddClass ( 'IE' );
	}
	if ( BrowserVersion.isMSIE6 ) {
		bodyTag.AddClass ( 'IE6' );
	}
	if ( BrowserVersion.isMSIE7 ) {
		bodyTag.AddClass ( 'IE7' );
	}
	if ( BrowserVersion.isMSIE8 ) {
		bodyTag.AddClass ( 'IE8' );
	}
	if ( BrowserVersion.isFirefox ) {
		bodyTag.AddClass ( 'Firefox' );
	}
	if ( BrowserVersion.isSafari ) {
		bodyTag.AddClass ( 'Safari' );
	}
	if ( BrowserVersion.isChome ) {
		bodyTag.AddClass ( 'Chome' );
	}

	// Fix orphans if included.
	if ( typeof ( SavageOrphanage ) == "function" ) {
		var FixOrphans = function ( ) {
			// Scope
			var Delay;
			var Types = [ "p" ];
			
			// Only one.
			if ( Delay ) {
				window.clearTimeout ( Delay );
			}
			
			// Run this on a delay
			Delay = window.setTimeout ( function ( ) {
				// Each tag type.
				for ( var Type = 0; Type < Types.length; Type ++ ) {
					// Grab Text tags, and run SavageOrphanage on them.
					var Texts = document.getElementsByTagName ( Types [ Type ] );

					// Loop those Texts
					for ( var Text = 0; Text < Texts.length; Text ++ ) {	
						// Find an orphan on this tag, max of 40 padding
						SavageOrphanage ( DOMObject ( Texts [ Text ] ) , 40 );
					}
				}
				
				if ( typeof ( CufonReplace ) != "undefined" ) {
					//CufonReplace ( );
				}
			} , 17 );
		};
		
		// Fire on resize
		SetEvent ( window , "resize" , FixOrphans );
		
		// Initial pre-load adjust
		FixOrphans ( );
	}
	

	// Grab A tags, and set "ExternalLink" to _blank targets.
	var Anchors = document.getElementsByTagName ( "a" ); 
	
	
	// Simple back button
	var HistoryBack = function ( Event ) { 
		// Simply go back.
		history.back ( );
		
		// Be sure to stop the link from being followed.
		return PreventDefault ( Event );
	};
	
	// Loop those As
	for ( var Anchor = 0; Anchor < Anchors.length; Anchor ++ ) { 
		// Convert this into a target _blank
		var Href = Anchors [ Anchor ].getAttribute ( "href" );
		var Rel = Anchors [ Anchor ].getAttribute ( "rel" );
		if ( Href && ( Rel == "ExternalLink" || Rel == "FileLink" ) ) {
			Anchors [ Anchor ].target = "_blank"; 
		}
		
		// JS History back.
		if ( Rel == "HistoryBack" ) {
			DOMObject ( Anchors [ Anchor ] ).SetEvent ( "click" , HistoryBack );
		}	
	}
	

	// LameBrowser is installed?
	if ( document.getElementById ( "LameBrowserButtonOpen" ) ) {
		// Open lightbox DIV -- DISABLED
		// DOMObject ( "LameBrowserLightboxWrapper" ).Show ( ); 
	
		// LameBrowser lightbox open
		DOMObject ( "LameBrowserButtonOpen" ).SetEvent ( "click" , function ( Event ) { 
			// Open lightbox DIV
			DOMObject ( "LameBrowserLightboxWrapper" ).Show ( );
			
			// Be sure to stop the link from being followed.
			return PreventDefault ( Event );
		} );
	
		// LameBrowser lightbox close
		DOMObject ( "LameBrowserButtonClose" ).SetEvent ( "click" , function ( Event ) { 
			// Close lightbox DIV
			DOMObject ( "LameBrowserLightboxWrapper" ).Hide ( );
			
			// Be sure to stop the link from being followed.
			return PreventDefault ( Event );
		} );
	}	
	
	
	// Run our Taipan if installed
	if ( typeof ( Taipan ) == "object" ) {
		Taipan.WindowLoad ( );
	}
} );


// XHTML compliant site scaling.
if ( typeof ( SavageScaler ) == "function" ) {
	// Fire on resize
	SetEvent ( window , "resize" , SavageScaler );
	
	// Initial pre-load adjust
	SavageScaler ( );
}



/* !REQUIRE Savage-Helpers.js

Savage-Tween.js v2.02
(c) Savage Media Pty Ltd

*/

/*global clearInterval, setInterval, ScopeFunction, window */

var SavageTweenFrameFail = false;
var SavageTween = function ( ) {
	// Make a duplicate each use.
	return {
		// Parameters.
		FramesIn : 100,
		FramesOut : 100,
		Ease : 0,
		Action : null,
		Complete : null,
		
		// Private.
		Frames : 0,
		Position : 0,
		Interval : null,
		Direction : null,
		FramesLost : 0,
		PreviousTime : null,
		FrameFail : false,
		
		// Start the iterations.
		Start : function ( Direction ) {			
			// Stop any tween on this button
			clearInterval ( this.Interval );
			
			
			// Setup up style
			if ( Direction ) {
				this.Frames = this.FramesOut;
			} else {
				this.Frames = this.FramesIn;
			}
			if ( this.Position ) {
				if ( Direction ) {
					this.Position = parseInt ( ( this.FramesIn - this.Position ) * ( this.FramesOut / this.FramesIn ) , 10 );
				} else { 
					this.Position = parseInt ( ( this.FramesOut - this.Position ) * ( this.FramesIn / this.FramesOut ) , 10 );
				}
				if ( this.Position < 0 ) {
					this.Position = 0;
				}
			} else {
				this.Position = 0;
			}
			
			
			// Previous = now
			var TimeLast = new Date ( );
			TimeLast = TimeLast.getTime ( );
			this.PreviousTime = TimeLast;
			
			// Reset 
			this.FramesLost = 0;
			
		
			// Change the % value.
			this.Interval = setInterval ( ScopeFunction ( this , function ( ) {					
				// Now
				var TimeEnd = new Date ( );
				TimeEnd.getTime ( );
			
				// Calculate how much time went past between intervals.
				var TimeSpent = TimeEnd - this.PreviousTime;
				
				// Update
				this.PreviousTime = TimeEnd;
				
				// Lost more than a single frame
				if ( TimeSpent > ( 17 * 2 ) ) {
					this.FramesLost = this.FramesLost + parseInt ( ( TimeSpent / 17 ) - 1 , 10 );
				}
				
			
				// Frames lost over threshold should make tweens instant!
				if ( this.FramesLost > 30 || this.FrameFail || window.SavageTweenFrameFail ) {
					if ( this.Position < this.Frames ) {
						this.Position = this.Frames;
					}
					this.FrameFail = true;
				}
				
				// So bad that we disable for good???
				if ( this.FramesLost > 80 ) {
					window.SavageTweenFrameFail = true;
				}
				
			
				
				// Finished?
				if ( this.Position > this.Frames  ) {
					// No more iterations
					clearInterval ( this.Interval );
					
					// Reset
					this.Position = 0;
					
					// Call back
					if ( this.Complete ) {
						this.Complete ( );
					}
					
					// No more to do.
					return;
				}
				
				
				
				// Scope
				var Value;
			
				// Calculate
				switch ( this.Ease ) {
					case 0:
						Value = this.Position / this.Frames;
					break;
					
					case 1:
						Value = -1 / 2 * ( Math.cos ( Math.PI * this.Position / this.Frames ) - 1 );
					break;
					
					case 2:
						Value = 1 - ( Math.cos ( Math.PI * this.Position / this.Frames ) );
					break;
				}
				if ( Direction ) {
					Value = 1 - Value;
				}
				
				// Update time counter	
				this.Position ++;
				
				// Take action.
				this.Action ( Value );			
			} ) , 17 );
		}
	};
};

/**
 * reflection.js v2.0
 * http://cow.neondragon.net/stuff/reflection/
 * Freely distributable under MIT-style license.
 */

var Reflection = {
	defaultHeight : 0.5,
	defaultOpacity: 0.5,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		var doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity };
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' ';
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options.height);
			var divHeight = Math.floor(p.height*(1+options.height));
			
			var reflectionWidth = p.width;
			if (reflectionWidth == 514) {reflectionWidth = 428;}
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
	                d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.display = 'block';
				reflection.style.height = p.height+"px";
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options.opacity*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options.height*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
				
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					
					context.translate(0,image.height-1);
					context.scale(1,-1);
					
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
	
					context.restore();
					
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options.opacity)+")");
		
					context.fillStyle = gradient;
					context.rect(0, 0, reflectionWidth, reflectionHeight*2);
					context.fill();
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
};


/* !REQUIRE Savage-Helpers.js, Savage-Tween.js, Reflection.js
*/
 
// Object to handle template based content switching.
var FooterHookSwitcher = {
	Hooks : [ ],	
	Controls : [ ],	
	
	Current : null,
	Previous : null,
	CurrentControl : null,
	PreviousControl : null,
	
	Iterator : 0,
	Auto : true,
	Timer : null,
	Animating : false,
	
	Choose : function ( Index ) {		
		if ( this.Previous != this.Hooks [ Index ] && !this.Animating ) {
			this.Auto = false;			
			if ( this.Timer ) {
				clearTimeout ( this.Timer );
			}
			
			this.Iterator = Index;	
			this.Change ( );	
		}
	},
	
	Change : function ( ) {
		if ( typeof Taipan != 'undefined' && Taipan.EditMode ) {
			// Setup the next one.
			setTimeout ( ScopeFunction ( this , this.Change ) , 500 );
			
			return;
		}	
		this.Animating = true;
		
		// Grab the object
		this.Current = this.Hooks [ this.Iterator ];
		this.Current.style.zIndex = 200;
		this.Current.style.visibility = 'visible';
		this.CurrentControl = this.Controls [ this.Iterator ];
		this.CurrentControl.AddClass ( 'On' );
		if ( this.PreviousControl ) {
			this.PreviousControl.RemoveClass ( 'On' );
		}
					
		if ( this.Timer ) {
			clearTimeout ( this.Timer );
		}
		
		// Tween in menu.
		var TweenIn = SavageTween ( );
		TweenIn.FramesIn = 15;
		
		if ( this.Previous ) {
			this.Previous.style.zIndex = 1;
		}
		
		
		// Fade action
		TweenIn.Action = ScopeFunction ( this , function ( Percent ) {
			this.Current.style.opacity = Percent;
			this.Current.style.filter = 'alpha(opacity='+Percent * 100+')';
			if (this.Previous) {
				this.Previous.style.opacity = 1-Percent;
				this.Previous.style.filter = 'alpha(opacity='+100-(Percent * 100)+')';
			}
		} , null , ScopeFunction_NOARGUMENTS );
		
		// Fade action
		TweenIn.Complete = ScopeFunction ( this , function ( ) {			
			// Next one
			this.Iterator ++;		
			if ( this.Iterator >= this.Hooks.length ) {
				this.Iterator = 0;
			}
			
			if ( this.Previous ) {
				this.Previous.style.opacity = 0;
				this.Previous.style.filter = 'alpha(opacity=0)';
				this.Previous.style.visibility = 'hidden';
			}
			this.Previous = this.Current;
			this.PreviousControl = this.CurrentControl;
			
			if ( this.Hooks.length > 1 && this.Auto ) {
 
				// Setup the next one.
				this.Timer = setTimeout ( ScopeFunction ( this , this.Change ) , 4000 );
			}
			
			this.Animating = false;
			
		} , null , ScopeFunction_NOARGUMENTS );
 
		// Start menu fade.	
		TweenIn.Start ( false );
	}
};

 
// Attach to Footer Hooks
SetEvent ( window , 'load' , function ( ) {
	var Hooks = DOMObject ( 'Footer-Hooks-Wrapper' );
	if ( Hooks.childNodes.length ) {
		for ( var node = 0; node < Hooks.childNodes.length; node ++ ) {
			if ( Hooks.childNodes [ node ].nodeName.toLowerCase ( ) == 'div' ) {
				var count = FooterHookSwitcher.Hooks.length;
				FooterHookSwitcher.Hooks [ count ] = DOMObject ( Hooks.childNodes [ node ] );
				
				var Control = DOMObject ( 'Footer-Hook-Control-' + count );
				Control.SetEvent ( 'click' , ScopeFunction ( FooterHookSwitcher , FooterHookSwitcher.Choose, [ count ] , ScopeFunction_PREVENTDEFAULT ) );
				FooterHookSwitcher.Controls [ count ] = Control;
			}
		}
		FooterHookSwitcher.Change ( );
	}	
	
	if ( ! BrowserVersion.isSafari ) {	
		Reflection.defaultHeight = 0.2;	
		var ReflectiveElements = DOMObject ( 'TemplateWrapper' ).GetElementsByClass ( 'Reflective[\\d]*' );
	
		for ( var i = 0; i < ReflectiveElements.length; i ++ ) {
			if ( ReflectiveElements[i].nodeName == 'IMG' ) {
				var Amount = 0.2;
				var Class = ReflectiveElements[i].className;
				if ( Class.length > 10 ) {
					Amount = (Class.substring (10) / 100);
				}
				
				Reflection.add ( ReflectiveElements[i], { opacity : Amount } );
				
			} else {
				ReflectiveElements[i].title = ReflectiveElements[i].textContent;
			}
		}
	}
} );


/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

/* !REQUIRE Savage-Helpers.js, SWFObject.js

Home.js

*/

var Home = {
	Objects : { },
	Slides : { },
	Counter : 1,
	Fader : null,
	AllowHTML5 : true,
	
	Playing : false,
	Hovering : false,
	MoveCount : 20,
	
	Initialise : function ( ) {
		var Objects = {
			Navigation : DOMObject ( 'Navigation' ),
			Tours : DOMObject ( 'Tours' ),
			Slide3Button : DOMObject ( 'Slide-3-Button' ),
			
			PlaySmall : DOMObject ( 'Video-Play-Small' ),
			PlayBig : DOMObject ( 'Video-Play-Big' ),
			//Stop : DOMObject ( 'Video-Stop' ),
			//Buffering : DOMObject ( 'Video-Buffering' )
		};

		
		//Objects.Play.SetEvent ( 'click' , ScopeFunction ( this , this.Play , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		//Objects.Stop.SetEvent ( 'click' , ScopeFunction ( this , this.Stop , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		
		SetEvent ( window , 'mousemove' , ScopeFunction ( this , this.Move ) );
		//DOMObject ( 'Video' ).SetEvent ( 'mouseover' , ScopeFunction ( this , this.Over ) );
		//DOMObject ( 'Video' ).SetEvent ( 'mouseout' , ScopeFunction ( this , this.Out ) );
		
		//Objects.PlayBig.SetEvent ( 'click' , ScopeFunction ( this , this.Play , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		//Objects.PlaySmall.SetEvent ( 'click' , ScopeFunction ( this , this.Play , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		
		this.Objects = Objects;
		
		this.Slides = [
			DOMObject ( 'Slide-Image-4' ),
			DOMObject ( 'Slide-Image-1' ),
			DOMObject ( 'Slide-Image-2' ),
			DOMObject ( 'Slide-Image-3' )
		];
		
		this.Fader = setTimeout ( ScopeFunction ( this , this.Next ), 12000 );
	},
	
	Next : function ( ) {
		// Tween in image.
		var Tween = SavageTween ( );
		Tween.FramesIn = 15;
		
		
		// Fade action
		Tween.Action = ScopeFunction ( this , function ( Percent ) {
			this.Slides [ this.Counter ].style.opacity = Percent;
			this.Slides [ this.Counter ].style.filter = 'alpha(opacity='+Percent * 100+')';
			
			if ( this.Counter == 1 ) {
				DOMObject ( 'Slide-4-Button' ).style.opacity = 1 - Percent;
				DOMObject ( 'Slide-4-Button' ).style.filter = 'alpha(opacity='+(100 - (Percent * 100))+')';
			}
		} , null , ScopeFunction_NOARGUMENTS );
		
		// Fade complete
		Tween.Complete = ScopeFunction ( this , function ( ) {	
			
			if ( this.Counter == 1 ) {
				DOMObject ( 'Slide-4-Button' ).style.display = 'none';
			}	

			this.Counter ++;
			if ( this.Counter < this.Slides.length ) {
				this.Fader = setTimeout ( ScopeFunction ( this , this.Next ), 6000 );
				
			} else {	
				this.Objects.Slide3Button.style.visibility = 'visible';
				
				if ( BrowserVersion.isSafari || BrowserVersion.isChrome || BrowserVersion.isFirefox ) {
					// Fade action		
					Tween.Action = ScopeFunction ( this , function ( Percent ) {
						this.Objects.Slide3Button.style.opacity = Percent;
						this.Objects.Slide3Button.style.filter = 'alpha(opacity='+Percent * 100+')';
					} , null , ScopeFunction_NOARGUMENTS );
					
					// Fade complete
					Tween.Complete = ScopeFunction ( this , function ( ) { } , null , ScopeFunction_NOARGUMENTS );
					
					// Start fade in.		
					Tween.Start ( false );
				}
			}
			
		} , null , ScopeFunction_NOARGUMENTS );
 
		// Start fade in.		
		Tween.Start ( false );
	},
	
	// Open button hover
	Over : function ( Event ) {
		if ( ! this.Playing && this.Counter > 1) {
			this.Hovering = true;
			this.Objects.PlayBig.style.visibility = 'visible';
		}
	},
	Out : function ( Event ) {
		this.Hovering = false;
	},
	Move : function ( Event ) {
		this.MoveCount ++;
		
		if ( !this.Hovering || this.MoveCount < 10 ) {
			//this.Objects.PlayBig.style.visibility = 'hidden';	
			return;
		}
		
		var CenterX = document.body.scrollWidth / 2;
		var CenterY = 279;
		var x = Event.clientX;
		var y = Event.clientY;
		x = x - CenterX;
		y = y - CenterY;
		x = (x < 0) ? -x : x;
		y = (y < 0) ? -y : y;
		x = x / 460;
		y = y / CenterY;

		var Distance = (x + y) / 2;
		Distance = (Distance > 0.8) ? 0.8 : Distance;
		this.Objects.PlayBig.style.opacity = 1 - Distance;
		this.Objects.PlayBig.style.filter = 'alpha(opacity='+(1 - Distance)*100+')';	
	},
	
	FadeIn : function ( ) {		
		// Tween in video
		var Tween = SavageTween ( );
		Tween.Ease = 1;
		Tween.FramesIn = 10;
		
		// Fade action
		Tween.Action = ScopeFunction ( this , function ( Percent ) {
			this.Objects.Video.style.opacity = Percent;
		} , null , ScopeFunction_NOARGUMENTS );
 
		// Start menu fade.		
		Tween.Start ( false );
	},
	
	FadeOut : function ( ) {
		//this.Stop ( );
				
		// Tween in video
		var Tween = SavageTween ( );
		Tween.Ease = 1;
		Tween.FramesOut = 10;
		
		// Fade action
		Tween.Action = ScopeFunction ( this , function ( Percent ) {
			this.Objects.Video.style.opacity = Percent;
		} , null , ScopeFunction_NOARGUMENTS );
 
		// Start menu fade.		
		Tween.Start ( true );
	},
	
	Buffered : function ( Amount ) {
		if ( Amount >= 100 ) {
			this.Objects.Buffering.Hide ( );
			//this.Objects.Play.Show ( );
		}
	},
	
	Play : function ( ) {
		/*
		if ( this.Fader ) {
			clearTimeout ( this.Fader );
		}
		
		var Objects = this.Objects;
		// h264/ogg or flv
		if ( this.AllowHTML5 && (BrowserVersion.isSafari || BrowserVersion.isChrome || BrowserVersion.isFirefox) ) {
			// Win!
			var Wrapper = DOMObject ( 'Video-HTML5' );
			var Video = DOMObject ( document.createElement ( 'video' ) );
			Video.SetEvent ( 'canplaythrough' , ScopeFunction ( this , this.Buffered , [ 100 ] ) );
			Video.SetEvent ( 'ended' , ScopeFunction ( this , this.Stop ) );
			Video.controls = 'controls';

			var Source1 = document.createElement ( 'source' );
			Source1.src = './Videos/Home.mp4';
			Source1.type = 'video/mp4';
			Video.appendChild ( Source1 );
			
			var Source2 = document.createElement ( 'source' );
			Source2.src = './Videos/Home.ogg';
			Source2.type = 'video/ogg';
			Video.appendChild ( Source2 );
			
			// Add to doc
			Wrapper.appendChild ( Video );
			
			// Save
			Objects.Video = Video;
			
		} else {
						
			var Wrapper = document.createElement ( 'div' );
			Wrapper.id = 'Video-Flash-Wrapper';
			DOMObject ( 'Video-Flash' ).appendChild ( Wrapper );
		
			// Flash
			swfobject.embedSWF ( './Flash/Video.swf', 'Video-Flash-Wrapper', '920', '730', '9.0.0', '', { VideoURL : '../Videos/Home.flv' }, { allowScriptAccess : 'always', wmode : 'transparent', menu: 'false' } );

			Objects.Video = DOMObject ( 'Video-Flash-Wrapper' );
		}
		
		this.Playing = true;
		this.FadeIn ( );
		this.Objects.PlayBig.Hide ( );
		this.Objects.Stop.Show ( );
		
		// Tween out Nav and etc.
		var Tween = SavageTween ( );
		Tween.Ease = 1;
		Tween.FramesOut = 10;
		
		// Fade action
		Tween.Action = ScopeFunction ( this , function ( Percent ) {
			this.Objects.Navigation.style.opacity = Percent;
			this.Objects.Tours.style.opacity = Percent;
			this.Objects.Slide3Button.style.opacity = Percent;
			this.Objects.Navigation.style.filter = 'alpha(opacity='+Percent * 100+')';
			this.Objects.Tours.style.filter = 'alpha(opacity='+Percent * 100+')';
		} , null , ScopeFunction_NOARGUMENTS );
		
		// Fade action
		Tween.Complete = ScopeFunction ( this , function ( ) {
			this.Objects.Navigation.Hide ( );
			this.Objects.Tours.Hide ( );
			this.Objects.Slide3Button.style.visibility = 'hidden';
		
			// h264/ogg or flv
			if ( this.AllowHTML5 && BrowserVersion.isSafari || BrowserVersion.isChrome || BrowserVersion.isFirefox ) {
				// Win!
				this.Objects.Video.play ( );
				
			} else {
				this.Objects.Video.VideoPlay ( );
			}
			
		} , null , ScopeFunction_NOARGUMENTS );
 
		// Start menu fade.		
		Tween.Start ( true );
		*/
	},
	
	Stop : function ( ) {
		
		/*
		this.Playing = false;
		this.FadeOut ( );
		this.Objects.Stop.Hide ( );
		this.Objects.PlayBig.Show ( );
		
		// Tween out Nav and etc.
		var Tween = SavageTween ( );
		Tween.Ease = 1;
		Tween.FramesIn = 10;
				
		// h264/ogg or flv
		if ( this.AllowHTML5 && BrowserVersion.isSafari || BrowserVersion.isChrome || BrowserVersion.isFirefox ) {
			// Win!
			this.Objects.Video.pause ( );
			
		} else {
			this.Objects.Video.VideoStop ( );
		}

		this.Objects.Navigation.Show ( );
		this.Objects.Tours.Show ( );
		
		// Fade action
		Tween.Action = ScopeFunction ( this , function ( Percent ) {
			this.Objects.Navigation.style.opacity = Percent;
			this.Objects.Tours.style.opacity = Percent;
			this.Objects.Slide3Button.style.opacity = Percent;
			this.Objects.Navigation.style.filter = 'alpha(opacity='+Percent * 100+')';
			this.Objects.Tours.style.filter = 'alpha(opacity='+Percent * 100+')';
		} , null , ScopeFunction_NOARGUMENTS );
 		
 		// Fade action
		Tween.Complete = ScopeFunction ( this , function ( ) {
			this.Objects.Video.Detach ( );
			this.Objects.Video = null;
			
		} , null , ScopeFunction_NOARGUMENTS );
		
		// Start menu fade.		
		Tween.Start ( false );
		*/
	}
};

// Attach Home
SetEvent ( window , 'load' , ScopeFunction ( Home , Home.Initialise ) );


/* !REQUIRE Savage-Helpers.js

Savage-Styles.js
(c) Savage Media Pty Ltd


Functions:

selector SavageStyles.GetSelector ( string Name ) : Grab a css selector for adding styles to.
selector SavageStyles.AddSelector ( string Name ) : First searches with GetSelector and if not found adds a new selector.
void	 SavageStyles.DeleteSelector ( string Name ) : Destroy a selector


Changes:

1.01 - Removed GetStyle
1.02 - Wrapped into object
1.03 - Documentation
1.04 - Bug fix.
1.05 - IE bug fix
1.06 - Reversed deletion.

*/

// A neat wrapper for all CSS manipulation
var SavageStyles = {
	// Contains our CSS sheet to add styles to.
	// created when AddSelector is called to create a new rule
	JavascriptSheet : false,
	
	
	// Collect a CSS rule.
	GetSelector : function ( Name ) {
		// Only if supported
		if ( ! document.styleSheets ) {
			return false; 
		}
	
		// Unfortunately for cross-browser support it must be non-caps
		Name = Name.toLowerCase ( ); 

		// Default to false nothing found
		var FoundRule = false;
		var StyleSheetRules;
	
		// Need to run over all sheets.
		for ( var SheetCount = document.styleSheets.length - 1; ! FoundRule && SheetCount >= 0; SheetCount -- ) {
			// Collect
			var StyleSheet = document.styleSheets [ SheetCount ]; 
			
			// Collect rules which ever way.
			if ( StyleSheet.cssRules ) {
				// the W3C standard
				StyleSheetRules = StyleSheet.cssRules;
			} else {
				// MS standard... wait, standard?
				StyleSheetRules = StyleSheet.rules; 
			}
			
			// Run over all selectors
			for ( var RuleCount = StyleSheetRules.length - 1; ! FoundRule && RuleCount >= 0; RuleCount -- ) {
				if ( StyleSheetRules [ RuleCount ].selectorText && StyleSheetRules [ RuleCount ].selectorText.toLowerCase ( ) == Name ) {
					FoundRule = StyleSheetRules [ RuleCount ];
				}
			}
		}	
		
		// Not found
		return FoundRule;
	},
	
	
	// Delete all selectors with a specific match
	DeleteSelector : function ( Name ) {
		// Only if supported
		if ( ! document.styleSheets ) {
			return false; 
		}
		
		// Unfortunately for cross-browser support it must be non-caps
		Name = Name.toLowerCase ( ); 
		var FoundRule = false;
		var StyleSheetRules;
				
		// Need to run over all sheets.
		for ( var SheetCount = document.styleSheets.length - 1; ! FoundRule && SheetCount >= 0; SheetCount -- ) {
			// Collect
			var StyleSheet = document.styleSheets [ SheetCount ]; 
			
			// Collect rules which ever way.
			if ( StyleSheet.cssRules ) {
				// the W3C standard
				StyleSheetRules = StyleSheet.cssRules;
			} else {
				// MS standard... wait, standard?
				StyleSheetRules = StyleSheet.rules; 
			}
			
			// Run over all selectors
			for ( var RuleCount = StyleSheetRules.length - 1; ! FoundRule && RuleCount >= 0; RuleCount -- ) {
				if ( StyleSheetRules [ RuleCount ].selectorText && StyleSheetRules [ RuleCount ].selectorText.toLowerCase ( ) == Name ) {
					FoundRule = true;
				
					// Delete rules which ever way.
					if ( StyleSheet.deleteRule ) {
						// the W3C standard
						StyleSheet.deleteRule ( RuleCount );
					} else {
						// MS standard... wait, standard?
						StyleSheet.removeRule ( RuleCount ); 
					}
				}
			}		  
		}
		
		return FoundRule;
	},
	
	
	// This function will create a new Stylesheet if required then add a rule to it.
	AddSelector : function ( Name ) {
		// Only if supported
		if ( ! document.styleSheets ) {
			return false;
		}
		
		// Search for a current version.
		var Selector = SavageStyles.GetSelector ( Name );
	
		// This doesn't already exist?
		if ( ! Selector ) {
			if ( ! this.JavascriptSheet ) {
				// Build tag and collect Head tag
				var Head = document.getElementsByTagName ( 'head' ) [ 0 ];
				this.JavascriptSheet = document.createElement ( 'style' );
				this.JavascriptSheet.type = 'text/css';
				
				// Place into Head tag
				Head.appendChild ( this.JavascriptSheet );
				
				// Collect it as a CSS object
				this.JavascriptSheet = document.styleSheets [ document.styleSheets.length - 1 ];
				
				// fail?
				if ( ! this.JavascriptSheet ) {
					return false;
				}
			}
			
			if ( this.JavascriptSheet.insertRule ) { 
				// the W3C standard
				this.JavascriptSheet.insertRule ( Name + ' { }' , this.JavascriptSheet.cssRules.length );
				
			} else {
				// MS standard... wait, standard?
				this.JavascriptSheet.addRule ( Name , null , this.JavascriptSheet.rules.length );
			}

			// Collect as object
			Selector = SavageStyles.GetSelector ( Name );
		}
		
		// Return object
		return Selector;
	}
};


/* !REQUIRE Savage-Helpers.js, Savage-Tween.js, Savage-Styles.js

Gallery.js

*/

var Gallery = {	
	Images : [ ],
	Objects : { },
	
	Width : false,
	Height : false,
	
	Scrolling : false,
	ScrollOffset : 0,
	
	Initialise : function ( ) {
		if ( !document.getElementById ( 'Gallery' ) ) {
			return;
		}
		
		var Objects = {
			Gallery : DOMObject ( 'Gallery' ),
			Close : DOMObject ( 'Gallery-Close' ),
			Thumbnails : DOMObject ( 'Gallery-Thumbnails' ),
			Content : DOMObject ( 'Gallery-Thumbnails-Content' ),
			Background : DOMObject ( 'Gallery-Background' ),
			
			Deadstate : DOMObject ( 'Gallery-Deadstate' ),
			Scrollbar : DOMObject ( 'Gallery-Scrollbar' ),
			Nubbin : DOMObject ( 'Gallery-Scrollbar-Nubbin' )
		};
		
		var Image = DOMObject ( document.createElement ( 'img' ) );
		Image.id = 'Gallery-Image';
		Image.src = './Savage/Images/0.gif/';
		Objects.Image = Image;
		Objects.Gallery.appendChild ( Image );
		
		Image.src = this.Images [ 0 ];
		Image.SetEvent ( 'load', ScopeFunction ( this , this.Loaded ) );
		
		if ( document.getElementById ( 'Gallery-Open' ) ) {
			Objects.Open = DOMObject ( 'Gallery-Open' );
			Objects.Open.SetEvent ( 'click' , ScopeFunction ( this , this.Open , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		}
		this.Objects = Objects;
		
		Objects.Close.SetEvent ( 'click' , ScopeFunction ( this , this.Close , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		Objects.Background.SetEvent ( 'click' , ScopeFunction ( this , this.Close , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		SetEvent ( window , 'resize' , ScopeFunction ( this , this.Size ) );
		
		
		Objects.Nubbin.SetEvent ( 'mousedown' , ScopeFunction ( this , this.StartScrolling , [ ] , ScopeFunction_PREVENTDEFAULT ) );
		SetEvent ( window , 'mouseup' , ScopeFunction ( this , this.StopScrolling ) );
		SetEvent ( window , 'mousemove' , ScopeFunction ( this , this.Scroll ) );
		
		if (BrowserVersion.isMSIE) {
			Objects.Nubbin.SetEvent ( 'mouseup' , ScopeFunction ( this , this.StopScrolling ) );
			Objects.Deadstate.SetEvent ( 'mouseup' , ScopeFunction ( this , this.StopScrolling ) );
			Objects.Background.SetEvent ( 'mouseup' , ScopeFunction ( this , this.StopScrolling ) );
			
			Objects.Nubbin.SetEvent ( 'mousemove' , ScopeFunction ( this , this.Scroll ) );
			Objects.Deadstate.SetEvent ( 'mousemove' , ScopeFunction ( this , this.Scroll ) );
			Objects.Background.SetEvent ( 'mousemove' , ScopeFunction ( this , this.Scroll ) );
			
			Objects.Content.style.width = 184 * this.Images.length + 'px';
		}
	},

	// Open Gallery
	Open : function ( ) {
		if (typeof Rolling != "undefined") {
			clearTimeout ( Rolling.Fader );
			Rolling.Fader = false;
		}
			
		this.Objects.Gallery.AddClass ( 'Show' );
		this.Objects.Image.AddClass ( 'Show' );	
	
		if ( typeof ( Taipan ) != 'undefined' && Taipan.EditMode ) {
			Taipan.WindowResize ( );
		}	
	},
	
	// Close Gallery
	Close : function ( ) {		
		this.Objects.Gallery.RemoveClass ( 'Show' );
		this.Objects.Image.RemoveClass ( 'Show' );
		
		if ( typeof ( Taipan ) != 'undefined' && Taipan.EditMode ) {
			Taipan.WindowResize ( );
		}
	},
	
	// Select Image
	Choose : function ( Url ) {
		if ( typeof ( Taipan ) != 'undefined' && Taipan.EditMode ) {
			return;
		}
		
		// Load
		var Image = this.Objects.Image;			
		var OldUrl = Image.src;
		Image.src = Url;
		if ( OldUrl != Image.src ) {
			Image.RemoveClass ( 'Show' );
			Image.className = '';
		}
	},
	
	// Setup image now it's loaded
	Loaded : function ( ) {
		var Image = this.Objects.Image;
		this.Width = Image.width;
		this.Height = Image.height;	
		
		this.Size ( );
		
		Image.className = 'Resized';
		Image.AddClass ( 'Show' );	
	},
	
	// Resize image
	Size : function ( ) {
		// The maximum X and Y, whether that be HTML or window size

		var MaxHeight = (!BrowserVersion.isMSIE) ? window.innerHeight : document.documentElement.clientHeight;
		var MaxWidth = (!BrowserVersion.isMSIE) ? window.innerWidth : document.documentElement.clientWidth;
		
		var MaxHeight = MaxHeight * 0.6;	
		var MaxWidth = MaxWidth * 0.8;
		
		var ScaleX = MaxWidth / this.Width;
		var ScaleY = MaxHeight / this.Height;
		var Scale = (ScaleX < ScaleY) ? ScaleX : ScaleY;
		Scale = (Scale < 1) ? Scale : 1;
		
		var Width = Scale * this.Width;
		var Height = Scale * this.Height;
		
		var Resized = SavageStyles.AddSelector ( ".Resized" );
		
		Resized.style.width = Width+'px';
		Resized.style.height = Height+'px';
		Resized.style.marginLeft = -Width/2+'px';
		Resized.style.marginTop = -Height/2+'px';
	},
	
	// Setup button
	Set : function ( Item ) {
		this.Images [ this.Images.length ] = Item.Url;
	
		// Attach
		DOMObject ( Item.ButtonID ).SetEvent ( 'click' , ScopeFunction ( this , this.Choose , [ Item.Url ] , ScopeFunction_PREVENTDEFAULT ) );	
	},
	
	StartScrolling : function ( Event ) {
		this.Scrolling = true;
		this.ScrollOffset = Event.clientX - this.Objects.Nubbin.UpdateXY ( ).offsetX;
	},
	StopScrolling : function ( ) {
		this.Scrolling = false;
	},
	Scroll : function ( Event ) {
		if ( this.Scrolling ) {
			var x = Event.clientX - this.ScrollOffset - this.Objects.Scrollbar.UpdateXY ( ).offsetX;
			
			x = (x < 0) ? 0 : x;
			x = (x > 600) ? 600 : x;
			this.Objects.Nubbin.style.left = x / 10 + 'em';
			
			var p = x / 600;
			this.Objects.Thumbnails.scrollLeft = (this.Objects.Thumbnails.scrollWidth - this.Objects.Thumbnails.offsetWidth) * p;
			
			if ( typeof ( Taipan ) != 'undefined' && Taipan.EditMode ) {
				Taipan.WindowResize ( );
			}
		}
	}
};

// Attach Gallery
SetEvent ( window , 'load' , ScopeFunction ( Gallery , Gallery.Initialise ) );
