function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function formVals(frm) {
	
	var vals = {};
	for (var loop=0; loop < frm.elements.length; loop++) {
		if (frm.elements[loop].type == 'text' || frm.elements[loop].type == 'select-one' || frm.elements[loop].type == 'hidden' || frm.elements[loop].type == 'radio') {
			vals[frm.elements[loop].name] = frm.elements[loop].value;
		} else if (frm.elements[loop].type == 'checkbox') {
			if (frm.elements[loop].checked == true) {
				if (vals[frm.elements[loop].name]) {
					vals[frm.elements[loop].name] = vals[frm.elements[loop].name] + ',' + frm.elements[loop].value;
				} else {
					vals[frm.elements[loop].name] = frm.elements[loop].value;
				}
			}
		}
	}
	return vals;
}
function showElement(id)
{
	//alert(id);
	e = document.getElementById(id);
	if (e.style)
		{
			e.style.display = 'block';
		}
}

function hideElement(id)
{
	//alert(id);
	e = document.getElementById(id);
	if (e.style)
		{
			e.style.display = 'none';
		}
}
function toggle(id)
	{
		var bVisible = true;
		e = document.getElementById(id);
		if (e.style.display == 'block')
		{
			e.style.display = 'none';
			bVisible = false;
		}
		else
		{
			if (e.style)
				{
					e.style.display = 'block';
				}
		}
		return bVisible;
	}

function setFocus(id)
{
	e = document.getElementById(id);
	try {e.focus();} catch (e) {}
}

function toggleButton(id)
{	
	b = document.getElementById(id);
	try {
		if (b.disabled == true)
		{
			b.disabled = false;
		}
		else
		{
			b.disabled = true;
		}
	} 
	catch (e) {}
}

function getSelectValue(sel)
{
	var idx = sel.selectedIndex;
	var value = sel[idx].value;
	return value;
}

function getRadioValue(rad)
{
	var value = '';
	for (var i = 0; i < rad.length; i ++)
	{
		if (rad[i].checked)
		{
			value = rad[i].value;
		}
	}
	return value;
}

function getCheckboxValues(chk)
{
	var value = '';
	for (var i = 0; i < chk.length; i ++)
	{
		if (chk[i].checked)
		{
			if (value == '')
			{
				value = chk[i].value;
			}
			else
			{
				value = value + ',' + chk[i].value;
			}
		}
	}
	return value;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
function isArray(obj) {
	return (obj.constructor.toString().indexOf("Array") != -1);
}
function changeClass(id, newClass)
{
	e = document.getElementById(id);
	e.className = newClass;
}

function loaderIcon(_state,_addressType) {

	var loader = document.getElementById(_addressType + "_loading_icon");
	if (_state == 'on') {
		loader.src = _imagepath + 'loading_on.gif';
	} else {
		loader.src = _imagepath + 'loading_off.gif';
	}
}

function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) { 
//Do not delete these comments. 
//Non-Obtrusive Image Swap Script V1.1 by Hesido.com 
//Attribution required on all accounts 
	if (typeof(elem) == 'string') elem = document.getElementById(elem); 
    if (elem == null) return; 
    var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
    var prel = new Array(), img, imgList, imgsrc, mtchd; 
    imgList = elem.getElementsByTagName('img'); 
    for (var i=0; img = imgList[i]; i++) { 
        if (!img.rolloverSet && img.src.match(regg)) { 
            mtchd = img.src.match(regg); 
            img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
            img.outSRC = img.src; 
            if (typeof(mouseOver) != 'undefined') { 
                img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
                img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
                img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
                img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
                } 
            if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
            if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
            if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
            if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
            img.rolloverSet = true; 
        } 
    } 
    function preLoadImg(imgSrc) { 
        prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
    } 
} 
function imgHoverSwap() {this.src = this.hoverSRC;} 
function imgOutSwap() {this.src = this.outSRC;} 
function imgMouseDownSwap() {this.src = this.mdownSRC;} 
function imgMouseUpSwap() {this.src = this.mupSRC;}

function getCacheBuster()
	{
		var d = new Date();
		var key_value = "&cacheBuster=" + d.getTime();
		return key_value;
	}

function getRandom(max)
{
	var rndNumber = Math.floor(Math.random() * max);
	return rndNumber;
}

function popup(fuseaction)
{
	url = "index.cfm?fuseaction=app." + fuseaction;
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=400,left = 137,top = 184');");
	
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

/*function popupImage(myimage, titletext) {
 html = "<HTML><HEAD><TITLE>"+ titletext + "</TITLE>" +
  "</HEAD><BODY LEFTMARGIN=0 " 
  + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>" 
  + "<IMG SRC='" + myimage + "' BORDER=0 NAME=image " 
  + "onload='window.resizeTo(document.image.width,document.image.height)'>"
  + "</CENTER>" 
  + "</BODY></HTML>";
 popup=
 window.open
  ('','image',
  'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
 popup.document.open();
 popup.document.write(html);
 popup.document.focus();
 popup.document.close()
 };*/

 function popupImage(myimage, titletext) {
 	url = "showPhoto.cfm?i_id=" + myimage;
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=460,height=300,left = 137,top = 384');");
	
 }
 
 function popupText(id, titletext) {
 	url = "showText.cfm?i_id=" + id;
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=500,left = 137,top = 137');");
	
 }