// JavaScript Document

var mnm = new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
function date_time_str(utc_time)
{
	var tmpTime = new Date(utc_time*1000);
	var GMThrs = tmpTime.getUTCHours();
	var GMTmns = tmpTime.getUTCMinutes();
	var GMTscs = tmpTime.getUTCSeconds();
	if (GMThrs <= 9) GMThrs = "0" + GMThrs;
	if (GMTmns <= 9) GMTmns = "0" + GMTmns;
	if (GMTscs <= 9) GMTscs = "0" + GMTscs;
	var GMTY = tmpTime.getUTCFullYear();
	//var GMTY = 2005;
	var GMTM = mnm[tmpTime.getUTCMonth()];
	var GMTD = tmpTime.getUTCDate();
	if (GMTD <= 9) GMTD = "0" + GMTD;
	return GMTD + "-" + GMTM + "-" + GMTY + " " + GMThrs + ":" + GMTmns + ":" + GMTscs + " UTC";
}

function local_date_str(utc_time)
{
	var tmpTime = new Date(utc_time*1000);
	var Y = tmpTime.getFullYear();
	var M = mnm[tmpTime.getMonth()];
	var D = tmpTime.getDate();
	if (D <= 9) D = "0" + D;
	return D + "-" + M + "-" + Y;
}

function getByID(id)
{
	if(document.getElementById)
	{
		return document.getElementById(id);
	}
	if(document.all)
	{
		return document.all(id);
	}
}


function set_clock()
{
	var clockObj = getByID('timeid');
	clockObj.innerHTML = date_time_str(UTC_time);
	UTC_time++;
	setTimeout("set_clock()", 1000);
}	

function ShowDocument(documentPath)
{    var left=(window.screen.width-800)/2;
     var top=0;
     if(screen.availHeight > 600)
       top=(window.screen.height-600)/2 - 45;
     var options='height=600,width=800,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no,';
     options=options+'left='+left+",top="+top;
     var new_win = window.open(documentPath,'doc'+Math.floor(Math.random()*100000),options);
     new_win.focus();
}

function ShowDocument2(documentPath,windowWidth,windowHeight,windowName)
{    var left=0; 
     if(screen.availWidth-25 >  windowWidth)
       left=(screen.availWidth-windowWidth)/2;
     var top=0;
     if(screen.availHeight-30 > windowHeight)
       top=(screen.availHeight-windowHeight)/2 - 15;
     var options='height='+windowHeight+',width='+windowWidth+',scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no,';
     options=options+'left='+left+",top="+top;
     if(windowName == null)
       windowName = 'doc2'+Math.floor(Math.random()*100000);
     var new_win = window.open(documentPath,windowName,options);
     new_win.focus();
}

function open_map_window(pSESS, pLNG)
{
     var w_left=0; 
     var w_top=0;
     
     var w_width = screen.availWidth -6;
     var w_height = screen.availHeight -50;
     
     var options='height='+w_height+',width='+w_width+',scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no,';
     options=options+'left='+w_left+",top="+w_top;

     var new_win = window.open('alone.php?fn=390&lng='+pLNG+'&mw_width='+w_width+'&mw_height='+w_height+'&sess='+pSESS,'map_window',options);
     new_win.focus();
  
}

function ShowImg(imgPath, desc1, desc2)
{
   var i_win_width = 550;
   var i_win_height = 600;
  
	 var aWidth=screen.availWidth;
   var aHeight=screen.availHeight;
   if(i_win_width>aWidth)
      i_win_width=aWidth;
   if(i_win_height>aHeight)
      i_win_height=aHeight;
    var vLeft = (aWidth-i_win_width)/2;
    var vTop =(aHeight-i_win_height)/2;

    var i_win=null;
    var html="";
    if(document.all) //MSIE
        i_win = window.open('', null,'width='+i_win_width+',height='+i_win_height+',left='+vLeft+',top='+vTop+', scrollbars=yes, resizable=yes');
    else
        i_win = window.open('','publ_info','width='+i_win_width+',height='+i_win_height+',screenX='+vLeft+',screenY='+vTop+',scrollbars=yes,resizable=yes');

  
    i_win.document.close();
    i_win.document.open();
    html += '<html><head>\n';
    html += '<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1250">\n';
    html += '<meta HTTP-EQUIV="Pragma" content="no-cache">\n';
    html += '<title>'+desc1+'</title></head>\n';
    html += '<body bgcolor="#ffffff" margin-top=0; style="margin-left: 0px; margin-top: 5px; margin-right: 0px;">';
    html += '<center><img src="images/shop/'+imgPath+'" vspace="0" hspace="0" border="0"><br><font face="Arial" size=2 color=#000000><b>'+desc1+'</b><br>'+desc2+'</font></center>';
    html += '</center></body></html>';
    i_win.document.write(html);
    i_win.document.close();
    i_win.focus();
  
}

