﻿/*
  Copyright 2007 Paperheads, All Rights Reserved.
  http://www.paperheads.co.uk
*/

if(typeof(Type) !== 'undefined') {
  Type.registerNamespace("PH.BeAt");
}
else {
  PH = function() {}
  PH.BeAt = function() {}
}

PH.BeAt.SetBackground = function(Url) {
  var oBackDiv = document.body;
  if(Url == 'none') {
    oBackDiv.style.backgroundImage = Url;
  } else {
    oBackDiv.style.backgroundImage = 'url(' + Url + ')';
  }
}

PH.BeAt.ShowFlash = function(ID, Path, Width, Height) {
  var oContainer = $get(ID);
  var sOutput = '';

  if(navigator.appName.indexOf("Microsoft") != -1) {
    sOutput = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+Width+'" height="'+Height+'" alowFullscreen="true"><param name="movie" value="'+Path+'" /><param name="quality" value="high" /><param name="allowFullScreen" value="true" /></object>'
    //sOutput = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+Width+'" height="'+Height+'"><param name="movie" value="'+Path+'" /><param name="quality" value="high" /><param name="allowscriptaccess" value="true" /><param name="wmode" value="transparent" /><param name="swliveconnect" value="true" /></object>'
  } else {
    sOutput = '<embed src="'+Path+'" width="'+Width+'" height="'+Height+'" quality="high" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash"></embed>'
    //sOutput = '<embed src="'+Path+'" width="'+Width+'" height="'+Height+'" quality="high" allowScriptAccess="true" wmode="transparent" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash"></embed>'
  }

  oContainer.innerHTML = sOutput;
}

PH.BeAt.GetFlashContent = function() {
  var oPlayer = $get('flash_player').childNodes[0];;
  var sContent = $get('flash_content').innerHTML;

  alert(oPlayer);
  alert(sContent);

  oPlayer.SetPlayerContent(sContent);
}

PH.FlashPage = function(appPath, url, query) {
    window.location.replace(appPath + '/#' + url + '/' + query);
}

PH.CheckSearch = function(e, sSearchUrl) {
  var charCode;
  if(window.event) { 
    charCode = e.keyCode;
  } else if(e.which) {
    charCode = e.which;
  }

  if (charCode==13) {
    PH.Search(sSearchUrl);
  } else {
    return true;
  }
}

PH.Search = function(sSearchUrl) {
  var sTerms = "";
  var oSearchTerms = $get('oSearchTerms');
 
  for (i=0;i<oSearchTerms.value.length;i++) {
    if (oSearchTerms.value.charAt(i) == " ") {
      sTerms += "+";
     } else {
      sTerms += oSearchTerms.value.charAt(i);
    }
  }

  sSearchUrl += "?terms=";
  sSearchUrl += escape(sTerms);
  
  window.location.href = sSearchUrl
}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();