﻿/* ********************************************************************
* GreyWyvern's Buffered Text-fade Effect - v2.2a
* - A bit of Javascript for handling intelligent fading of text
* - Copyright 2006 - Licenced for free distribution under the BSDL
*   - http://www.opensource.org/licenses/bsd-license.php
*
*   This program is licenced under the BSDL and may be distributed far
* and wide, anywhere on the planet and beyond (maybe!)  If you happen
* to get a kick out of this script, please drop me a note at:
* javascript@greywyvern.com and tell me where you gave it a good home
* and plenty of bytes to eat, hmmm? :)  I'd be eternally grateful.
*
* Description:
*   A complete recode of the original fade in and out javascript I
* wrote with many improvements.  The buffer system now works almost
* flawlessly, and making fade effects is much easier for the javascript
* beginner.  Just fill in the messages and assign the onmouseover and
* onmouseout attributes with the appropriate fade function!  It also
* helps *me* out by allowing the instruction manual (below) to be much
* simpler to write ;)
*
* Changelog:
*  2.2a - Code optimization accumulation release
*       - No need to upgrade from 2.2 if it works for you
*
*  2.2 - Licence changed from GPL to BSDL
*
*  2.1 - The script would cancel two fade commands if one was a fade in
*        and one was a fade out of the same fade target and message.
*        I added some extra code to cancel the opposite case: two
*        commands where one is a fade out and the other is a fade in of
*        the same message.
*      - If the fade trigger element contained text within an HTML
*        element, a quick mouseover/mouseout or mouseout/mouseover pair
*        of events would be triggered if you moused-out of the text,
*        while staying within the trigger element.  I added a new
*        timeout to catch this set of events.
*
* Support:
*   Opera 7.x  - Perfectly
*   IE 6       - Perfectly
*   IE 5.5     - Perfectly
*   IE 5.01    - Fails
*   Mozilla    - Flickers slightly
*   Firefox    - Flickers slightly
*
*
* I) Setting Up
*   Copy the javascript from this page into an external .js file or
* into the <script> tag of your own HTML page.  This shouldn't be that
* difficult, but you wouldn't believe the kind of mail I get about
* this!  Just do it, okay?  Jeez.
*
* a) The Fade Object
*   After that's done we need to create a fade object.  We do this by
* calling the fadeObj function with a number of arguments.  We'll use
* the default example included in the script: fader[0].  You can delete
* the fader[1] lines if you like.
*
* fader[0] = new fadeObj(0, 'fade0', 'dddddd', '000000', 20, 20, true);
*
*   We'll go through the arguments in order.
*
*   The first argument (0), is the same number you give to the fader
* variable.  So if your fader object is fader[78], the first argument
* would be 78.
*
*   Next is the id of the HTML tag which will be displaying the fading
* effect.  Usually you'll want to apply some height and width styles to
* this element, since it starts out with no text by default and will
* probably be collapsed.  You don't want it jumping around when the
* script writes new text to it.
*
*   The next two values are hexidecimal colour values, WITHOUT the
* preceding #.  The first value is the starting colour, or the colour
* the text is before it fades in.  The second value is the ending
* colour, or the colour the text will be when it finishes fading in.
*
*   After this comes two speed integers, the first for fade-in speed,
* the second for fade-out.  The speed of the fade will increase the
* smaller these numbers get.  At a value of one there is no visible
* fade effect; the text will just "appear".
*   Essentially what these numbers are is the number of "steps" the
* script must take to complete the fade.  With a value of 20 like in
* the example above, there will be 20 colour changes before the text
* is fully faded-in or faded-out.
*
*   The final argument is very important.  It tells the script if there
* is a default block of text you'd like to display in the fade element.
* If set to true, the value of the message[0] will be faded-in if there
* are no more fade commands in the queue.  Once another fade is
* triggered, the default text will fade out first before the new text
* fades in.
*   If set to false, the script will erase the text in the fade element
* if there are no more fade commands left in the queue, leaving it
* completely blank.
*
*
* b) The Fade Messages
*   After setting up our fade object, all we need to do now is write
* out all of the messages which will be displayed in this element.
* Remember that this script only affects text and including images or
* links won't work.
*
*   Messages are included in the message[] array.  Simply assign each
* message a number, like so:
*
* fader[0].message[1] = "Fade text, message one.";
*
*   Each fade object can have as many messages as you want, and be in
* any numerical order.  You can even skip numbers, but note that if you
* use the fade() pointed at a message number which doesn't exist, you
* will get an error.
*
*   As mentioned above, if your fade object has a default message
* specified, it will use the message text from message[0].  Specifying
* a default message and not including a message[0] will cause an error.
*
*
* II) The Events
*   Fades can be triggered by any DOM event, but most likely you'll be
* using mouseover and mouseout events.  I used those events as examples
* below.
*
*   To trigger a fade, you use the fade() function which takes a few
* important arguments:
*
* Example: onmouseover="fade(0, 1, true);"
* 
*   The first argument is the number of the fade object this command is
* targetting.  In this case, it's been pointed at fader[0].
*
*   The second is the message this command refers to.  This one has
* been associated with message[1] of fader[0].
*
*   Lastly, the final argument indicates the direction of the fade.
* true = fade in, false = fade out.
*
*   Examine the working example script to see how these events were
* placed on the <td> elements below.
*
*
* III) Tips
*   - If you give your fade object a default message, it won't appear
* until after the first mouseover event is triggered.  To rectify this
* you can add an onload event to the <body> tag which triggers the
* default message: <body onload="fade(0, 0, true);"> where the first
* argument is, of course, the number of the desired fade object.
*
*   - All the text in each message[] variable MUST be on one line in
* the code.  That means this:
*
*   fader[0].message[1] = "Fader zero,
* message one";
*
* ... is not allowed!  The text should wrap automatically when it's
* displayed on your HTML page, but you can force line breaks with the
* <br> tag.
*
*   - If you're placing the fading text on a background, make the
* starting colour an average sample of the background instead of just
* black or white.  This will enhance the "disappearing" effect.
*
*   - The script can only fade text, but can accept non-graphical HTML
* tags like <p>, <table> (no borders), <strong> and <em>.  Use these
* tags to add structure and simple text-effects to your fades.
*
*   - To have links fade along with with the surrounding text, apply
* the CSS style: color:inherit !important; to all links within the fade
* text messages.
*
* *********************************************************************
* That's it!  Isn't that amazing!?! :)
*
* If you have any problems with this script, don't hesitate to email me
* at javascript@greywyvern.com and I'll be happy to answer your matter-
* of-life-and-death questions!  Cheers!
* ****************************************************************** */

