/** init flash titles **/

function setDimensions(id, width, height) {
	//alert("setDimensions(" + id + ", " + width + ", " + height + ");");
	try {
		var titleObject = document.getElementById(id);
		titleObject.style.width = width + 'px';
		titleObject.style.height = height + 'px';
		//titleObject.style.border = '1px solid red';
		//titleObject.childNodes[0].width = width + '0px';
		//alert(titleObject.childNodes[0].width + ' id=' + titleObject.childNodes[0].id);
	}
	catch(e) {
		
	}
	//return null; // pouzita ako getURL("javascript: setDimensions()"); vo flashPlayeri
}

// window.onload event handler
function addOnLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
/* pouzitie
addOnLoadEvent(function() {  
    document.body.style.backgroundColor = 'yellow';  
});
*/



/** flash komunikacia **/
function getFlashMovieObject(movieName) {
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    	if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	}
	else { // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		return document.getElementById(movieName);
	}
}
/** vloz/zisti variable v _root swf **/
function SendDataToFlashMovie(movieName, varName, value) {
	try {
		var flashMovie = getFlashMovieObject(movieName);
		flashMovie.SetVariable("/:"+varName, value);
	}
	catch(e) {
		return false;
	}
}

function ReceiveDataFromFlashMovie(movieName, varName) {
	try {
		var flashMovie = getFlashMovieObject(movieName);
		if(typeof(flashMovie) != 'undefined') {
			return flashMovie.GetVariable("/:"+varName);
		}
		else {
			return false;
		}
	}
	catch(e) {
		return false;
	}
}

/** TODO - doladit casovu kontrolu v realnej prevadzke **/
function manageSWFObjectSize(SWFobject, movieName, htmlId) {
	var Dimensions = ReceiveDataFromFlashMovie(movieName, 'Dimensions');
	//alert(Dimensions);
	//alert(Dimensions + ', SWFobject.Tint = ' + SWFobject.TintCnt);
	if(Dimensions != false && Dimensions != 'false'/* && Dimensions != null && Dimensions != 'null'*/) {
		if(Dimensions == 'ok') {
			clearInterval(SWFobject.Tint);
			//delete(SWFobject); /**clearinterval nestihne prebehnut ked vymazem objekt*/
			// opera fix
			var titleObject = document.getElementById(htmlId);
			titleObject.style.visibility = 'hidden';
			setTimeout('var titleObject = document.getElementById("'+htmlId+'"); titleObject.style.visibility = \'visible\';',300);
			
		}
		else if(typeof(Dimensions) == 'string') {//alert(typeof(Dimensions));
			var values = Dimensions.split(',');
			
			if(values.length == 3) {
				SendDataToFlashMovie(movieName, 'Dimensions', 'ok');
				clearInterval(SWFobject.Tint);
				//alert(Dimensions + ', SWFobject.Tint = ' + SWFobject.TintCnt);
				setDimensions(values[0], values[1], values[2]);
				//setTimeout('setDimensions',3000, values[0], values[1], values[2]);
			}
			else {
				SWFobject.TintCnt++;
			}
		}
		else {/**FF typeof(Dimensions) je Object - preco ? clearinterval nestihne prebehnut ked vymazem objekt*/
			//clearInterval(SWFobject.Tint);
			// opera fix
			var titleObject = document.getElementById(htmlId);
			titleObject.style.visibility = 'hidden';
			setTimeout('var titleObject = document.getElementById("'+htmlId+'"); titleObject.style.visibility = \'visible\';',300);
		}
	}
	else {
		SWFobject.TintCnt++;
	}
	
	if(SWFobject.TintCnt > 10) { // nepodarilo sa natiahnut
		clearInterval(SWFobject.Tint);
		//delete(SWFobject); //clearinterval nestihne prebehnut ked vymazem objekt
		// opera fix
		var titleObject = document.getElementById(htmlId);
		titleObject.style.visibility = 'hidden';
		setTimeout('var titleObject = document.getElementById("'+htmlId+'"); titleObject.style.visibility = \'visible\';',300);
	}
}

