﻿/// <reference path="jquery/jquery-1.3.2.js" />
/// <reference path="jquery/jsonStringify.js" />
/* 
* FlyAwake
*  
* Copyright © 2009 Macrosystems, Inc. All rights reserved. www.macrosystems.com
* 
* File:			flyAwake_utils.js
* Author:		Andrew Ittner
* Created Date:	2009-06-08
* Description:	Utility functions for FlyAwake
* Comments:		
* 
*/

var ICAO_EMPTY_TEXT = "KADW, TCM, Tinker";
var HOURS_EMPTY_TEXT = "1.5, 3";
var NAME_EMPTY_TEXT = "Quick Flight";
var TIME_EMPTY_TEXT = "1645";
var DATE_EMPTY_TEXT = "MM/DD/YYYY";

// keyCode utilities
// Get the actual cross-browser keycode from a keypress event
function getkeyCode(evt) {
    var kc = null;
    if (evt.which == null) {
        kc = evt.keyCode;    // IE
    }
    else if (evt.which > 0) {
        kc = evt.which; 	  // All others
    } else {
        // special key; unhandled
    }
    return kc;
}

// get the actual cross-browser character from a keypress event
function getkeyChar(evt) {
    var keychar = null;
    if (evt.which == null) {
        keychar = String.fromCharCode(evt.keyCode);    // IE
    }
    else if (evt.which > 0) {
        keychar = String.fromCharCode(evt.which); 	  // All others
    } else {
        // special key; unhandled
    }
    return keychar;
}

// oddly-named function to return a querystring parameter
function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
      };

function Html() {

};

Html.encode = function(text, truncate) {
    if (truncate) {
        if (text.length > truncate)
            text = text.substr(0, truncate) + "...";
    }
    
    return $("<div/>").text(text).html();
};