var win=null;

function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}

function up(o){
	if(/[^0-9A-Z\._ -@]/.test(o.value)){
		o.value=o.value.toUpperCase().replace(/([^0-9A-Z\._ -@])/g,"");
	}
}

function showImage(photo,width,height,caption) {
var wrapWidth = width + 50;
var wrapHeight= height + 50;

//get browser height/width and scroll positions
var scroll_array= getScrollXY();
var size_array=alertSize();



myleft=(screen.width)?(size_array[0]-wrapWidth)/2:100;
mytop=(screen.height)?(size_array[1]-wrapHeight)/2:100;
myleft+=scroll_array[0];
mytop+=scroll_array[1];
//document.write(myleft+ ''+mytop);
var i = document.getElementById('imageBlock');
i.style.left=myleft+"px";
i.style.top=mytop+"px";
//i.style.left="50px";
//i.style.top="100px";
photo.onload=i.style.display="none";
i.innerHTML = "<div id=\"wrapper\" style=\"width:" + wrapWidth + "px;height:" + wrapHeight + "px;z-index:1000 !important;\"><div class=\"closemer\" style=\"height:25px !important;\"><a href=\"javascript:loaderClose();\" style=\"color:#cf1212; font-size:11px; float:right; font-family: Arial, sans-serif; text-transform:uppercase; margin:5px 10px; \" title=\"close here\">x</a></div><div class=\"largeImage\"><a href=\"javascript:loaderClose();\" class=\"imageClose\"><img src=\"http://www.akemi.be/images/dynamic/" + photo + "\" width=\"" + width +"\" height=\"" + height +"\" alt=\"close\" title=\"click to close\" id=\"largeImage\" /></a><div style=\" font-family: verdana; font-size:10px; color: #3f3f3f; \">"+ caption +"</div></div></div>";
//i.innerHTML = "<img src=\"http://test.909.be/images/uploaded/" + photo + "\" width=\"" + width +"\" height=\"" + height +"\" alt=\"$photo\" id=\"largeImage\" /></a>";
i.style.display='block';
i.style.opacity="0.1";
new Rico.Effect.FadeTo( i, 1 , 10, 10, {complete:function() {i.style.display='block';}})


}

function loaderClose() {
var loader = document.getElementById('loader');
//loader.innerHTML = "";
//loader.style.display='none';
var p = document.getElementById('imageBlock');
//new Rico.Effect.FadeTo(element, opacity, duration, steps, options)
new Rico.Effect.FadeTo(p, .0, 20, 10, {complete:function() {p.style.display='none';}})
}

///get scrollposoition

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

///getsize of window

function alertSize() {
  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;
  }
 return[ myWidth , myHeight];

}

function fixflash(containerID){
var flashContainer = document.getElementById(containerID);
var flashMovie = document.createElement("div");
flashMovie.innerHTML = flashContainer.innerHTML.replace(/</g, "<").replace(/>/g, ">");
flashContainer.parentNode.insertBefore(flashMovie, flashContainer);
flashContainer.parentNode.removeChild(flashContainer);
flashMovie.setAttribute("id",containerID);
}
