//<SCRIPT>
//all clientside functions used by left menu or rest page
function redir(sURL)
{
	window.location.href= sURL;
}	
//submitting subscription
function submitSubscr()
{		
	//validate email
	if (valiEmail(JSTrim(fSubscr.email.value)))
		fSubscr.submit();
	else
		alert("Zadaná adresa nie je správna!");	
}
//validates email address - by tomas@gratex.com
function valiEmail(sEmail)
{
   var emailReg= "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
   var regex= new RegExp(emailReg);
   return regex.test(sEmail);
}	
function redirSurvey(sAnswID,sSurvID)
{		
	redir("support/survey_update.asp?id="+sAnswID+"&qid="+sSurvID);
}
function NewWin(url, name, xsize, ysize, type, pleft, ptop)
{
	var	sWinFtrs, oW;
	sWinFtrs = 'toolbar=0,location=0,directories=0,status=0,resizable=1,scrollbars=1,menubar=';
	sWinFtrs += ((type!= null)?'1':'0');
	sWinFtrs += ',width=' + ((xsize==null)?'500':xsize);
	sWinFtrs += ',height=' + ((ysize==null)?'350':ysize);
	sWinFtrs += ',top=' + ((ptop==null)?'100':ptop);
	sWinFtrs += ',left=' + ((pleft==null)?'100':pleft);
	oW= window.open(url, (name==null)?'NewWin':name, sWinFtrs);
	oW.focus();			
}

//banner refresh
function bnrRefresh() {
	topBannerDiv.innerHTML = "<a href='http://ad.gratex.sk/jumpTo.asp?alias=b2' target=_blank><img SRC='http://ad.gratex.sk/gifGen.asp?alias=b2&format=large468x60' border=0 width=468 height=60></a><a href='http://ad.gratex.sk/jumpTo.asp?alias=b1' target=_blank><img SRC='http://ad.gratex.sk/gifGen.asp?alias=b1&format=small127x60' border=0 width=127 height=60></a>"
}
//menu code
// this two arrays are used because of stupid 4.0, TD with SPAN window generates following flow of event 
// when new item in same root TD is entered    mouseOut, mouseOver (for the same element) and mouseMove
// so mouseMove event is used for chcecking if cursor is really leaving the item area and if yes, child 
// window is closed	
var MENU_HIGH_COLOR= "#f0f0f0";
var MENU_BG_COLOR= "white";
var sAppVer= navigator.appVersion.toLowerCase();
var VERSION= parseFloat(sAppVer.substr(sAppVer.indexOf("msie")+5,3));

var oWinToHide= null;
var iWinToTimeoutHndl= null; 
var oElemToShow= null;
var CLOSE_DELAY= 500;

function eh_click()
{
	var oSrcElem= window.event.srcElement;
	if (oSrcElem.tagName.toLowerCase()=="td") 	
		redir("/section.asp?sec="+oSrcElem.id.replace("mi", ""));	
	window.event.cancelBubble= true;	
	window.event.returnValue= false;
	return false;
}
	
