var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

function OpenInNewWindow(url)
{
	window.open(url);
}
function Replace(s, t, u) {
	i = s.indexOf(t);
	r = "";
	if (i == -1) return s;
	r += s.substring(0,i) + u;
	if ( i + t.length < s.length)
		r += replace(s.substring(i + t.length, s.length), t, u);
	return r;
}
function SetDisplay(id, display)
{
	var sect =document.all[id];
	if (sect != null)
		sect.style.display = display;
}
function CreateFlashObject(movie, width, height)
{
document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
document.writeln('ALIGN="center" width="' + width + '" height="' + height + '">');
document.writeln('<param name="movie" value="' + movie + '" />');
document.writeln('<param name="quality" value="high" />');
document.writeln('<param name="menu" value="false">');
document.writeln('<param name="scale" value="noscale">');
document.writeln('<param name="wmode" value="transparent">');
document.writeln('<embed src="' + movie + '" menu="false" quality="high" scale="noscale" WIDTH="' + width + '"');
document.writeln('HEIGHT="' + height + '" NAME="intro" ALIGN="center" pluginspage="http://www.macromedia.com/go/getflashplayer"');
document.writeln('type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
document.writeln('</object>');
}
//ShowDialog('', 1, 1, 0, 0, 0, 0, 320, 240, '')
function ShowDialog(url, cache, center, scroll, left, top, width, height, advancedFeatures)
{
	if (cache == 0)
	{
		var d = new Date();
		if (url.indexOf('?') == -1)
			url = url + "?pageversion=" + d.getTime();
		else
			url = url + "&pageversion=" + d.getTime();
	}
	if (center == 1)
	{
		left = (screen.availWidth - width)/2;
		top = (screen.availHeight - height)/2;
	}
	var features = "toolbar=0,status=1,scrollbars=" + scroll + ",left=" + left + ",top=" + top + ",height=" + height + ",width=" + width + "";
	if (advancedFeatures != "")
		features = features + "," + advancedFeatures;
	window.open(url, "", features);
}
function ResetForm()
{
	document.frm.reset();
}

function ChangePage(val)
{
	QueryString_Set("CurrentPage", val);
	window.location = GetUrl();	
}

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

var ajaxReq;

function GetXmlHttpPrefix() {
	if (getXmlHttpPrefix.prefix)
		return getXmlHttpPrefix.prefix;
	
	var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
	var o;
	for (var i = 0; i < prefixes.length; i++) {
		try {
			// try to create the objects
			o = new ActiveXObject(prefixes[i] + ".XmlHttp");
			return getXmlHttpPrefix.prefix = prefixes[i];
		}
		catch (ex) {};
	}
	
	throw new Error("Could not find an installed XML parser");
}

function GetXmlHTTP()
{
	if(typeof XMLHttpRequest!="undefined"){
		return new XMLHttpRequest();
	}
	else if(typeof ActiveXObject != "undefined")
	{
		try{
			var xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			return xmlhttp;
		}
		catch(e)
		{
			return null;
		}
	}
	return null;
}

function GetXmlDoc()
{
	if (document.implementation && document.implementation.createDocument) {
		var doc = document.implementation.createDocument("", "", null);			
		return doc;
	}
	if (window.ActiveXObject)
		return new ActiveXObject(GetDomDocumentPrefix() + ".DomDocument");
	return null;
}

function GetVer()
{
	var d = new Date();	
	return d.getTime()
}

function GetAjaxResponse(url)
{
	req=GetXmlHTTP();
	req.open("GET", url + "&Version=" + GetVer(), false);
	req.send(null);
	return req.responseText;
}

function setElementText(obj, val)
{
	if (is_ie)
		obj.innerText = val;
	else
		obj.textContent = val;
}
