
function adc_controlFlashByType(display, typename)
{
    var objects = document.getElementsByTagName(typename);
    for (var i = 0; i < objects.length; i++)
    {
        if (objects[i].id == 'xmoov-flv-player')
        {
            objects[i].style.display = display;
        }
    }
}

function adc_controlFlash(display)
{
    adc_controlFlashByType(display, "object");
    adc_controlFlashByType(display, "embed");
}

function adc_showOverlay(name, allowResize)
{
    adc_controlFlash("none");
	arrayPageSize = getPageSize();
	adc_controlWindow(arrayPageSize[1] + 'px', 'hidden');
	adc_controlOverlay(name, 'block', allowResize);
}

function adc_hideOverlay(name)
{
    adc_controlFlash("");
    adc_controlOverlay(name, 'none');
	adc_controlWindow('auto', 'auto', false);
}

function adc_controlWindow(height, overflow)
{
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	bod.style.overflow = overflow;

	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	htm.style.overflow = overflow;
	
//	bodc = document.getElementById('main');
//	bodc.style.height = height;
//	bodc.style.overflow = overflow;
	
}

function adc_controlOverlay(name, display, allowResize)
{
	arrayPageSize = getPageSize();

	oConfirm = document.getElementById(name + '_o_confirm');
    oBackground = document.getElementById(name + '_o_background');
    
//    if (oConfirm == null || oBackground == null) return false;

	oBackground.style.display = display;
	oConfirm.style.display = display;

	var windowLeft = arrayPageSize[2];	
	var windowTop = arrayPageSize[3];
	var confirmWidth = oConfirm.offsetWidth;
	var confirmHeight = oConfirm.offsetHeight;
	
	if (allowResize)
	{
	    if (confirmWidth > windowLeft)
	    {
		    confirmWidth = windowLeft - 100;
		    oConfirm.style.width = confirmWidth + "px";
	    }
	    if (confirmHeight > windowTop)
	    {
		    confirmHeight = windowTop - 125;
		    oConfirm.style.height = confirmHeight + "px";
	    }
	}
		
	var marginLeft = 0;
	var marginTop = 0;

	marginTop = (windowTop / 2) - (confirmHeight / 2)
	marginLeft = (windowLeft / 2) - (confirmWidth / 2)

	if (marginTop < 0) marginTop = 0;
	if (marginLeft < 0) marginLeft = 0;
	
	oConfirm.style.top = marginTop + "px";
	oConfirm.style.left = marginLeft + "px";

}

function adc_createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
