// Big Brother JavaScript Document

function changUrl(url)
{

window.location=url;
}

/* @author:Damien W J King
   @copyright:Virgin Media
   @lastUpdated:24/5/06
   @description: function for outputting embed/object tags for i.e. issue with active x.
   @attibutes: please call with following - divID,codebase,width,height,id,align,movie,quality,bgcolor,wmode in this order as first 8 params.
   anything after this should be "paramName","paramValue" followed in pairs.
   @Function call example 
   <div id="flashContainer"></div>
	<script language="JavaScript" type="text/javascript">
	embedFlash("flashContainer","http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0","600","440","main","middle","http://www.virgin.net/cards/ecards.swf","high","#339999","Transperant","salign","T","swLiveConnect","TRUE");
	</script>
	<noscript>This page requires Javascript to be enabled and Macromedia Flash to be installed.</noscript>
	
   @Note: Removed some attributes like quality, seem to be causing type mismatch in ie6.
*/

var w3c=(document.getElementById)? true: false;
var ie5=(w3c && document.all)? true : false;
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;
var saf=(navigator.userAgent.indexOf('Safari')!=-1);

function embedFlash() {
	// standard flash attributes
	var classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	var type = "application/x-shockwave-flash";
	var pluginspage="http://www.macromedia.com/go/getflashplayer"
	var allowScriptAccess = "sameDomain";

	// get extra paramaters
	var DivID = arguments[0];
	var codebase = arguments[1];
	var width = arguments[2];
	var height = arguments[3];
	var id = arguments[4];
	var align = arguments[5];
	var movie = arguments[6];
	var quality = arguments[7];
	var bgcolor = arguments[8];
	var wmode = arguments[9];
	
	var obj = document.createElement('object');
	var div = document.getElementById(DivID);
	var img = document.createElement('image');
	
	var flashDetected = isFlashReady();

	if(flashDetected) {
		// append object
		if(!saf) {
			div.appendChild(obj);
		}	
		// set object attributes
		obj.setAttribute('width',width);
		obj.setAttribute('height',height);
		obj.setAttribute('align',align);
		obj.setAttribute('id',id);
		obj.setAttribute('codebase',codebase);
		obj.setAttribute('classid',classid);
		obj.setAttribute('bgcolor',bgcolor);
		obj.setAttribute('wmode',wmode);
		
		// reset params - ie 7 compatable yippy
		obj.movie = movie;
		//obj.quality = quality;
		//obj.allowScriptAccess = allowScriptAccess;
		
		// set embed for mozilla 
		var embed = document.createElement('embed');
		embed.setAttribute('src',movie);
		embed.setAttribute('bgcolor',bgcolor);
		embed.setAttribute('name',id);
		embed.setAttribute('type',type);
		embed.setAttribute('pluginspage',pluginspage);
		embed.setAttribute('width',width);
		embed.setAttribute('height',height);
		embed.setAttribute('wmode',wmode);
		
		// arrays for extra params
		xparams = new Array;
		xembed = new Array;

		if(arguments.length > 10 ) {
			i = 10;
			p = 0;
			while(i<arguments.length) {
				eval('obj.'+arguments[i]+'="'+arguments[i+1]+'";');
				embed.setAttribute(arguments[i],arguments[i+1]);
				i=i+2;
				p++;
			}
		}
		if(ns6)div.appendChild(embed); // added to fix ie jscript error
	} else {
		// no flash installed
		div.innerHTML = '<p class="TxtMed">This page requires Macromedia Flash to be installed</p>';
		div.innerHTML += '<p><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="http://www.virgin.net/pix/getFlash.gif" width="89" height="31" border="0" alt="Download Macromedia Flash"/></a></p>';
	}
}

//Flash Detection

function isFlashReady() {
	 var MM_FlashCanPlay = false;
	 var detected = false; 
     var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
     if(plugin) {
          detected = true;
     } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {				   
		// IE flash detection.
		var detected = ieDetection();

	 }
	 return detected;
}

function ieDetection() {
	for(var i=0; i<10; i++){
		flashVersion = 0;
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashVersion = i;
			return true;
		}
		catch(e){
		}
		
	}
}
