﻿var dhtmlgoodies_slideSpeed = 10; // Higher value = faster
var dhtmlgoodies_timer = 10; // Lower value = faster
var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;

function showHideContent(e, inputId) {
    if (dhtmlgoodies_slideInProgress) return;
    dhtmlgoodies_slideInProgress = true;
    if (!inputId) inputId = this.id;
    inputId = inputId + '';
    var numericId = inputId.replace(/[^0-9]/g, '');
    var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

    objectIdToSlideDown = false;

    if (!answerDiv.style.display || answerDiv.style.display == 'none') {
        if (dhtmlgoodies_activeId && dhtmlgoodies_activeId != numericId) {
            objectIdToSlideDown = numericId;
            slideContent(dhtmlgoodies_activeId, (dhtmlgoodies_slideSpeed * -1));
        } else {

            answerDiv.style.display = 'block';
            answerDiv.style.visibility = 'visible';

            slideContent(numericId, dhtmlgoodies_slideSpeed);
        }
    } else {
        slideContent(numericId, (dhtmlgoodies_slideSpeed * -1));
        dhtmlgoodies_activeId = false;
    }
}

function slideContent(inputId, direction) {

    var obj = document.getElementById('dhtmlgoodies_a' + inputId);
    var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
    height = obj.clientHeight;
    if (height == 0) height = obj.offsetHeight;
    height = height + direction;
    rerunFunction = true;
    if (height > contentObj.offsetHeight) {
        height = contentObj.offsetHeight;
        rerunFunction = false;
    }
    if (height <= 1) {
        height = 1;
        rerunFunction = false;
    }

    obj.style.height = height + 'px';
    var topPos = height - contentObj.offsetHeight;
    if (topPos > 0) topPos = 0;
    contentObj.style.top = topPos + 'px';
    if (rerunFunction) {
        setTimeout('slideContent(' + inputId + ',' + direction + ')', dhtmlgoodies_timer);
    } else {
        if (height <= 1) {
            obj.style.display = 'none';
            if (objectIdToSlideDown && objectIdToSlideDown != inputId) {
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display = 'block';
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility = 'visible';
                slideContent(objectIdToSlideDown, dhtmlgoodies_slideSpeed);
            } else {
                dhtmlgoodies_slideInProgress = false;
            }
        } else {
            dhtmlgoodies_activeId = inputId;
            dhtmlgoodies_slideInProgress = false;
        }
    }
}



function initShowHideDivs() {
    var divs = document.getElementsByTagName('DIV');
    var divCounter = 1;
    for (var no = 0; no < divs.length; no++) {
        if (divs[no].className == 'dhtmlgoodies_question') {
            divs[no].onclick = showHideContent;
            divs[no].id = 'dhtmlgoodies_q' + divCounter;
            var answer = divs[no].nextSibling;
            while (answer && answer.tagName != 'DIV') {
                answer = answer.nextSibling;
            }
            answer.id = 'dhtmlgoodies_a' + divCounter;
            contentDiv = answer.getElementsByTagName('DIV')[0];
            contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
            contentDiv.className = 'dhtmlgoodies_answer_content';
            contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
            answer.style.display = 'none';
            answer.style.height = '1px';
            divCounter++;
        }
    }
}

function more(obj) {

    var t = document.getElementById('mnu' + obj);

    var rows = t.getElementsByTagName('p');
    for (i = 0; i < rows.length; i++)
        rows[i].style.display = 'block';

    var m = document.getElementById('More_' + obj);
    m.style.display = 'none';


    initShowHideDivs();

    showHideContent(false, parseInt(obj));

}

function hideDiv(obj)
{
    var x = document.getElementById(obj);
    x.style.display='none';
    return;
}

function homeMouseOver(obj) {
    if (obj.className != 'tabstyle3')
        obj.className = 'tabstyle2-h';
}

function homeMouseOut(obj) {
    if (obj.className != 'tabstyle3')
        obj.className = 'tabstyle2';
}

function homeClick(homeId) {
    var t1 = document.getElementById('homeTab1');
    var t2 = document.getElementById('homeTab2');

    t1.className = 'tabstyle2';
    t2.className = 'tabstyle2';

    var t1 = document.getElementById('homeTab1x');
    var t2 = document.getElementById('homeTab2x');

    t1.style.display = 'none';
    t2.style.display = 'none';


    var t3 = document.getElementById(homeId);
    t3.className = 'tabstyle3';

    t3 = document.getElementById(homeId + 'x');
    t3.style.display = 'block';
}


if (document.images)
{
  preload_image_object = new Image();
  // set image url
  image_url = new Array();
  image_url[0] = "arrival_in.gif";
  image_url[1] = "arrival_ac.gif";
  image_url[2] = "depart_in.gif";
  image_url[3] = "depart_ac.gif";
  image_url[4] = "search_ac.gif";
  image_url[5] = "search_in.gif";

   var i = 0;
   for(i=0; i<6; i++) 
     preload_image_object.src = image_url[i];
}

var hi = 0
var wndWidth;
var wndHeight;

function Hide() {
    document.all.wnd.className = 'PopupHide';
    document.all.wnd.style.display = 'none';
    hi = 0;
    return false;

}

function Show(Header, objName, Width, Height) {
    var obj = document.getElementById(objName);
    var cnt = document.getElementById('wndText');
    var hdr = document.getElementById('wndHeader');
    wnd.style.width = Width + 'px';
    wnd.style.height = Height + 'px';
    wnd.style.left = (wndWidth - Width) / 2;
    wndText.innerHTML = obj.innerHTML;
    wndHeader.innerHTML = Header;
    document.all.wnd.style.top = (wndHeight - Height) / 2;
    document.all.wnd.style.display = 'block';
    document.all.wnd.className = 'PopupShow';
    doTrans();
    return false;
}

function doTrans() {
    if (hi < 95) {
        wnd.filters.item('DXImageTransform.Microsoft.alpha').opacity = hi
        wnd.filters[0].apply()
        wnd.filters[0].play()
        hi+=5;
        setTimeout("doTrans()", 1)
    }
}  
