// Deliah's javascript functionality

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//
// EnterKey
// Target text box enter key press to a submit button.
//
function EnterKey ( id )
{
   if ( window.event )
   {
      // IE - window.event global object.
      if (window.event.keyCode == 13 )
      {
         window.event.cancelBubble = true;
         window.event.returnValue = false;
         document.getElementById(id).click();
      }
   }
   else
   {
      // Browsers that support Mozilla style event parameters.
      if ( id.keyCode && id.keyCode === 13 )
      {
         id.stopPropogation();
         document.getElementById(id).click();
      }
   }
}

function DisplayFlash(movie, width, height, link,title, divID, image)
{
   // In this section we set up the content to be placed dynamically on the page.
	// Customize movie tags and alternate html content below.
   if (!useRedirect) // if dynamic embedding is turned on
   {    
      if(hasRightVersion)  // if we've detected an acceptable version
      {
         // new javascript for inserting flash object - side-steps flash activation
         myFlashObject=new Object
         myFlashObject.movie= movie
         myFlashObject.quality="high"
         myFlashObject.wmode="transparent"
         myFlashObject.width= width
         myFlashObject.height=height
         myFlashObject.version="5,0,0,0"
         myFlashObject.FlashVars="flashLinkURL="+link+""
         commitFlashObject(myFlashObject, divID);
      } 
      else   // flash is too old or we can't detect the plugin
      {
         // NOTE: height, width are required!
         var alternateContent = ''
         + '<a href="'+link+'" target="_self" title="'+title+'"><img src="'+image+'" class="racAd_image" \/><\/a>';
         document.write(alternateContent);   // insert non-flash content
      }
   }
}

//
// DisplayFlash2
// Converted to wrapper around SWFObject code.
//
function DisplayFlash2 ( movie, width, height, link, title, divID, image )
{
   var minversion = '5.0.0';
   if ( swfobject.hasFlashPlayerVersion(minversion) )
   {
      swfobject.embedSWF('/'+movie, divID, width, height, minversion, false, false, { quality: 'high', wmode: 'transparent'} );
   }
   else
   {
      var imageLink = 
         '<a href="' + link + '" target="_self" title="' + title + '">' + 
         '<img src="/' + image + '" class="racAd_image" border="0" \/><\/a>';
      $('#'+divID).html(imageLink);   // insert non-flash content  
   }
}

//
// onClick
// Used throughout the site to make divs into clickable links.
//
function onClick(target) 
{
   location.href = target;
}


//
// GetFlashRef
// Get reference to the flash movie. 
//
function GetFlashRef ( movieName ) 
{
   var swfRef = false;
   if ( window[movieName] )
   {
      swfRef = window[movieName];
   }
   else if ( document[movieName] )
   {
      swfRef = document[movieName];
   }
   return swfRef;
}

