/* =========================================================
// jquery.flipv.js
// Author: OpenStudio (Arnault PACHOT)
// Mail: apachot@openstudio.fr
// Web: http://www.openstudio.fr
// Copyright (c) 2008 OpenStudio http://www.openstudio.fr
========================================================= */


(function($) {

    $.fn.flipv = function(options) {

        this.each(function() {
            var htmlsav = $(this).html();
            var textsav = $(this).text();
            var fontsizesav = '14';
            if ($(this).css('font-size') != '') {
                fontsizesav = parseInt($(this).css('font-size'));
            }
            var heightsav = 25;
            var widthsav = textsav.length * fontsizesav * .60;

            var colorsav = '#FFF';
            if ($(this).css('color'))
                colorsav = $(this).css('color');

            if ($.browser.msie) {
                $(this).css('writing-mode', 'tb-rl').css('filter', 'flipv fliph');
            } else {
                $(this).empty().append(svg_vtext(textsav, widthsav));
            }
        });
        return $(this);
    };
})(jQuery);

function svg_vtext(mytext, textwidth) { 
    return '<object style="height: '+textwidth+'px;" type="image/svg+xml" data="data:image/svg+xml,<svg xmlns=\'http://www.w3.org/2000/svg\'>' +
           '<text x=\'-' + (textwidth-0) + '\' y=\'16\' font-family=\'Arial\' font-size=\'13\' transform=\'rotate(-90)\' text-rendering=\'optimizeSpeed\' fill=\'#FFF\'>' + mytext + '</text>' +
           '</svg>">' +
	       '<div class="old_canv">' + mytext + '</div>' +
           '</object>'
}

$(document).ready(function(){
	$('.flipv').flipv();
});


