ns = (document.getElementById)? true:false; ie = (document.all)? true:false

var claimlist = [];
var errors = [];

function gete(id) {if(ie) return document.all[id]; if(ns) return document.getElementById(id);}
function lw(id,text) {if(exist(id)){try {gete(id).innerHTML = text;}catch (e) {debug('Error:'+e.number+'\nName:'+e.name+'\nMessage:'+e.message+'\n','Layer Write to: '+id+'\n'+text);}}}
function lr(id) {if(exist(id)){return gete(id).innerHTML}}
function exist(id) {if(ie)	{if(document.all[id] != null) {return true;}}else if(ns)	{if(document.getElementById(id) != null) {return true;}}return false;}
function hide(id)
	{if(gete(id).style.visibility != 'hidden') gete(id).style.visibility='hidden';}
function show(id)
	{if(gete(id).style.visibility != 'visible') gete(id).style.visibility='visible';}

function togdisp(id)
	{
	if(isdisp(id))
		{gete(id).style.display = 'none';}
	else
		{gete(id).style.display = 'inline';}
	}
function isdisp(id)
	{
	if(gete(id).style.display == 'inline') return true;
	else return false;
	}


function createhttpObj()
	{
	var xmlhttp;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try
		{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}
	catch (e)
		{
		try {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}
		catch (E)	{xmlhttp=false}
		}
	@else
	xmlhttp=false
	@end @*/
	if (!xmlhttp)
		{
		try	{xmlhttp = new XMLHttpRequest();}
		catch (e) {xmlhttp=false}
		}
	return(xmlhttp);
	}

var xmlhttp = createhttpObj();

var listentime;
var httpvars = ["listen="+listentime,"dataid=<%$user{'dataid'}%>","valid=<%$user{'valid'}%>","invalid=<%$user{'invalid'}%>"];
function addvars(key,value)
	{
	if(!value) value = '';
	delvars(key,value);
	httpvars.push(key+"="+value);
	}
function delvars(key,value)
	{
	if(value == undefined) value = '';
	for(a=0;a < httpvars.length;a++)
		{
		var piece = httpvars[a].split('=');
		if((value)&&(httpvars[a] == key+"="+value))
			{httpvars.splice(a,1);}
		else if((!value)&&(piece[0] == key))
			{httpvars.splice(a,1);}
		}
	}

var httpcons=0;
var lastresult;
function sendhttp(url,lwid)
	{
    lw(lwid,'<div style="width:100%;height:100%;text-align:center;"><img src="/images/loading.gif" alt="Loading..."></div>');
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4)
			{
			httpcons=httpcons-1;
			if(lwid)
				{
				try {lw(lwid,xmlhttp.responseText); }
				catch (e) {debug('Error:'+e+'\nName:'+e.name+'\nMessage:'+e.message,'');}
				}
			}
		}
	xmlhttp.send(null);
	}

function evalrequest(url,failure)
	{
	xmlhttp.open('GET', url, true);
    if(exist('loaderimg'))
        {gete('loaderimg').style.display='inline';}

	xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4)
			{
            if(exist('loaderimg'))
                {gete('loaderimg').style.display='none';}
			httpcons=httpcons-1;
			try { eval(xmlhttp.responseText); }
			catch (e) {debug(e.message,'');}
			}
		}
	xmlhttp.send(null);
	}

function popup(name,id,url,x,y,width,height)
	{
	if(!exist(id))
		{
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id',id);
        if(ie)
            { newdiv.style.setAttribute('cssText','display:inline;position:absolute;z-index:220;top:'+x+';left:'+y+';width:'+width+';height:'+height); }
        else
            { newdiv.setAttribute('cssText','display:inline;z-index:110;position:absolute;z-index:220;top:'+x+';left:'+y+';width:'+width+';height:'+height); }
		document.body.appendChild(newdiv);
		}

        var innerwidth = width-8;
    var myhtml = '<table border="0" cellpadding="0" cellspacing="0" style="width:'+width+'px;height:'+height+'px">' +
'<tr><td height="17" width="100%" style="overflow:hidden;"><div id="'+id+'_handle" onselectstart="return false;" style="position:relative;width:100%;cursor:pointer"><img src="box_top.gif" width="'+width+'" height="17"><div style="padding-left:8px;position:absolute;overflow:hidden;height:17px;width:100%;left:0px;top:0px;font-family:verdana, arial, helvetica;font-size:12px;"><b>'+name+'</b></div>' +
'<div onclick="gete(\''+id+'\').removeNode(true);" style="position:absolute;left:'+(width-20)+';top:2px;cursor:pointer;"><img  src="x.gif"></div></div></td></tr>' +
'<tr><td height="100%" width="100%">' +
'<div style="position:relative;width:'+width+'px;height:100%;overflow:hidden">' +
'<img src="box_mid.gif" width="'+width+'">' +
'<div id="'+id+'_body" style="font-family:verdana, arial, helvetica;font-size:9px;overflow-x:hidden;overflow-y:auto;height:100%;width:'+innerwidth+'px;position:absolute;padding:4px;left:0px;top:0px;"></div>' +
'</div>' +
'</td></tr>' +
'<tr><td height="7"><img src="box_bot.gif" width="'+width+'" height="7"></td></tr>' +
'</table>';

	lw(id,myhtml);
	sendhttp(url,id+'_body');
	var dd = new YAHOO.util.DD(id);
	dd.setHandleElId(id+'_handle');
//    alert(gete(id).outerHTML);

	}

function debug(error,mesg)
	{
    alert(error+mesg);
	}

function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);}
