
// <script type="text/javascript">var bbSite='http___online-nhl.eu'; var bbMainDomain='intext.billboard.cz';</script>
// <script type="text/javascript" src="http://code.intext.billboard.cz/code/http___online-nhl.eu/code.js"></script>


$(document).ready(function() {
    $('#step3block').click(function() {
      $.blockUI({ message: "<br><h1>Probíhá přepočítávání záznamů</h1>", css: { width: '500px', height: '46px' } });
//       $('.blockOverlay').attr('title','Click to unblock').click($.unblockUI);
    });
    $(".sortable").each(function(){
    	$(this).tablesorter({
    		cssDesc : 'desc',
    		cssAsc : 'asc'
    	/*
    		textExtraction: function(node)
		{
			if( node.innerHTML.toString().search(/^[0-9]+\.$/) ){
				//alert(parseInt(node.innerHTML).toString());
				return parseInt(node.innerHTML).toString();
			} else {
				return node.innerHTML.toString();
			}
		}
	*/});
    });
  });



/*
 * Originaly from:
 * http://www.somacon.com/p355.php
 */

  String.prototype.trim = function() {
  	return this.replace(/^\s+|\s+$/g,"");
  }

  function trim(stringToTrim) {
  	return stringToTrim.replace(/^\s+|\s+$/g,"");
  }

  function in_array(needle, haystack, strict) {
      // http://kevin.vanzonneveld.net
      // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
      // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
      // *     returns 1: true

      var found = false, key, strict = !!strict;

      for (key in haystack) {
          if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
              found = true;
              break;
          }
      }

      return found;
  }

/*
 * Originaly from:
 * http://www.bram.us/2008/02/01/javascript-isarray-check-if-an-elementobject-is-an-array/
 */

  function isArray(obj) {
      return obj.constructor == Array;
  }

/*
 * fix IE li:hover problem
 */

  navHover = function() {
          var lis = document.getElementById("sectionmenu").getElementsByTagName("LI");
          for (var i=0; i<lis.length; i++) {
                  lis[i].onmouseover=function() {
                          this.className+=" iehover";
                  }
                  lis[i].onmouseout=function() {
                          this.className=this.className.replace(new RegExp(" iehover\\b"), "");
                  }
          }
  }
  if (window.attachEvent) window.attachEvent("onload", navHover);

/*
 * Admin functions:
 */

  function get(e)
  {
    return document.getElementById(e);
  }

  function createXHR()
  {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
  }

  function submenu( index )
  {
    for(i=0; true ;i++)
    {
      try{
        document.getElementById('menu_' + i.toString()).style.display="none";
      } catch(e){ break; }
    }
    document.getElementById('menu_' + index).style.display="block";
    return false;
  }

  function helper(kind_of_help)
  {
    alert('Funkce není dokončená!');
  }

  function get_radio_value(radio_name)
  {
    radio = document.getElementsByName(radio_name);
    for(var i=0; i < radio.length; i++)
    {
      if( radio[i].checked )
      {
        return radio[i].value;
        break;
      }
    }
  }

  function array_keys(arr)
  {
    var keys = new Array();
    for( key in arr )
    {
      keys.push(key);
    }
    return keys;
  }

  function changecolor(tr,inpt)
  {
    r = document.getElementById(tr);
    i = document.getElementById(inpt);
    switch(i.checked)
    {
      case true: r.className='on'; break;
      case false: r.className='off'; break;
      default: r.className='on'; break;
    }
  }

  function addfield(e)
  {
    e = document.getElementById(e);
    //e.innerHTML += "<br><input type=\"text\" name=\"questions[]\" value=\"\" class=\"question\">\n    ";
    e.innerHTML = e.innerHTML.replace(/$/, "<br><input type=\"text\" name=\"questions[]\" value=\"\" class=\"question\">\n    ");
  }

  function addfield_upload(e)
  {
    e = document.getElementById(e);
    e.innerHTML = e.innerHTML.replace(/$/, "<br><input type=\"file\" name=\"file[]\" onchange=\"addfield_upload('uploadf');\">\n    ");
  }

  function load_image(path)
  {
    var e = document.getElementById('thumbnail');
    e.innerHTML="<img src='"+path+"' alt='' id='thumbnailimg' onclick='hide_image();' onload='show_image();'>";

    return false;
  }

  function show_image(path)
  {
    var e = document.getElementById('thumbnail');
    var i = document.getElementById('thumbnailimg');
    var img_w = parseInt(i.naturalWidth);
    var img_h = parseInt(i.naturalHeight);
    var w_w = parseInt(window.innerWidth);
    var w_h = parseInt(window.innerHeight);

    var e_top = parseInt((w_h-img_h)/2);
    var e_left = parseInt((w_w-img_w)/2);

    if( e_top <= 0 && e_left <= 0 ){
      e.style.margin='0px'; }
    else if( e_top <= 0 ){
      e.style.marginTop=e_top+'px';
      e.style.marginBottom=e_top+'px'; }
    else if( e_left <= 0 ){
      e.style.marginLeft=e_left+'px';
      e.style.marginRight=e_left+'px'; }
    else {
      e.style.margin=e_top+'px '+e_left+'px '+e_top+'px '+e_left+'px'; }

    e.style.display='block';
  }

  function getElementPosition(element)
  {
    var x=0,y=0;
    while (element!=null){
    x+=element.offsetLeft-element.scrollLeft;
    y+=element.offsetTop-element.scrollTop;
    element=element.offsetParent;
    }
    return {x:x,y:y};
  }

  function getuserlist(element)
  {
    var x,e = element;
    var d = document.getElementById('fixeduserlist');

    window.userlistinput = e;
    window.userlistref = d;

    var e_h = parseInt(e.offsetHeight);
    var e_t,e_l,p = getElementPosition(e);
    e_t = p.y;
    e_l = p.x;

    d.style.top = e_t+e_h+3+'px';
    d.style.left = e_l+'px';
    d.style.display='block'; //alert(e_t+e_h+3+'px '+e_l+'px');
  }

  function choise_from_userlist(username)
  {
    e = window.userlistinput;
    e.value = username;

    d = window.userlistref;
    d.style.display='none';
  }

  function validate(ref, valuereg, id)
  {
    var tick = './themes/admin/icons/tick.png'
      , cross = './themes/admin/icons/cross.png'
      , wcheck = ref.value;

    var matched = wcheck.match(valuereg);
    eval("matches = matched.length");

    if( wcheck.length >0 && matches>0 ) { get(id).src=tick; }
    else                                { get(id).src=cross; }
  }

  /*function sendData(var_name, var_val, confirm_it=NULL)
  {
    var from = document.data_sender;

    return true; //document.getElementById('form').submit();
  }*/




