//
// Version 1.01
//

//------------------------------------------------------------------------------
//
// Function randomly select an element from the given array.
//
// args: theArray - array from which to choose an element
//
// rtns: an element if the array has at least one element
//       empty string if the array has no elements
//
//------------------------------------------------------------------------------
var theElem = null;

function randArrayElem(theArray,noSync)
{
   if( noSync )
   {
      theElem = null;
   }
   
   var numElem = theArray.length;
   
   if( numElem > 0 )
   {
      if( theElem == null )
      {
         numElem = theArray.length-1;

         var num = Math.random()*(numElem);
         theElem = Math.round(num);
         return theArray[theElem];
      }
      else
      {
         return theArray[theElem];
      }
   }
   else
   {
      return 0;
   }
}

function showRandomTextKeBiz(theHeadline,theText)
{
   var headlineText = randArrayElem(theHeadline);
   var contentText = randArrayElem(theText);
   var returnText = "<span class=\"subhead\">"+headlineText+"</span><div><img src=\"/shared/graphics/kebiz/images/blank.gif\" alt=\" \" width=\"2\" height=\"5\"/></div>"+contentText;
   if( headlineText == ""  )
   {
      returnText = contentText;
   }

   return returnText;
}

function showRandomPic(thePicture,picName,changeAlt)
{
   var pictureSrc = randArrayElem(thePicture,true);
   eval("document."+picName+".src =  pictureSrc.src");
   if( changeAlt )
   {
      var altText = randArrayElem(theAltText,false);
      eval("document."+picName+".alt =  altText"); 
   }
   //return pictureSrc.src;
}
