function winOpen(url,name,w,h)
{
	window.open(url,name,"location=0,address=0,status=0,scrollbars=0,menubar=0,directories=0,width="+w+",height="+h);
}

function winOpen2(url,name,w,h,s) 
{
	window.open(url,name,"top=0,location=0,address=0,status=0,scrollbars="+s+",menubar=0,directories=0,width="+w+",height="+h);
}

function winOpen3(url,name,w,h,s) 
{
	window.open(url,name,"location=0,address=0,status=0,scrollbars="+s+",menubar=0,directories=0,width="+w+",height="+h);
}

function winOpen4(url,name,w,h,s) 
{
	window.open(url,name,"location=0,address=0,resizable=1,status=yes,scrollbars="+s+",menubar=0,directories=0,width="+w+",height="+h);
}
// matches one whole string inside another and replaces all occurrences it with a third string
// o = the main string
// i = the string you want to look for in 'o'
// t = the string you want to replace in 'i's position (can be blank)

function stringreplace(o,i,t) {
 if (!t) t=null;
 r = new RegExp(i);
 r.compile(i,"g")
 re = r.valueOf();
 return o.replace(re, t);
}

var bload;
function gleanInfo() {
  if (bLoad) {
    var i,args = gleanInfo.arguments;
    if (args.length > 0) {
        var strForm = args[0];
        var strField = '';
        var strFormVal = '';
        
        for (i=1;i < args.length;i++) {
            strField = args[i];
            strFormVal = 'editBox'+strField
            if (document.getElementById(strFormVal)) {
	            strFormVal = document.getElementById(strFormVal).html;
	            //alert(strFormVal);
	            document.getElementById(strField).value = cleanUp(strFormVal);
	           //alert('foo:'+document.getElementById(strField).value);
			}
        }
    } 
  }
}
function cleanUp(sHtml) {
  re = new RegExp("http\:\/\/hd2(\:80)?\/", "gi");
  return sHtml.replace(re, '/');
}

function check(field,state) 
{
    var box = document.forms[0].elements[field];
    var i;
    for (i=0; i != box.length; i++) {
        box[i].checked = state;
    }
}
function parseForm(field,buttonName)
{
	var flag=0;
    var box = document.forms[0].elements[field];
                
    for (var i=0; i != box.length; i++) {
        if (box[i].checked == true) {
            flag=1;
            document.getElementById(buttonName).click(); 
        }
    }
    if (flag == 0) {
        alert("Please select one or more options");
    }
}

function popDescription(table,rowguid,wide,high) {
	var w = window.open('popDescription.asp?Table='+table+'&id='+rowguid,'desc','width='+wide+',height='+high+',scrollbars=1,resizable=1,status=1');
	w.focus();
}


//
//	VBScript equivalent functions (for the lazy programmer), capitalised to avoid clashes
//
function Trim(szWhat) {
	return(szWhat.replace(/^\s*|\s*$/g, ""));
}

function Left(str, n){
	if (n <= 0) {
		return "";
	} else if (n > String(str).length) {
		return str;
	} else {
		return String(str).substring(0,n);
	}
}
function Right(str, n) {
	if (n <= 0) {
		return "";
	} else if (n > String(str).length) {
		return str;
    } else {
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

function objPosition( obj ) {
	if (typeof obj == 'string') obj = document.getElementById( obj );
	if (obj) {
		var w = parseInt(obj.offsetWidth);
		var h = parseInt(obj.offsetHeight);
		if ( obj.offsetParent ) {
			for ( var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent ) {
				posX += parseInt(obj.offsetLeft);
				posY += parseInt(obj.offsetTop);
			}
			if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
				var l = parseInt(document.body.leftMargin);
				var t = parseInt(document.body.topMargin);
				w += l;
				h += t;
			}
			return[ posX, posY, w, h ];
		} else {
			return[ obj.x, obj.y, w, h ];
		}
	} else {
		return [0,0,0,0];
	}
}
