// Collection of general JS functions

function checkOldIE(){  
	
	var nav = navigator.userAgent.toLowerCase();
	if((nav.indexOf("msie 6.0") !=-1) || (nav.indexOf("msie 5.0") !=-1) || (nav.indexOf("msie 5") !=-1) || (nav.indexOf("msie 5.5") !=-1))
	{
		return true;
	}
	else
	{
		return false;
	}
}  

function getXMLHttpRequestObject()
{
	var request = null;
	try
	{
		request = new XMLHttpRequest();		
	}
	catch(e)
	{
		try
		{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		
		catch(e)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			
			catch(e)
			{
				alert("no");
			}
		}
	}
	
	return request;
}

function getXmlDoc()
{
	var doc = null;
	
	if(document.implementation.createDocument)
	{
		doc = document.implementation.createDocument(null, "ajax-request", null);
	}
	
	else
	{
		doc = new ActiveXObject("MSXML2.DOMDocument");
		doc.appendChild(doc.createElement("ajax-request"));
	}
	
	return doc;
}

function openPopup(url) 
{
	nw = window.open(url, "", 'scrollbars=yes,resizable=yes,status=no,location=no,menubar=no,width=500,height=700');

}

function getCookieVal (offset) 
{
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
            endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) 
{
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
            var j = i + alen;
            if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) break;
        }
        return null;
}

function GetRandom( min, max ) {
        if( min > max ) 
		{
			return( -1 );
        }

        if( min == max ) 
		{
			return( min );
        }

        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
} 

