var OpenIndex = null;
var FooterHeight = 115;

function ToggleClass( id ) {

	jQuery.easing.def = "easeInQuad";
	var object = document.getElementById( id );
	var link = document.getElementById( 'OpenClose' );
	var FooterHolder = document.getElementById( 'Footer' );
	content = document.getElementById( 'Content' );

	if ( object != null ){''
		if( ( link.className == "OpenContent" ) ) {
			//open content with animation
			$(object).animate( {
				height : content.getAttribute( 'origheight' )-FooterHeight
			}, {
				queue :false,
				duration : 900
			});

			$(FooterHolder).animate( {
				top : parseInt( content.getAttribute( 'origheight' ) )+95
			}, {
				queue :false,
				duration : 900
			});
			
			$(content).animate( {
				height : parseInt( content.getAttribute( 'origheight' ) )-FooterHeight
			}, {
				queue :false,
				duration : 900
			});
	
			if( OpenIndex != null ){
				link.className = "OpenContent";
				document.getElementById( 'Content' ).className = "Invisible";
			}
			
			link.className = "CloseContent";
			document.getElementById( 'Content' ).className = "Visible";
			OpenIndex = id;
		} else {
			//close content with animation
			$(object).animate( {
				height : 0 //480
			}, {
				queue :false,
				duration : 900
			});
			
			$(content).animate( {
				height : 0
			}, {
				queue :false,
				duration : 900
			});
			
			$(FooterHolder).animate( {
				top : FooterHeight+465 
			}, {
				queue :false,
				duration : 900
			});

			//object.className = "Open";
			link.className = "OpenContent";
			document.getElementById( 'Content' ).className = "Invisible";
			OpenIndex = null;
		}
	}
}

function setWidth( ObjectID ) {
	var Element = document.getElementById( ObjectID );
	if( Object ) {
		Element.style.width = document.body.clientWidth+'px';
	}
} 

function setHeight( ObjectID ) {
	var Object = document.getElementById( ObjectID );
	var FooterHolder = document.getElementById( 'Footer' );

	if( Object ) {
		content = document.getElementById( 'Content' );
		
		var Height =  parseInt( content.offsetHeight );//+FooterHeight ;
		//default height
		if( Height < 380 ) {
			//minimal height = 500;
			var Height = 400;
		}
		
		FooterHolder.style.top = parseInt( Height )+FooterHeight+95 + 'px';
		content.style.height = parseInt( Height )+ 'px';
		Object.style.height = Height + 'px';
		
	}
}

$(document).ready(function() {
	
	content = document.getElementById( 'Content' );

	setHeight( 'ContentHolder' );

	content.setAttribute('origheight', parseInt( content.offsetHeight )+FooterHeight );

});
