/* Bambit Static Setter
 * This code is provided as is Copyrighted 2009 Bambit Technolgoies, Inc.
 * Unauthorized reproduction is illeagal
 * This copyright notice must remain intact.
 */
var FlashSetter_Global;

function FlashSetter() {
    this.src="";
    this.width="";
    this.height="";	
    this.Position
	this.Location=new this.Point();
	this.Location.X=0;
    this.Location.Y=0;
	this.PositionMode='absolute';
	this.anchorMode = 'static';
	this.positionFrom = 'fromBottom';
	this.positionHorizontalFrom='fromLeft';
	this.ReferenceID=null;
	if(document.body.attachEvent) { this.isIE=true;} else { this.isIE=false;}
	this.ParseBrowser();
	this.NeedsFix=false;
	this.WriteWrapper=true;
	this.FlashVars='';
    this.urlArray=null;
    this.InitialX = 0;
    this.RequiredVersionMinor = 0;
    this.RequiredVersionMajor = 9;
}

FlashSetter.prototype.el = function(e) { return document.getElementById(e); }

function RestorePosition() {
    FlashSetter_Global.FixFF15Position();
}

FlashSetter.prototype.Initialize = function() {
    FlashSetter_Global = this;    this.InitialX = this.Location.X;

    if (this.ReferenceID != null && this.el(this.ReferenceID) != null) {
        this.AnchorToObjectX();
        this.LockInitialX();
    }
    this.positionMode = 'fixed';
    if (this.isIE) {
        if (this.appVersion != 7 || !this.isCompatible) {
            this.positionMode = 'absolute';
            this.NeedsFix = true;
        }
    }
    if (this.isFirefox && this.browserVersionMaj < 2) {
        this.positionMode = 'absolute';
        window.addEventListener('scroll', RestorePosition, false);
        window.addEventListener('size', RestorePosition, false);
    }
    this.WriteDiv();
    
    if (this.ReferenceID != null && this.el(this.ReferenceID) != null) {
        this.AnchorToObjectX();
    }
}

FlashSetter.prototype.GetObjectAbsoluteX = function(o) {
    var x;
    x = 0;
    while (o != null) {
        x += o.offsetLeft;
        o = o.offsetParent
    }
    return x;
}


FlashSetter.prototype.AnchorToObjectX = function() {
    if (this.isIE) {
        window.attachEvent('onresize', AnchorResizedX);
        window.attachEvent('onload', AnchorResizedX);
    } else {
        window.addEventListener('load', AnchorResizedX, false);
        window.addEventListener('resize', AnchorResizedX, false);
    }
}

FlashSetter.prototype.Point = function(x, y) {
    this.X = x;
    this.Y = y;
}


FlashSetter.prototype.LockInitialX = function() {
    var src = this.el(FlashSetter_Global.ReferenceID);
    var srcLoc = this.GetObjectAbsoluteX(src);
    this.InitialX = srcLoc + this.Location.X;
}


FlashSetter.MouseX=function( e ) {


	return e.pageX || ( e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft ) );
}
FlashSetter.MouseY=function ( e ) {
	return e.pageY|| ( e.clientY + ( document.documentElement.scrollTop|| document.body.scrollTop ) );
}


FlashSetter.prototype.trace=function(t) {
	alert(t);
}

FlashSetter.prototype.GetTimeCookie=function() {
	this.cookie= this.gc("isvTime");
	return this.cookie;
}

FlashSetter.prototype.GetPlayCookie=function() {
	this.playCountCookie= parseInt(this.gc("playCount"));
	if(isNaN(this.playCountCookie)) { this.playCountCookie=0;}
	
	return this.playCountCookie;
}


FlashSetter.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;
	}
}



FlashSetter.prototype.PlaceElement=function (o,s,l,t) {
	var obj=this.el(o); var src=this.el(s);
	var srcLoc=GetObjectPosition(src);
	var nl=l+srcLoc[0];
	var nt=t+srcLoc[1];
	obj.style.left=nl + 'px';
	obj.style.top= nt + 'px';
}
FlashSetter.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; }

}
	

FlashSetter.prototype.GetObjectPosition=function(o) {
	var l,t;
	l=t=0;
	if(o.offsetParent) {
		l=o.offsetLeft;
		t=o.offsetTop;
		while((o=o.offsetParent)) {
			l+=o.offsetLeft;
			t+=o.offsetTop;
		}
	}
	return [l,t];
}

FlashSetter.prototype.HideWhenFinished=function(){
	this.el('FlashSetter_Container').style.display='none';
}

FlashSetter.prototype.GetObjectAbsoluteLocation=function(o) {
	var p=new this.Point(0,0);
	while(o!=null) {
		p.X+=o.offsetLeft;
		p.Y+=o.offsetTop;
		o=o.offsetParent
	}
	return p;
}

FlashSetter.prototype.GetObjectAbsoluteY=function(o) {
	var y;
	y=0;
	while(o!=null) {
		y+=o.offsetTop;
		o=o.offsetParent
	}
	return y;
}