/* ***** Begin: GreyWyvern's Buffered Text-fade Effect - v2.2a ***** */
var fader = new Array(), fadeQ = new Array();
var RGB = new Array(256), k = 0, hex = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
for (var i = 0; i < 16; i++) for (var j = 0; j < 16; j++) RGB[k++] = hex[i] + hex[j];

function fadeObj(number, id, colOff, colOn, spdIn, spdOut, def) {
  this.number = number;
  this.id = id;
  this.colOff = [parseInt(colOff.substr(0, 2), 16), parseInt(colOff.substr(2, 2), 16), parseInt(colOff.substr(4, 2), 16)];
  this.colOn = [parseInt(colOn.substr(0, 2), 16), parseInt(colOn.substr(2, 2), 16), parseInt(colOn.substr(4, 2), 16)];
  this.colNow = [parseInt(colOff.substr(0, 2), 16), parseInt(colOff.substr(2, 2), 16), parseInt(colOff.substr(4, 2), 16)];
  this.spdIn = spdIn;
  this.spdOut = spdOut;
  this.def = def;
  this.direction = false;
  this.active = false;
  this.message = new Array();
  this.messageNow = 0;
}

function fadeCmd(number, message, direction) {
  this.number = number;
  this.message = message;
  this.direction = direction;
}

function fade(number, message, direction) {
  if (fader[number].def && fader[number].messageNow == 0 && fader[number].direction) {
    fadeQ[fadeQ.length] = new fadeCmd(number, 0, false);
    fadeQ[fadeQ.length] = new fadeCmd(number, message, direction);
    message = 0;
    direction = false;
  } else fadeQ[fadeQ.length] = new fadeCmd(number, message, direction);
  setTimeout(function() { fadeBegin(number); }, 20);
}

