var videoDirectory = "http://www.cricketeurope4.net/CRICKETEUROPE/DATABASE/VIDEOZONE/";
var audioDirectory = "http://www.cricketeurope4.net/CRICKETEUROPE/DATABASE/AUDIOZONE/";

var playerWindow;

var styleRules = "<style>";
styleRules += ".mediaAnnotationBox{margin:10px;padding:5px;background-color:#FFFFFF;font-size:10px;font-weight:bold;color:#000000;text-align:center;}";
styleRules += ".mediaLinkBox{margin-left:75px;margin-right:75px;padding:2px;background-color:#FFCC00;font-size:10px;font-weight:bold;color:#000000;text-align:center;}";
styleRules += ".mediaLinkBox:hover{background-color:#FFFFFF;color:#000000;}";
styleRules += ".mediaLink {color: #000000; font-weight:bold; text-decoration:none;}";
styleRules += "</style>";



function OpenJWPlayer(mediaType, URL, description, width, height, countryID, country) {

  if ((playerWindow) && (!playerWindow.closed)) {
   playerWindow.close();
  }
    
  windowHeight = height + 176;
  
  if (mediaType == "video") {
    attString = "width=" + width + ",height=" + windowHeight + ",top=50,left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0"
  }
  else {
    attString = "width=340,height=236,top=50,left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0"
  }

  playerWindow = window.open('','JWPlayer',attString);
  playerWindow.focus(); 
  
  if (mediaType == "video") {
    var html = "<html><head><title>CricketEurope videoZone</title>";
  }
  else {
    var html = "<html><head><title>CricketEurope audioZone</title>";
  }
  html += styleRules + "</head>";
  
  html += "<body bgcolor='#005432' topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>";
  html += "<table width='320' cellpadding='0' cellspacing='0' border = '0' bgcolor='#005432'>";
  html += "<tr><td align='center'>";

  if (mediaType == "video") {
      html += "<img src='http://www.cricketeurope4.net/MEDIA/CRICKETEUROPE/MEDIAZONES/videoZonegreen.gif' width='320' height='81' border='0'>";
  }
  else {
     html += "<img src='http://www.cricketeurope4.net/MEDIA/CRICKETEUROPE/MEDIAZONES/audioZonegreen.gif' width='320' height='81' border='0'>";
  }

  html += "</td></tr>";
  
  html += "<tr><td align='center'>";
//  html += "<object width='" + width + "' height='" + height + "'>";
//  html += "<param value='" + URL + "' />";
//  html += "<param name='allowfullscreen' value='false'>";
//  html += "<param name='flashVars' value='" + "config=http://cricketeurope.myphotoalbum.com/inc/share/flashvideoxml.php?flvFile=http://rawimages.myphotoalbum.com/c/cr/cri/cric/crick/cricketeurope/albums" + turl1 + "/" + turl2 + "' />";
  html += "<embed src='/JSCSS/JWP/player.swf' width='" + width + "' height='" + height + "' allowFullScreen='false' AllowScriptAccess='always' bgcolor='#000000' flashVars='file=" + URL + "&autostart=true' />";
  html += "</embed>";
//  html += "</object>";
  html += "</td></tr>";

  html += "<tr><td align='center' valign = 'middle' height = '60'><div>";
  html += "<div class = 'mediaAnnotationBox'>" + description + "</div>";
  html += "</td></tr>";

  if (mediaType == "video") {
    hrefURL        = videoDirectory + countryID + ".shtml";
    clickHandler   = "opener.location.href = \"" + videoDirectory + countryID + ".shtml\"; window.close()";
  }
  else {
    hrefURL        = audioDirectory + countryID + ".shtml";
    clickHandler   = "opener.location.href = \"" + audioDirectory + countryID + ".shtml\"; window.close()";
  }

  if (mediaType == "video") {
    moreMessage = "View more " + country + " videos";
  }
  else {
    moreMessage = "Listen to more " + country + " audio";
  }
  
  html += "<tr><td align='center' valign = 'middle' height = '30'><div>";
  html += "<div class = 'mediaLinkBox'>" + "<a class = 'mediaLink' href = '" + hrefURL + "' onClick = '" + clickHandler + "'>" + moreMessage + "</a></div>";

  html += "</td></tr></table>";
  html += "</body></html>";

  playerWindow.document.write(html);
  playerWindow.document.close();
}


// JW Player Control **********************************
function createJWPLayer(playlistFile, theWidth, theHeight) {
  var so = new SWFObject('/JSCSS/JWP/player.swf','mpl',theWidth,theHeight,'9');
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addParam('flashvars','&file=' + playlistFile + '&playlistsize=300&playlist=right');
  so.write('player');
}



// WMV Player Control **********************************
var WMLplayer = null;
var WMLPlayerWidth = new String;
var WMLPlayerHeight = new String;
var WMLPlayerDefaultFile = "http://www.cricketeurope2.net/AUDIOVIDEO/default.wmv";

function setWMLPlayerSize(theWidth, theHeight) {
	WMLPlayerWidth = String(theWidth);
	WMLPlayerHeight = String(theHeight);
}

function createWMLPlayer(theContainer, theFile, go) {
	var cnt = document.getElementById(theContainer);
	var src = "/JSCSS/JWP/wmvplayer.xaml";
	var cfg = {height:WMLPlayerHeight, width:WMLPlayerWidth, file:theFile, autostart:go};
	WMLplayer = new jeroenwijering.Player(cnt,src,cfg);
}


// Slideshow display **********************************

var SS_speed = 6000; //milliseconds
var SS_photoInfo = new Array();
var SS_photoDirectory;
var SS_albumDirectory;
var SS_next = 0;

function showNextSlide() {
  SS_next = SS_next + 1;
  if (SS_next == SS_photoInfo.length) SS_next = 0;
  imageHTML = "<a href = '" + SS_albumDirectory + "'><img src='" + SS_photoDirectory + SS_photoInfo[SS_next][0] + ".jpg'" + " border = '0' /></a>";
  document.getElementById("SS_imageArea").innerHTML = imageHTML;
//  document.getElementById("SS_imageCaption").innerHTML = SS_photoInfo[SS_next][1];
  setTimeout('showNextSlide()', SS_speed);
}

function runSlideShow(slideshowTitle) {
  var preLoad = new Array();
  for (i = 0; i < SS_photoInfo.length; i++) {
    preLoad[i] = new Image();
    preLoad[i].src = SS_photoDirectory + SS_photoInfo[i][0] + ".jpg";
  }
  document.write ('<div class = "sidebarheader">' + slideshowTitle + '</div>');
  document.write ('<div id = "SS_imageArea" class = "sidebarframe mainBackground" style = "padding:0px;text-align:center;height:180px;overflow:hidden;">');
  document.write ('<a href = ' + SS_albumDirectory + '><img src="' + SS_photoDirectory + SS_photoInfo[0][0] + '.jpg" border = "0" /></a>');
  document.write ('</div>');
  document.write ('<div class = "sidebarfooter" style = "text-align:center">');
  document.write ('<a style = "color:#FFFFFF;" href = ' + SS_albumDirectory + '>View the complete album at full-size!</a>');
  document.write ('</div>');
//  document.write ('<div id = "SS_imageCaption" class = "sidebarfooter">' + SS_photoInfo[0][1] + '</div>');
  setTimeout('showNextSlide()', SS_speed);
}

