

/* Flash Video Player - Simple Abstraction		*/
/* ============================================ */

function VideoEmbed( w, h, flash, swf, autoPlay){

    // Initial Properties
    var t=this;
	t.autoPlay = autoPlay || true;
	t.flashVersion = 7;

	// Pass Params to Flash
	t.setParamsString = function(videoPath, name, autoplay){
		t.flashParams = 'flashVars=videoPath='+videoPath+'&autoPlay='+autoPlay+'&vidName='+name+'';
	}

	// Output the Flash Markup with Params
    t.writeFlash=function(flashObject,swfFile,width,height,bgcolor,ver,altFormat,params,target){
        if(flashObject && flashObject.hasVersion(ver)){
			flash.embedMovie(swfFile,width,height,bgcolor,ver,altFormat,params,target);
			flash.userHasFlash = true;
		}else{
			flash.userHasFlash = false;
		}
    }

	// Method Call to Embed the Video
	t.embedVideo = function(videoPath,name,containerElem, autoPlay){
		if(!autoPlay){autoPlay = true;}
		if(!$(containerElem)){return false;}else{$(containerElem).innerHTML = '';}
		t.setParamsString(videoPath, name, autoPlay);
		t.writeFlash(flash, swf, w, h, 'transparent', t.flashVersion, $(containerElem).innerHTML, t.flashParams, containerElem);
	}

	// Initialization
    t.init=function(){
		//console.log('hi');	
	}

   //initialize and fire
   t.init();

}


SmallVideo = new VideoEmbed(380, 270, flash, 'media/flash/hyatt.swf', true);
SmallWideVideo = new VideoEmbed(350, 306, flash, 'media/flash/flvplayer/video_small_wide.swf', false);
LargeVideo = new VideoEmbed(446, 375, flash, 'media/flash/flvplayer/video_big.swf', false);
LargeFullVideo = new VideoEmbed(446, 375, flash, 'media/flash/flvplayer/video_big_full.swf', false);

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