FlashSetter.prototype.WriteStandardContainer= function(){
	document.write('<div id="FlashSetter_Container" style="z-index:10001;');
	this.WritePositionStyleInfo();
	document.write('z-index: 10000;border: 0px; width:'+this.width+'px;height:'+this.height+';">');
}

FlashSetter.prototype.WritePositionStyleInfo=function() {
		
	document.write('position: '+this.positionMode+'; ');
	if(this.positionFrom=='fromBottom')
	{
		document.write('bottom: ');
	}
	else {document.write('top: ');}
	document.write(this.Location.Y+'px; ');
	if(this.positionHorizontalFrom=='fromLeft')
	{
		document.write('left: ');
	}
	else
	{
		document.write('right: ');
	}

	document.write(
	this.InitialX+'px;'); 
//	this.Location.X
}
FlashSetter.prototype.WriteNeedFlashContainer= function(){
	document.write('<div id="FlashSetter_Container" style="');
	this.WritePositionStyleInfo();
	document.write('z-index: 10000;border: 0px; width:'+this.width+'px; background-color:#FFF; padding:4px 4px 4px 4px; border:inset 3px #F00 ">');
}

FlashSetter.prototype.WriteDiv = function() {

if (this.CheckFlashVersion()) {
    
		if(this.WriteWrapper) {
		
			this.WriteStandardContainer();
		}
		this.WriteMovieObject();
	}
	else {
		this.WriteNeedFlashContainer();
		this.WriteNeedFlash();
	}
	if(this.NeedsFix){
		this.FixIEFixed();
	}
	if(this.WriteWrapper) {
		document.write('</div>');
	}
}
FlashSetter.prototype.WriteNeedFlash=function() {
		document.write(this.needFlashString);
}

	
function AnchorResizedX() {
	var obj=FlashSetter_Global.el('FlashSetter_Container');
	var src=FlashSetter_Global.el(FlashSetter_Global.ReferenceID);
	var srcLoc=FlashSetter_Global.GetObjectAbsoluteX(src);
	var nl=video.Location.X+srcLoc;
	obj.style.left=nl + 'px';
}

function getIEFixHeight() {
	var loc;
	var scrollTop;
	var clientHeight;
  if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
    clientHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
    clientHeight  = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
    clientHeight  = document.body.clientHeight;
  }
	if( typeof( window.pageYOffset ) == 'number' ) {	//Netscape compliant
    scrollTop = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant
    scrollTop = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrollTop = document.documentElement.scrollTop;
  } else {scrollTop=0;}
	if(FlashSetter_Global.positionFrom=='fromBottom'){
		loc=scrollTop+clientHeight-FlashSetter_Global.Location.Y-FlashSetter_Global.el('FlashSetter_Container').clientHeight ;	
	} else {
		loc=scrollTop+FlashSetter_Global.Location.Y;
	}
	return loc;
}

FlashSetter.prototype.WriteMovieObject = function() {
    document.write('<object ');
    if (!this.WriteWrapper) {
        document.write(' id="FlashSetter_Container"  style="');
        this.WritePositionStyleInfo();
        document.write('z-index: 1000;"');
    } else {
        document.write(' id="FlashSetter_Container_o"  ');
    }
    document.write(' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0" width="');
    document.write(this.width + 'px" height="' + this.height + '">\n');
    document.write('\t<param name="movie" value="' + this.src + '" />\n');
    document.write('\t<param name="quality" value="high" />\n');
    if (this.FlashVars != '') {
        document.write('\t<param name="FlashVars" value="' + this.FlashVars + '"');
    }
    document.write('\t<param name="menu" value="false" />\n');
    document.write('\t<param name="wmode" value="transparent" />\n');
    document.write('\t<embed id="FlashSetterVideo" src="' + this.src + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
    document.write(this.width + 'px" height="' + this.height + '" menu="false"');
    if (this.FlashVars != '') {
        document.write('FlashVars="' + this.FlashVars + '"');
    }
    document.write('></embed>\n');
    document.write('</object>\n');
}

FlashSetter.prototype.FixIEFixed=function(){
	if(document.body.currentStyle['backgroundImage']=='none')
	{
		document.body.style.backgroundImage='url('+this.backgroundImage+')';
		document.body.style.backgroundRepeat='no-repeat';
		document.body.style.backgroundAttachment='fixed';
	}
	this.el('FlashSetter_Container').style.setExpression('top','getIEFixHeight()');
}

FlashSetter.prototype.FixFF15Position=function(){
	var scrollTop=	window.pageYOffset;
	var clientHeight=window.innerHeight;

	if(this.InitialHeight== undefined) { this.InitialHeight=this.el('FlashSetter_Container').clientHeight;}
	if(this.positionFrom=='fromBottom'){
		loc = scrollTop + clientHeight - 
				this.Location.Y-this.InitialHeight ;	
	} else {
		loc=scrollTop+FlashSetter_Global.Location.Y;
	}
	this.el('FlashSetter_Container').style.top=loc+'px';
}