function eh_mOr(oElm, iLvl)
{			
	var oWinElm= oElm.children(0);	
	var oBody= document.body;	
					
			
	var oSrcElem= window.event.srcElement;
	if (oSrcElem.tagName.toLowerCase()=='td')
	{		
		oSrcElem.style.backgroundColor= MENU_HIGH_COLOR;
		oElm.style.backgroundColor= MENU_HIGH_COLOR;  

		//clearTimeOut
	if(oWinElm==oWinToHide)	
	{			
		window.clearTimeout(iWinToTimeoutHndl);
		oWinToHide= null;
		iWinToTimeoutHndl= null;						
	}

		if(oWinToHide!=null && oWinElm!=oWinToHide) 		
		{	
			oElemToShow= oElm; 		
			window.event.cancelBubble= true;	
			window.event.returnValue= false;
			return false;	
		}
	
		if (VERSION>=5.1)
		{								
			//if will this menu will be used outside inzine layout you have to enumerate through all offsetParent.offsetTop
			offsetParentsTops= oElm.offsetParent.offsetTop+oElm.offsetParent.offsetParent.offsetTop+oElm.offsetParent.offsetParent.offsetParent.offsetTop;			
			posTop1= (iLvl==1)?offsetParentsTops+ oElm.parentElement.offsetTop- oWinElm.clientHeight+ oElm.offsetHeight +1:oElm.parentElement.offsetTop- oWinElm.clientHeight+ oElm.offsetHeight;							
			posTop2= (iLvl==1)?offsetParentsTops+ oElm.parentElement.offsetTop:oElm.parentElement.offsetTop-1;										
			
			//display window check			
			if (posTop2+oWinElm.offsetHeight-oBody.scrollTop > oBody.clientHeight)						
				if (posTop1 < oBody.scrollTop)								
					if(posTop2-oBody.scrollTop>oBody.scrollTop+oBody.clientHeight-posTop2)					
						oWinElm.style.posTop= oBody.scrollTop+oBody.clientHeight- oWinElm.clientHeight;																	
					else					
						oWinElm.style.posTop= oBody.scrollTop;												
				else				
					oWinElm.style.posTop= posTop1;							
			else			
				oWinElm.style.posTop= posTop2;			
			
	
			oWinElm.style.posLeft= oElm.parentElement.parentElement.parentElement.offsetWidth-2;							
			oWinElm.style.visibility= "visible";										
		}
	}		
	window.event.cancelBubble= true;	
	window.event.returnValue= false;
	return false;	
}
	
function eh_mOt(oElm, iLvl)
{	
	var oSrcElem= window.event.srcElement;
	if (oSrcElem.tagName.toLowerCase()=='td' && iLvl!=null)
	{
		if (VERSION>=5)	
		{						
			if(oWinToHide==null)
			{
				oWinToHide= oElm.children(0);			
				iWinToTimeoutHndl= window.setTimeout(menu_hide_window, CLOSE_DELAY);			
			}				
		}
		oElemToShow= null;		
		oSrcElem.style.backgroundColor= MENU_BG_COLOR; 
		oElm.style.backgroundColor= MENU_BG_COLOR;  
	}	
		
	window.event.cancelBubble= true;	
	window.event.returnValue= false;
	return false;
}	

function menu_hide_window()
{
	if(oWinToHide!=null)
	{ 
		oWinToHide.style.visibility="hidden";
		oWinToHide= null;
		iWinToTimeoutHndl= null;
		if(oElemToShow!=null)
		{
			oElemToShow.fireEvent("onmouseover");
			oElemToShow= null; 		
		}
	}
}

function eh_mOv(oElm)
{	
	oElm.style.backgroundColor= MENU_HIGH_COLOR;	
	window.event.cancelBubble= true;	
	window.event.returnValue= false;
	return false;
}

function eh_mOu(oElm)
{	
	oElm.style.backgroundColor= MENU_BG_COLOR;	
	window.event.cancelBubble= true;	
	window.event.returnValue= false;
	return false;
}
function JSTrim(sStr)
{
	return(sStr.replace(/(^\s+)|(\s+$)/g,''));	
}

// pre potreby zostatkov stareho inzine - nik presne nevie kde sa to pouziva..
// je to aj natrvdo v niektorych clankoch, cize to pouzijeme..
function New_Window(url)
{
	NewWin(url,'inzine',486, 420, null, 190, 150);	
}
function New_Window_Big(url)
{
	NewWin(url,'big',650,550);		
}
function New_Window_Komix(url)
{
	NewWin(url,'komix',576,493);	
}
function New_Window_Body(url)
{
	NewWin(url, 'body', 510, 200, null, 150, 150);	
}

function go2s(oFrm, gSec) {
	self.location = "section.asp?sec=" + gSec + "&page=" + oFrm.options[oFrm.selectedIndex].value;
}
function go2m(oFrm) {
	self.location = "main2.asp?page=" + oFrm.options[oFrm.selectedIndex].value;
}
function go2f(oFrm, gFor) {
	self.location = "forum.asp?id_forum=" + gFor + "&page=" + oFrm.options[oFrm.selectedIndex].value;
}