// JavaScript Document

var gal=false;
var down=false;
var MouseX = 0;
var MouseY = 0;
var xx=100;
var yy=100;
var scrolly;
var scroll_on;
var maxx;
var maxy;
var topy;


function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    maxx = window.innerWidth;
    maxy = window.innerHeight;
	
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    maxx = document.documentElement.clientWidth;
    maxy = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    maxx = document.body.clientWidth;
    maxy = document.body.clientHeight;
  }
  topy = document.body.scrollTop;
  //window.alert( 'Width = ' + maxx );
  //window.alert( 'Height = ' + maxy );
}


scrolly=0;
scroll_on=false;

var IE = document.all?true:false;

if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
MouseX = event.clientX + document.body.scrollLeft;
MouseY = event.clientY + document.body.scrollTop;

}
else {  // grab the x-y pos.s if browser is NS
MouseX = e.pageX;
MouseY = e.pageY;

}  

if (gal&&down){
	 move_gal();
	
	}
return true;
}



function do_search(kulcs){
	document.getElementById('search_str').value=kulcs;
	document.getElementById('search_form').submit();
}

function chg_src(obj, nsrc){
	obj.src=wwwsite+nsrc;
}

function open_gal(id){
	document.getElementById('shadow').style.visibility='visible';
	document.getElementById('shadow').style.display='block';
	do_ajax('gal.php?keptarid='+id,'galery');
	document.getElementById('galery').style.visibility='visible';
	
	document.body.style.overflow="hidden";
	alertSize();
	xx=maxx/2-360;
	yy=topy+maxy/2-260;
	document.getElementById('galery').style.top=yy+'px';
	document.getElementById('galery').style.left=xx+'px';
	document.getElementById('shadow').style.top=topy+'px';
	 move_shadow();
	gal=true;
	
	
}

function hide_gal(id){
	document.getElementById('shadow').style.visibility='hidden';
	document.getElementById('shadow').style.display='none';
	document.getElementById('galery').style.visibility='hidden';
	document.body.style.overflow="auto";
	gal=false;
}

function scrollleft(){
	if (scroll_on) {
		scrolldiv('scroll_clipper',-5);
		setTimeout("scrollleft()",20);
	}
}

function scrollright(){
	if (scroll_on) {
		scrolldiv('scroll_clipper',5);
		setTimeout("scrollright()",20);
	}
}

function scrolldiv(obj,y){
	
	o=document.getElementById(obj);
	b=scrolly+y;
	if(b>0&&b<=o.scrollHeight-o.clientHeight+49) {
		scrolly+=y;		
	}
	if (b<5) scrolly=0;
	
	o.scrollTop=scrolly;
}


function do_ajax(wwwstr,divid){
	var url=wwwstr;
	
	var pars='';
	var target=divid;
	var myAjax=new Ajax.Updater(
								target,
								url,
								{
									method: 'get', 
									parameters: pars
									
								}
								);
}

function move_gal(){
	if (mx!=MouseX||my!=MouseY){
	  if (MouseX-mx+xx>=-100&&MouseX-mx+xx<maxx+100) {
	   xx=MouseX-mx+xx; 	  
	   mx=MouseX;	  
	  }
	  if (MouseY-my+yy>=-100&&MouseY-my+yy<maxy) {
	  yy=MouseY-my+yy;
	  my=MouseY;
	  }
	  document.getElementById('galery').style.top=yy+'px';
	  document.getElementById('galery').style.left=xx+'px';
	  move_shadow();
	}
	
}

function move_shadow(){
	 
	 sx=xx-10+(xx-maxx/2+360)/10;
	 sy=yy-10+(yy+20)/10;
	 
	 document.getElementById('shadowp').style.top=sy+'px';
	 document.getElementById('shadowp').style.left=sx+'px';
}

function disabletext(e){
return false
}

function reEnable(){
return true
}

function downin(){
	down=true;
	document.onmousedown=disabletext;
	mx=MouseX;
	my=MouseY;
	
}

function upin(){
	down=false;
	document.onmousedown=reEnable;
}