$(document).ready(function() {
    // do stuff when DOM is ready
    $("#maincolumn").css("width", "100%");
    if ($("#specials").size() > 0) {
        $("#specials").hide().delay(500).slideDown(500);
    }
    if ($("#news").size() > 0) {
        $("#news").hide().delay(500).slideDown(500);
    }
    // Style text in content
    var newContent = $(".content").html().replace("Euro Massage","<span style='color:#EC008C'>Euro Massage</span>");
    newContent = newContent.replace(/you/g, "<span style='color:#EC008C'>you</span>")
    newContent = newContent.replace(/You/g, "<span style='color:#EC008C'>You</span>")
    $(".content").html(newContent);
    // Image rotation
    var odd=false;
    $(".content img").each(function( intIndex, image ){
        var degree = Math.floor(Math.random()*11);
        $(image).attr("id", "contentPicture_" + intIndex);
        var floating = $(image).css("float");
        if (odd) {
            $(image).rotate(-3-degree);
        } else {
            $(image).rotate(3+degree);
        }
        odd=!odd;
        $("#contentPicture_" + intIndex).css("float", floating);
        $("#contentPicture_" + intIndex).addClass("rotatedPicture");
        $("#contentPicture_" + intIndex).fadeIn(1000);
    });
    // resize and show the widgets
    if ($("#form1\\:lastTreatment").size() > 0) {
        var mainWidth = $("#maincolumn").width();
        if ($("#specials").size() > 0) {
            mainWidth -= $("#specials").width();
            mainWidth -= 5;
        }
        if ($("#news").size() > 0) {
            mainWidth -= $("#news").width();
            mainWidth -= 5;
        }
        mainWidth -= 15;
        $("#form1\\:lastTreatment").width(mainWidth);
        $("#form1\\:nextTreatment").width(mainWidth);
        $("#form1\\:lastTreatment").hide().delay(500).slideDown(500);
        $("#form1\\:nextTreatment").hide().delay(500).slideDown(500);
    }

    $("#form1\\:lastTreatment table td:nth-child(1)").addClass('firstChild');
    $("#form1\\:nextTreatment table td:nth-child(1)").addClass('firstChild');
    $("#form1\\:lastTreatment span:nth-child(2)").addClass('secondChild');
    $("#form1\\:nextTreatment span:nth-child(2)").addClass('secondChild');
    $("#form1\\:lastTreatment table td:nth-child(3)").addClass('thirdChild');
    $("#form1\\:nextTreatment table td:nth-child(3)").addClass('thirdChild');

    // replace main span tag of .content
});
