var ns4					= document.layers ? true : false;
var ie4					= document.all ? true : false;
var any_ie				= document.all ? true : false;
var dom					= document.getElementById ? true : false;
if (dom) ie4			= false;

txt = new Array();
dir = new Array();
var occupied_header = new Array();
var occupied_menu = new Array();

function delcontent(form,obj) {
document.forms[form].elements[obj].value = '';
//document.all.elements[obj].value = '';
}


function setLoginFocus() {
	document.login.frmLogin.focus();
}

function setPointer(theRow, thePointerColor) {
    theRow.bgColor = thePointerColor;
    return true;
} 

function goSelection (form)
{
  for (i = 0; i < document.all.fastcat.options.length; i++)
    {
	   if (document.all.fastcat.options[i].selected)
    {
      document.location = document.all.fastcat.options[i].value;
    }
  }
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MarkRadio(name) {
	document.order[name].checked = true;
}

/*
Checks/unchecks all tables
*/
function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                  ? document.forms[the_form].elements['selected_db[]']
                  : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
          ? document.forms[the_form].elements['selected_tbl[]']
          : document.forms[the_form].elements['selected_fld[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function


function CreateLayer(text, id, t, l, m) {
//	window.alert(text);
//	if (text.lenght) 
	var onmouse = " onmouseover=\"occupied_menu[" + id + "]=1;\" onmouseout=\"Turn('" + id + "',0);occupied_menu[" + id + "]=0;\"";
//	else var onmouse = '';
	
	if(document.layers) {
		var str="<LAYER ID=m" + id + " TOP=" + t + " LEFT=" + l + onmouse + " VISIBILITY=hide Z-INDEX=5 bgcolor=\"#FFFFFF\">" + text + "</LAYER>";
		document.write(str);
	}
	else if(document.all) {
		var strng="<div id=m" + id + " style=\"position:absolute;top:" + t + ";left:" + l + ";visibility:hidden;width:100;z-index:5;\" " + onmouse + ">" + text + "</div>";
		document.write(strng);
	}
}
 
 
function Turn(id, mode, xcrd) {
		
		var xy = GetXY(document.images["mm" + id]);
		var xcrd = xy[0]+50;
		var ycrd = xy[1]+11;
		
	if(document.layers || document.all) {
		if(mode) eval(setTimeout("On(" + id + ", " + xcrd + ", " + ycrd + ");",400));
		else eval(setTimeout("Off(" + id + ");",400));
	}
}
 
 
 function On(id, xcrd, ycrd){
 
 
	for (i=1; i<=20;i++) {
		if (i != id && occupied_header[i]) occupied_header[id] = 0;
	}

	
	if(occupied_header[id]) {
	
//		document.images["mm"+id].src = '/i/m-' + dir[id] + '-' + lng + '-a.gif';
		
		if(document.all) {

			LeftCoord = xcrd;
			TopCoord = ycrd;
			
			document.all["m" +id].style.left = LeftCoord;
			document.all["m" +id].style.top = TopCoord;
			eval("m" + id).style.visibility = 'visible'
	   }    
	   else if(document.layers) {
			LeftCoord = xcrd;
			TopCoord = ycrd;
			eval('document.layers["m" +id].left = LeftCoord');    
			eval('document.layers["m" +id].top = TopCoord');    
			eval("document.layers['m" + id + "']").visibility = "show";
		}    
	}
}
 
function Off(id){

	if(!occupied_menu[id] && !occupied_header[id]) {
		
//		document.images["mm"+id].src = '/i/m-' + dir[id] + '-' + lng + '-p.gif';
		
		if(document.all) eval("m" + id).style.visibility = 'hidden';
		else if(document.layers) {
			eval("document.layers['m" + id + "']").visibility = "hide";
	   }    
	}
}
 


CalendarWindow = null;
 
function calendar(pos)	{

	if (pos == 1) {
		day = document.all.dayN1.value;
		month = document.all.monthN1.value;
		year = document.all.yearN1.value;
	}
	else if (pos == 2) {
		day = document.all.dayN2.value;
		month = document.all.monthN2.value;
		year = document.all.yearN2.value;
	}
	else if (pos == 3) {
		day = document.all.dayN3.value;
		month = document.all.monthN3.value;
		year = document.all.yearN3.value;
	}

	var language = 'en';
	
	if(CalendarWindow && !CalendarWindow.closed){
		CalendarWindow.close();
	}
	calendarX = 420;
	calendarY = 450;
	if (ns4) {
		calendarX = posX + 50;
		calendarY = posY - 150;
	}
	if (any_ie) {
		var browserposx = window.screenLeft;
		var browserposy = window.screenTop;
		calendarX = window.event.clientX + 50 + browserposx;
		calendarY = window.event.clientY + browserposy - 150;
	}
	CalendarWindow = window.open( '/t/calendar.php?&lng=' +language+ '&pos=' + pos + '&day=' + day + '&month=' + month + '&year=' + year, 'calendar', 'menubar=0,toolbar=0,status=0,scrollbars=auto,width=170,height=180,left='+ calendarX +',screenX='+ calendarX +',top=' + calendarY +',screenY='+ calendarY +'');
	CalendarWindow.focus();
}

function set_ret_date(day,month,year,pos)	{

	if (pos == 1) {
		document.all.dayN1.value	= day;
		document.all.monthN1.value = month;
		document.all.yearN1.value = year;
	}
	else if (pos == 2) {
		document.all.dayN2.value	= day;
		document.all.monthN2.value = month;
		document.all.yearN2.value = year;	
	}
}

function GetXY(el) {
	for(var xy=[0,0];el;el=el.offsetParent){
	xy[0]+=el.offsetLeft;
	xy[1]+=el.offsetTop;
	} 
return(xy);
}

function delcontent(form,obj) {
document.forms[form].elements[obj].value = '';
//document.all.elements[obj].value = '';
}

//onmouseover="javascript:style.backgroundColor='#f1f1f1'" onmouseout="javascript:style.backgroundColor='white'">

