//window.onerror = fnErrorTrap;

var LINK_STYLE		= 0

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 = SCRIPT_NAME;


//Set a status message
function clink(){
	''
}

//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);
	}
}

var Calendar_HostForm="";
var Calendar_HostItem="";

function calendarOpenWindow(formName, ItemName) { //v2.0
	Calendar_HostForm = formName;
	Calendar_HostItem = ItemName;
  	window.open('../accessories/calendar.asp','CalendarWin','status=true,width=206,height=210');
}
function calendarSetWindowValue(dateVal){
	eval('document.' + Calendar_HostForm + '.' + Calendar_HostItem + '.value = dateVal')
}

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";
}

var menu_bg_color_default = "#F4F4F4"
var menu_bg_color_highlight = "#FF6600"

function mOvr(src,clrOver){
	if (!src.contains(event.fromElement)){
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}
function mOut(src,clrIn){
	if (!src.contains(event.toElement)){
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}
function mClk(src){
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
}