$(document).ready( Init );

function Init() {
	KondomRadio.Init();
}

var KondomRadio = {
	
	Txts : new Array(),
	
	Init : function() {
	
		// Check if kondomradion exists
		if( $('#kondomradio').is('div') ) {
			
			// Since radiobtns render differently in every browser we fix that here, CSS contains good values for FF
			if( jQuery.browser.safari ) {
				$('#kondomradio label input').css('marginLeft', '3px');
				$('#kondomradio label input').css('marginRight', '3px');				
			} else if( jQuery.browser.msie ) {
				$('#kondomradio label input').css('marginLeft', '0px');
				$('#kondomradio label input').css('marginRight', '0px');
			} 
			
			// Get the text-strings
			var allText = $('#kondomradio label span');
			
			// Get the labels and put the in an array for later use
			// We also asign an id to the label which is used for finding out which text to show
			for( i = 0 ; i < allText.length; ++i ) {
				KondomRadio.Txts[i] = allText[i].innerHTML;
				allText[i].parentNode.id = 'krlabel_' + i;
			}
		
			// Add the mouse-over/-out event that will trigger the tool-tip
			$('#kondomradio label').mouseover(KondomRadio.Show);
			$('#kondomradio label').mouseout(KondomRadio.Hide);
			
		}
	},
	
	Show : function() {
		// Get the array key from the label id
		var key = ( this.id ).split('_');
				key = key[1];
				
		// Build the tool-tip		
		var tool_tip = '<div id="tool_tip">';
				tool_tip+= '<p>' + KondomRadio.Txts[key] + '</p>';		
				tool_tip+= '</div>';
		
		// Append the tool-tip
		$('#kondomradio #' + this.id).append(tool_tip);

	},
	
	Hide : function() {
		$('#kondomradio #tool_tip').remove();
	}
}