

var ie4=document.all
var ns6=document.getElementById&&!document.all


var DnxRefCtlID="";
var DnxRefTableName="";
var DnxRefFieldName="";

var ow_resizable	= 'yes'
var ow_toolbar		= 'yes'
var ow_status		= 'yes'
var ow_scrollbars	= 'yes'
var ow_width		= 500
var ow_height		= 400

var Page_TimeOut_Sec = 1500;
var Page_TimeOut_URL = document.URL;



//Set a status message
function setStatus(tMsg){
	window.status = tMsg
}

function fnErrorTrap(sMsg,sUrl,sLine){
   oErrorLog.innerHTML="&lt;b&gt;An error was thrown and caught.&lt;/b&gt;&lt;p&gt;";
   oErrorLog.innerHTML+="Error: " + sMsg + "&lt;br&gt;";
   oErrorLog.innerHTML+="Line: " + sLine + "&lt;br&gt;";
   oErrorLog.innerHTML+="URL: " + sUrl + "&lt;br&gt;";
   return false;
}

//Hyperlink to Document
function h(tLink){
	if(LINK_STYLE == 0) { document.location.href = tLink }
	else
	if(LINK_STYLE == 1) { window.location.replace(tLink) }
	else
	document.location.href = tLink
}

//Redirect Document
function rd(str){
	//alert("rd: " + str)

	pg_path = SITE_BASE_URL + "/site_lib/page_redirect.asp?page=" + str
	//alert("pg_path: " + pg_path)
			
	document.location.href = pg_path
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ow(vURL){
	window.open(vURL , '', 'resizable=' + ow_resizable + ',toolbar=' + ow_toolbar + ',menubar=no,scrollbars=' + ow_scrollbars + ',status=' + ow_status + ',width=' + ow_width + ',height=' + ow_height); 
}

function js_preview(vURL, vType){
	vURL = "../accessories/preview_window.asp?Type=" + vType + "&Show=" + vURL
	ow(vURL);
}

function js_preview_img(vURL, vWidth, vHeight){
	ow_width		= vWidth
	ow_height		= vHeight
	js_preview(vURL, "IMAGE")
}

function oi(vURL, vWidth, vHeight){
	ow_width		= vWidth
	ow_height		= vHeight
	js_preview(vURL, "IMAGE")
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function ValidateEmailStruct(str){
	//alert("ValidateEmailStruct" + str)
	error = "0";

	//alert("IndexOf @ : " + str.indexOf("@"))
	//alert("IndexOf . : " + str.indexOf("."))

	if (str.indexOf("@") < 0 ){error = "-1";}
	if (str.indexOf(".") < 0 ){error = "-1";}
	if (str.indexOf("!") >= 0){error = "-1";}
	if (str.indexOf("#") >= 0){error = "-1";}
	if (str.indexOf(",") >= 0){error = "-1";}
	if (str.indexOf(";") >= 0){error = "-1";}
	if (str.indexOf(":") >= 0){error = "-1";}
	if (str.indexOf(" ") >= 0){error = "-1";}
	return error;
}


function validateDate(str){
	//alert("ValidateDate:" + str)
	hError = "0";

	var t1 
	t1 = new Date(str)
	//alert("ValidateDate:" + t1)
	if( isNaN(t1) ) {hError="-1"}
	//alert("hError:" + hError)
	
	//{error = "-1";}
	return hError;
}


function pageTimeOut() { 
	var retVal = 0; 
	
	//if (Page_TimeOut_Sec <= 30) {
	//	window.status = "Session will time out in: " + Page_TimeOut_Sec + " seconds";
	//}
	
	Page_TimeOut_Sec--;     

	if (Page_TimeOut_Sec <= 0) {
		//alert("Your session has timed out.");
		window.location.href = Page_TimeOut_URL;
	}
	else {
		retVal = setTimeout("pageTimeOut()", 1000);
	}
}


function formatForHTML(str){
	var NewStr;
	NewStr = String(str)
	NewStr = NewStr.replace(/|/g, "|");
	return (NewStr);
}


function readNameValuePair(tStr, tName){
var the_pairs;
var nv_info;
var the_name;
//var the_value;
		
	//tStr = tStr.replace(/&/g, ":");
	//var the_pairs = tStr.split(":");
	tStr = tStr.replace(/\+/g, " ");

	the_pairs = tStr.split("&");

	for (var loop = 0; loop < the_pairs.length; loop++){

		nv_info = the_pairs[loop].split("=");
		the_name = nv_info[0];
		if(the_name == tName){
			return unescape(nv_info[1]);
		}
	}
	//If you reach here then a value was not obtained
	return "N/A";
}


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;
}