/* ONCLICK - OLD IMPLEMENTATION */
document.onclick = doSomething;

function popwin(cesta, nazov, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=yes,status=no,resizable=no,width='+width+',height='+height;
	ShowWindow = window.open(cesta,nazov,WinFeatures);
	}


function doSomething(e)
{
	

	//var targ;
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug

	targ = targ.parentNode;

	//alert(targ.tagName); // porovnavat na A  funguje v IE, FF
       
     


		
		if (targ.parentNode.className == 'reply') 
		{

		pid	= targ.parentNode.id;
		outdform=dform.replace('{parent-id}',pid);
		targ.parentNode.className='reply2';
		targ.parentNode.innerHTML=outdform;

		
		return false;


		}
		
	   if (targ.parentNode.className == 'confirm')
     {       
      return confirm('Naozaj si želáte vykonať príkaz?');
    }
}

/*ONCLICK for profile new implementation */
$(document).ready(function()     
{
//user profile show
  $("body").mousedown(function(e) {   
  

   //alert('ide');
    if ($(e.target).attr("class")=='profil' && $(e.target).attr("rel")!=='profil-atatched') {
      $(e.target).attr('rel','profil-atatched'); //zabránime aby sa thicbox inicializoval viackrát    
      tb_init($(e.target)); //apply thickbox only to clicked element	  
    }
    
    //V pripade ze klikol na objekt ktory je vnutri linku
     if ($(e.target).parent().attr("class")=='profil' && $(e.target).parent().attr("rel")!=='profil-atatched') {
      $(e.target).parent().attr('rel','profil-atatched'); //zabránime aby sa thicbox inicializoval viackrát    
      tb_init($(e.target).parent()); //apply thickbox only to clicked element	  
    }
    
    //V pripade ze klikol na objekt ktory je vnutri linku
     if ($(e.target).parent().attr("class")=='reply') 
     {
     
        /*
      		outdform=dform.replace('{parent-id}',pid);
      		targ.parentNode.className='reply2';
      		targ.parentNode.innerHTML=outdform;
        */
        /*
      		pid	= $(e.target).parent().attr("id");
      		alert (pid);
        
        return false;
        */	  
     }    
    
   

    if ($(e.target).attr("class")=='hmin' || $(e.target).attr("class")=='hplu') 
    {     
    


    
      var idp=$(e.target).attr("tabindex");
      var forum=$(e.target).attr("rel");
      idp=idp.replace('#','&pid=');
      
      var mylink=forum+idp+'&action=plusminus';
     //alert(mylink);
                
         $(e.target).parent().parent().fadeTo(100,0.3);
         
      		$.get(mylink,
      		  { }, 
      		  function(data){
        			//alert("Data Loaded: " + data);
        			if (data=='OK!')
        			{
        			 
        			  
        			  
        			} 
              else if (data=='NOTOK!')
              {
                 
                 $(e.target).parent().parent().fadeTo(100,0);
                 
              }
            } 
   
      		);
      
      	
      
      	
      return false;     
      
    } 

  
    
  });
});

/*functions.js */
$(document).ready(function(){

$("#close-ustrizok").click(function(){

  $("#ustrizok").toggle();

});



	$(".znamka").click( function() { 

		totok=$(this);
    totok.parent().children().removeClass("vybrata_znamka");

	mylink = $(this).attr("href")+'&ahah=1';
		$.get(mylink,
		  { }, //name: "John", time: "2pm"
		  function(data){
			//alert("Data Loaded: " + data);
			if (data=='ok')
			{
			//$("a.znamka").removeClass("vybrata_znamka");
			
			totok.addClass("vybrata_znamka");
			} 
      else if (data=='ok-votes-removed')
      {
        $("a.znamka").removeClass("vybrata_znamka");
				totok.addClass("vybrata_znamka");
      } 
      else if (data=='access-denied')
      {
        alert('Tento rozhodca v tomto zápase sa už nedá známkovať.');
      } 
      else
      { 
      alert (data+'Ak chcete známkovať rozhodcov, musíte byť prihlásení.'); }
		  }
		);

	return false;

	});
	

});


