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;
}
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 get_coords_for_win(w,h){
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	ret=new Array();
	//alert(arrayPageSize[3]);
	//alert(arrayPageScroll[1]);
	//alert(h);
	ret["top"]=(arrayPageSize[3]-h)/2;
	ret["left"]=(arrayPageSize[2]-w)/2;
	return ret;
}
function get_coords_for_div(id){
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	//alert(arrayPageSize[0]+"\n"+arrayPageSize[1]+"\n"+arrayPageSize[2]+"\n"+arrayPageSize[3]+"\n"+arrayPageScroll[1]);
	var o=document.getElementById(id);
	// center o if it exists
	if (o) {
		ret=new Array();
		var re=/^(\d+)px/;
		var tp=o.style.height;
		tp=tp.replace(re, "$1");
		var tp=(arrayPageScroll[1] + (arrayPageSize[3] -35 -tp) / 2)+'px';
		var lf=o.style.width;
		lf=lf.replace(re, "$1");
		var lf=((arrayPageSize[0] - 20 - lf) / 2)+'px';
		//alert(tp+"\n"+lf);
		ret["top"]=tp;
		ret["left"]=lf;
	}
	else {var ret=false;}
	return ret;
}
function show_block(id, op){
	var o=document.getElementById(id);
	// center o if it exists
	if (o) {
		var coords=get_coords_for_div(id);
		o.style.position='absolute';
		o.style.top=coords["top"];
		o.style.left=coords["left"];
		o.style.display='block';
	}
	return false;
}
function close_block(id, op){
	document.getElementById(id).style.display='none';
	//if(op>0){
	//	var b=document.getElementsByTagName("body");
	//	b[0].style.opacity=op;
	//}
	return false;
}

function close_floatblock(tgt){
	var e=document.getElementById(tgt);
	var es=e.style;
	es.display='none';
	es.position='absolute';
	es.top='0px';
	es.left='0px';
	es.width='1px';
	es.height='1px';
	es.borderWidth=0;
	e.innerHTML='';
}

function screenshot(url,w,h){
	if(w>0 && h>0 ){
		var tgt='floatblock';
		var coords=get_coords_for_div(tgt);
		//width+=40;
		//height+=40;
		var e=document.getElementById(tgt);
		var es=e.style;
		es.top=coords["top"];
		es.left=coords["left"];
		es.width=w+'px';
		es.height=h+'px';
		es.borderWidth=2;
		es.display='block';
		e.innerHTML='<img src="'+url+'" width='+w+' height='+h+' border=2><div style="position: absolute; top: 0px; right: 0px; background-color: #999999; color: #ffffff; font-family: Tahoma, Arial, Verdana; font-weight: bold; font-size: 16px; cursor: pointer; padding: 3px" onclick="javascript: close_floatblock(\''+tgt+'\');">X</div>';
	}
	//newWindow=window.open(url,"plan",
   	//"top=0,left=0,toolbar=no,status=yes,location=no,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height);
  // newWindow.onLoad=newWindow.focus();
}
function screenshot6(url,width,height){
	width+=40;
	height+=40;
   newWindow=window.open(url,"plan",
   	"top=0,left=0,toolbar=no,status=yes,location=no,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height);
   newWindow.onLoad=newWindow.focus();
}
function screenshot5(id,width,height){
	width+=40;
	height+=40;
   newWindow=window.open('/images/show_img.php?id='+id+'&w='+width+'&h='+height,"plan",
   	"top=0,left=0,toolbar=no,status=yes,location=no,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height);
   newWindow.onLoad=newWindow.focus();
}
function hide_floatblock(){
	$("#floatblock").css("display", "none");
	$("#floatblock").width(1);
	$("#floatblock").height(1);
	$("#floatblock").removeClass("txt");
	$("#floatblock").css("top", "0px");
	$("#floatblock").css("left", "0px");
	$("#floatblock").css("border", "0px");
	$("#floatblock").html("");
}
function refresh_captcha(id){
	var s=new Date().getTime();
	document.getElementById(id).src='/capcha-sess-give.php?dummy='+s;
}