var selectedImg = null;

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("mainMenu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

//obsługa menu górnego
function przygotuj()
{
	//pobieram wszystkie anchory z diva "mainMenu"
	var menu = document.getElementById("mainMenu").getElementsByTagName("li");
	for(i = 0; i < menu.length; i++)
	{
		//przypisanie do akcji ONLCIK funckji "zmienPrzycisk"
		if( menu[i].className == 'lvl1' )
		{
			menu[i].onmouseover = function() { this.style.background = 'url(./Firms/Komako/images/mm_left.gif) no-repeat'; }
			menu[i].onmouseout = function() { this.style.background = 'url(./Firms/Komako/images/m_pipe.jpg) right top no-repeat'; }
		}
	}
}

function changeBg( id, photo )
{
	var zakladki = document.getElementById("paginesBox").getElementsByTagName("a");
	for(d = 0; d < zakladki.length; d++)
	{
		zakladki[d].className = "";
	}
	for(k = 1; k < 4; k++ )
		document.getElementById('p'+k).style.display = 'none';

	document.getElementById("s"+id).className="selected";
	var image = 'url(./Firms/Komako/images/welcomebox/'+photo+')';
	document.getElementById('welcomeBox').style.backgroundImage = image;
	document.getElementById('p'+id).style.display = 'block';
}
var changingIndex = 1;
var changingHandler;
var foto1;
var foto2;
var foto3;

function startChanging(){
  switch (changingIndex)
  {
	case 1:
	  changeBg(changingIndex, foto1);
	  break;
	case 2:
	  changeBg(changingIndex, foto2);
	  break;
	case 3:
	  changeBg(changingIndex, foto3);
	  break;
		
  }
  changingIndex++;
  if (changingIndex == 4){
    changingIndex = 1;
  }
}
function stopChanging(){
  window.clearInterval(changingHandler)
}
function setChanging(pFoto1, pFoto2, pFoto3){
  foto1 = pFoto1;
  foto2 = pFoto2;
  foto3 = pFoto3;
  changingHandler = setInterval("startChanging();", 5000);
}

function changeEl( id1, id2)
{
	var m = document.getElementById(id1);
	var l = document.getElementById(id2);
	
	if( m.style.display == 'block')
	{
		m.style.display = 'none';
		l.style.display = 'block';
		Set_Cookie( 'ShowLoggedUserMenu', '', '', '/', '', '' );
		if (id1 == 'mainMenuLoged')
			document.getElementById('rightMenu').style.display = 'block';
	}
	else
	{
		m.style.display = 'block';
		l.style.display = 'none';
		if (id1 == 'mainMenuLoged')
			document.getElementById('rightMenu').style.display = 'none';
		Set_Cookie( 'ShowLoggedUserMenu', '1', '', '/', '', '' );
	}
}
function SetMenus()
{
	if ((document.getElementById('mainMenuLoged') != null) && Get_Cookie('ShowLoggedUserMenu') && (Get_Cookie('ShowLoggedUserMenu') != ''))
	{
		document.getElementById('mainMenuLoged').style.display = 'block';
		document.getElementById('mainMenu').style.display = 'none';
		document.getElementById('rightMenu').style.display = 'none';
	}
	else
	{
		if (document.getElementById('mainMenuLoged') != null)
			document.getElementById('mainMenuLoged').style.display = 'none';
		document.getElementById('mainMenu').style.display = 'block';
		document.getElementById('rightMenu').style.display = 'block';
	}
}
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
function PrepareAll()
{
	startList();
	przygotuj();
	SetMenus();
	//externalLinks();
}
//window.onload=PrepareAll;

function SumbitPaymentForm() {
    if (document.forms[1] != null) {
        document.forms[1].submit();
    }
}