View Single Post
Old 01-03-2013, 02:17 AM   PM User | #5
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,355
Thanks: 3
Thanked 458 Times in 445 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title></title>
<script type="text/javascript">
/*<![CDATA[*/

function rotateText(el, textGroup)
{
  zxcOpacity(el, 0);
  rotateText.opc=0 // bad to rely on style.opacity so use an object property
  //grab current text
  var sametext = document.getElementById('quotes').innerHTML;

   //get new text
   var group = rotateText.texts[textGroup];
   var t = group[Math.round(Math.random() * (group.length - 1))];

   //if they are the same then get another one
   if(sametext == t)
    {
     var group = rotateText.texts[textGroup];
     var t = group[Math.floor(Math.random() * (group.length - 1))];
      }//close if

  el.innerHTML = t;
  unfadeText(el, textGroup);

}//close function rotateText

rotateText.texts =
{
  quotes: [
    "text1...",
    "text2...",
    "text3...",
    "text4...",
    "text5...",
    "text6...",
    "text7...",
    "text8..."
        ]
};


function zxcOpacity(obj,opc){
 obj.style.filter='alpha(opacity='+opc+')';
 obj.style.opacity=obj.style.MozOpacity=obj.style.WebkitOpacity=obj.style.KhtmlOpacity=opc/100-.001;
 rotateText.opc=opc;
}

function unfadeText(el, tg){
  var v = rotateText.opc+1;
  if(v > 100) {
    zxcOpacity(el, 100);
    setTimeout(bundleFunction(null, fadeText, [el, tg]), 10000);  /* number of seconds, this is 10 sec */
    return;
  }
  zxcOpacity(el, v);
  setTimeout(bundleFunction(null, unfadeText, [el, tg]), 10);
}

function fadeText(el, tg){
  var fadt = rotateText.opc-1;
  if(!fadt > 0){
    zxcOpacity(el, 0);
    rotateText(el, tg);
    //or... setTimeout(bundleFunction(null, rotateText, [el, tg]), NUMBER);
    return;
  }
  zxcOpacity(el, fadt);
  setTimeout(bundleFunction(null, fadeText, [el, tg]), 10);
}//close function fadeText

function bundleFunction(context, func, args){
  context = context || null;
  if(typeof func == "string"){
   if(context){
    func = context[func];
   }//close if
  }//close if

  if(!args){
   args = [];
  }
  else if(!(args instanceof Array)){
   args = [args];
  }//close elseif

 return function(){
  return func.apply(context, args);
 }//close return function

}//close function bundleFunction

/*]]>*/
</script></head>

<body>
<!-- added for text rotator -->

<noscript>
<div style="font-size:small;margin:0px 10px 0px 10px;">
We can customize a plan just for your particular needs...<br /><br />Also it appears you have javascript disabled or your browser does not support JavaScript!
</div>
</noscript>

<div style="font-size:20px;margin:0px 10px 0px 10px;" id="quotes"></div>

<script type="text/javascript">
rotateText(document.getElementById("quotes"), "quotes");
</script>

<!-- end text rotator -->
</body>

</html>
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/

Last edited by vwphillips; 01-03-2013 at 02:22 AM..
vwphillips is offline   Reply With Quote
Users who have thanked vwphillips for this post:
durangod (01-03-2013)