﻿// JScript File
var IE = false;
var Net = false;
var guserId = 0
var lat = 0
var lon = 0
var latmax = 0
var latmin = 1000
var lonmax = 0
var lonmin = 1000
var tripDistance = 0
var curCity = ""
var offsetX = 0
var offsetY = 0
var lat1 = 0
var lon1 = 0
var lat2 = 0
var lon2 = 0
var setDepId = 0;
var inLoad = 0;
var region = "US"




function User() {
    this.userId = 0;
    this.userName = "";
    this.cityIndex = 0;
}


User.prototype.userId = 0;
User.prototype.userName = "";
User.prototype.cityIndex = 0;

// not being used
var inProcess = 0

//trip record id
var currentTripId = 0
// aircraftData record id
var currentADId = 0

// switch for oneway return or multi leg
var retOrMulti = ""

// array for multi leg
var cityArray = new Array(); 

// for debugging
var cycle = 0

// aircraft tail #
var tail = ""

// to tell the google mapper where to draw the airports
var AirportMap = ""

// this is the city that appears in the marker for the airport
var AirportCity = ""

// lat lon for the airport
var AirportLatLon = ""

// departure airport
var depAirCode = ""

// arrival airport
var arrAirCode = ""

function SetBrowser(){
		if (navigator.appName.substring(0,1)=="M"){
			IE = true;
		}
		else{
			Net = true;
		}
		if (document.getElementById("ctl00_huserId")!=null){
			guserId = document.getElementById("ctl00_huserId").value
		}
		else{
			guserId = document.getElementById("huserId").value
		}
		
	}
	
	
function mouseOver(obin){

			cur = obin.src
			
			obin.src = cur.replace("off","on") 
			//alert(obin.src)
		}
	    
		function mouseOut(obin){
	    
			cur = obin.src
			obin.src = cur.replace("on","off")
			
}

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)   {
   return (number < 1000) ? number + 1900 : number;
}

// Join it all together
 var today =  days[now.getDay()] + " " +  months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ;

// Print out the data.
//document.write("" +today+ "");


timeis=now.getTime();
now.setTime(timeis);
houris = now.getHours();
if (houris >= 17) display = "evening";
else if (houris >= 12) display = "afternoon";
else display = "morning";
var welcome = ("Good " + display + ",");

function SetArea(obin){
		
	if (obin.id !="NA"){
	
		alert("Sorry, that area is not currently active")	
	
	}
	else{
	
		alert("System is currently monitoring North America")
	
	}

}


function CheckCookie(obin) {

    
    SetLanding()


    if (obin == 1) {  // this flag is set to 1 on charterJetTraffic.aspx
         // sets the flag for getDepInfo after getcities
         setDepId = 1;
    }
    
    
    var qString = ""

    if (guserId > 0) {

        qString += "&userId=" + guserId

        //alert(qString)

        callService(GetUserInfo, "GetUser", qString)

    }
    else { // no user so we can set the dep info

        GetCities(region);

    }



}
    
String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g, "");
}



 function SetLanding() {

        test = document.URL.lastIndexOf("/");
        SetCookie("landing",document.URL.substring(test + 1));
     
    }


 function SetCookie(cook, val) {
        cookAr = document.cookie.split(";");
        document.cookie = cook + "=" + val + " ;expires=Fri, 17 Dec 2020 10:00:00 GMT";
    }

 function GetCookie(cookieName) {
        cookAr = document.cookie.split(";");
        for (y = 0; y < cookAr.length; y++) {
            curCook = cookAr[y].split("=");
            if (curCook[0].toString().trim() == cookieName.toString().trim()) {
                return (curCook[1])
            }
        }
    }

    function CycleMessage() {

        //        amessage = document.getElementById(mid).innerText
        //        if (amessage == undefined) {
        //            amessage = document.getElementById(mid).textContent
        //        }

        amessage = document.getElementById(mid).value
        //        if (amessage == undefined) {
        //            amessage = document.getElementById(mid).textContent
        //        }

        //document.getElementById(mid).innerHTML = "";
        //document.getElementById(mid).value = "";
        mlen = amessage.length
        if (cssStart == 1) {
            cssStart = 6
        }
        else {
            cssStart--;
        }
        css = cssStart
        for (x = 0; x < amessage.length; x = x + letterInc) {
            messText = amessage.substring(x, x + letterInc);
            messText = messText.replace(" ", "&nbsp;");
            WriteMessage(messText, mid, "message" + css);
            if (css == 6) {
                css = 1
            }
            else {
                css++;
            }
        }
    }

    function WriteMessage(message, domid, cssclass) {

        //        aElement = document.createElement('span');
        //        aElement.setAttribute('className', cssclass);
        //        aElement.setAttribute('class', cssclass);
        //        aElement.innerHTML = message;
        //        document.getElementById(domid).appendChild(aElement);

        document.getElementById(domid).className = cssclass;

    }

    var cssStart = 1;
    var css = 1;
    var flashspeed = 200;
    var letterInc = 8;
    var flashing = 0;

    // dom id that will pulse
    var mid = ""

    function MessageAnimation(domElement) {

        mid = domElement;
        flashing = setInterval("CycleMessage()", flashspeed);

    }

    function ClearValue(obin) {

        obin.value = "";

    }

    function StopAnimation(obin) {

        if (obin.value == "Type city name here") {
            window.clearInterval(flashing)
            obin.value = "";
            obin.className = "message3";
            obin.focus()
        }

    }



