/* =========================================================
// 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 = '13';
		if ($(this).css('font-size') != '') {
			fontsizesav = parseInt($(this).css('font-size'));
		}
		var heightsav = $(this).height();
		var widthsav = textsav.length*fontsizesav*.60;
		
		var colorsav = '#CCC';
		if ($(this).css('color'))
			colorsav = $(this).css('color');
			
		if ($.browser.msie) {
			$(this).css('font-size', fontsizesav).css('width', heightsav+'px').css('height', widthsav+'px').css('font-family', 'Verdana').css('writing-mode', 'tb-rl').css('font-weight', 'normal');
		} else {
			var my_id = "canvas"+parseInt(Math.random()*1000);
			$(this).empty().append("<canvas id='"+my_id+"' width='"+heightsav+"' height='"+widthsav+"'>"+htmlsav+"</canvas>");
			vertical_text(textsav, fontsizesav, colorsav, my_id);
		}
		
	});
	return $(this);
};
})(jQuery);

function vertical_text(mytext, fontsize, colorsav, my_id){
	var canvas = document.getElementById(my_id);
	if (canvas.getContext){
		var context = canvas.getContext('2d');
		set_textRenderContext(context);
		if(check_textRenderContext(context)) {
			context.translate(80,0);
			context.rotate(Math.PI/2);
			context.strokeStyle = colorsav;
			context.strokeText(mytext,3,78-fontsize,fontsize-3);
			
		}
	}
}

$(document).ready(function(){
	$('.flipv').flipv();
});


/**
 * Set all passed elements to the same height as the highest element.
 * 
 * Copyright (c) 2010 Ewen Elder
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @author: Ewen Elder <glomainn at yahoo dot co dot uk> <ewen at jainaewen dot com>
 * @version: 1.0
**/ 
(function($){$.fn.equalHeightColumns=function(e){var J,a;e=$.extend({},$.equalHeightColumns.defaults,e);a=$(this);J=e.height;$(this).each(function(){if(e.children)a=$(this).children(e.children);if(!e.height){if(e.children){a.each(function(){if($(this).height()>J)J=$(this).height()})}else{if($(this).height()>J)J=$(this).height()}}});if(e.minHeight&&J<e.minHeight)J=e.minHeight;if(e.maxHeight&&J>e.maxHeight)J=e.maxHeight;a.animate({height:J},e.speed);return $(this)};$.equalHeightColumns={version:1.0,defaults:{children:false,height:0,minHeight:0,maxHeight:0,speed:0}}})(jQuery);