function fadeBegin(number) {
  for (var x = 0; x < fadeQ.length; x++) {
    for (var y = x + 1; y < fadeQ.length; y++) {
      if (fadeQ[x].number == fadeQ[y].number && fadeQ[x].message == fadeQ[y].message && fadeQ[x].direction != fadeQ[y].direction) {
        fadeQ.splice(x, 1);
        fadeQ.splice(y - 1, 1);
      }
    }
  }
  if (!fader[number].active) {
    for (var x = 0; x < fadeQ.length; x++) {
      if (fadeQ[x].number == number && fadeQ[x].direction != fader[number].direction) {
        var del = fadeQ.splice(x, 1);
        setTimeout(function() { fadeEng(number, del[0].message, del[0].direction); }, 0);
        break;
      }
    }
  }
}

function fadeEng(number, message, direction) {
  if (!fader[number].active) {
    fader[number].active = true;
    fader[number].direction = direction;
    fader[number].messageNow = message;
    document.getElementById(fader[number].id).innerHTML = fader[number].message[message];
  }
  var iniCol = (direction) ? fader[number].colOff : fader[number].colOn;
  var endCol = (direction) ? fader[number].colOn : fader[number].colOff;
  var incCol = fader[number].colNow;
  var spd = (direction) ? fader[number].spdIn : fader[number].spdOut;
  for (var x = 0; x < 3; x++) {
    var incr = (endCol[x] - iniCol[x]) / spd;
    incCol[x] = (incr < 0) ? Math.max(incCol[x] + incr, endCol[x]) : Math.min(incCol[x] + incr, endCol[x]);
  }
  document.getElementById(fader[number].id).style.color = "#" + RGB[parseInt(incCol[0])] + RGB[parseInt(incCol[1])] + RGB[parseInt(incCol[2])];
  if (incCol[0] == endCol[0] && incCol[1] == endCol[1] && incCol[2] == endCol[2]) {
    fader[number].active = false;
    for (var x = 0; x < fadeQ.length; x++) {
      if (fadeQ[x].number == number) {
        var del = fadeQ.splice(x, 1);
        setTimeout(function() { fadeEng(number, del[0].message, del[0].direction); }, 0);
        return false;
      }
    }
    if (!direction) {
      if (fader[number].def) {
        setTimeout(function() { fadeEng(number, 0, true); }, 0);
      } else document.getElementById(fader[number].id).innerHTML = "&nbsp;";
    }
  } else setTimeout(function() { fadeEng(number, message, direction); }, 0);
}
/* ***** End: GreyWyvern's Buffered Text-fade Effect - v2.2a ******* */


/* *****
 * User defined fade objects and messages
 *
 * These messages are used in fades triggered by mouseovers and
 * mouseouts on table cells.  They are the simplest type of fade and
 * require no extra Javascript code.
 */
//index.php fade objects 
fader[0] = new fadeObj(0, 'fade0', 'dddddd', '000000', 20, 20, true);
fader[0].message[0] = "an integrated";
fader[0].message[1] = "Integrated and Intuitive";

fader[1] = new fadeObj(1, 'fade1', 'dddddd', '000000', 20, 20, true);
fader[1].message[0] = "approach";
fader[1].message[1] = "Growth and Efficiency";

fader[2] = new fadeObj(1, 'fade2', 'dddddd', '000000', 20, 20, true);
fader[2].message[0] = "to wireless engineering";
fader[2].message[1] = "Knowledge and Experience";


//main_products.php fade objects
fader[3] = new fadeObj(1, 'fade3', 'dddddd', '000000', 20, 20, true);
fader[3].message[0] = "";
fader[3].message[1] = "OptPCS is a multi-band 2G/3G/4G LTE multi-vendor network operation and optimization tool, developed by a team of experienced engineers with extensive knowledge in wireless system design, analysis, and optimization. As a result, OptPCS is the most intuitive tool on the market today. Engineers find OptPCS highly interactive and productive depending on approaches and levels of experience.";
fader[3].message[2] = "Intelligent Cell Engineering (iCE) bridges the gap between planning and optimization by allowing engineers to utilize their experience and measured data when planning new sites or optimizing existing site configurations";
fader[3].message[3] = "In complex operating environments with mulitple vendors and multiple technologies, simplifying the approach to configuring and changing parameters, conducting discrepency and consistency checks, auditing changes to the system, administrating users and systems, and reporting is possible.  CM can do it and over the web.";
fader[3].message[4] = "NetRescue automates the day to day troubleshooting activities related to network performance. The result allows operational teams to focus on near-term solutions to maintain the network quality levels while allowing engineers to focus on longer-term network optimization and growth objectives.";
fader[3].message[5] = "Enterprise Server centralizes data processing and management of measurement data to enhance performance, reusability, accessibility, and integrity during RF planning and optimization.";

