
function Browser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6.0')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is = new Browser();



//       document.classes.fsize3.all['fontSize']="14px";



function ClickToHelp() {}

function ClickMe() {}

function Select() {}


function numberFormat(amount) {
	var rawNumStr = round(amount) + '';
	rawNumStr = (rawNumStr.charAt(0) == '.' ? '0' + rawNumStr : rawNumStr);
	if (rawNumStr.charAt(rawNumStr.length - 3) == '.') {
		return rawNumStr;
		}
		else if (rawNumStr.charAt(rawNumStr.length - 2) == '.') {
			return rawNumStr + '0';
			}
			else {return rawNumStr + '.00' }
	}

	function round(number, decPlace) {
	decPlace = (!decPlace ? 2 : decPlace);
	return Math.round(number * Math.pow(10, decPlace)) / Math.pow(10, decPlace);
	}


function nym(number) {
	number += "";
	return ((number.length == 1) ? "0" + number : number)
}


var WindowHelpMe = ""; // Динамическое окно справки
var AvtonomHelp = ""; // Автономное окно справки

// function OpenHelp(template) {
// var rand = Math.random().toString().substring(2,7);
// var WindowName = "Window" + rand;
// WindowName = window.open( ServerCGIDirectory + 'help.me/index.cgi?list=' + template + '&av=' + rand,WindowName,'height=415,width=590,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,top=10,left=10');
// WindowName.focus();
// }

// function HelpMe(template) {
// WindowHelpMe = window.open( ServerCGIDirectory + 'help.me/index.cgi?template=' + template ,'WinHelpMe','height=445,width=590,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,top=10,left=10');
// WindowHelpMe.focus();
// }

function OpHelp(table,uid) {
var rand = Math.random().toString().substring(2,7);
var WindowName = "Window" + rand;
WindowName = window.open( ServerCGIDirectory + 'help.me/index2.cgi?table=' + table + '&uid=' + uid + '&c=n&av=' + rand,WindowName,'height=415,width=590,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,top=10,left=10');
WindowName.focus();
}

function catalog(country) {
var count = escape(country);
var rand = Math.random().toString().substring(2,7);
var WindowName = "Window" + rand;
var url = "/cgi/cat/cat.cgi?country=" + escape(country) + "&page=1&av=" + rand;
WindowName = window.open('about:blank',WindowName,'height=415,width=590,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,top=10,left=10');
WindowName.focus();
WindowName.location.href = url;
}

function HoverButtonOver(button) {
button.style.backgroundColor="#dcdfe9";
}

function HoverButtonOut(button) {
button.style.backgroundColor="#d8d8d8";
}

function SetTimeInformer() {

var thisTime = new Date();
var thisSecs = thisTime.getSeconds();

// Перескочили на следующую секунду
if (lastSecs != thisSecs )
  {
    lastSecs = thisSecs;
    incSec();
  }

} // End SetTimeInformer()


function nym(number) {
	number += "";
	return ((number.length == 1) ? "0" + number : number)
}

function incSec() {TickSec++; if (TickSec > 59) {TickSec = 0; setTimeout('incMin()', 250)}; SEC.innerHTML = nym(TickSec) }
function incMin() {TickMin++; if (TickMin > 59) {TickMin = 0; setTimeout('incHour()', 250)}; MIN.innerHTML = nym(TickMin) }
function incHour() {TickHour++; if (TickHour > 23) {TickHour = 0; setTimeout('setDay()', 250)}; HOUR.innerHTML = nym(TickHour)}
function setDay() {DAY.innerHTML = nextDay}


