var mousex = 0;
var mousey = 0;
var imout  = true;

isDOM=document.getElementById;
isOpera=isOpera5=window.opera && isDOM;
isOpera6=isOpera && window.print;
isOpera7=isOpera && document.readyState;
isMSIE=document.all && document.all.item && !isOpera;
isMSIE5=isDOM && isMSIE;
isNetscape4=document.layers;
isMozilla=isDOM && navigator.appName=="Netscape";

if(isNetscape4) document.captureEvents(Event.MOUSEMOVE)
if(isMSIE || isOpera7)
{
	document.onmousemove=function(){
		mousex=event.clientX+document.body.scrollLeft;
		mousey=event.clientY+document.body.scrollTop;
	}
}
else if(isOpera)
{
	document.onmousemove=function(){
		mousex=event.clientX;
		mousey=event.clientY;
  }
}
else if(isNetscape4 || isMozilla)
{
	document.onmousemove=function(e)
	{
		mousex = e.pageX;
		mousey = e.pageY;
  }
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function adjust_popup()
{
        var w, h, fixedW, fixedH, diffW, diffH;

        if (document.all) {
                fixedW = document.body.clientWidth;
                fixedH = document.body.clientHeight;
				window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.body.clientWidth;
                diffH = fixedH - document.body.clientHeight;
        } else {
				fixedW = window.innerWidth;
                fixedH = window.innerHeight;
				window.resizeTo(fixedW, fixedH);
                diffW = fixedW - window.innerWidth;
				diffH = fixedH - window.innerHeight;
        }
		w = fixedW + diffW;
        h = fixedH + diffH;
		if (h >= screen.availHeight) w += 16;
		if (w >= screen.availWidth)  h += 16;
		w = Math.min(w,screen.availWidth);
        h = Math.min(h,screen.availHeight);
		window.resizeTo(w,h);
		window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

function getElementTop(elName)
{
		var node = document.getElementById(elName);
		var sum = node.offsetTop;
		while(node=node.parentNode)
		{
				if (node.offsetTop
					&& node.nodeName!=='A'
					&& node.nodeName!=='TR'
					&& node.nodeName!=='TBODY'
					&& node.nodeName!=='FORM'
					)
				{
						if (a=node.offsetTop)
							sum = sum + a;
				}
	}
	return sum;
}

function getElementLeft(elName)
{
		var node = document.getElementById(elName);
		var sum = node.offsetLeft;
		while(node=node.parentNode)
		{
				if(node.offsetLeft
					&& node.nodeName!=='A'
					&& node.nodeName!=='TR'
					&& node.nodeName!=='TBODY'
					&& node.nodeName!=='FORM'
					)
				{
						if (a=node.offsetLeft)
							sum = sum + a;
				}
	}
	return sum;
}
function ShowSmallImg(t,img_src,w,h,n)
{
	if (document.MM_p){
	var img 	= document.MM_p[n];//document.getElementById('im');

	var iimm	= document.getElementById('im');
	iimm.src	= img_src;
	iimm.width	= w;
	iimm.height	= h;
	var timg	= document.getElementById(t);
	var node	= document.getElementById('imglayer');

	var link = document.getElementById('link'+t);
//	var ilink = document.getElementById('imglink');
//	ilink.onclick = link.onclick;
//	ilink.locationhref = link.locationhref;

	node.style.position = "absolute";
	node.style.top		= mousey+10; //getElementTop(timg.id)  + (timg.height - h);
	node.style.left		= mousex+10; //getElementLeft(timg.id) + (timg.width  - w);
	node.style.width	= 'auto';
	node.style.height	= 'auto';
	node.style.zIndex	= 1;

	node.style.display	= "block";
	}
	return true;
}

function MoveSmallImg(t,img_src,w,h,n)
{
	var node = document.getElementById('imglayer');
	node.style.top  = mousey+10;
	node.style.left = mousex+10;
}

function HideSmallImg(def_img_src)
{
	document.getElementById('imglayer').style.display	='none';
	document.getElementById('im').src					= def_img_src;
}

  function CheckAll(e_check) {
   for (i=0;i<document.forms["form"].elements.length;i++) {
		var j=document.forms["form"].elements[i];
		jj=e_check.id;
		if ((j.type=="checkbox")&&(j.id==jj)) {j.checked=e_check.checked;}
	}
  }


  function ActionIsChanged(act,cat){
	if (act.value=="move"){
		cat.style.display = "";
	}else{
		cat.style.display = "none";
	}
  }

  function ActIsChecked(act,cat){
	if (act.checked){
		cat.style.display = "block";
	}else{
		cat.style.display = "none";
	}
  }

  function rset(item_exists,item_title){
	if (item_exists.checked) item_title.disabled = false;
	else item_title.disabled = true;
  }

