// Reloaded JavaScript
// [a] Escape frames
// [b] Flash detection
// [c] Writing flash object or alternate GIF (no link)
// [d] Writing flash object or alternate GIF (promo banner with link)
// [e] Competition banner
// [f] Competition popup
// [g] Siteseal banner
// [h] Siteseal popup
// [i] Standard popups


// [a]
// Escape frames

if (top.location != self.location) top.location = self.location;


// [b]
// Flast detection
// moock fpi [f.lash p.layer i.nspector] | version: 1.3.7 | Original code written by Colin Moock (this is an adapted version)

flash2Installed = false;    // true if flash 2 is installed
flash3Installed = false;    // true if flash 3 is installed
flash4Installed = false;    // true if flash 4 is installed
flash5Installed = false;    // true if flash 5 is installed
flash6Installed = false;    // true if flash 6 is installed
flash7Installed = false;    // true if flash 7 is installed
flash8Installed = false;    // true if flash 8 is installed
flash9Installed = false;    // true if flash 9 is installed
requiredVersion = 5;        // version the user needs to view site (max 9, min 2)
maxVersion = 9;             // highest version we can actually detect
actualVersion = 0;          // version the user really has
hasRightVersion = false;    // true if it's safe to embed the flash movie

isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
if(isIE && isWin){
  document.write('<scr' + 'ipt language="vbscript"\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/scr' + 'ipt\> \n');
}

if (navigator.plugins) {
  if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
    isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
    flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
    flashVersion = parseInt(flashDescription.substring(16));
    flash2Installed = flashVersion == 2;    
    flash3Installed = flashVersion == 3;
    flash4Installed = flashVersion == 4;
    flash5Installed = flashVersion == 5;
    flash6Installed = flashVersion == 6;
    flash7Installed = flashVersion == 7;
    flash8Installed = flashVersion == 8;
    flash9Installed = flashVersion >= 9;
  }
}
for (i = 2; i <= maxVersion; i++) {  
  if (eval("flash" + i + "Installed") == true) actualVersion = i;
}
if (actualVersion >= requiredVersion) {
  hasRightVersion = true;                
}


// [c]
// Write Flash object (no link)

function writeFlash(flashFile,altFile,altText,height,width){
	if(hasRightVersion) {
    flashContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
    + 'height="' + height + '" width="' + width + '" '
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="' + flashFile + '">'
    + '<param name="play" value="true">'
    + '<param name="loop" value="false">'
    + '<param name="quality" value="high">'
    + '<param name="menu" value="false">'
    + '<embed src="' + flashFile + '"'
    + 'height="' + height + '" width="' + width + '" '
    + 'alt="' + altText + '" '
    + 'play="true" loop="false" quality="high" menu="false" '
    + 'type="application/x-shockwave-flash"'
    + 'pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
    + '<\/embed>'
    + '<\/object>';
    document.write(flashContent);
  } else {
    altContent = '<div><img src="' + altFile +'" height="' + height + '" width="' + width + '" alt="' + altText + '" ></div>';
    document.write(altContent);
	}
}


// [d]
// Write Flash promo banner object (with link)

function writeFlashPromo(flashFile,altFile,height,width,promoLink,promoText){
	if(hasRightVersion) {
    flashContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
    + 'height="' + height + '" width="' + width + '" '
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="' + flashFile + '">'
    + '<param name="play" value="true">'
    + '<param name="loop" value="false">'
    + '<param name="quality" value="high">'
    + '<param name="menu" value="false">'
    + '<embed src="' + flashFile + '"'
    + 'height="' + height + '" width="' + width + '" '
    + 'alt="' + promoText + '" '
    + 'play="true" loop="false" quality="high" menu="false" '
    + 'type="application/x-shockwave-flash"'
    + 'pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
    + '<\/embed>'
    + '<\/object>';
    document.write(flashContent);
  } else {
    altContent = '<a href="http://www.play.com/' + promoLink +'">'
	  	+ '<img src="' + altFile +'" height="' + height + '" width="' + width + '" alt="' + promoText + '" >'
		  + '<\/a>';
    document.write(altContent);
	}
}


// [e]
// Competition banner

function competitionBanner(competitionFile,productID,productRegion,imgFile,imgWidth,imgHeight,altText){
bannerLink = '<div><a href="javascript:competitionPopUp(\'' + competitionFile + '\',\'' + productID + '\',\'' + productRegion + '\');"'
  + 'title="' + altText + '">'
  + '<img src="http://www.play.com/newimages/' + imgFile + '"'
  + 'width="' + imgWidth + '" height="' + imgHeight + '" alt="' + altText + '" \/><\/a></div>';
document.write(bannerLink);
}

// [f]
// Competition popup

function competitionPopUp(competitionFile,productID,productRegion){
// Create popup
popupURL = "http://competition.play.com/"+competitionFile
popupName = productID;
popupFeatures = "width=610,height=550,left="+(screen.availWidth-620)+",top=0,resizable=no,scrollbars=yes"
popup = window.open(popupURL,popupName,popupFeatures);
// Place content into original browser window
if(productID != '') {
 productID.toLowerCase();
 if(productID.indexOf("promo_") == -1){
  if(productID.indexOf("link_") == -1){
   document.location.href = "http://www.play.com/play247.asp?page=title&r="+productRegion+ "&title="+productID;
		}	else {
			productID=productID.replace("link_", "");
			document.location.href = "http://www.play.com/play247.asp?page="+productID;
		}
 } else {
  productID=productID.replace("promo_", "");
  document.location.href = "http://www.play.com/play247.asp?page=promo&r="+ productRegion + "&id="+productID;
 }
}
// Bring popup to front
popup.focus();
}


// [g]
// Siteseal banner

function sitesealBanner(){
// Construct banner link
bannerLink = '<div><a href="javascript:sitesealPopup();" title="Verisign Secure Site: click to verify">'
  + '<img src="../../img/footer_siteseal.gif" width="85" height="46" alt="Verisign Secure Site: click to verify" />'
  + '</a></div>';
// Write link
document.write(bannerLink);
}


// [h]
// Siteseal popup

function sitesealPopup(){
popup = window.open('https://servicecenter.verisign.com/cgi-bin/Xquery.exe?Template=authCertByIssuer&remote_host=https://digitalid.trustwise.com/globalServer/cgi-bin/haydn.exe&form_file=../fdf/authCertByIssuer.fdf&issuerSerial=c84ad9c2c59c6c67e514b9cea5bf676d', 'siteseal', 'toolbar=0,menubar=0,location=0,status=0,scrollbars=1,width=720,height=450');
popup.focus();
}


// [i]
// Standard popups

function popupEmail() {
	window.open('popup-friend.htm','email','toolbar=0,menubar=0,location=0,status=0,scrollbars=1,width=400,height=575');
}

function popupMistake() {
	window.open('popup-mistake.htm','mistake','toolbar=0,menubar=0,location=0,status=0,scrollbars=1,width=400,height=380');
}

function popupClose() {
	window.close();
}
