var minWidth = 1000;
var minHeight = 763;
var directory = "";

// --------------------------------------------------------- SWFs 
// Creacion de SWF
function mainSWF() {
	setLevel(0);
	createCSSFull();
	var flashvarsObj = { };
	var paramsObj = {
		menu	: "false",
		bgcolor	: "#FFFFFF",
		scale	: "noscale",
		AllowScriptAccess : "always",
		wmode: 'opaque'
	};
	var attributesObj = {
		id		: "MainClip",
		name	: "MainClip"
	};
	swfobject.embedSWF(directory + "main.swf", "flashFullSWF", "100%", "100%", "9.0.0", false, flashvarsObj, paramsObj, attributesObj);
	swfobject.addDomLoadEvent(createFullBrowserFlash);
}
	
//  Patch para resize de flash al 100%
// ---------------------------------------------------------
function createCSSFull() {
	swfobject.createCSS("*", "margin:0; padding:0;");
	swfobject.createCSS("object", "display:block");
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "height:100%;");
	swfobject.createCSS(
		"#flashFull",
		"margin:0; width:100%; height:100%; min-width:" +
		minWidth + "px; min-height:" + minHeight + "px;"
	);
}

function getViewportSize() { 
	var size = [0, 0];
	if (typeof window.innerWidth != "undefined") {
		size = [window.innerWidth, window.innerHeight];
	}
	else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
		size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
	}
	else {
		size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight];
	}
	return size;
}

function createFullBrowserFlash() {
	window.onresize = function() {
		var el = document.getElementById("flashFull");
		var size = getViewportSize();
		el.style.width = size[0] < minWidth ? (minWidth + "px") : "100%";
		el.style.height = size[1] < minHeight ? (minHeight +"px") : "100%";
	};
	window.onresize();
}

// --------------------------------------------------------- Nivel de directorio
function setLevel(number) {
	directory = level(number);
	directoryLogout = level(number - 1);
}
function level(number) {
	var level_str = "";
	for (var a = 0; a < number; a++) {
		level_str += "../";
	}
	return level_str;
}
	
// --------------------------------------------------------- PopUps
function popUpw(url, wW, wH){ 
	var
	wX = (screen.width - wW)/2,
	wY = (screen.height - wH)/2,
	other = ',toolbar=no,scrollbars=no,resizable=no,menubar=no,status=no,directories=no,location=no',
	windowFeatures = 'width=' + wW + ',height=' + wH + ',left=' + wX + ',top=' + wY + other;
	window.open(url, 'ventana' + randRange(1, 100000), windowFeatures);
}
function randRange(min, max) {
	var randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
	return randomNum;
}

