function trim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(" " + str + " ");
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
			j++;
		}
            s = s.substring(j, i);
	}

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;       
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
			i--;
		}
            s = s.substring(0, i+1);
	}
	return s;
}

function openLightWindow(url, mytitle, height, width) {
    $.fn.colorbox({ href: url, height: height, width: width, transition: "elastic", iframe:true, title: mytitle });
}
function openModal(mytitle, w, h, url) {
    if (w > 0) {
        $.fn.colorbox({ href: url, height: h, width: w, transition: "elastic", iframe:true, title: mytitle });
    }
    else {
        $.fn.colorbox({ href: url, transition: "elastic", iframe:true, title: mytitle });
    }
}
function openModalInline(mytitle, w, h, url) {
    if (w > 0) {
        $.fn.colorbox({ href: url, height: h, width: w, transition: "elastic", inline: true, title: mytitle });
    }
    else {
        $.fn.colorbox({ href: url, transition: "elastic", inline: true, title: mytitle });
    }
}
function openInline(mytitle, w, h, url, isinline) {
    $.fn.colorbox({ href: url, height: h, width: w, transition: "elastic", iframe:true, title: mytitle, inline: isinline });
}
function win(URL, w, h) {
    swidth = (screen.width - w) / 2;
    sheight = (screen.availHeight - h) / 2
    var win = window.open(URL, 'win', 'width=' + w + ',height=' + h + ',top=' + sheight + ',left=' + swidth + ',resizable=yes,scrollbars=yes,toolbar=yes,location=yes');
    win.focus();
}
function winMin(URL, w, h) {
    swidth = (screen.width - w) / 2;
    sheight = (screen.availHeight - h) / 2
    var win = window.open(URL, 'win', 'width=' + w + ',height=' + h + ',top=' + sheight + ',left=' + swidth + ',resizable=yes,scrollbars=no,toolbar=no,location=yes');
    win.focus();
}
