jQuery(document).ready(function() {
  
  //IE6 hover background image caching fix (removes hourglass flicker)
  //Author: Dan Popa - http://www.mister-pixel.com/
  try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) { }
    
      $(".tab04 li").click( function() { 
        chosen=$(this).attr("class");
        $(".tab04 #tabs li").removeClass("active");
        $(".tab04 div").removeClass("active");
        
        $(this).addClass("active"); 
        
        
        $(".tab04 #"+chosen).addClass("active");
        
        return false;
      });
      
    $("#log-login").click( function() {
    
      $("#log-checkbox").css("display","block");
        
    });
    
    // TODO1
    // PRE class="password" pri registracii 
    // treba asi spravit javascriptovu kontrolu onKeyPress="return pismenacisla(event);
    
  $(".password").bind("keypress", pismenacisla  );
  
  $("#diskuse").mousedown(function(e) {
  
    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	  
    }
  
  });
    

});


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

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 setImage (imgname,type,path)
	{
	$("#user_image").attr('src',imgname);
	$("#user_icon").attr('value',path);
	$("#user_avtype").attr('value',type);
	
	}








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

document.onclick = doSomething;
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 == 'profil') 
		{

			riadok=targ.parentNode.href.split('?');

			nazov=riadok[1].split('&id_user=');
			nazov=nazov[1].split('&');
			nazovokna='id'+nazov[0];

			popwin ("http://www.hokejportal.sk/pages_user/profil.php?"+riadok[1],nazovokna,473,500);
		
			return false;


		}

		if (targ.parentNode.className == 'pro') 
		{

			riadok=targ.parentNode.href.split('?q=');

			nazov=riadok[1].split('/');

			nazovokna='id'+nazov[0];

			popwin ("http://www.hokejportal.sk/pages_user/profil.php?p=profil&id_user="+nazov[1]+"&username="+nazov[2],nazovokna,473,500);


		
		return false;


		}

		
		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;


		}
}



function popwin(cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=no,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open(cesta,'info',WinFeatures);
	}

function showpic(language,cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=no,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open('showpic.php?language='+language+'&path='+cesta,'info',WinFeatures);
	}

function showpic_scrollbar(language,cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=yes,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open('showpic.php?language='+language+'&path='+cesta,'info',WinFeatures);
	}


function targetBlank(href) {
	var newWindow = window.open(href, "print_page", "toolbar=yes,titlebar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes");

	if(!newWindow) return false;
	return true;
}


function stripHTML(oldString) {

var re= /<\S[^>]*>/g; 
oldString = oldString.replace(re,""); 
return oldString;
  
}

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('Prosím vložte správnu e-mailovú adresu!');
    field.focus();
    field.select();
  }
}




