
var activeBrand = '';
function showText(id,aid) {
	var aobj = document.getElementById(aid);
	if (activeBrand != '') {
		Effect.BlindUp(activeBrand, { duration: 0.4 });
		if (activeBrand!=id) setTimeout('Effect.BlindDown(\''+id+'\', { duration: 0.4 })',400);
	} else {
		Effect.BlindDown(id, { duration: 0.4 });
	}
	aobj.blur();

	if (activeBrand == id) activeBrand = '';
	else activeBrand = id;

	return false;
}

var t7_storage_id = false;
var t7_storage_text = '';

function t7_get(id, text) {
	if (t7_storage_id) {
		var o = document.getElementById(t7_storage_id);
		o.className = '';
	}
	var o = document.getElementById(id);
	o.className = 'vybrany';
	t7_storage_id = id;
	t7_storage_text = text;
}

function t7_put(target) {
	// odstraneni "xxx" po kliknuti
	if (target.value == "xxx") target.value = '';
	// funkce napovedy
	if (t7_storage_id) {
		//var t = document.getElementById(target);
		target.value = t7_storage_text;
		var o = document.getElementById(t7_storage_id);
		o.className = '';
		t7_storage_id = false;
		t7_storage_text = '';
	}
}

function newwin(name,url,width,height,params) {
	if (!params) params='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no';
	picwin = window.open(url,name,"width=" + width + ",height=" + height + "," + params);
	picwin.focus();
}

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);
	}
}

function mp3_play(data) {
	var o = document.getElementById('mp3playerbox');
	o.style.visibility = 'visible';
    var invoker = "mp3"+data;
    data ="http://m.p.mobilem.cz/play.php?id_input="+data;
	var playerPosition = getElementPosition(invoker);
	//alert(playerPosition.left+' - '+playerPosition.top);
	var newxpos = playerPosition.left+25;
	if ( (newxpos+418) > 770 ) {
		newxpos = playerPosition.left-419;
		if (newxpos < 0 ) newxpos = 770-418;
	}
	o.style.top = (playerPosition.top+25)+"px";
	o.style.left = (newxpos)+"px";

	var flashMovie=getFlashMovieObject('mp3player');
	flashMovie.SetVariable("/:url", data);
}

function mp3_close_player() {
	var o = document.getElementById('mp3playerbox');
	o.style.visibility = 'hidden';
	var flashMovie=getFlashMovieObject('mp3player');
	flashMovie.SetVariable("/:url", '');
}


// FCE VRACI OBJEKT PODLE ZADANEHO ID
var getElementWithId;
if(document.getElementById){
	getElementWithId = function(id){
		return document.getElementById(id);
	}
}else if(document.all){
	getElementWithId = function(id){
		return document.all[id];
	}
}else{
	getElementWithId = function(id){
		return false;
	}
}

// VRACI OBJEKT OBSAHUJICI PROMENNE .TOP A .LEFT, KTERE OBSAHUJI SPRAVNE INFORMACE O POZICI PRVKU NA STRANCE (I V IE :)
function getElementPosition(elemID) {
    var offsetTrail = getElementWithId(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 &&
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}



// VLOZENI HTML KODU DO VRSTVY DLE ID
function update_div_html(objectId, html) {
	obj = getElementWithId(objectId);
	if(obj) {
		obj.innerHTML = html;
		return true;
	} else {
		return false;
	}
}

// VLOZENI HTML KODU DO VRSTVY DLE ID
function update_div_html_prepend(objectId, html) {
	obj = getElementWithId(objectId);
	if(obj) {
		obj.innerHTML = html+obj.innerHTML;
		return true;
	} else {
		return false;
	}
}

function stars(id,max){
//    var key_id = id.substr(id.length-1, 1);
//    var max = id.substr(id.length-1, 1);
    if(max == "clear"){
        this.timeout = new Array();
        this.timeout[id] = setTimeout(stars, 250, id, 0);
    }
    else{
        clearTimeout(this.timeout[id]);
        for (i = 1; i <= 5; i++) {
            var o = document.getElementById(id+"_"+i);
            var src = o.src;
            if(i <= max && src.indexOf("_act.gif") == -1){
                o.src = src.substr(0, src.length-4)+"_act.gif";
            }
            else if(i > max){
                if(src.indexOf("_act.gif") != -1){
                    o.src = src.substr(0, src.length-8)+".gif";
                }
            }
        }
    }
}

function gameBannerOver() {
    new Effect.Morph('bannerright', {
        style: 'width: 250px; height: 500px; background: url(../img/rightbanner_velky.jpg) no-repeat; display: block; position: absolute; right: 0px; top: 0px;',
        duration: 0.4
    });
}

function gameBannerOut() {
    new Effect.Morph('bannerright', {
        style: 'width: 48px; height: 500px; background: url(../img/rightbanner_velky.jpg) no-repeat; display: block; position: absolute; right: 0px; top: 0px;',
        duration: 0.7
    });
}
