function stopError() { return true;}
window.onerror = stopError;

var myRemote;
window.onunload=CloseRemote;

function CloseRemote()
{
	if (myRemote!=null) myRemote.close();
}

function ns_ShowWindowEx(i,newURL,x,y,w,h) {
	var NS6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
	if (!NS6)
	{
		IE = (document.all) ? true : false;
		NS4 = (document.layers) ? true : false;
	}
	else
	{
		IE = false;
		NS4 = false;
	}
	
	if(NS4)
	{
		if (myRemote==null) {
			  myRemote = window.open(newURL, '', 'height='+h+',width='+w+',screenX='+x+',left='+x+',screenY='+y+',top='+y+',channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0', 'myWindow');
			  myRemote.focus();
		}
		else{
			if(!myRemote.closed)	// Mora zaradi Netscape oti ako myRemote e zatvoren od strana na korisnikot puka
			{
				myRemote.close();
			}
			
			myRemote = window.open(newURL, '', 'height='+h+',width='+w+',screenX='+x+',left='+x+',screenY='+y+',top='+y+',channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0', 'myWindow');
			myRemote.focus();
		}	
	}
	else
	{
		if (myRemote==null) {
			  myRemote = window.open(newURL, '', 'height='+h+',width='+w+',screenX='+x+',left='+x+',screenY='+y+',top='+y+',channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0', 'myWindow');
			  myRemote.focus();
		}
		else{
			if(!myRemote.closed)	// Mora zaradi Netscape oti ako myRemote e zatvoren od strana na korisnikot puka
			{
				myRemote.close();
			}
			
			myRemote=null;
			myRemote = window.open(newURL, '', 'height='+h+',width='+w+',screenX='+x+',left='+x+',screenY='+y+',top='+y+',channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0', 'myWindow');
			myRemote.focus();
		}	
	}
}



function dummy(){
}

//wb2flymenu scripts

var prevPopup=null;
var timeOutID=0;
var subMenuOffset=0;
			
function mouseIn(src,childID)
{
	var chMenu = document.all(childID);
	var posLeft;
	var posTop;
	var posWidth;
	var x;
	var y;
	var masterParent=null;
				
	if(prevPopup!=null)
	{
		if(prevPopup!=chMenu)
		{
			prevPopup.style.visibility="hidden";
		}
	}
	
/*	masterParent = src
	while(true)
	{
		masterParent = masterParent.parentElement;
		if(masterParent==null)
		{
			break;
		}
		posLeft = posLeft + masterParent.offsetLeft;
	}*/
			
	//posLeft = src.parentElement.parentElement.parentElement.parentElement.parentElement.offsetLeft;
	
	//posLeft = src.parentElement.parentElement.parentElement.parentElement.offsetLeft;
	//posTop = src.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.offsetTop;
	prevPopup = chMenu;
	posLeft = src.offsetLeft-10;
	//posLeft = window.event.clientX;
	//document.title = src.tagName;
	posTop = src.offsetTop + src.offsetHeight + 5;
	 

	
	//posWidth = src.offsetWidth;
	posWidth = 0;
				
	y = posTop;
	x = subMenuOffset+posLeft+posWidth;
	chMenu.style.visibility="visible";
	chMenu.style.left = 3+x+"px";
	chMenu.style.top = y+"px";
}
			
function mouseOut(src,childID)
{
	var strEval;
				
	if(!src.contains(window.event.toElement))
	{
		strEval = new String();
		strEval = "MainMenuTimer('" + childID + "')";
		timeOutID = window.setTimeout(strEval,250);
	}
}
			
function MainMenuTimer(childID)
{
	var chMenu = document.all(childID);
	chMenu.style.visibility="hidden";
	if(timeOutID!=0)
	{
		window.clearTimeout(timeOutID);
		timeOutID = 0;
	}
}
			
function subMenuMouseIn(src,elementID)
{
	if(timeOutID!=0)
	{
		window.clearTimeout(timeOutID);
		timeOutID = 0;
	}
}
			
function subMenuMouseOut(src,elementID)
{
	if(!src.contains(window.event.toElement))
	{
		var chMenu = document.all(elementID);
		chMenu.style.visibility="hidden";
	}
}
// end of wb2flymenu

//Funkciite isDomestic() i isInRange() ovozmozuvaat da se opredeli
//dali korisnikot surfa od doma ili od nadvor

function isDomestic(clientIP)
{
            var Client = clientIP;

            //ova sme nie
            if(isInRange(Client,'85.30.96.120','85.30.96.121'))
                        return true;

            //onnet
            if(isInRange(Client,'217.16.64.0','217.16.95.255'))
                        return true;
            if(isInRange(Client,'85.30.64.0','85.30.127.255'))
                        return true;                                                        

            // mtnet
            if(isInRange(Client,'62.162.0.0','62.162.255.255'))
                        return true;                                                        
            if(isInRange(Client,'195.26.128.0','195.26.159.255'))
                        return true;                                                                                                                    
            if(isInRange(Client,'62.220.192.0','62.220.223.255'))
                        return true;        
                                                            

            //marnet
            if(isInRange(Client,'194.149.158.0','194.149.159.255'))
                        return true;                                                                    
                                                            
            //Sonet
            if(isInRange(Client,'212.120.0.0','212.120.31.255'))
                        return true;                                                                                                                                
                                                            
            //unet
            if(isInRange(Client,'212.13.64.0','212.13.95.255'))
                        return true;                                                                                                                                                        
                                                            
            //neotel
            if(isInRange(Client,'80.77.144.0','80.77.159.255'))
                        return true;                                                                                                                                                        
                                                            
            //mol
            if(isInRange(Client,'212.110.64.0','212.110.95.255'))
                        return true;                                                                                                                                                        
            //Kadis
            if(isInRange(Client,'82.114.75.0','82.114.75.255'))
                        return true;                                                                                                                                                        
                                                            
            if(isInRange(Client,'82.114.78.0','82.114.78.255'))
                        return true;                                                                                                                                                        
                                                            
            return false
}
                        
function isInRange(Client,StartIP,EndIP)
{
            var IPQuadClientIP;
            var IPQuadStartIP;
            var IPQuadEndIP;
                                                
            IPQuadClientIP = Client.split(".");
            IPQuadStartIP = StartIP.split(".");
            IPQuadEndIP = EndIP.split(".");
                                                
            if(IPQuadClientIP[0]==IPQuadStartIP[0] && IPQuadClientIP[1]==IPQuadStartIP[1])
            {
                        if(IPQuadClientIP[2]>=IPQuadStartIP[2] && IPQuadClientIP[2] <= IPQuadEndIP[2])
                        {
                                    if(IPQuadClientIP[3]>= IPQuadStartIP[3] && IPQuadClientIP[3]<= IPQuadEndIP[3])
                                    {
                                                return true;
                                    }
                        }
            }
            return false;
}