var $=function(id){return document.getElementById(id);}
var n_browser = navigator.userAgent;
function ClickSubmit(nameForm){$(nameForm).submit();return false;}
function WindowClose(){	window.close();	return false;}
function WindowBack(){window.history.back();return false;}
function ChangeValue( sign , elem, elem2){
	elem =elem + elem2 - 1;
	var tags = $('ContentMain').getElementsByTagName( 'input' );
	for (var i=0; i<tags.length; i++){
		var par = tags[i].parentNode;
		if( par.className == 'Item' ){
			var newVal = eval( parseInt( tags[elem].value ) + sign + 1 );
			if( newVal < 1 ) newVal = 1;
				tags[elem].value = newVal;
			break;
		}
	}
}
function ChangeText( pl, cont){
	while( pl.hasChildNodes() )
		pl.removeChild( pl.lastChild );
	var t = document.createTextNode(cont);
	pl.appendChild(t);
}
function Show(elem){
	var but = $('ContentMain').getElementsByTagName( 'button' );
	if( $(elem).style.display == 'none' || $(elem).style.display == ''  ){
		$(elem).style.display='block';
		var text ='zwiń';
	}else{
		$(elem).style.display ='none';
			var text = 'rozwiń';
	}
	if( but.length > 0 && text)
		for( var i=0; i<but.length; i++ )
			if( but[i].className != 'Link' )
				ChangeText( but[i], text );

	return false;
}

var nn = new String();
function getParent( elem ){
	var elems = elem.parentNode;
	if( elems.tagName == "TR")
		return elems;
	else
		return getParent( elems );
}
function FindTrTag( elem ){
	if( elem.tagName == "TR" )
		return elem;
	else{
		return getParent( elem );
	}
}
function DoOverM(){
	if( document.attachEvent ){
		var elem = FindTrTag(this.event.srcElement );
		nn = elem.className;
		elem.className = 'Select';
	}else{
		nn = this.className;
		this.className = 'Select';
	}
}
function DoOutM(){
	if( document.attachEvent ){
		var elem = FindTrTag(event.srcElement );
		elem.className = nn;
	}else{
		this.className = nn;
	}
}
function TableRow(){
	if (!$('ContentMain')) return;
	var tags=$('ContentMain').getElementsByTagName("tr");
	var z = 0;
 	for (var i=0; i<tags.length; i++){
		var name = tags[i].className;
		if(document.attachEvent && name != 'Head' && name != 'HeadCustom' && name !=  'Roll' && name !=  'Choosen' ){
			tags.item(i).attachEvent("onmouseover", DoOverM );
			tags.item(i).attachEvent("onmouseout", DoOutM );
		}
		if( tags.item(i).addEventListener && name != 'Head' && name !=  'Roll' && name != 'HeadCustom' ){
			tags.item(i).addEventListener("mouseover", DoOverM , false );
			tags.item(i).addEventListener("mouseout", DoOutM , false );
		}
	}
}
if( window.attachEvent ){
	window.attachEvent("onload", TableRow);
}
if( window.addEventListener ){
	window.addEventListener("load", TableRow, false);
}

function initActiveElement(id, nr, div)
{
	var list=$(id).getElementsByTagName("LI");
	var i;
	for(i=0;i<list.length;i++)
	{
		//$(div+i).className = 'hide';
		$(div+i).className = $(div+i).className.replace(/[ ]*block/g,'');
		$(div+i).className += ' hide';
		list[i].getElementsByTagName("A")[0].onclick = new Function('return setActiveElement("'+id+'",'+i+',"'+div+'")');
	}
	if(null!==nr) setActiveElement(id,nr,div);
}

function setActiveElement(id, nr, div)
{
	var list=$(id).getElementsByTagName("LI");
	var i;

	for(i=0;i<list.length;i++)
	{
		list[i].getElementsByTagName("A")[0].className = list[i].getElementsByTagName("A")[0].className.replace(/[ ]*Choosen/g,'');
		//$(div+i).className = 'hide';
		$(div+i).className = $(div+i).className.replace(/[ ]*block/g,'');
		$(div+i).className += ' hide';
	}
	list[nr].getElementsByTagName("A")[0].className+=" Choosen";
	//$(div+nr).className = 'block';
	$(div+nr).className = $(div+nr).className.replace(/[ ]*hide/g,'');
	$(div+nr).className += ' block';

	return false;
}


//strona glowna
function ShowBoxes()
{
    this.number = 0;	
	this.idbox = '';
    this.ShowBoxOn = ShowBoxOn;
    this.Showy = Showy;  
	this.SetBox = SetBox;  
	this.SetParam = SetParam;
}


function ShowBoxOn(  next ){
//alert(this.idbox + '/' + this.number );
	if( !$( this.idbox ) )
		return false;
 	var tags=$( this.idbox ).getElementsByTagName("li");	
	
	
	this.number=this.number + next;

	if( this.number == tags.length-2  ){
		this.number = tags.length-3; 
		return false;
	}
	
	if( this.number < 0 ) {
		this.number = 0;
		return false;
	}

	var number_n = this.number + 1;
	var number_nn = this.number + 2;	
	
	var z = 0;
	for (var i=0; i<tags.length; i++){
     	if( i == this.number || i == number_n || i == number_nn ){
			if( z == 0 ){			
				tags[i].style.width = '138px';
				tags[i].style.background = 'none';
				tags[i].style.paddingLeft = '0';
				//var bo = tags[i].childNodes;
				//bo = bo[0].getElementsByTagName("img");				
				//bo[0].style.marginLeft='6px';
				z++;
			}else{
				tags[i].style.width = '136px';
				tags[i].style.background = 'transparent url(/img/newest_li_back.gif) no-repeat scroll';
				tags[i].style.paddingLeft = '1px';
			}
			tags[i].style.display = 'block';
			
		}else
			tags[i].style.display = 'none';
	}
	return false;	
}

function SetBox(  next ){	
	this.ShowBoxOn( next );
	return false;
}

function Showy( ){
   	this.ShowBoxOn( 1 );	
	setTimeout(  "this.Showy()", 3600 );	
	
}


function SetParam(param){
	this.idbox=param;
}

var myShowy1 = new ShowBoxes();
myShowy1.SetParam('BoxRollover');
//myShowy1.Showy();


var myShowy2 = new ShowBoxes();
myShowy2.SetParam('BoxRollover2');
//myShowy2.Showy();