 
$(function(){
	var loader=$('#loader');
	var pollcontainer=$('#pollcontainer');
	loader.fadeIn();
	//Load the poll form
	$.get('/poll.php', '', function(data, status){
		pollcontainer.html(data);
		animateResults(pollcontainer);
		pollcontainer.find('#viewresult').click(function(){
			//if user wants to see result
			loader.fadeIn();
			$.get('/poll.php', 'result=1', function(data,status){
				pollcontainer.fadeOut(1000, function(){
					$(this).html(data);
					animateResults(this);
				});
				loader.fadeOut();
			});
			//prevent default behavior
			return false;
		}).end()
		.find('#pollform').submit(function(){
			var selected_val=$(this).find('input[name=poll]:checked').val();
			if(selected_val!=''){
				//post data only if a value is selected
				loader.fadeIn();
				$.post('/poll.php', $(this).serialize(), function(data, status){
					$('#formcontainer').fadeOut(100, function(){
						$(this).html(data);
						animateResults(this);
						loader.fadeOut();
					});
				});
			}
			//prevent form default behavior
			return false;
		});
		loader.fadeOut();
	});
	
	function animateResults(data){
		$(data).find('.bar').hide().end().fadeIn('slow', function(){
							$(this).find('.bar').each(function(){
								var bar_width=$(this).css('width');
								$(this).css('width', '0').animate({ width: bar_width }, 1000);
							});
						});
	}
	
});

$(document).ready(function(){


//   Cufon.replace('.home h3,.away h3', {fontFamily:'Adelaide CE',fontSize:'18px'}); 
//   Cufon.replace('.skore-zapasu', {fontFamily:'Adelaide CE', marginTop:'105px',fontSize:'45px',color:'#cc3333',textShadow: '1px 1px 1px #000'}); 

   Cufon.replace('#featured h2', {fontFamily:'Adelaide CE', fontSize:'14px'}); 
   Cufon.replace('#featured h2 a', {fontFamily:'Adelaide CE', fontSize:'14px',hover:true});
   Cufon.replace('#featured h1', {fontFamily:'Adelaide CE', fontSize:'14px'}); 
   Cufon.replace('#featured h1 a', {fontFamily:'Adelaide CE', fontSize:'14px',hover:true});

   Cufon.replace('.info-clanku', {fontFamily:'Bahamas CE', fontSize:'13px',fontWeight:'normal',lineHeight:'5'}); 
   Cufon.replace('.info-clanku a', {fontWeight:'normal', hover: true}); 
   Cufon.replace('#stats-format', {fontFamily:'Bahamas CE', fontSize:'11px'}); 
   Cufon.replace('.napis-liga, .napis-copa, .napis-lm', {fontFamily:'Bahamas CE', fontSize:'18px', color:'#d30d0d'});
   Cufon.replace('.popisek_obrazku', {fontFamily:'Bahamas CE'}); 
   Cufon.replace('.article-nadpis', {fontFamily:'Adelaide CE',fontSize:'22px',textShadow: '2px 1px 2px #ccc'}); 
   Cufon.replace('.profil-tym-jmeno', {fontFamily:'Adelaide CE',fontSize:'16px',textShadow: '1px 1px 2px #999'}); 
   Cufon.replace('h4.levy-vysledek, h4.pravy-vysledek', {fontFamily:'Adelaide CE',fontSize:'25px'}); 
   Cufon.replace('.popis-zdroje', {fontFamily:'Bahamas CE', fontSize:'13px',fontWeight:'normal'}); 
Cufon.replace('.dalsimatch', {fontFamily:'Adelaide CE',fontSize:'13px'}); 
Cufon.replace('.adelaide', {fontFamily:'Adelaide CE'}); 
Cufon.replace('.brooklyn11', {fontFamily:'Brooklyn',fontSize:'11px'});


 if ($('.chat-hide').length != 0) {

$('.zapasovy-chat').html($('.chat-hide').html());
//$('.chat-2').css('display', 'block'); 
}

$('.uvod-clanku-report').html($('.uvod').html());
$('.obrazek-clanku-report').html($('.obrazek-clanku-stadard').html());


 if ($('.souvisejici-hide').length != 0) {

$('.souvisejici-pridej').html($('.souvisejici-hide').html());

}

   Cufon.replace('.pravy-box .nahore', {fontFamily:'Adelaide CE', fontSize:'13px'}); 

//Set default open/close settings
$('.acc_container').hide(); //Hide/close all containers
$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

//On Click
$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
	}
	return false; //Prevent the browser jump to the link anchor
});



