var pop;
var IE=document.all?true:false;


function sendmail(login,domain) {
  document.location.href='mailto:'+login+'@'+domain;
}

function redirect(url) {
  document.location.replace(url);
}

function reportresolution() {
//  id='res-'+screen.width;
//  logimg=new Image;
//  logimg.src='img-counter.php?id='+id;
}

if(!IE) {
        document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove=mousePos;
        var netX, netY;
}

function init() {
        if(IE) pop=document.all.pop; else pop=document.getElementById("pop");
        b=document.body;
}

function mousePos(e) {
        netX=e.pageX;
        netY=e.pageY;
}

function popPrzesun(pX, pY) {
        init();
        if(pop.style.visibility!='visible') return;
        if(IE) {myszX=event.clientX; myszY=event.clientY;}
                else {myszX=netX-b.scrollLeft; myszY=netY-b.scrollTop;}

        tempX=myszX+pX;
        if(tempX<0) tempX=0;
        tmp=b.clientWidth-myszX-pX-pop.offsetWidth-20;
        if(tmp<0) {tempX+=tmp; if(tempX<0) tempX=0;}
        pop.style.left=b.scrollLeft+tempX+"px";

        tempY=myszY+pY;
        if(tempY<0) tempY=0;
        tmp=b.clientHeight-myszY-pY-pop.offsetHeight-15;
        if(tmp<0) {
                tmp=myszY-15-pop.offsetHeight;
                if(tmp>=0) tempY=tmp;
        }
        pop.style.top=b.scrollTop+tempY+"px";
}

function popPokaz(pX, pY, src) {
        init();
        pop.style.visibility='visible';
        pop.innerHTML=src;
        popPrzesun(pX,pY);
}

function popZamknij() {
        init();
        pop.style.visibility='hidden';
        pop.innerHTML='';
        pop.style.left=0;
        pop.style.top=0;
}

function popKom(tresc) {
        text='<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=3 bgcolor=silver height=1></td></tr>';
        text+='<tr><td width=1 bgcolor=silver></td><td class=poptd>'+tresc+'</td><td width=1 bgcolor=silver></td></tr>';
        text+='<tr><td colspan=3 bgcolor=silver height=1></td></tr></table>';
        popPokaz(5,20,text);
}

function popLinkPrzesun() {
        popPrzesun(5,20);
}

function popSrodekPrzesun() {
        popPrzesun(-90,20);
}



  function show_hide_column(col_no, do_show) {

    var stl;
    if (do_show) stl = 'block'
    else         stl = 'none';

    var tbl  = document.getElementById('id_of_table');
    var rows = tbl.getElementsByTagName('tr');

    for (var row=0; row<rows.length;row++) {
      var cels = rows[row].getElementsByTagName('td')
      cels[col_no].style.display=stl;
    }
  }

function showhide(colid){
 if(document.all.row[colid].style.display == 'none'){
  document.all.row[colid].style.display ='';
 }else{
  document.all.row[colid].style.display ='none';
 }
 return false;
}

function setFlashWidth(divid, newW){
        document.getElementById(divid).style.width = newW+"px";
}
function setFlashHeight(divid, newH){
        document.getElementById(divid).style.height = newH+"px";
}
function setFlashSize(divid, newW, newH){
        setFlashWidth(divid, newW);
        setFlashHeight(divid, newH);
}
function canResizeFlash(){
        var ua = navigator.userAgent.toLowerCase();
        var opera = ua.indexOf("opera");
        if( document.getElementById ){
                if(opera == -1) return true;
                else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
        }
        return false;
}

var form='list' //Give the form name here

function SetChecked(val,chkName) {
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements[i].id==chkName) {
dml.elements[i].checked=val;
}
}
}

function ValidateForm(dml,chkName){
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if ((dml.elements[i].id==chkName) && (dml.elements[i].checked==1)) return true
}
alert("Please select at least one record to be deleted")
return false;
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}

function openWin(URL,width,height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = 237,top = 184');");
}

var opened = "";
var lasttimeout;

function showmenu(menuid)
{
	hideall(menuid);
	clearTimeout(lasttimeout);
	var name = new String;
	name = "sub" + menuid;
	nameb = "sua" + menuid;

	document.getElementById(name).style.display ='';
	document.getElementById(nameb).style.background = '#900000';
	//document.getElementById(nameb).style.fontcolor = '#EFC500';
	//document.getElementById(menuid).colspan = 2;
}

function hideoneT(menuid)
{
	func = 'hideone("'+menuid+'");';
	clearTimeout(lasttimeout);
	lasttimeout = setTimeout(func,1500);
}

function hideone(menuid)
{
	name = "sub" + menuid;
	nameb = "sua" + menuid;
	document.getElementById(name).style.display ='none';
	document.getElementById(nameb).style.background = 'none';
}

function hideall(but)
{
	var name = new String;
	for (var i = 1; i < 9; i++) {
		name = "sub" + i;
		nameb = "sua" + i;
		if (i != but)
		{
			document.getElementById(name).style.display ='none';
			document.getElementById(nameb).style.background = 'none';
			//document.getElementById(nameb).style.background ='#000000';
		}
	}
}

function pause(numberMillis)
{
 var now = new Date();
 var exitTime = now.getTime() + numberMillis;
 while (true)
 {
  now = new Date();
  if (now.getTime() > exitTime)
  return;
 }
}