$id = function (el)
{
	return document.getElementById(el);
} // end id

cl = function ( msg ) 
{
	//console.log( typeof console )
	if ( typeof console == 'object' ) {
		console.log( msg )
	}
}; // end cl

pr = function ( obj ) 
{
	if ( typeof console == 'object' ) { // don't bother unless this exists
		for( i in obj ) {
			cl( i + ' is: ' + obj[i] );	
		}
	} //
}; // end pr
///*




	var fade_container_id = 'fade_container';
fadeBG = {
	windowHeight: 600,
	windowWidth: 800,
	contentTop: 0,
	sizeIframe: function()
	{	
		$id('up_frame').height = this.windowHeight + 'px';
		$id('up_frame').width = this.windowWidth + 'px';
	}, // end size Iframe function
	getDocHeight: function ()
	{
		var db = document.body;
		var de = document.documentElement
		return Math.max(
			Math.max(db.scrollHeight, de.scrollHeight),
			Math.max(db.offsetHeight, de.offsetHeight),
			Math.max(db.clientHeight, de.clientHeight)
		);
	},

	fadeInPopUp: function ( elID, closeID, callback )
	{
		var clickedEl = this;
		$(clickedEl).unbind('click');
		var scrollTop = $().scrollTop();
		if ( !$id(fade_container_id) ) { // if the fade container is not in the dom, add it
			var html = '<div id="' + fade_container_id + '"></div>';
			$('body').prepend( html );
			$('#' + fade_container_id ).click( function (ev) { ev.preventDefault(); fadeBG.fadeOutPopUp( 'shadow_box_holder', fade_container_id); });
		}
		
		$('#' + fade_container_id).css({ opacity: 0, 'z-index': 10, 
			width: '100%', height: fadeBG.getDocHeight(), position: 'absolute', left: 0, top: 0,
			backgroundColor: 'black', display: 'block'
		}).fadeTo( 750, 0.6, function () {
			$id(elID).style.display = 'block';
			var scrollTop = $().scrollTop();
			var centeringAdd =  0;//Math.round( (winDim.getHeight() - $id(elID).offsetHeight ) / 2 );
		 	var contentTop = ( scrollTop + centeringAdd ) + 'px';
			
			$id(elID).style.top = contentTop;
			
			$('#'+closeID).click( function(ev)
			{	
				$('#'+closeID).unbind('click');
				me_id = elID;
				ev.preventDefault();
				fadeBG.fadeOutPopUp(me_id, clickedEl);
				
				////////////////////////////////////////////////////////////
				////////////////////////////////////////////////////////////
				////////////////////////////////////////////////////////////
				
				slide_number = 0;
				$("#shadow_box_holder").fadeOut("slow");//hardcoded element	
				
				////////////////////////////////////////////////////////////
				////////////////////////////////////////////////////////////
				////////////////////////////////////////////////////////////
				
			}); // end click
			if( typeof callback == 'function') {
				callback();
			}
		});
	}, // fade in pop up
	fadeOutPopUp: function (elID, clickedEl)
	{
		$id(elID).style.display = 'none';
		if ( elID == 'discipline_container' ) { // must be removed to clean it out
			if( $id('discipline_container') ) { // double check it exists
				$('#discipline_container').remove();
			}
		} // end if disc container
		$($id('fade_container')).fadeOut(750, function()
		{
			$($id('fade_container')).remove();	
		});
		$(clickedEl).click( function( ev )
		{
			ev.preventDefault();
			fadeBG.fadeInPopUp('video_holder','video_close');
		}); // CLOSE CLICK
	}, // fade out pop up
	closeBGcontainers: function ()
	{
		$('#' + fade_container_id).unbind('click');
		//if ( $id('up_frame') ) { // prevent the function from running twice
				$('.close_button', $id('up_frame').contentWindow.document).unbind('click');
			
			$($id(fade_container_id)).fadeOut(750, function()
			{
				$($id(fade_container_id)).remove();
			});
		//}
		//$($id('pop_up_container')).fadeOut(750, function()
		//{
			//$id('up_frame').remove();
			$($id('pop_up_container')).remove();	
		//});
	}

} // end fadeBG object