/// PROFILOVÉ MENU
    $('.profilove-menu').hover( function(){ // změna pozadí položky menu po najetí
    if($(this).css('background-color') != 'rgb(211, 13, 13)' && $(this).css('background-color') != 'rgb(211,13,13)' && $(this).css('background-color') != '#d30d0d'){
            $(this).css('background-color', '#3399FF');
         }

    })
    
    $('.profilove-menu').mouseout( function(){ // změna pozadí položky menu po odjetí myší

    if($(this).css('background-color') != 'rgb(211, 13, 13)' && $(this).css('background-color') != 'rgb(211,13,13)' && $(this).css('background-color') != '#d30d0d'){
            $(this).css('background-color', '#fff');
       }
    });


    $('.profilove-menu').click( function(){ // funkce po kliknutí na položku menu
       $('.profilove-menu').css('background-color', '#fff'); 
       $(this).css('background-color', 'rgb(211,13,13)');
       $('.profilove-menu').css('color', '#434040');
       $(this).css('color', '#fff');
       $('.profil-item').css('display', 'none'); 
       jmeno_divu = '#'+$(this).attr('id')+'-div';
       $(jmeno_divu).css('display', 'block'); 
    });

//Larger thumbnail preview 

$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-39px', 
			marginLeft: '-39px', 
			top: '0', 
			left: '0', 
			width: '100px', 
			height: '100px', 
			padding: '5px' 
		}, 200);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '6px', 
			left: '0', 
			width: '25px', 
			height: '25px', 
			padding: '3px'
		}, 400);
});

 
});  

function ukazme(id) {
document.getElementById("pristizapas").style.display="none";
document.getElementById("minulyzapas").style.display="none";
document.getElementById(id).style.display="block";
}
function go(s)
{
var t=s.options[s.selectedIndex].value;
if (t!="") window.location.href=t;
}




function Odpoved(jmeno) {
if(document.formularek.messageGB.value=="") {
document.formularek.messageGB.value = "[b]"+jmeno+"[/b]: ";
}
else
{
document.formularek.messageGB.value = document.formularek.messageGB.value + "\r\r[b]"+jmeno+"[/b]: ";
}
}


function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}


var my_div = null;
var newDiv = null;

$(document).ready(function(){

 	if ($.browser.msie) {
		$("#featured > ul").tabs({event: 'mouseover',fx:{height: "toggle", duration: "normal"}}).tabs("rotate", 5000, false); 
 
 	}
	else
	{
		$("#featured > ul").tabs({event: 'mouseover',fx:{opacity: "toggle", duration: "fast"}}).tabs("rotate", 5000, false); 
	}

 
});

function WSR_getElementsByClassName(_2,_3,_4){
var _5=(_3=="*"&&_2.all)?_2.all:_2.getElementsByTagName(_3);
var _6=new Array();
_4=_4.replace(/\-/g,"\\-");
var _7=new RegExp("(^|\\s)"+_4+"(\\s|$)");
var _8;
for(var i=0;i<_5.length;i++){
_8=_5[i];
if(_7.test(_8.className)){
_6.push(_8);
}
}
return (_6);
}

function odkaz(url){

document.location.href = url;
}

function ukaz(id) {
if (document.getElementById("show_"+id).style.display == ""){
show = "none";
show2 = "";
}
else{
show = "";
show2 = "none";
}
document.getElementById("show_"+id).style.display = show;
document.getElementById("ukazka_"+id).style.display = show2;
}

      function nahled(image,popis) {
      document["profil_hrace"].src = image;
//      document["profil_hrace"].style.borderColor = 'black';
//      document["profil_hrace"].style.border = '1';
        document["profil_hrace"].style.border = '1px solid #cccccc';
      var textContent = document.getElementById('popisek_obrazku');
      document.getElementById('popisek_obrazku').innerHTML = popis;
      }


 function setPointer(theRow, thePointerColor)
 {
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
 }


