 function get_Element(id)	{

  if(document.getElementById) 	{ selected_Element = document.getElementById(id); } 
    else if(document.all)	{ selected_Element = document.all[id]; } 
     else return;

   return selected_Element;
}




function showHide(id, action)	{

   if(document.getElementById) 	{
      				 element = document.getElementById(id);
   				} 
    else if(document.all) {
      			   element = document.all[id];
   			  } 
     else return;

 if(action == 'sh')	{

   if(element.style) {

      		      if(element.style.display == 'block' ) 	{ 
			 					 element.style.display = 'none';
								} 
    		       else 	{
			    	 element.style.display = 'block';
				}

   		     }

			}

  else if(action == 's')	{
				 element.style.display = 'block';
				}

  else if(action == 'h')	{
				 element.style.display = 'none';
				}


				}


function deleteItem(val, link, text)	{

   if(document.getElementById) 	{
      				 element = document.getElementById(val);
   				} 
    else if(document.all) {
      			   element = document.all[val];
   			  } 
     else return;

 var id= element.options[element.selectedIndex].value;
 var answer = confirm(text);
  if(answer)	{
   document.location.href= link + "." + id;
		}

				}

//-------------------------------------------------------------------------------------------------------------------
//	zmiana orazy tła 


function replaceImage(id, img)	{


   if(document.getElementById) 	{
      				 document.getElementById(id).style.backgroundImage='url(images/flags/'+ img +'.gif)';
   				} 
    else if(document.all) {
      			   element = document.all[id].style.backgroundImage='url(images/flags/'+ img +'.gif)';
   			  } 
     else return;

				}


//-------------------------------------------------------------------------------------------------------------------
//	wstawianie textu na zewnarz zaznaczonej frazy/textu


function insertOutsideSelected(myField, val1, val2) {

//IE support

 if (document.selection) {
			  currentText= document.selection.createRange().text;
			  myField.focus();
			  sel = document.selection.createRange();
			  sel.text = val1 + currentText + val2;
			 }

//MOZILLA/NETSCAPE support
 
  else if (myField.selectionStart || myField.selectionStart == '0')	{
								
	var startPos = myField.selectionStart;
	var endPos = myField.selectionEnd;
	var selectedText= myField.value.substring(startPos, endPos);
	myField.value = myField.value.substring(0, startPos) + val1 + selectedText + val2 + myField.value.substring(endPos, myField.value.length);

									}
   else {
	 currentText= myField.value;
	 myField.value = val1 + currentText + val2;
	}
					}


//-------------------------------------------------------------------------------------------------------------------
//	wstawianie textu w miejscu gdzie znajduje sie kursor


function insertAtCursor(myField, val) {

//IE support

 if (document.selection) {
			  myField.focus();
			  sel = document.selection.createRange();
			  sel.text = val;
			 }

//MOZILLA/NETSCAPE support
 
  else if (myField.selectionStart || myField.selectionStart == '0')	{
								
	var startPos = myField.selectionStart;
	var endPos = myField.selectionEnd;
	myField.value = myField.value.substring(0, startPos) + val + myField.value.substring(endPos, myField.value.length);

									}

   else {
	 myField.value += myValue;
	}
					}


//-------------------------------------------------------------------------------------------------------------------
//	wstawianie textu na zewnarz zaznaczonej frazy/textu


function splitString(string, separator)	{

	var arrayOfStrings = string.split(separator);

	return arrayOfStrings;

					}


function insertSourceStrings(string, separator, form, field1, field2)	{

	var arrayOfStrings= splitString(string, separator);


	document.forms[form].elements[field1].value= arrayOfStrings[0];
	document.forms[form].elements[field2].value= arrayOfStrings[1];


									}

function selectReplay(id)	{

  document.add_comment.comment_reply.value= id;

				}


 /* Dodawanie do ulubionych */


function addToFavorites(page) {

    // internet explorer

    if ((navigator.userAgent.toLowerCase().indexOf('msie') > 0) && window.external)

	{
        window.external.AddFavorite(page, document.title);
    	}

    //fire fox || opera

    else if (window.sidebar && window.sidebar.addPanel)
 	{
        window.sidebar.addPanel(document.title, page, null);
    	}

    // pozostałe przegladarki

    else
	 {
         alert('Naciśnij ctrl+d');
    	 }

    return false;
			}


