/*
 ### jQuery custom functions pre firemnifinance.cz
 Martin 7.5.2010
*/

(function($){
	
  $.fn.outerHTML = function() { //mozilla nepozna outerHtml, takze si ju spravime
  // WARNING - pouzivat len pri prvkoch v premennych nie v DOMe, pretoze prvok obalujeme divom, alebo potom
  //nezabudnut div zmazat
  	if($(this)[0].outerHTML) return $(this)[0].outerHTML; //ak prehliadac podporuje atribut outerHTML, tak ho pouzijeme...
  	else return $('<div>').append( $(this).eq(0).clone() ).html();
  };

  $.fn.customizeLinks = function(){//console.log($(this).length);
  	if($(this).length == 0) return;
  	if(links = $().getLinks())
		$(this).after('<p class="table-btns"><a class="ico-print" href="'+links[0][0].href+'">Tisk výsledků</a>&nbsp;<a class="ico-xls" href="'+links[1][0].href+'">Export do XLS</a></p>');
  };
  
  $.fn.getLinks = function() { //vytiahne linky na xls a print 
  	var links = []; 
  	if($('#print-xls-links').length != 0){
	  	a = $('#print-xls-links').remove(); //odstranime div na tisk vysledku a export XLS
	  	a = a.find('a');
	  	links[0] = a.eq(0).addClass('ico-print'); //pridame potrebne triedy
	  	links[1] = a.eq(1).addClass('ico-xls');   	
	  	return links;
  	}else
  		return false;
  };
  
  $.fn.customizeTHead = function() { 
  	if($(this).length == 0) return;
  	th = $(this).find('th').remove();
  	
    console.log($(this).find('th'));
  };
  
  $.fn.test = function() { 
  	if($(this).length == 0) return;
    console.log('lol');
  };
  
})(jQuery);

