// JavaScript Document
/* iSpeakVideo class
 * This code is provided as isCopyrighted 2007 Bambit Technolgoies, Inc.
 * and licensed to iSpeakVideo
 * Unauthorized reproduction is illeagal
 * This copyright notice must remain intact.
 */
var iSpeakVideo_Global;

function hideWhenFinished() {
	iSpeakVideo_Global.HideWhenFinished();
	document.getElementById('video_img').style.display = 'inline';
	//document.getElementById('video_img').style.cursor = 'cursor:hand;cursor:pointer;';
}

function iSpeakVideo() {
	this.src="";
	this.width="";
	this.height="";	
	this.top = 0;
	this.left = 0;
	this.RequiredVersionMajor=9;
	this.RequiredVersionMinor=0;
	this.needFlashString="Flash Version "+this.RequiredVersionMajor+"."+this.RequiredVersionMinor+" is needed.<br/><a href='http://www.adobe.com/go/getflash/' target='_blank'>Get it here</a>";
	this.isIE = (document.body.attachEvent) ? true : false;
	this.ParseBrowser();
	
	return this;
}

iSpeakVideo.prototype.ParseBrowser=function() {
	this.isNetscape=false;
	this.isFirefox=false;
	this.isIE=false;
	this.isOpera=false;
	this.isSafari=false;
	this.appName=navigator.appName;
	this.appVersion=navigator.appVersion;
	if(this.appName=="Netscape"&&parseFloat(this.appVersion)>4.7) {
		var uai=navigator.userAgent.indexOf("Firefox");
		if(uai!=-1) {
			this.isFirefox=true
			this.browserVersionMaj=parseInt(navigator.userAgent.charAt(uai+8));
		} else {
			this.isNetscape=true;
			this.browserVersionMaj=parseFloat(this.appVersion);
		}
	} else {
		var uai=navigator.appVersion.indexOf("MSIE");
		if(uai!=-1) {
			this.isIE=true;
			var temp=navigator.appVersion.split("MSIE")
			this.appVersion=parseFloat(temp[1]);
			this.browserVersionMaj=parseInt(this.appVersion);
		} else {
			var uai=navigator.userAgent.indexOf("Opera");
			if(uai!=-1){
				this.isOpera=true;
				this.browserVersionMaj=parseInt(navigator.userAgent.charAt(uai+6));
			}
		}
	}
	if(document.compatMode=='CSS1Compat') {
		this.isCompatible=true;
	} else {
		this.isCompatible=false;
	}
}

iSpeakVideo.prototype.Intialize=function() {
	iSpeakVideo_Global=this;
	
	this.DisplayFlash();
}

iSpeakVideo.prototype.CheckFlashVersion = function() {
	var maj=0;
	var min=0;
	if(navigator.plugins != null && navigator.plugins.length > 0) {
		if(navigator.plugins["Shockwave Flash"]) {
			var d=navigator.plugins["Shockwave Flash"].description;
			var a=d.split(" ");
			var version=a[2];
			var a1=version.split(".");
			maj=a1[0];
			min=a1[1];
		} 
	}
	else {
		try {
			// version will be set for 7.X or greater players
			var o = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		 	var d = o.GetVariable("$version");
			var a=d.split(" ");
			var version=a[1];
			var a1=version.split(",");
			maj=a1[0];
			min=a1[1];
		} catch (e) {
		}
	}
	if(maj>this.RequiredVersionMajor || (maj==this.RequiredVersionMajor && min>=this.RequiredVersionMinor)) { return true;}
	else {	return false;}
}
	
iSpeakVideo.prototype.HideWhenFinished=function(){
	document.getElementById('iSpeakVideo_Container').style.display='none';
}

iSpeakVideo.prototype.SetPositionStyleInfo=function() {
	document.getElementById('iSpeakVideo_Container').style.marginTop = this.top+'px';
	document.getElementById('iSpeakVideo_Container').style.marginLeft = this.left+'px';
}

iSpeakVideo.prototype.DisplayFlash=function() {
	this.SetPositionStyleInfo();
	
	if(this.CheckFlashVersion()) {
		document.getElementById('iSpeakVideo_Container').style.display = 'block';
		document.getElementById('iSpeakVideo_Container').innerHTML = this.WriteMovieObject();
	}
	else {
		document.getElementById('iSpeakVideo_Container').innerHTML = '<div id="iSpeakVideo_Container_NeedFlash">' + this.needFlashString + '</div>'
	}
}


var shown=0;
var lastNum=0;

iSpeakVideo.prototype.WriteMovieObject=function() {
	var lOutput = '';
	lOutput += '<object ';
	lOutput += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0" width="';
	lOutput += this.width+'px" height="'+this.height+'">\n';
	lOutput += '\t<param name="movie" value="'+this.src+'" />\n';
	lOutput += '\t<param name="quality" value="high" />\n';
	lOutput += '\t<param name="menu" value="false" />\n';
	lOutput += '\t<param name="wmode" value="transparent" />\n';
	lOutput += '\t<embed src="'+this.src+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="';
	lOutput += this.width+'px" height="'+this.height+'" menu="false"></embed>\n';
	lOutput += '</object>\n';
	
	return lOutput;
}
