﻿var language="ind";
var animHeaderCount = 1;

function activeMenu()
{
    var location = returnDocument();
    var menuLoc;
    
    if (location == "" || location == "Default.aspx")
    {
        menuLoc = document.getElementById("Home").className = "active";
    }
    else if (location == "AboutUs.aspx")
    {
        menuLoc = document.getElementById("AboutUs").className = "active";
    }
    else if (location == "ContactUs.aspx")
    {
        menuLoc = document.getElementById("ContactUs").className = "active";
    }
    else if (location == "PickUp.aspx")
    {
        menuLoc = document.getElementById("PickUp").className = "active";
    }
    else if (location == "Services.aspx")
    {
        menuLoc = document.getElementById("Services").className = "active";
    } 
    setTimeout('animHeader()', 1000);
}

function ChangeLocation()
{
    var redirectUrl;
    
    redirectUrl = returnDocument();
    
    if (language == "ind")
    {
        if (redirectUrl == "")
        {
            window.location = "/Default.aspx";
        }
        else
        {
            window.location = "/" + redirectUrl;
        }
    }
    else
    {
        if (redirectUrl == "")
        {
            window.location = "/en/Default.aspx";
        }
        else
        {
            window.location = "/en/" + redirectUrl;
        }
    }
}

function ChangeInd()
{     
    language = "ind";
    ChangeLocation();
}

function ChangeEngl()
{   
    language = "eng";
    ChangeLocation();
}

function returnDocument() 
{
    var file_name = document.location.href;
    var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
    return file_name.substring(file_name.lastIndexOf("/")+1, end);
}


function animHeader()
{
    var temp = document.getElementById('mexHeader');
    
    if (animHeaderCount % 3 == 1)
    {
        temp.innerHTML = '<span>PT MEX</span> Barlian Dirgantara';
        animHeaderCount++;
    } 
    else if (animHeaderCount % 3 == 2)
    {
        temp.innerHTML = 'PT MEX <span>Barlian</span> Dirgantara';
        animHeaderCount++;
    }
    else if (animHeaderCount % 3 == 0)
    {
        temp.innerHTML = 'PT MEX Barlian <span>Dirgantara</span>';
        animHeaderCount++;
    } 
    setTimeout('animHeader()', 1000);
}