var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;

//preload rollover images
function preloadFunc(tempPath, varString) {
	imgArray = new Array();
	arrayOfString = new Array();
	arrayOfStrings = varString.split(',');
	for (i=0; i<arrayOfStrings.length; i++) {
		imgArray[i] = new Image();
		imgArray[i].src = tempPath + arrayOfStrings[i];
	}
}

function out(obj,color){obj.bgColor = color;}
function over(obj,color){obj.bgColor = color;cursor(obj);}
function cursor(obj){obj.style.cursor = 'hand'; }
function clicked(obj){if (obj.cells[1].children[0]){if (obj.cells[1].children[0].tagName == "A"){location.href = obj.cells[1].children[0].href;}}}
function clicked2(obj){if (obj.cells[0].children[0]){if (obj.cells[0].children[0].tagName == "A"){location.href = obj.cells[0].children[0].href;}}}
function clicked_blank(obj){if (obj.cells[0].children[0]){if (obj.cells[0].children[0].tagName == "A"){window.open(obj.cells[0].children[0].href);}}}

///////////////////////////////////////////////////////////////////////////////
//Global vars
//////////////////////////////////////////////////////////////////////////////

// whitespace characters
var whitespace = " \t\n\r";
//All the ilegal characters in a email adress i think!




var ilegal = "!\"#$%&'()*+,/:;<=>?[\\]^`{|}~ "
//																																																																		|
//var ilegal = "!\"#$%&'()*+,/:;<=>?[\\]^`{|}~  "
var g_strFromDB = "";
// Check whether string s is empty.
function isEmpty(s)
{
  return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s)
{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}
function isEmail (s,canBeEmpty)
{   if (isEmpty(s))
       if (!canBeEmpty) return false;
       else return true;

    // is s whitespace?
    if (isWhitespace(s)) return false;

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
   while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    //look for a dubble @
	 if (s.indexOf("@") != -1)
	 {
		if (s.indexOf("@",s.indexOf("@")+1) != -1)
		{
			return false;
		}
	 }
	 // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// checks for ilegal chars
function isLegal (s)
{   var i;

	//Well if the string is not a valid email adress then  add the @ sign
	if (isEmail(s)){ilegal1 = ilegal}else{ilegal1 = ilegal + "@"}
    // Search through string's characters one by one
    // until we find a ilegal character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (ilegal1.indexOf(c) != -1) return false;
    }

    // All characters are whitespace.
	 return true;
}


//Strips a numeric value of all illegal chars. Gunther Kruger.
function cleanNumericField(iVal) {
	var re = /\s|\W|\D/g;
	if ( iVal != '' ) {
		var tmpStr = iVal;
		tmpStr = tmpStr.replace(re, '');
		if ( tmpStr != '' ) {
			return parseInt(tmpStr);
		} else {
			return parseInt(0);
		}
	} else {
		return parseInt(0);
	}
}

function viewImage(obj,size) {
	alert("hi 2..");
	window.open('../cfm/showImage.cfm?imageName='+obj+'&size='+size,'imageWin','width=180,height=180,scrollbars=no,toolbars=no');
}
function twodec(value) {
	//tempValue = parseInt(value*100)/100;
  tempValue = parseInt(value);
  //Make Pretty Numbers
  //return commify(tempValue);
	return tempValue;
}
function cents(value) {
	tempValue = parseInt(value*100)/100;
  //tempValue = parseInt(value);
  //Make Pretty Numbers
  //return commify(tempValue);
	return tempValue;
}
function nodec(value) {
	tempValue = parseInt(value);
  //Make Pretty Numbers
  //return commify(tempValue);
	return tempValue;
}
function navi(value) {
  document.location='default.asp?nav='+value;
}
function subNavi(value,value2) {
  document.location='default.asp?nav='+value+'&subNav='+value2;
}

function showDiv(name) {
  theDiv = document.getElementById(''+name);
  theDiv.style.visibility='visible';
}
function hideDiv(name) {
  theDiv = document.getElementById(''+name);
  theDiv.style.visibility='hidden';
}

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;
}

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));
}
function readCookie(aName)
  {
    //alert(document.cookie);
    var start = document.cookie.indexOf(aName+"=");
    if (start == -1){return ''} 
    start = document.cookie.indexOf("=",start)+1;
    var end =  document.cookie.indexOf(";",start);
    if (end == -1){return ''}
    return unescape(document.cookie.substring(start,end));
  }
function getOBJ(obj) {
  return document.getElementById(''+obj);
  
} 

function money(variable) {
	
	var Num = String(variable);
	var newNum = "";
	var newNum2 = "";
	var count = 0;

	//this loop adds the commas
	for (var k = Num.length-1; k >= 0; k--){
		var oneChar = Num.charAt(k);
		if (count == 3){
			newNum += ",";
			newNum += oneChar;
			count = 1;
			continue;
		}
		else {
			newNum += oneChar;
			count ++;
		}
	} //but now the string is reversed!
	//re-reverse the string
	for (var k = newNum.length-1; k >= 0; k--){
		var oneChar = newNum.charAt(k);
		newNum2 += oneChar;
	}

	return newNum2;	
}

function changeContent(name,toName,fieldName) {
 obj = document.getElementById(''+name);
 toObj = document.getElementById(''+toName);
 toObj.innerHTML = obj.innerHTML;
 if (fieldName != '') {
   toField = document.getElementById(''+fieldName);
   toField.value = obj.innerHTML;
 }
}



