///////////////////////////////////////////
// Browser utilities v2.0.0              //
// (c) 2001 by Flying/DR/HRz             //
///////////////////////////////////////////
// Contact me: flying@dom.natm.ru        //
// if you want to use this script        //
// or need something else for your site. //
///////////////////////////////////////////

// Supported browser types
var browser = null;                     // Browser identifier
var isIE4   = false;                    // Internet Explorer 4
var isIE5   = false;                    // Internet Explorer 5 or higher
var isIE    = false;                    // Internet Explorer 4 or higher
var isNS4   = false;					// Netscape Communicator 4
var isNS6   = false;					// Netscape 6
var isO4    = false;                    // Opera 4
var isO5    = false;                    // Opera 5 or higher
var isOpera = false;                    // Opera

var ua = navigator.userAgent.toLowerCase();
var app = navigator.appName.toLowerCase();
var ver = parseInt(navigator.appVersion);

// Perform browser detection.
if ((ua.indexOf('mozilla')!=-1) && (ua.indexOf('compatible')==-1) && (ua.indexOf('opera')==-1) && ((app.indexOf('netscape')!=-1) || (ua.indexOf('gecko')!=-1)))
    {
// Netscape browsers family
        if (ver>=5)
            {
                browser = 'NS6';
                isNS6 = true;
            }
        else
            {
                browser = 'NS4';
                isNS4 = true;
            };
    }
else
    if ((ua.indexOf('compatible')!=-1) && (ua.indexOf('msie')!=-1) && (ua.indexOf('opera')==-1))
        {
// Internet Explorer
            ver = navigator.appVersion;
            ver = parseFloat(ver.substring(ver.indexOf('MSIE')+4));
            if (isNaN(ver))
                ver = 4;
            if (ver>=5)
                {
                    browser='IE';
                    isIE = true;
                    isIE5 = true;
                }
            else
                {
                    browser='IE';
                    isIE = true;
                    isIE4 = true;
                };
        }
    else
        if (ua.indexOf('opera')!=-1)
// Opera
        {
            ver = parseInt(ua.substring(ua.indexOf('opera')+6));
            if (ver>=5)
                {
                    browser='Opera';
                    isOpera = true;
                    isO5 = true;
                }
            else
                {
                    browser='Opera';
                    isOpera = true;
                    isO4 = true;
                };
        };

var browserParams = new Array();
var mousePageX = 0;
var mousePageY = 0;
var mouseScreenX = 0;
var mouseScreenY = 0;
var windowWidth = null;
var windowHeight = null;
var hrzBrowserUseGlobalParameters = false;

// Start browser parameters capturing
// At enter:
//   useGlobals - set to TRUE to enable duplication of browser parameters into global variables
//                (optional, by default they're stored only into browserParams array with the same
//                names used as indexes)
function startBrowserParametersCapture()
{
    if (startBrowserParametersCapture.arguments.length>0)
        hrzBrowserUseGlobalParameters = startBrowserParametersCapture.arguments[0];
    if (isNS4)
        document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = hrzBrowserOnMouseMoveHandler;
    window.onresize = hrzBrowserOnResizeHandler;
};

// Stop browser parameters capturing
function stopBrowserParametersCapture()
{
    if (isNS4)
        document.releaseEvents(Event.MOUSEMOVE);
    document.onmousemove = null;
    window.onresize = null;
};

function hrzBrowserOnMouseMoveHandler(ev)
{
    var px = 0;
    var py = 0;
    var sx = 0;
    var sy = 0;
    if (isNS4 || isNS6)
    {
        px = ev.pageX;
        py = ev.pageY;
        sx = ev.screenX;
        sy = ev.screenY;
    };
    if (isOpera)
    {
        px = ev.clientX;
        py = ev.clientY;
        sx = ev.screenX;
        sy = ev.screenY;
    };
    if (isIE)
	{
        if (document.body)
        {
    		px = window.event.clientX + document.body.scrollLeft;
    		py = window.event.clientY + document.body.scrollTop;
    		sx = window.event.screenX;
    		sy = window.event.screenY;
		};
	};
    browserParams['pageX'] = px;
    browserParams['pageY'] = py;
    browserParams['screenX'] = sx;
    browserParams['screenY'] = sy;
    if (hrzBrowserUseGlobalParameters)
    {
        mousePageX = px;
        mousePageY = py;
        mouseScreenX = sx;
        mouseScreenY = sy;
    };
// We need to call onResize handler because of IE and Opera
    hrzBrowserOnResizeHandler();
    return(true);
};

function hrzBrowserOnResizeHandler()
{
    var ww = (isIE)?((document.body)?document.body.clientWidth:0):window.innerWidth;
    var wh = (isIE)?((document.body)?document.body.clientHeight:0):window.innerHeight;
    browserParams['windowWidth'] = ww;
    browserParams['windowHeight'] = wh;
    if (hrzBrowserUseGlobalParameters)
    {
        windowWidth = ww;
        windowHeight = wh;
    };
    return(true);
}
function kombiClass2() {
 var args=kombiClass2.arguments;if(document.getElementById){
  for(var i=0;i<args.length;i+=2){if(document.getElementById(args[i])!=null){
  if(document.p7setdown){for(var k=0;k<p7dco.length-1;k+=2){
  if(args[i]==p7dco[k]){args[i+1]=p7dco[k+1];break;}}}
  document.getElementById(args[i]).className=args[i+1];}}}
}
var cnt=0;
function CheckSubmit() {
    if(cnt == 0) {
        cnt++;
        return true;
    } else {
        alert("The Form was already submited");
        return false;
    }
}

///// onload cursor in depApt field with first time
function depApt(){document.MainForm.depApt.focus();}

//// oneway swich

function MM_findObj(n, d) { 
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { 
  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 enable(){
    return;
    document.MainForm.retDay.disabled = false;
    document.MainForm.month_2.disabled = false;
    if(document.MainForm.flystay) {
        document.MainForm.flystay.disabled= false;
    }
    if(document.MainForm.flydrive) {
        document.MainForm.flydrive.disabled= false;
    }
}

function disable(){
    return;
    //enable();
    //alert(document.MainForm.onewayswitch[1].checked);
    if (document.MainForm.onewayswitch[1].checked) {
       
        document.MainForm.retDay.disabled= true;
        if(document.MainForm.flystay) {
            document.MainForm.flystay.disabled= true;
        }
        if(document.MainForm.flydrive) {
            document.MainForm.flydrive.disabled= true;
        }
        document.MainForm.month_2.disabled= true;
    } 
}

