/****************************************
CONSTANTS
 *****************************************/
//accomp ribbons folder
var ACCOMP_RIBBONS_PATH = webroot + "img/accomp_ribbons/";

var GOLD = "gold"; //available gold_popup states
var NO_POPUP = ""; //var ACCOMPLISHMENT = "accomp";
var ACCOMPLISHMENT = "accomp";
var gold_popup;
var gold_flash; //the swf
var gold_swfReady = false;
var gold_popup_is_go_bottom = false;

/****************************************
		INITIALIZATION
 *****************************************/
//called by the swf when it's ready to use
function swfready(){
	gold_swfReady = true;
	gold_flash = document.getElementById("gold_flashPopUp");
	hidePopUp();
}


/****************************************
		SHOW POPUP
 *****************************************/
//show gold_popup
//set its state and arguments
function showPopUp(state,arg){
	if (IN_FBOOK && !gold_popup_is_go_bottom){
		gold_popup_is_go_bottom = true;
		document.location.href = "#inner_footer";
	}
	if (!gold_swfReady) {
		setTimeout("showPopUp('"+state+"',"+arg+")", 1000);
		return;
	}
	$('#gold_popup').css('bottom','0px');
	$('#gold_popup').css('right','20px');
	gold_popup = document.getElementById("gold_popup");
	gold_flash = document.getElementById("gold_flashPopUp");
	if(!gold_popup) return;
	gold_popup.style.visibility = "visible";
	if(!gold_flash) return;
	gold_flash.setState(state,arg);
	if (IN_FBOOK){
		document.location.href = "#inner_footer";
	}
}

//hide the gold_popup
//can be called by the SWF
function hidePopUp(){
	//move the popup out of screen so that it is not shown
	$('#gold_popup').css('bottom','-230px');
	$('#gold_popup').css('right','-590px');
	if(gold_swfReady == false) return;
	//gold_popup.style.visibility = "hidden";
	//empty the gold_popup
	gold_flash.setState(NO_POPUP);
}

/****************************************
		REDIRECTIONS
 *****************************************/
//called when users click on the Gold-gold_popup's Go Shopping button
function goShopping(){
	location.href = webroot + "shop";
}
//called when users click on the Accomplishment-gold_popup's Check Out button
function goCheckOutGold(){
	location.href = webroot + "profile/accomplishment";
}

/****************************************
		SWFOBJECT
 *****************************************/

var gold_flashvars = {};
var gold_params = {};
gold_params.scale = "noscale";
gold_params.salign = "br";
gold_params.wmode = "transparent";
gold_params.menu = "false";
gold_params.allowScriptAccess = "always";

var gold_attributes = {};
gold_attributes.align = "right";
gold_attributes.id = "gold_flashPopUp";
gold_attributes.name = "gold_flashPopUp";
var src = webroot + 'img/popup/MobracerPopUp.swf';
swfobject.embedSWF(src, "gold_altContentPopup", "100%", "230", "9.0.124", "expressInstall.swf", gold_flashvars, gold_params, gold_attributes);