function  cust_list_sel(ctrl)
{
  var poc = document.CustsList.CNum.value;
  var i=0;
  var chck_name='';
  
  for(i=1; i<=poc; i++)
  {
    chck_name='cust_'+i;
    document.CustsList.elements[chck_name].checked = (ctrl==1 ?true :false);
  }  
}

function e_notam_send()
{
  var poc = document.CustsList.CNum.value;
  var i=0;
  var chck_name='';
  var custs_list='';
  
  for(i=1; i<=poc; i++)
  {
    chck_name='cust_'+i;
    if(document.CustsList.elements[chck_name].checked)
    {
      if(i >1)
        custs_list += ',';
      custs_list += document.CustsList.elements[chck_name].value;
    }
  }
  if(custs_list != '')
  {
    document.ENotamCtrl.Custs.value = custs_list;
    document.ENotamCtrl.submit();
  }
  else
  {
    alert("Žiaden výber");
  }
}

function create_xls()
{
  var poc = document.CustsList.CNum.value;
  var i=0;
  var chck_name='';
  var custs_list='';
  
  for(i=1; i<=poc; i++)
  {
    chck_name='cust_'+i;
    if(document.CustsList.elements[chck_name].checked)
    {
      if(i >1)
        custs_list += ',';
      custs_list += document.CustsList.elements[chck_name].value;
    }
  }
  if(custs_list != '')
  {
    document.DistrLCtrl.Custs.value = custs_list;
    
    if(document.CustsList.elements['CompanyDiv'].checked)
      document.DistrLCtrl.CompanyDiv.value = 1;
    else
      document.DistrLCtrl.CompanyDiv.value = 0;

    if(document.CustsList.elements['Contact'].checked)
      document.DistrLCtrl.Contact.value = 1;
    else
      document.DistrLCtrl.Contact.value = 0;

    if(document.CustsList.elements['Country'].checked)
      document.DistrLCtrl.Country.value = 1;
    else
      document.DistrLCtrl.Country.value = 0;

    if(document.CustsList.elements['AIPAMDT'].checked)
      document.DistrLCtrl.AIPAMDT.value = 1;
    else
      document.DistrLCtrl.AIPAMDT.value = 0;

    if(document.CustsList.elements['AIPSUP'].checked)
      document.DistrLCtrl.AIPSUP.value = 1;
    else
      document.DistrLCtrl.AIPSUP.value = 0;
    
    if(document.CustsList.elements['AICA'].checked)
      document.DistrLCtrl.AICA.value = 1;
    else
      document.DistrLCtrl.AICA.value = 0;
   
    if(document.CustsList.elements['AICC'].checked)
      document.DistrLCtrl.AICC.value = 1;
    else
      document.DistrLCtrl.AICC.value = 0;
    
    if(document.CustsList.elements['VFRAIP'].checked)
      document.DistrLCtrl.VFRAIP.value = 1;
    else
      document.DistrLCtrl.VFRAIP.value = 0;

    if(document.CustsList.elements['EAIP'].checked)
      document.DistrLCtrl.EAIP.value = 1;
    else
      document.DistrLCtrl.EAIP.value = 0;

    if(document.CustsList.elements['MAPS'].checked)
      document.DistrLCtrl.MAPS.value = 1;
    else
      document.DistrLCtrl.MAPS.value = 0;
    
    document.DistrLCtrl.submit();
    //alert(document.DistrLCtrl.AIPAMDT.value);
  }
  else
  {
    alert("Žiaden výber");
  }
}

function copy_from_inet(from_str, to_str)
{
  document.CmpUsrForm.elements[to_str].value = document.CmpUsrForm.elements[from_str].value;
}

function copy_sync_data(from_str, to_str)
{
  document.SyncDBIPForm.elements[to_str].value = document.SyncDBIPForm.elements[from_str].value;
}

function copy_cname(iname, isurname)
{
  document.SyncDBIPForm.elements['CustName'].value = iname;
  document.SyncDBIPForm.elements['CustSname'].value = isurname;
}

function copy_cemail(iemail)
{
  document.SyncDBIPForm.elements['Email'].value = iemail;
}
