$(document).ready(function() {
    var numOfLinks;
    var lastLink;
    var imgUrl;
    var imgW;
    var imgH;
    var text;
    $('.holder').each(function(index) {

        thisImg = $(this).find("img");
        
        tag = thisImg.next().get(0); //.tagName;
       // alert($(this).children().children().get(0).tagName);
        firstTag = $(this).children().children().get(0).tagName;
        firstTag = firstTag.toLowerCase();
        if (thisImg.length == 1) {
            if (firstTag != 'img') {
                tag = thisImg.next().get(0).tagName;
                tag = tag.toLowerCase();
                imgUrl = thisImg.attr('src');
                if (tag == "a") {
                    numOfLinks = $(this).find('a').size();

                    lastLink = $(this).find('a').get(numOfLinks - 1);

                    lastLink_obj = $(this).find('a').filter(function(i) {
                        return i == numOfLinks - 1;
                    });
                    textOfLastLink = lastLink_obj.html();

                    thisImg.attr({
                        style: "display:none"
                    });

                    $(lastLink).attr({
                        style: "display:none"
                    });

                    text = $(this).contents().html();

                    $(this).html('<div style="float:left;width:252px;overflow:hidden">' + text + '</div><div style="width:225px;overflow:hidden;padding-left:8px"><div style="text-align:right;padding-bottom:25px"><a style="display:block;text-decoration:underline;font-size:0.9em;color: #6a037c;line-height:100%;" href="' + lastLink + '">' + textOfLastLink + '</a></div><a href="' + lastLink + '"><img src="' + imgUrl + '" border="0" style="padding:0px"/></a></div>');
                }
            }

        } else {
            thisImg.attr({
                style: "display:none"
            });
            $(this).prepend('<img src="' + imgUrl + '" border="0" style="padding:0px"/>');

        }
    });

});
function clearText(thefield) {
    if (thefield.defaultValue == thefield.value) thefield.value = ""
}