/*---------------------------------------------------------------------------

JavaScript Flirty Text Effect for Web Designers Toolkit
(C)1999-2004 USINGIT.COM, All Rights Reserved.
To get more free and professional scripts, visit:
http://www.usingit.com/
http://www.usingit.com/products/webtoolkit
email: support@usingit.com

This script can be used freely for commercial and non-commercial sites only if 
you don't alert the copyright info here! 

-----------------------------------------------------------------------------*/

//**************************************************************
//Set the parameters below to make this script to fit your need.
//**************************************************************

var aniSpeed = 100; //The speed of the animation effect. Lower is faster.
var charWidth = 9;; // Minimum width per character in pixels.

var FontName = "arial"; //The family name of the font. Such as Ms Sans Serif,Georgia,Helvetica,Arial;
var FontSize = 40; //Font size of the text
var FontWeight = "bold"; //Bold or Normal
var FontStyle = "normal"; //Italic or Normal
var textColor = "#999999"; //The color of the text
var onLoadEventHandler = ""; //The names of the other functions that you need to call in body's onload event.
                           //This script will override the onload event handler of this web page and some 
                           //other scripts may not work if they also need to use onLoad event handler. Put
                           //those scripts's onload event handler here will solve this problem.
                           //for example, set it to "document.bgColor='red';" will change the background
                           //color of the document to red.

//**************************************************************
//DO NOT CHANGE ANYTHING BELOW.
//**************************************************************

var DOM=document.getElementById;
var flirtText;
var flirtPos=0;
var flirtDir=1;

window.onload=onLoad_FlirtText;
if(onLoadEventHandler!=""){eval(onLoadEventHandler);}


function onLoad_FlirtText(){
  if(DOM)
  {
    var lobj=document.getElementById("FLIRTTEXT");
    flirtText=String.fromCharCode(32)+lobj.firstChild.nodeValue+String.fromCharCode(32);

    while(lobj.childNodes.length){lobj.removeChild(lobj.childNodes[0]);}
    for(var i=0;i<flirtText.length;i++)
    {
      var lochar=document.createElement("span");
      lochar.setAttribute("id","FLIRTCHARID"+i);
      lochar.appendChild(document.createTextNode(flirtText.charAt(i)));
      lochar.style.fontFamily=FontName;
      lochar.style.fontSize=FontSize;
      lochar.style.fontWeight=FontWeight;
      lochar.style.fontStyle=FontStyle;
      lochar.style.color=textColor;
      lochar.style.width=charWidth+"px";
      lochar.style.textAlign="center";
      lobj.appendChild(lochar);
    }
    setInterval("doAni()",aniSpeed);
  }
};

function doAni(){
  flirtPos+=flirtDir;
  if(flirtPos>flirtText.length||flirtPos<-flirtText.length)
  {
    flirtPos-=flirtDir;
    if(Math.random()<0.2){flirtDir=-flirtDir;}
    if(Math.random()<0.2){flirtPos=-flirtPos;}
  }
  else
  {
    if(flirtPos==flirtDir&&Math.random()<0.9)
    {
      flirtPos-=flirtDir;
      flirtDir=-flirtDir;
    }
  }
  for(var i=0;i<flirtText.length;i++)
  {
    if(flirtPos+i>-1&&flirtPos+i<flirtText.length)
    {
      document.getElementById("FLIRTCHARID"+i).firstChild.nodeValue=flirtText.charAt(flirtPos+i);
    }
  }
};


