var currentState = "NONE"; // Initialize the current state to none
var previousState = "NONE"; // Initialize the previous state to none
var player = null; // Set the player value to null

function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id); // GGet the id of the player
	addListeners(); // Call the addListeners function
}

function addListeners() {
	player?player.addModelListener("STATE", "stateListener"):setTimeout("addListeners()",100);
	// If player is true, addModeListener, otherwise, listen until the player becomes true
}

function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
	currentState = obj.newstate; // Get the obj's new state
	previousState = obj.oldstate; // Get the obj's old state

	if ((currentState == "COMPLETED")&&(previousState == "PLAYING"))	// If the flash has done playing
		ray.animate(); // Call the animate property of ray object
}

/**
Code Title: Animate Flash and Move Tabs Up
Author: Raymond Angana contracted via rentacoder.com [username=Raymond Angana]
Date Created: 1/13/09
This notice must stay intact for legal use
*/
var ray={
animate:function(){
	$('#flvplayer').html(''); // Remove the contents
	$('#flvplayer').animate({height:'320px'},1500); // Adjust the height
	$('div[id^=\'flake\']').show(); // Show the snow flakes
	}
}

$(document).ready(function(){
$('div[id^=\'flake\']').hide(); // Hide the snow flakes
	var flashvars = {
		file:"http://www.islamswomen.com/extras/video/flv/IslamsWomen-Promo.flv",
		backcolor:"60469b",
		frontcolor:"dfdaeb",
		lightcolor:"FFFFFF",
		screencolor:"000000", 
		autostart:"true"
	} // Flash variable config

	var params = {
		allowfullscreen:"true", 
		allowscriptaccess:"always",
		wmode:"transparent"
	} // Flash parameters

	var attributes = {
		id:"ply",  
		name:"ply"
	} // Flash attributes

	swfobject.embedSWF("../includes/player_home.swf", "container", "873", "460", "9.0.115", false, flashvars, params, attributes); // Embed the flash file on the page
	});