<!-- 

//AppGenie True ID Portal - Generic JaVaScript Library


// Open a Popup screen------------------------------------------------------------

function popup(url){popup(url,'_new','_ag=');}

function popup(url,target){popup(screen,target,'');}

function popup(url,target,params){
	if(params != ''){
		params = '&' + params;
	}
	window.open('Popup.aspx?popup='+url+params, target, 'location=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes');
}

// Open a window------------------------------------------------------------------

function windowOpen(url){
	var options = 'location=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=yes';
	windowOpen(url,'_new',options);	
}

function windowOpen(url,title){
	var options = 'location=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=yes';
	windowOpen(url,title,options);	
}

function windowOpen(url,title,options){
	var win = window.open(url,title,options);
	win.focus();
}

// Open a new Url

function go(destination){
    if(destination){ location.href = destination;}
}

// Finds the X position of an object----------------------------------------------

function findPosX(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;
}

// Finds the X position of an object---------------------------------------------

function findPosY(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;
}

// Show a hidden DIV ---------------------------------------------

function showMenu(ok)
{
	var obj = ok;
	obj.style.visibility="visible";
	obj.style.display="block";
}
	
// Hide a visible DIV ---------------------------------------------
	
function hideMenu(ok){
	var obj = ok;
	obj.style.visibility="hidden";
	obj.style.display="none";
}		

// Check allowed Characters ----------------------------------------

function isAllowedChars(field, valid, noValid, defa, manda){
	if(field != undefined)
	{
	    var fld = field;
	    var fieldValue = field.value;
	    //alert(field.name + ' value=' + field.value + ' valid=' + valid + ' novalid=' + noValid + ' defa=' + defa + ' manda=' + manda);
	    if(fieldValue == '' && manda == 'no'){field.value = defa; return true;}
	    if(fieldValue == '' && manda == 'yes'){alertField(fld); return false;}
	    if(valid != ''){
		    for (var j=0; j<fieldValue.length; j++) {
			    temp = fieldValue.substring(j, j+1);
			    if (valid.indexOf(temp) == "-1"){alertField(fld); return false;}
		    }
	    }
	    if(noValid != ''){
		    for (var j=0; j<fieldValue.length; j++) {
			    temp = fieldValue.substring(j, j+1);
			    if (noValid.indexOf(temp) != "-1"){alertField(fld); return false;}
		    }
	    }
	}
	return true;
}

function alertField(field){
	if(fld != undefined){
		var fld = field;
		fld.focus();
		fld.blur();
		if(fld.select){
		    fld.select();
		}
		alert(fld.name);
	}
	return false;
}

function isMandatory(field, defa, manda){
	if(field != undefined)
	{
	    var fld = field;
	    if(fld.length == 0 && manda == 'no')
	    {
	        if(defa != "")
	        {
	            fld.options[0] = new Option();
	            fld.options[0].value = defa; 
	        }
	        return true;
	    }
	    if(fld.length == 0 && manda == 'yes'){alertField(fld); return false;}
	}
	return true;
}

//----------Load image ----------------

function image(name)
{
    return "Image.aspx?dn=" + name;
}


//----------Preview functionality ----------------

var xhr = false;
var xparams = "";

function ShowPreview(sender, displayDiv, url, params)
{
    GetPreview(sender, displayDiv, url, params);
    return false;
}

function HidePreview(displayDiv)
{   
    var obj = document.getElementById(displayDiv);
    if(obj)
    {
    	obj.style.visibility = "hidden";
    }
}

function GetPreview(sender, displayDiv, url, params)
{
	var obj = document.getElementById(displayDiv);

    if(xparams != url + "?" + params){
    	xparams = url + "?" + params;
	    url += "?" + params;
	    url += "&" + Math.random();

	    if(window.XMLHttpRequest) 
	    {
			xhr = new XMLHttpRequest();
		} else {
		    if (window.ActiveXObject) 
		    {
			    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
			    for(var i=0; i<aVersions.length; i++){
				    try
				    {
					    xhr = new ActiveXObject(aVersions[i]);
				    } catch (oError) {  }
			    }
			 }
		}
		
		if(xhr)
		{
			xhr.onreadystatechange = function()
			{
				if (xhr.readyState==4 || xhr.readyState=="complete"){ 
					obj.innerHTML = xhr.responseText;
					var newx = findPosX(sender); 
			        var newy = findPosY(sender); 
					obj.style.top = newy + 5 + 'px';
					obj.style.left = newx + 10 + 'px'
	                obj.style.width = 400 + 'px';
					obj.style.display = 'block';
					obj.style.visibility = 'visible';
					obj.onmouseout = function() { HidePreview(displayDiv); }
				} 
			}
			xhr.open("GET", url, true);
			xhr.send(null);
		}
	} else {
			obj.style.display = 'block';
			obj.style.visibility = 'visible';
			obj.style.width = 400 + 'px';
	}
}

function GetImagePreview(sender, displayDiv, params)
{
	var obj = document.getElementById(displayDiv);
    url = "Image.aspx";
    if(xparams != url + "?" + params){
    	xparams = url + "?" + params;
	    url += "?" + params;
	    url += "&" + Math.random();

		obj.innerHTML = "<img src='" + url + "' border='0' />" ;
		var newx = findPosX(sender); 
        var newy = findPosY(sender); 
		obj.style.top = newy + 5 + 'px';
		obj.style.left = newx + 10 + 'px'
        obj.style.width = 400 + 'px';
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
		obj.onmouseout = function() { HidePreview(displayDiv); }
	} else {
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
		obj.style.width = 400 + 'px';
	}
}


//-->