if(document.all){
	// fix background image flicker in IE6
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {

	}
}

snap_css = function() {
	var divContentStyle = document.getElementById("content").style;
	divContentStyle.position   = "relative";
	divContentStyle.position   = "static";
	divContentStyle.marginLeft = "0px";
}

if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", snap_css, false);
}

// Function to Add "_embed" for ID-based Access of Flash Video Player
function getEmbedFlag() {
	if (navigator.appName.indexOf("Microsoft") != -1) return '';
	else return '_embed';
}

//show video choices
function chooseVideo() {
	$('#choose-video').slideDown(1000);
	$('#flash_header').slideUp(500)
}

// swfobject functions to hide video when stopped or finished
function stateTracker(obj) {
	if(obj.newstate == 'COMPLETED') {
		$('#flash_header').fadeIn(500);
		$('#video').css({'height': '300px', 'display': 'none'});
	}
	if(obj.newstate == 'IDLE') {
		$('#flash_header').fadeIn(500);
		$('#video').css({'height': '300px', 'display': 'none'});
	}
	//console.log('Object: ' + obj.toSource());
};

var player;

//Watch for state of video
function playerReady(obj) {
	var id = obj['id'];
	var version = obj['version'];
	var client = obj['client'];
	player = document.getElementById(id);
	player.addModelListener("STATE","stateTracker");
};

function playVideo(id, width, height, desc, path) {
	var so = new SWFObject('http://www.harvest.org/flash/jwplayer.swf','video'+id, width, height,'9');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addParam('bgcolor','#000000');
		so.addParam('flashvars','&author=Harvest Ministries&description='+desc+'&file='+path+'&backcolor=000000&frontcolor=FFFFFF&lightcolor=888888&screencolor=000000&controlbar=over&autostart=true');
		so.write('player');
};

//Get the video
function getVideo(id, width, height, desc, path) {
	$('#choose-video').hide();
	$('#flash_header').hide();
	$('#video').slideUp().animate({height: height+'px', width: width+'px'}, 1000);
	playVideo(id, width, height, desc, path);
}