function Trim(x) {
	var theString = x;
	if (theString.length > 0) {
		if (theString.charAt(0) == ' ') {
			return Trim(theString.substring(1,theString.length));
		} else if (theString.charAt(theString.length - 1) == ' ') {
			return Trim(theString.substring(0,(theString.length - 1)));
		} 
		else
			return theString;
		}
	else
		return theString;
}
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 checkBrokenImage(img){
	if (!IsImageOk(img)) {
		img.src = "/_img/noimageSmall.jpg";
	}
}


function IsImageOk(img) {
	// During the onload event, IE correctly identifies any images that
	// weren't downloaded as not complete. Others should too. Gecko-based
	// browsers act like NS4 in that they report this incorrectly.
	if (!img.complete) {
		return false;
	}
	// However, they do have two very useful properties: naturalWidth and
	// naturalHeight. These give the true size of the image. If it failed
	// to load, either of these should be zero.
	if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
		return false;
	}
	// No other way of checking: assume it's ok.
	return true;
}

function updateAdCounter(bannerid){
	try{
		var request = getRequestObj();
		request.open("get", "/_inc/act_retrieve_Data.cfm?data=updateBannerCLick&bannerid="+bannerid, false);
		request.send(null);
	} catch (e){ }
}

function getRequestObj() {
    var xmlhttp=false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");				
				} catch (e) {
					xmlhttp=false;
				}
		}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp=false;
        }
    }
    if (!xmlhttp && window.createRequest) {
        try {
            xmlhttp = window.createRequest();
        } catch (e) {
            xmlhttp=false;
        }
    }

	return xmlhttp;
}
//required for greybox
var GB_ROOT_DIR = "/_js/greybox/";