﻿// JScript File

function getObj(objID)
{
    if (document.getElementById) {return document.getElementById(objID);}
    else if (document.all) {return document.all[objID];}
    else if (document.layers) {return document.layers[objID];}
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

function Left(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
		
	return curleft;
}

function Top(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		
	return curtop;
}

function OpenAvailability( Url )
{
    window.open( Url, '', 'menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=300,height=250,top=' + (screen.height - 250) / 2 + ',left=' + (screen.width - 300) / 2 );
}

function OpenMap( Url, Title )
{
    window.open( Url, Title, 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes'); 
}


function bookmarksite( title, url )
{
    if (window.sidebar)
	    window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print)
    {
	    var elem = document.createElement('a');
	    elem.setAttribute('href',url);
	    elem.setAttribute('title',title);
	    elem.setAttribute('rel','sidebar');
	    elem.click();
    } 
    else if(document.all)
	    window.external.AddFavorite(url, title);
}

function trim(stringa)
{
    while (stringa.substring(0,1) == ' ')
    {
        stringa = stringa.substring(1, stringa.length);
    }
        
    while (stringa.substring(stringa.length-1, stringa.length) == ' ')
    {
        stringa = stringa.substring(0,stringa.length-1);
    }
        
    return stringa;
}