function switchMenu(content){
	obj=document.getElementById('IDmainMenu');
	obj.className='CSSmenuCONTENT'+content;
	
	
	
	document.getElementById('SubMenuuvod').className='Moff';
	document.getElementById('SubMenuspravy').className='Moff';
	document.getElementById('SubMenulive_vysledky').className='Moff';
	document.getElementById('SubMenulive_prenosy').className='Moff';
	document.getElementById('SubMenuzabava').className='Moff';
	document.getElementById('SubMenutipovacka').className='Moff';
	document.getElementById('SubMenuuzivatelia').className='Moff';
	document.getElementById('SubMenublog').className='Moff';
	document.getElementById('SubMenuPodSpravy').className='Moff';
	
		
	
	/* onmouseout="javascript:switchMenu('none')" */
	
  /*
  obj1=document.getElementById('Menu'+content);
  obj1.className='act';
  */
	obj=document.getElementById('SubMenu'+content);
	obj.className='Mon';
	
}




function switchTopXY(obj, show){
	/*
	obj.className='CSStopXY'+obj.value;
	*/
	obj.parentNode.parentNode.className='CSStopXY'+show;
	document.getElementById('ncc').className='vyp';
	document.getElementById('nhd').className='vyp';
	document.getElementById(show).className='zap';
}

var scroll_speed=0;
function scrollIt(id, speed){
	if(speed){
		scroll_speed=speed;
	}
	obj=document.getElementById(id);
	obj.scrollTop=obj.scrollTop+Math.round(scroll_speed);
	tmpid=id;
	scroll_timeout=setTimeout("scrollIt(tmpid)", 20);
}

function scrollStop(){
	clearTimeout(scroll_timeout);
}



function letternumber(e)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
// control keys
if ((key==null) || (key==0) || (key==8) || 
(key==9) || (key==13) || (key==27) )
return true;
// alphas and numbers
else if (((":0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}	


function showpic(cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=no,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open('showpic.php?path='+cesta,'info',WinFeatures);
	}



function isEmailAddress (string) {
  var addressPattern = 
    /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return addressPattern.test(string);
}
function checkEmail (field) {
  if (!isEmailAddress(field.value)) {
    alert('Please enter correct email address!');
    field.focus();
    field.select();
  }
}

// script by 1999 Idocs, Inc. http://www.idocs.com
function pismenacisla(e)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
// control keys
if ((key==null) || (key==0) || (key==8) || 
(key==9) || (key==13) || (key==27) )
return true;
// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}	

/*
startList=function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("IDddmenu").firstChild;
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" CSSover";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" CSSover", "");
				}
			}
		}
	}
}


window.onload=startList;
*/

//user profile settings
function setImage (imgname,type,path)
	{
	$("#user_image").attr('src',imgname);
	$("#user_icon").attr('value',path);
	$("#user_avtype").attr('value',type);
	
	}

function livepopup() 
	{
	WinFeatures = 'scrollbars=no,status=no,resizable=no,width=270,height=270';
	ShowWindow = window.open('live_window.php','info',WinFeatures);
	}


function uploadpopup(parameter) 
	{
	WinFeatures = 'scrollbars=no,status=no,resizable=no,width=320,height=60';
	ShowWindow = window.open('pages_user/upload_popup.php'+parameter,'info',WinFeatures);
	}
function insertimagepopup() 	
	{
	WinFeatures = 'scrollbars=yes,status=no,resizable=yes,width=422,height=400';
	ShowWindow = window.open('pages_user/filemanager/browse.php','info',WinFeatures);
	}

function setownImage (imgname)
	{
	document.settings_form.user_icon.value=imgname;
	document.user_image.src = 'icony/users/'+imgname;
	}

function setownPhoto (imgname,cislo_adresara)
	{
	foto_id=imgname.split("."); 
	document.fotozabava_form.foto_id.value=foto_id[0];
	document.user_image.src = 'photos_zabava/thumb'+cislo_adresara+'/'+imgname;
	pathpath= 'photos_zabava/thumb'+cislo_adresara+'/'+imgname;
	}


function fixLiveFrame (newsize) {

vyska=newsize+20+5;
document.getElementById('live2-iframe').style.cssText='width:255px; height:'+vyska+'px';

}




