
function ShowHide( TheDiv )
{
	if( target = document.getElementById( TheDiv ) )
	{
		if( target.style.display == "none" )
		{
			target.style.display = "";
			target.style.visibility = "visible";
		}
		else
		{
			target.style.display = "none";
			target.style.visibility = "hidden";
		}
	}
}

function popupwindow(url,width,height) {
	w=window.open(url,'_blank','resizable=no,menubar=no,scrollbars=yes,status=no,height='+height+',width='+width);
	w.focus();
	return w;
}

function hideAlert()
{
	var obj = document.getElementById('MessageContainer');
	obj.style.display = "none";
}

function myCustomFileBrowser (field_name, url, type, win) {
	if( type == "flash" ) url = '/admin/uploads/popupchooser/?st=popup&df={df}&oc=Image,libfile,1&type=swf';
	else if( type == "media" ) url = '/admin/uploads/popupchooser/?st=popup&df={df}&oc=Image,libfile,1&type=swf,dcr,mov,qt,mpg,mp3,mp4,mpeg,avi,wmv,wm,asf,asx,wmx,wvx,rm,ra,ram';
	else if( type == "file" ) url = '/admin/uploads/popupchooser/?st=popup&df={df}&oc=link,href,1&type=*';
	else url = '/admin/uploads/popupchooser/?st=popup&df={df}&oc=Image,libfile,1&type=img';
	w = popupwindow(url,650,580);
	top.alternate = win;
	top.field_name = field_name;
}



// SIMPLE MODAL SCRIPT - Revisit might be nessecary
// Script from http://www.pjhyett.com/posts/190-the-lightbox-effect-without-lightbox

function showBox( divvar ){
	$('ModalBack').show();
	$('ModalTop').show();
    $('ModalMain').show();
    $('ModalBottom').show();
    $( divvar ).show();
	center( 'ModalContainer' );
    return false;
}

function hideBox(){
    $('ModalBack').hide();
    $('ModalTop').hide();
    $('ModalMain').hide();
    $('ModalBottom').hide();
    return false;
}

function center(element){
    try{
	element = $(element);
    }catch(e){
	return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
	my_width  = window.innerWidth;
	my_height = window.innerHeight;
    }else if ( document.documentElement && 
	     ( document.documentElement.clientWidth ||
	       document.documentElement.clientHeight ) ){
	my_width  = document.documentElement.clientWidth;
	my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && 
	    ( document.body.clientWidth || document.body.clientHeight ) ){
	my_width  = document.body.clientWidth;
	my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
	scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
	scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
	scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
	scrollY = window.scrollY;
    }

    var elementDimensions = Element.getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

    element.style.display  = 'block';
   }
// END MODAL SCRIPT
