﻿// JScript File
function _close(obj){
    document.getElementById(obj).style.visibility = 'hidden';
}

function removeCommas(aNum) {

//remove any commas

aNum=aNum.replace(/,/g,"");

//remove any spaces

aNum=aNum.replace(/\s/g,"");

return aNum;

}

 function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function DOMTable(){
    this.data = false;
    this.target = false;
    this.pagingTarget = false;
    this.page = 1;
    this.ispaged = false;
    this.caption = false;
}

function getElementbyClass(classname){
    var allPageTags = new Array(); 
    var temparray=new Array()
    var inc=0
    var rootlength

    rootobj = document.getElementsByTagName("*"); 
    rootlength=rootobj.length

    for (i=0; i<rootlength; i++){

    if (rootobj[i].className==classname)
        temparray[inc++]=rootobj[i]
    }

    return temparray
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

if (!Array.prototype.forEach){
	Array.prototype.forEach = function(fun /*, thisp*/){
		var len = this.length;
		if (typeof fun != "function") throw new TypeError();

		var thisp = arguments[1];
		for (var i = 0; i < len; i++){
			if (i in this) fun.call(thisp, this[i], i, this);
		}
	};
}

function isNAN(obj, e) {
    
	var key;
    var keychar;
    
    if (window.event){
        key = window.event.keyCode;
    }
    else if (e){
        key = e.which;
    }
    else{
        return true;
    }

    keychar = String.fromCharCode(key);
          
    if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ){
        return true; // control keys
    }
    else if ((("0123456789").indexOf(keychar) > -1)){
        return true; // numbers
    }
    else{
        return false;
    }
}

// JavaScript Document

sfHover = function() {
	sfEls = document.getElementById("naveng");
	if(sfEls){
	var sfEls = sfEls.getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			hideSelect();
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			unhideSelect();
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);
 
function hideSelect() {
	if (document.all) {
		if(document.all.makefield){ document.all.makefield.style.visibility="hidden";}
		if(document.all.modelfield){ document.all.modelfield.style.visibility="hidden";}
	}
}

function unhideSelect() {
	if (document.all){
		if(document.all.makefield){ document.all.makefield.style.visibility="visible";}
		if(document.all.modelfield){ document.all.modelfield.style.visibility="visible";}
	}
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );
    
  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";  
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
   
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