function Smajlik(co) {
        document.formularek.kobsah.value = document.formularek.kobsah.value + co;
}


function pridej_soupisku()
{
if (document.getElementById('soupiska')== null)
{
// create a new div element
// and give it some content
newDiv = document.createElement("div");
newDiv.id = "soupiska";
newDiv.innerHTML = "potřebuješ flash";
// add the newly created element and it's content into the DOM
my_div = document.getElementById("header");
my_div.appendChild(newDiv);
var so = new SWFObject("http://www.real-madrid.cz/vypis/soupiska.swf", "zapasy_m", "845", "530", "8", "#000046");
so.addParam("wmode", "transparent");
so.write("soupiska");
}
}
function schovej_soupisku () {
if (document.getElementById('soupiska')!= null)
{
var t = document.getElementById('soupiska');
t.parentNode.removeChild(t);
}
}

function rozbal(id){
     var i = 1; 
     while(document.getElementById('menu_id_'+i))     {
          document.getElementById('menu_id_'+i).style.display = 'none';
          document.getElementById('menu_'+i).className = '';
          i = i+1;
     } 
     document.getElementById('menu_'+id).className = 'menu-a';
     document.getElementById('menu_id_'+id).style.display = 'inline';    
}
function zmiz(){
     var i = 1;
     while(document.getElementById('menu_id_'+i))     {
          document.getElementById('menu_id_'+i).style.display = 'none';
          document.getElementById('menu_'+i).className = '';
          i = i+1;
 
     }
}
function zmiz2(){
document.getElementById('menu_1').className = 'menu-a';
document.getElementById('menu_id_1').style.display = 'inline';

}


function bublinoviny(e){
lbActions=WSR_getElementsByClassName(document,"a","napovedna");
for(i=0;i<lbActions.length;i++){
if(window.addEventListener){
lbActions[i].addEventListener("mouseover",zobrazbublinu,false);
lbActions[i].addEventListener("mouseout",schovejbublinu,false);
}else{
lbActions[i].attachEvent("onmouseover",zobrazbublinu);
lbActions[i].attachEvent("onmouseout",schovejbublinu);
}
}
}
function zobrazbublinu(_b){
var _c;
if(_b["srcElement"]){
	_c=_b["srcElement"];
}else{
	_c=_b["target"];
}
if (_c.href == undefined){
	_c=_c.parentNode;
}
var _d=_c.href;
var _qq=_c.name;
var _e=findPos(_c)[0]+5;
var _f=findPos(_c)[1]+17;
var _10=document.createElement("div");
document.getElementsByTagName("body")[0].appendChild(_10);
_10.className="previewbubble";
if (BrowserDetect.browser == 'Explorer') {
_10.style.width="240px";
_10.style.position="absolute";
_10.style.top=_f;
_10.style.zIndex=99999;
_10.style.left=_e;
_10.style.textAlign="left";
_10.style.height="190px";
_10.style.paddingTop="0";
_10.style.paddingLeft="0";
_10.style.paddingBottom="0";
_10.style.paddingRight="0";
_10.style.marginTop="0";
_10.style.marginLeft="0";
_10.style.marginBottom="0";
_10.style.marginRight="0";
_10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImagePath + "',sizingMethod='image')";
} else {
_10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+_f+"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;");
}
if (BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Konqueror' ) {

var _height = _f;
    
_10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+ _height +"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;");
    
}
var vlozeny = document.createElement("div");
_10.appendChild(vlozeny);
vlozeny.appendChild(document.createTextNode(_qq));
vlozeny.style.marginTop="27px";
vlozeny.style.marginLeft="24px";
vlozeny.style.marginBottom="12px";
vlozeny.style.marginRight="12px";
vlozeny.style.textAlign= "justify";
vlozeny.style.color= "#ff6600";
vlozeny.style.fontSize= "16px";
}


function schovejbublinu(_12){
lbActions=WSR_getElementsByClassName(document,"div","previewbubble");
for(i=0;i<lbActions.length;i++){
lbActions[i].parentNode.removeChild(lbActions[i]);
}
}
if(window.addEventListener){
addEventListener("load",bublinoviny,false);
}else{
attachEvent("onload",bublinoviny);
}

function setPointer(theRow, thePointerColor)
 {
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
 }