function VievImage(w,h,url) {

var scrollbars = "no";
var width = w+20;
var height = h+20;

if ((width+50) > screen.width) {width = screen.width - 50; scrollbars = "yes"}
if ((height+50) > screen.height) {height = screen.height - 50; width = width + 30; scrollbars = "yes"}


var WindowName = "Window" + Math.random().toString().substring(2,7);
WindowName = window.open( "about:blank",WindowName,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=' + scrollbars + ',toolbar=no,status=no');
WindowName.document.open();
WindowName.document.write("<html><head></head><title>AVALI</title><body bgcolor='#3676B6' text='white' topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 style='margin:0'>");
WindowName.document.write("<table width=100% height=100% border=0 cellspacing=0 cellpadding=0><tr><td align=center valign=middle>");
WindowName.document.write("<img src='/in_image/" + url + "' width=" + w + " height=" + h + " vspace=0 hspace=0 border=0 bgcolor='white' style='border:1px solid white'>");
WindowName.document.write("</td></tr></table></body></html>");
WindowName.document.close();
}

function ViewTablo(n) {
top.location.href = ServerCGIDirectory + "tablo/view.cgi?my=" + n + "&width=" + screen.width + "&av=" + Math.random().toString().substring(2,7);
} // End ViewTablo2

function PathInfo() {
alert("Обратите внимание!\nЭтот маршрут состоит из нескольких стыковочных рейсов.\nВо время перелёта вы делаете остановку в промежуточном\nгороде и пересаживаетесь на другой рейс (другой авиакомпании).\nУточняйте детали такого перелёта у операторов при покупке билета.");
}


// Замораживание кнопок

function ButtonOneSubmit() {
if (is.ie) {
	if (!OneDisabled) {OneDisabled = 1; document.SendFormOne.SendButtonOne.disabled=1}
	if (OneTick > 1) {OneTick--; document.SendFormOne.SendButtonOne.value = "Ожидание ответа: " + OneTick + " сек."; setTimeout('ButtonOneSubmit()', 1000)}
	else {OneTick = 60; OneDisabled = 0; document.SendFormOne.SendButtonOne.disabled=''; document.SendFormOne.SendButtonOne.value = OneTickValue;}
	}
}

function ButtonTwoSubmit() {
if (is.ie) {
	if (!TwoDisabled) {TwoDisabled = 1; document.SendFormOne.SendButtonTwo.disabled=1}
	if (TwoTick > 1) {TwoTick--; document.SendFormOne.SendButtonTwo.value = "Ожидание ответа: " + TwoTick + " сек."; setTimeout('ButtonTwoSubmit()', 1000)}
	else {TwoTick = 60; TwoDisabled = 0; document.SendFormOne.SendButtonTwo.disabled=''; document.SendFormOne.SendButtonTwo.value = TwoTickValue;}
	}
}

function ButtonTabloSubmit() {
if (is.ie) {
	if (!ButTabloDisabled) {ButTabloDisabled = 1; document.TabloForm.TabloButtonSubmit.disabled=1}
	if (ButTabloTick > 1) {ButTabloTick--; document.TabloForm.TabloButtonSubmit.value = "Ожидание ответа: " + ButTabloTick + " сек."; setTimeout('ButtonTabloSubmit()', 1000)}
	else {ButTabloTick = 60; ButTabloDisabled = 0; document.TabloForm.TabloButtonSubmit.disabled=''; document.TabloForm.TabloButtonSubmit.value = ButTabloValue;}
	}
}

function ButtonTick(objId,vaitLine,sekund) {
if (!is.ie) {return 0}
var valtLine = vaitLine? vaitLine : "Ожидание ответа:";
var obj = eval(objId);
var defValue = obj.value;
var sekund = sekund? sekund : "60";
obj.value = vaitLine + " " + sekund;
obj.disabled = 1;
eval("setTimeout\(\"SetButtonValue\('" + objId + "','" + defValue + "'\)\",950\)");
} // End function ButtonTick

var Tick = new Array();
function ButtonSubmit(tip) {
	obd=tip.form.name+'.'+tip.name;
	Tick[obd+'sek']=!Tick[obd+'sek']?60:Tick[obd+'sek']-1;
	if(!Tick[obd+'val']) Tick[obd+'val']=tip.value;
	tip.disabled=Tick[obd+'sek']?true:false;
	tip.value=Tick[obd+'sek']?"Ожидание ответа: "+(Tick[obd+'sek']-1)+" сек.":Tick[obd+'val'];
	if(Tick[obd+'sek']) setTimeout('ButtonSubmit(document.'+obd+')',970);   	
} // End function ButtonSubmit


function SetButtonValue(objId,defValue) {
var obj = eval(objId);
var value = obj.value;
value = obj.value.substring(obj.value.length-2,obj.value.length)*1-1;
if (value < 1)
	{
		obj.value = defValue;
		obj.disabled = 0;
	}

	else

	{
		value = value<10? value + " " : value;
		obj.value = obj.value.substring(0,obj.value.length-2) + value;
		eval("setTimeout\(\"SetButtonValue\('" + objId + "','" + defValue + "'\)\",950\)");
	}
} // End function SetButtonValue

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) {endstr = document.cookie.length;}
return unescape(document.cookie.substring(offset, endstr));
}


// Работа с кукисами

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg) {
    return getCookieVal(j);
    }
  i = document.cookie.indexOf(" ", i) +1;
  if (i == 0) break;
  }
return null;
}

function DeleteCookie (name, path, domain) {
if (GetCookie(name)) {
  document.cookie = name + "=" +
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" +domain : "") +
   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function SetCookie (name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value) +
  ((expires) ? "; expires=" + expires.toGMTString() : "") +
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" +domain : "") +
  ((secure) ? "; secure" : "");
}

function CF1() {
var flag = window.confirm("Заказ перемещается в выполненные.\nЭто действие нельзя отменить.\nОператор будет уведомлён.");
return (flag);
}

function CF2() {
var flag = window.confirm("Заказ перемещается в удалённые.\nЭто действие нельзя отменить.\nОператор будет уведомлён.");
return (flag);
}

// ЖД
function expressSpravka(num,day,month,poezd,from,to) {
var WindowName = "Window" + Math.random().toString().substring(2,8);
if (num == 3) {
WindowName = window.open('about:blank',WindowName,'width=700,height=280,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
var url = IndexPage + "express/index.html?ExFromDay=" + day + "&ExFromMonth=" + month + "&ExPoezd=" + poezd + "&ExCityFrom=" + from + "&ExCityTo=" + to + "&action=3";
WindowName.location.href = url;
}
if (num == 4) {
WindowName = window.open('about:blank',WindowName,'width=420,height=430,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
var url = IndexPage + "express/index.html?ExFromDay=" + day + "&ExFromMonth=" + month + "&ExPoezd=" + poezd + "&action=4";
WindowName.location.href = url;
}

}


// Детальная информация по отелю
function hoteldetail(id) {
var WindowName = "Window" + Math.random().toString().substring(2,8);
HotelDetailForm.target = WindowName;
HotelDetailForm.hotel.value = id;
WindowName = window.open('about:blank',WindowName,'width=690,height=410,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
HotelDetailForm.submit();
}



// Окно селектора городов

	var WinCode = "";
	var NewWin;
	var frma = ""; // Форма, в которую упадёт название города
	var obj = ""; // Поле, в которое упадёт название города

function WinCodeClose() {

	WinCode = "";
}

function City(o,f) {

	if (!f) {frma="document.SendFormOne"}
	else {frma=f}
	obj = o;
	if (WinCode == "") {
		WinCode = window.open("/in_code/code.html","WinCode","height=380,width=340,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
		}

	WinCode.focus();
}

function SetValue(val) {
	o=frma + "." + obj;
	o=eval(o);
	o.value = val;
}

function SetPlas(val) {
	document.SendFormOne.SetCityTo.value=val;
	window.scroll(0,10000);
}
