//Выход начало
function logout()
{
		var url = 'auth.inc.php';
    var div='login_div';
    //$(div).innerHTML = "<center><img src='./images/loading.gif' align=absmiddle> идет загрузка данных, подождите немного...</center>";
		var pars = 'mode=logout';
		var myAjax = new Ajax.Request(
					url,
					{method: 'post', parameters: pars, onComplete: showResponse}
					);

    function showResponse(originalRequest)
    {
		  //put returned XML in the textarea
		  $(div).innerHTML = originalRequest.responseText;
      //alert(originalRequest.responseText);
    }
}
//выход конец
//Авторизация начало
function auth(login,pass)
{
		var url = 'auth.inc.php';
    var div='login_div';
    //$(div).innerHTML = "<center><img src='./images/loading.gif' align=absmiddle> идет загрузка данных, подождите немного...</center>";
		var pars = 'login=' + login + '&pass='+pass+'&mode=check_login';
		var myAjax = new Ajax.Request(
					url,
					{method: 'post', parameters: pars, onComplete: showResponse}
					);

    function showResponse(originalRequest)
    {
		  //put returned XML in the textarea
		  $(div).innerHTML = originalRequest.responseText;
      //alert(originalRequest.responseText);
    }
}
//Авторизация конец


function subscribe(mail)
{
  new Ajax.Request('./subscribe.php',
  {
    method: 'get',
    parameters: {email: mail},
    onComplete: finish_request,
    div: 'subscribe'
  });
}

function finish_request(request)
{
	alert(request.responseText);
}

function plus_minus(imgid,host)
{
  minus=host+'/images/minus2.jpg';
  plus=host+'/images/plus2.jpg';
  if(document.getElementById(imgid).src==plus)document.getElementById(imgid).src=minus; else document.getElementById(imgid).src=plus;
}
function selectStatus() {
if (document.registration.status.value == '1') menu2.style.display = "none";
if (document.registration.status.value == '2') menu2.style.display = "";
}

function show_hide(elmnt)
{
 document.getElementById(elmnt).style.display=(document.getElementById(elmnt).style.display != 'block' ? 'block' : 'none');
}

function showLogin(){
 document.getElementById('login').style.display=(document.getElementById('login').style.display != 'block' ? 'block' : 'none');
}

function showdate()
{
  today=new Date();// Build an array initializer
  function isnArray()
  {
    argnr=isnArray.arguments.length
    for (var i=0;i<argnr;i++)
    {
      this[i+1] = isnArray.arguments[i];
    }
  }
  // And months and day arrays
  var isnMonths=new   isnArray("Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря");
  var thisyear = today.getFullYear(); // varies in JavaScript and JScript

  var isnDays=new   isnArray("Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота");
  var thisday = today.getDay(); // varies in JavaScript and JScript

  document.write(" "+isnDays[today.getDay()+1]+",  "+today.getDate()+" "+isnMonths[today.getMonth()+1]+"  "+thisyear+" г.")
}

function ChangeImg() {
 if(document.images) {
  eval("document."+ChangeImg.arguments[0]+
  ".src=('"+ChangeImg.arguments[1]+"')");
 }
}

function showmenu(elmnt)
{
document.getElementById(elmnt).style.visibility="visible"
}
function hidemenu(elmnt)
{
document.getElementById(elmnt).style.visibility="hidden"
}

v=0;

function ShowMap(path,w,h)
{
	if (v!=0) v.close();
	h+=30;
	v=window.open ('', 'view', 'scrolling=no,height='+h+',width='+w);
	with (v.document)
	{
	    open ();
	       write('<html><head><title>Карта проезда</title></head><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 ><table cellspacing="0" cellpadding="0" border="0"><tr><td align><img src="'+path+'" border=0></td></tr><tr><td align="center" valign="middle" height="30"><a href="javascript:;" onClick="window.close()">[ закрыть окно ]</a></td></tr></table></body></html>');
	    close ();
	}
	return false;
}

v=0;
function ShowPhoto(path,w,h,name)
{
  if (v!=0) v.close();
  //h=130;
  v=window.open ('', 'view', 'scrolling=no,height='+h+',width='+w);
  with (v.document)
{
 open ();
  write('<html><head><title>'+name+'</title></head><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 bgcolor="white"><table cellspacing="0" cellpadding="0" border="0"><tr><td align><img src="'+path+'"     border=0></td></tr></table></body></html>');
  close ();
}
	return false;
}

function popup(fileUrl, winW, winH, winN, scrollB) {
var winWidth = (winW)? winW : 200;
var winHeight = (winH)? winH : 200;
var winName = (winN)? winN : 'popupWin';
var scrollBars = (scrollB)? scrollB : 'auto'
posX = Math.round((screen.width - winWidth) / 2);
posY = Math.round((screen.height - winHeight) / 2);
posCode = "left="+posX+",top="+posY;
var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
if (popupWin) popupWin.focus();
}

function makedate()
            {
              document.forms.booking.dd.value = document.forms.booking.outDay.value +"/"+ document.forms.booking.outMonth.value +"/"+document.forms.booking.outYear.value
              document.forms.booking.ad.value = document.forms.booking.inDay.value +"/"+ document.forms.booking.inMonth.value +"/"+document.forms.booking.inYear.value
              document.forms.booking.inYear.value=''
              document.forms.booking.inDay.value=''
              document.forms.booking.inMonth.value=''
              document.forms.booking.outYear.value=''
              document.forms.booking.outDay.value=''
              document.forms.booking.outMonth.value=''
            }

function sMenu(obj, menu, align)
{

  pTop=0;
  pLeft=0;
  getAbsolutPosition(obj);
  if (align=="left")
  {
    //window.alert(menu);
    //document.getElementById(menu).offsetWidth=obj.offsetWidth='px';
    //document.getElementById(menu).style.left=pLeft - 250 + 'px';
    document.getElementById(menu).style.left=pLeft - obj.offsetWidth + 'px';
    //document.getElementById(menu).style.left=pLeft - document.getElementById(menu).offsetWidth+'px';
    document.getElementById(menu).style.top=pTop+'px';
    document.getElementById(menu).style.display = 'block';
  }
  else if (align=="down")
  {
    //window.alert(obj.tagName);
    document.getElementById(menu).style.left=pLeft-9+'px';
    document.getElementById(menu).style.top=pTop+obj.offsetHeight+'px';
    document.getElementById(menu).style.display = 'block';
  }
  else
  {
    pTop=pTop+'px';
    document.getElementById(menu).style.left=pLeft+obj.offsetWidth+'px';
    document.getElementById(menu).style.top=pTop;
    document.getElementById(menu).style.display = 'block';
  }
}

function getAbsolutPosition(obj)
{
  //      debugger;
  pObj=obj.offsetParent;
  //window.alert(obj.tagName);
  //window.alert(pObj.tagName);
  if (pObj.tagName!="BODY")
  {
    getAbsolutPosition(pObj)
  }
  pTop=pTop+obj.offsetTop;
  pLeft=pLeft+obj.offsetLeft;
}

function hMenu(obj, menu)
{
  //obj.className="menul3";
  document.getElementById(menu).style.display = 'none';
}
