var jripMaxLength = 450;
var jripMaxheight = 65;


$(document).ready(function() {

    $(".jrip").each(function(i) {
	
		// alert(escape($(this).html()));
	
        attr = getremotevalue("/jrip/jrip.aspx?text=" + escape($(this).html()) + "&class=" + escape($(this).attr("class")) + "&ie=" + jQuery.browser.msie).split(",");

        if (attr[0] != "-1") {
	
			var mwidth = attr[1];
			if(mwidth > jripMaxLength){ mwidth = jripMaxLength; }
			
			var mheight = attr[2];
			if(mheight > jripMaxheight){ mheight = jripMaxheight; }
	
            if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) {
	
				if(this.style.width==""){ this.style.width = mwidth + "px"; }
				if(this.style.height==""){ this.style.height = mheight + "px"; }

                //this.style.width = mwidth + "px";
                //this.style.height = mheight + "px";
                // this.style.background = "url(" + attr[0] + ")";
                $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + attr[0] + "')")
                $(this).addClass("jripClass");

            } else {
                if(this.style.width==""){ this.style.width = mwidth + "px"; }
				if(this.style.height==""){ this.style.height = mheight + "px"; }
                
                this.style.background = "url(" + attr[0] + ")";
                $(this).addClass("jripClass");

            }
        }

    });

});

function getremotevalue(url){
	var content = '';

	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (request){
		request.open("GET", url, false);
		request.send(null);

		if (request.status == 200) {
			content = request.responseText;
		} else {
			content = 'Error: ' + request.status + ' ' + request.statusText;
		}
	}
	return content;
}