/*funkcje do menu na górze*/

function at_display(x)	{

  win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');

			}

//menu



function menuClick(id, id2)	{

 var d = document.getElementById(id);
 var c = document.getElementById(id2);

  for (var i = 1; i<=10; i++)	{

   if (document.getElementById('mchild'+i))	{ 

    var e = document.getElementById('mchild'+i);	// odwolanie do wybranego potomka
    var f = document.getElementById('mparent'+i);   // odwolanie do rodzica aktywnego potomka

    e.style.display='none';

    if(f != c)	{
     if(f.className='menu_parent_active')	{
						 f.className='menu_parent';
						}
																	}
		}
				}

  if (d)	{

   d.style.display='block';		// pokazujemy wybrane submenu
   c.className= 'menu_parent_active';	// zaznaczona opcja menu

		}

				}


function menuHover(id)	{

  var d = document.getElementById(id);
  if(d.className != 'menu_parent_active')	{ d.className='menu_parent_hover'; }


			}

function menuOut(id)	{

  var d = document.getElementById(id);
  if(d.className !='menu_parent_active')	{ d.className='menu_parent'; }

			}

//scroller 

var scrollSpeed=2;

var timerLeft="";
var timerRight="";


function scrollDivLeft(id){
  clearTimeout(timerRight)
  get_Element(id).scrollLeft+=scrollSpeed
  timerRight=setTimeout("scrollDivLeft('"+id+"')",1)
}

function scrollDivRight(id){
  clearTimeout(timerLeft) 
  get_Element(id).scrollLeft-=scrollSpeed
  timerLeft=setTimeout("scrollDivRight('"+id+"')",1)
}

function stopScroll(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}

//wstawianie textu
//wstawianie textu
function putInnerText(id, text) {
  text1= "<div class='events-hide'><a href='#' class='hide-events-box'>ukryj </a> | </div>";
  get_Element(id).innerHTML=text1+text

}

function showBetType(text) {
  if(text.length > 0) {
   get_Element('user_bet_info').innerHTML= "zwycięstwo drużyny <strong>" +  text + "</strong>";
  }
  else {
   get_Element('user_bet_info').innerHTML= "<strong>remis</strong>";
  }


}


//efekty wykorzystane prze pokazywaniu wydarzen
//new Effect.SlideDown('events');
//new Effect.SwitchOff('events');

function submitForm(form) {
document.forms[form].submit();
}


/*JQuery*/

$(document).ready(function(){
	//colorbox
	/*$("a[rel='example1']").colorbox();*/
	$("a[rel='lightbox[group]']").colorbox({transition:"fade", slideshow:true});
	
	$("div.events_selected").toggle(function() {
		$("div.events_box").slideDown("slow");
	}, function() {
		$("div.events_box").slideUp("slow");
	});
	
	$('a.hide-events-box').live('click', function() {
		$("div.events_box").slideUp("slow");
	});
	
//sortowanie tabel
//column 1 - by place name

$("a.sort-by-lp").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 1,
		keepRelationships: true,
		sortType: 'numeric'
	});
});	

$("a.sort-by-name").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 2,
		keepRelationships: true
	});
});	

$("a.sort-by-games").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 3,
		keepRelationships: true,
		sortType: 'numeric',
		sortDesc: true
	});
});	

$("a.sort-by-points").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 4,
		keepRelationships: true,
		sortType: 'numeric',
		sortDesc: true
	});
});	

$("a.sort-by-wins").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 5,
		keepRelationships: true,
		sortType: 'numeric',
		sortDesc: true
	});
});	

$("a.sort-by-draws").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 6,
		keepRelationships: true,
		sortType: 'numeric'
	});
});	

$("a.sort-by-lost").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 7,
		keepRelationships: true,
		sortType: 'numeric'
	});
});	

$("a.sort-by-goals").click(function() {
	$('#tab-seniorzy').sortTable({
		onCol: 7,
		keepRelationships: true,
		sortType: 'numeric'
	});
});	
		
	
});



