
function showBox(box1){
		overlayHeight();
    $('overlay').show();
	$(box1).show();
    center(box1);
    return false;
}

function hideBox(box1, box2){
    $(box1).hide();
    $(box2).hide();
    $('overlay').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';
}


function getViewPortSize(type) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	if (type == 'width')
	{
		return myWidth;

	}else if(type == 'height')
	{
		return myHeight;
	}
}


function overlayHeight(){

	var bdimensions = $('main_container_id').getDimensions();
	var bheight = (bdimensions.height + 250);
	var winHeight = getViewPortSize('height');

	if (bheight > winHeight) 
		{
			$('overlay').setStyle({ height: bheight + 'px' });
		}
	else {
		$('overlay').setStyle({ height: winHeight + 'px' });
	}
}


function openPopup() {
                var largeur = getViewPortSize('width');
                var hauteur = getViewPortSize('height');
                var win = window.open("http://albums.sendphotos.com/default.aspx?projType=PhotobookModule&lang=de-DE&name=test", "popup", "width="+largeur+", height="+hauteur+", top=0, left=0, fullscreen=no, location=no,menubar=no,status=no,resizable=no, scrollbars=1, copyhistory=0, directories=0");
                win.focus();
                win.resizeTo(largeur, hauteur);
}
