

var ie4=document.all
var ns6=document.getElementById&&!document.all


var DnxRefCtlID="";
var DnxRefTableName="";
var DnxRefFieldName="";


function scriptLink() {
	//Do Nothing
}

/** 
 * Adds a new onload function to append onload events to the 
 * window onload.
 */
function AddOnloadFunction(func) {
    if( window.onload ) {
        var oldfunc = window.onload;
        window.onload = function() { 
            oldfunc(); 
            func(); 
        };
    }
    else {
        window.onload = func;
    }
} 

function getTime(){

        var now = new Date();
        var hour = now.getHours();
        var min = now.getMinutes();
        var sec = now.getSeconds();
        return hour + ":" + min + ":" + sec;
}
function getRefToDiv(divID) {
	if( document.layers ) { //Netscape layers
		return document.layers[divID]; }
	if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
		return document.getElementById(divID); }
	if( document.all ) { //Proprietary DOM; IE4
		return document.all[divID]; }
	if( document[divID] ) { //Netscape alternative
		return document[divID]; }
	return false;
}

function LayerViewSwitch(strLay, strText) {

	if (getRefToDiv(strLay).style.visibility =="visible") {
		getRefToDiv(strLay).style.visibility = "hidden";
		getRefToDiv(strLay).innerHTML = "";
	}else{
		getRefToDiv(strLay).style.visibility = "visible";
		getRefToDiv(strLay).innerHTML = strText;
	}
}

function LookupListSelect(strID, strRefTableName, strRefFieldName, eventObj){
	jsLookupListSelect(strID, strRefTableName, strRefFieldName, eventObj)
}


function DoCallback(url, params){
// url:    URL to invoke
// params: string object to pass to the remote URL
// Add some parameters to the query string
	var pageUrl = "";
	
	if(url.indexOf("?")>0){
        pageUrl = url + "&DnxJsCallback=true&" + params;
	}else{
        pageUrl = url + "?DnxJsCallback=true&" + params;
	}
	
	// Initialize the XmlHttp object
	try {
		//Mozilla Browsers
		xmlRequest = new XMLHttpRequest();
	} 
	catch (e) {
		try {
			//IE
			xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (e) {
			//Something else that won't work with this code...
			xmlRequest=false;
		}
	} 
	try{
	    // Post our XmlRequest and get our desired string
	    xmlRequest.open("GET", pageUrl, false);
	    xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xmlRequest.send(null);
	    // Return the XmlHttp object
	    return xmlRequest; 
	}
    catch(err){
        var txt="";
        txt+="An error was encountered while connecting to the server.\n"
        txt+="(Description: " + err.description + ")\n\n"
        //txt+="Click OK to continue.\n\n"
        //alert(txt)
        window.status = txt;
        return null;
    }  

}

	
	



function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	//if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	if (e.type=="click" && obj.visibility==hidden)
	obj.visibility=visible
	//else if (e.type=="click")
	//obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
			edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}




function dropdownmenu(obj, e, menuwidth, menulayerName, menulayerObj){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? getRefToDiv(menulayerName) : menulayerObj


	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6){dropmenuobj.style.visibility="hidden";}
	}
}

function delayhidemenu(){
	if (ie4||ns6)
	delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}


function showPrintPreview(printArea, commonPath){ 

    //Creating new page
    var pp = window.open();
    
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')
    pp.document.writeln('<LINK href=' + commonPath + 'styles.css type="text/css" rel="stylesheet">')
    pp.document.writeln('<LINK href=' + commonPath + 'print_style.css type="text/css" rel="stylesheet" media="print">')
    pp.document.writeln('<base target="_self"></HEAD>')
    
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
    pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
    
    //Adding form Tag
    pp.document.writeln('<form method="post">');
    
    //Creating two buttons Print and Close within a HTML table
    pp.document.writeln('<TABLE width=100% border=0><TR><TD></TD></TR><TR><TD align=right>');
    pp.document.writeln('<INPUT ID="PRINT" type="button" value="Print" ');
    pp.document.writeln('onclick="javascript:location.reload(true);window.print();">');
    pp.document.writeln('<INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();">');
    pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');

    //Writing print area of the calling page
    if (document.getElementById(printArea)) {
        var printData = document.getElementById(printArea).innerHTML
		var re = new RegExp('\<a.*?\>', 'gi');
		var printData = printData.replace(re, '');
        pp.document.writeln(printData);
    }
    
    
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>'); 

}



/* function Hashtable() */

function Hashtable(){
    this.hashtable = new Array();
}

/* privileged functions */
Hashtable.prototype.clear = function(){
    this.hashtable = new Array();
}              
Hashtable.prototype.containsKey = function(key){
    var exists = false;
    for (var i in this.hashtable) {
        if (i == key && this.hashtable[i] != null) {
            exists = true;
            break;
        }       
    }
    return exists;
}
Hashtable.prototype.containsValue = function(value){
    var contains = false;
    if (value != null) {
        for (var i in this.hashtable) {
            if (this.hashtable[i] == value) {
                contains = true;
                break;
            }
        }
    }        
    return contains;
}
Hashtable.prototype.get = function(key){
    return this.hashtable[key];
}
Hashtable.prototype.isEmpty = function(){
    return (parseInt(this.size()) == 0) ? true : false;
}
Hashtable.prototype.keys = function(){
    var keys = new Array();
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            keys.push(i);
    }
    return keys;
}
Hashtable.prototype.put = function(key, value){
    if (key == null || value == null) {
        throw "NullPointerException {" + key + "},{" + value + "}";
    }else{
        this.hashtable[key] = value;
    }
}
Hashtable.prototype.remove = function(key){
    var rtn = this.hashtable[key];
    this.hashtable[key] = null;
    return rtn;
}    
Hashtable.prototype.size = function(){
    var size = 0;
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            size ++;
    }
    return size;
}
Hashtable.prototype.toString = function(){
    var result = "";
    for (var i in this.hashtable)
    {     
        if (this.hashtable[i] != null)
            result += "{" + i + "},{" + this.hashtable[i] + "}\n";  
    }
    return result;
}                                  
Hashtable.prototype.values = function(){
    var values = new Array();
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null)
            values.push(this.hashtable[i]);
    }
    return values;
}                                  
Hashtable.prototype.entrySet = function(){
    return this.hashtable;
}
                

Hashtable.prototype.toQueryString = function(){
    var retVal = "";
    for (var i in this.hashtable) {
        if (this.hashtable[i] != null) {
            retVal += i + "=" +  escape(this.hashtable[i]) + "&"
        }       
    }
    return retVal;
}