var MENU_STATUS_OPENED = "opened";
var MENU_STATUS_CLOSED = "closed";

var menuStatus = MENU_STATUS_OPENED;

var timeOutFunc = "";
var itv;
var rootPath = "../";
if(document.URL.indexOf("/dlj") > 0 || document.URL.indexOf("/ra") > 0) rootPath = "../../";

var flashPlayerDefaultConf = {
	configxml : rootPath + 'common/request/get_flv_player_config.php'
};

function getFlashPlayerDefaultConf(){
	var copyObj = {};
	for(var k in flashPlayerDefaultConf) copyObj[k] = flashPlayerDefaultConf[k];
	return copyObj;
}

var initialized = false;
var initialize;
$(document).ready(function() {
	_initialize();
	if(initialize != null) initialize();
	initialized = true;
} );

function _initialize(){
	replacePNGonIE6();
	
	var flashvars = {};
	swfobject.embedSWF(rootPath + "images/background.swf", "background", "100%", "100%", "9.0.124", "",
		flashvars, { bgcolor: "#000000", quality:"high", wmode:"opaque", allowscriptaccess:"sameDomain" }, { bgcolor: "#000000", id:"fbackground", name:"fbackground" });
	
	$("#navigation .navBckgd, #menu").mouseover( function(){ // $("#menu")
		timeOutFunc = "openMenu";
		clearTimeout(itv);
		itv = setTimeout("menuAction()", 0);
	} );
	
	$("#menu").mouseout( function(){ // $("#menu")
		timeOutFunc = "closeMenu";
		clearTimeout(itv);
		itv = setTimeout("menuAction()", 0);
	} );
	
	$("#footer .deco .bckgd").click( function(){
		if(document.URL.indexOf("/dlj") > 0 || document.URL.indexOf("/ra") > 0) document.location.href = "../index.php";
		else document.location.href = "index.php";
	} );
	
	setTimeout("_st_initialized()", 100);
}

function rollBckgd(way){
	var player;
	if(document && document.getElementById) player = document.getElementById("fbackground");
	else if(document) player = document["fbackground"];
	
	if(player != null) {
		try { player.roll(way); } catch(e){ }
	}
}

function openMenu(){
	if(menuStatus != MENU_STATUS_OPENED){
		$("#menu").stop();
		$("#menu").animate({ left: "0px" }, 1000, "easeOutCirc");
		menuStatus = MENU_STATUS_OPENED;
	}
}

function closeMenu(){
	if(menuStatus != MENU_STATUS_CLOSED){
		$("#menu").stop();
		$("#menu").animate({ left: "-191px" }, 1000, "easeOutCirc");
		menuStatus = MENU_STATUS_CLOSED;
	}
}

function menuAction(){
	if(timeOutFunc.length > 0) this[timeOutFunc]();
	timeOutFunc = "";
}

function replacePNGonIE6(){
	if($.browser.msie && parseFloat($.browser.version) < 7){
		var pngImages = $("img[src$='.png']");
		for(var a=0; a<pngImages.length; a++){
			var imgSrc = pngImages[a].src;
			var gifImg = imgSrc.substr(0, imgSrc.length - 4) + ".gif";
			pngImages[a].src = gifImg;
		}
	}
}

function _st_initialized(){
	if($("#content .main")) {
		$("#content .main").jScrollPane({ scrollbarWidth:21, showArrows:true, arrowSize:27, observeHash:false });
		$("#content .main").bind({
			emchange : function(){
				$("#content .main").jScrollPane({ scrollbarWidth:21, showArrows:true, arrowSize:27, observeHash:false });
			}
		});
	}
}

var refreshItv;
$(window).resize(function(){
	clearTimeout(refreshItv);
	refreshItv = setTimeout("location.reload(true)", 200);
});
