

function GoToPage(newpage,url,pagename)
{
	location=url+"&"+pagename+"="+newpage
}
function rowOverEffect(object) {
  if (object.className == 'StdTableRow') object.className = 'StdTableRowOver';
}
function rowOutEffect(object) {
  if (object.className == 'StdTableRowOver') object.className = 'StdTableRow';
}
function rowOverEffectSelected(object) {
  if (object.className == 'StdTableRowSelected') object.className = 'StdTableRowOverSelected';
}
function rowOutEffectSelected(object) {
  if (object.className == 'StdTableRowOverSelected') object.className = 'StdTableRowSelected';
}





function ValNotEmail(field) {
if (field.value=="") {return false}
if (!field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.info)|(\.mobi)|(\.biz)|(\.org)|(\..{2,2}))$)\b/gi)) {
	   field.className  ="formback"
     field.focus()
		 return (true)
 	 }
 	 return false
}

function ValNotEmpty(field)
{

 if (field.value=="") {
	 	 field.focus()
		 field.className  ="formback"
	 	 return (true)
	 	  }	
 	return (false)
}

function ValidateLoginPilots(form) {
   

     
	 form.error.value=''    
	 
	 if (ValNotEmpty(form.loginName))    { 
		  form.error.value='Zadejte přihlašovací jméno.'
	 	  return(false) 
	       }     
	 if (ValNotEmpty(form.loginPass))    {
		  form.error.value='Zadejte heslo.'
	 	  return(false) 
	       } 
   form.action.value='querylogin'
   form.error.value=''
   form.submit()
   return true	 	
	}




function ValidateEditMessage(form) {
    
	 
   form.error.value=''
       
   if (ValNotEmpty(form.text))    { 
		  form.error.value='Zadejte text.'
		  form.text.focus();
	 	  return(false)       
	        } 
  
   	  
   form.action.value='savemessage'
   form.error.value=''
   form.submit()
   return true	 	
}

function ValidateEditFiles(form) {
    
	 
   form.error.value=''
  
   if (ValNotEmpty(form.filename1))    { 
		  form.error.value='Zvolte dokument.'
		  form.filename1.focus();
	 	  return(false)       
	        } 
       
   if (ValNotEmpty(form.descript))    { 
		  form.error.value='Zadejte popis.'
		  form.descript.focus();
	 	  return(false)       
	        } 
  
  
   	  
   form.action.value='savefiles'
   form.error.value=''
   form.submit()
   return true	 	
}


function ValidateEditAfis(form) {
    
	 
   form.error.value=''
       
   if (ValNotEmpty(form.id))    { 
		  form.error.value='Zadejte datum.'
		  form.id.focus();
	 	  return(false)       
	        } 
	        
         
  
   	  
   form.action.value='saveafis'
   form.error.value=''
   form.submit()
   return true	 	
}


function ValidateAfis1(form) {
    

   form.error.value=''
       
   if (ValNotEmpty(form.id)|| form.id.value<"2010")    { 
		  form.error.value='Zadejte rok.'
		  form.id.focus();
	 	  return(false)       
	        } 
	        
         
  
   	  
   form.action.value='newafis'
   form.error.value=''
   form.submit()
   return true	 	
}



function ValidateEditPilots(form) {
    
	 
   form.error.value=''
   
   if (ValNotEmpty(form.password) && form.newkey==1)    { 
		  form.error.value='Zadejte heslo.'
		  form.password.focus();
	 	  return(false)       
	        } 
   
       
   if (ValNotEmpty(form.fullname))    { 
		  form.error.value='Zadejte Příjmení a jméno.'
		  form.fullname.focus();
	 	  return(false)       
	        } 
  
   if (ValNotEmpty(form.email) && ValNotEmpty(form.tel))  { 
		  form.error.value='Zadejte E-mail nebo telefon.'
		  form.email.focus();
	 	  return(false)       
	        } 
  
   if (ValNotEmpty(form.email) && ValNotEmail(form.email))  { 
		  form.error.value='E-mail správně e-mail.'
		  form.email.focus();
	 	  return(false)       
	        } 
  
  
   	  
   form.action.value='savepilot'
   form.error.value=''
   form.submit()
   return true	 	
}


window.wind_animate=new Array();

 function getBeat()
{
	var now = new Date();
	var off = (now.getTimezoneOffset() + 60)*60;
	var theSeconds = (now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + off;
	var beat = Math.floor(theSeconds/86.4);
	if (beat > 1000) beat -= 1000;
	if (beat < 0) beat += 1000;
	return beat;
}


function ShowLoad(id,img,url)
{ 
    element =document.getElementById(img);
	    if (!element) { element = parent.document.getElementById(img) }
	    if (element)  { element.src = url   }
  	 Show(id)
}


function ShowGraph(id,url)
{    
	 element = document.getElementById("loc_"+id);
	 if (!element) { element = parent.document.getElementById("loc_"+id) }
	 if (element)  { element.src = url}
	 Show(id)
}


function ShowWindow(url)
{
     Show('winframe')	 
  	 winframe.location=url
 }
function Show(id)
{   
		var element
	    element = document.getElementById(id);
	    if (!element) { element = parent.document.getElementById(id) }
	    if (element)  { element.style.display = ""}
}	
function Hidde(id)
{   
		var element
	    element = document.getElementById(id);
	    if (!element) { element = parent.document.getElementById(id) }
	    if (element)  { element.style.display = "none"}
}	



var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]

function showLocalTime(container, servermode, offsetMinutes, displayversion){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.displayversion=displayversion
var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'
this.localtime=this.serverdate=new Date(servertimestring)
this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
this.updateTime()
this.updateContainer()
}

showLocalTime.prototype.updateTime=function(){
var thisobj=this
this.localtime.setSeconds(this.localtime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

showLocalTime.prototype.updateContainer=function(){
var thisobj=this
if (this.displayversion=="long")
this.container.innerHTML=this.localtime.toLocaleString()
else{
var hour=this.localtime.getHours()
var minutes=this.localtime.getMinutes()
var seconds=this.localtime.getSeconds()
this.container.innerHTML=formatField(hour)+":"+formatField(minutes)+":"+formatField(seconds)
add=":"+formatField(seconds)
}
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
}

function formatField(num)
{
return (num<=9)? "0"+num : num//if this is minute or sec field
}


function ShowInWin(urls)
{
element=document.getElementById("inwin")
element.style.display="";
inwin.location=urls;
}	
function HiddeInWin()
{
element=document.getElementById("inwin")
element.style.display="none";
}



var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};