//main_solutions.php fade objects
fader[4] = new fadeObj(4, 'fade4', 'dddddd', '000000', 20, 20, true);
fader[4].message[0] = "";
fader[4].message[1] = "SCOPES is an end-to-end solution leveraging its flagship software, OptPCS and its industry-known experts to assist major wireless carriers understand their market and provide recommendations to grow their network in a spectrally efficient manner.";  
fader[4].message[2] = "";
fader[4].message[3] = "By defining the different types of areas and collecting drive test data in a standardized way, TTS can tune your models for any planning tools to achieve greater accuracy in planning of your network for the future.";
fader[4].message[4] = "Our highly skilled teams of seasoned managers, engineers and technicians, working together, provide clients with the option of executing projects quickly and efficiently.";


//main_consulting.php fade objects
fader[5] = new fadeObj(5, 'fade5', 'dddddd', '000000', 20, 20, true);
fader[5].message[0] = "";
fader[5].message[1] = "Our engineers are quick to integrate into market-related processes, coordination of site acquisition, RF design, zoning, construction, equipment installation, testing and acceptance, optimization, training and process development.";
fader[5].message[2] = "Our greatest strength is overcoming challenges in the areas of complex heterogeneous wireless systems and relationships between operators, vendors, engineers and regulatory agencies. ";
fader[5].message[4] = "Our advanced technology engineers bring a full scale knowledge base in niche parts of the network.  These individuals are highly specialized and experts in their field.";
fader[5].message[5] = "Our world-class software development team has helped several wireless operators develop their own daily operation software tools to meet carrier-specific management needs for cost-effective operational procedures.";
fader[5].message[6] = "Our Broadband Wireless Access (BWA) engineers are experts in both fixed WiFi/802.11 and mobile WiMAX 802.16e as well as Long Term Evolution (LTE) technology.  We understand the physical environment and its challenges and assembled the right team to deliver innovation and spend of implementation.";

//main_company.php fade objects
fader[6] = new fadeObj(6, 'fade6', 'dddddd', '000000', 20, 20, true);
fader[6].message[0] = "";
fader[6].message[1] = "";
fader[6].message[2] = "";
fader[6].message[3] = "";

//company_careers.php fade objects
fader[7] = new fadeObj(7, 'fade7', 'dddddd', '000000', 20, 20, true);
fader[7].message[0] = "";
fader[7].message[1] = "A rewarding career and personal life depend in part on your continued good health and peace of mind. TTS offers a wide range of high-quality health insurance plans as part of our flexible benefits program.";
fader[7].message[2] = "Our positions range from engineering to software development to project management to business-related positions.  We look for enthusiasm and innovation in our candidates from anywhere in the world.  ";
fader[7].message[3] = "Each year, we look for the best and brightest young minds to bring in new ideas and approaches to our products, services and corporate culture.  Universities offer a unique talent pool and gives us an opportunity to harness that energy.";

//main_support.php fade objects
fader[8] = new fadeObj(8, 'fade8', 'dddddd', '000000', 20, 20, true);
fader[8].message[0] = "";
fader[8].message[1] = "Online software updates gives our customers faster access to the latest feature enhancements and fixes.  Request access to our client portal. ";
fader[8].message[2] = "Open discussions about 2G, 3G and WiMax not only gives our customers access to leading industry experts, but also provides us with the top technology issues facing our customers today. ";
fader[8].message[3] = "Meeting online gives us a chance to come together, talk and share each others desktop.  It is an effective way to quickly resolve issues or update our customers at anytime from anywhere.";
fader[8].message[4] = "Instructor led training provides students with hands-on experience with our tools and solutions in a dynamic learning environment."

//company_news.php fade objects
fader[9] = new fadeObj(9, 'fade9', 'dddddd', '000000', 20, 20, true);
fader[9].message[0] = "";
fader[9].message[1] = "Go back in time to see the incredible progression of innovation taken place.  ";
fader[9].message[2] = "Our monthly OptPCS techblasts are designed to keep our user base up-to-date with the latest features and functions released with our flagship tool. ";
fader[9].message[3] = "The key to being an industry leader is to keep our industry informed of the paths we are forming in wireless engineering with our customers.";


