//showRoundedButton shows rounded buttons of different classes
//$Id: showRoundedButton.js 33621 2010-04-08 11:06:22Z iargent $
function showRoundedButton(){
	
	//detection numerical browser version 
	var browserVersion = $.browser.version;	
	
	while (browserVersion.lastIndexOf(".")!=-1 && browserVersion.lastIndexOf(".")!=1){	
		browserVersion = browserVersion.substr(0,browserVersion.lastIndexOf("."));	
	}
	
	browserVersion = Number(browserVersion);

	route = "../../../../../static/img/cm/button_states/";
	
	finalClassName = "." + $(this).attr("class");	
	
	do	{
		idTemp = "buttonwrapper" + Math.round(Math.random()*10000);
	}	while ($("#" + idTemp).length == 1);

	
	if ($(this).attr("class").indexOf(" ")!=-1){
		className = $(this).attr("class").substr(0, $(this).attr("class").indexOf(" "));
		aditionalClasses = $(this).attr("class").substr($(this).attr("class").indexOf(" "), $(this).attr("class").length);
		str = '<div class="button-wrapper-' + className  + ' ' +  aditionalClasses + '" id="' + idTemp + '"></div>';
	}	else	{
		className = $(this).attr("class");
		str = '<div class="button-wrapper-' + className  + '" id="' + idTemp + '"></div>';
	}
		
	$(this).wrap(str);
	
	var left  = "<img src='" + route + className + "-left.gif'  style='float:left;' />";
	var right = "<img src='" + route + className + "-right.gif' style='float:left;' />";
	
	var id = "#" + idTemp;
	
	$(id).prepend(left);
	$(id).append(right);
	
	var input = "#" + idTemp + " input, #" + idTemp + " button";
	
	$(input).css("background" , "url(" + route + className + "-back.gif)");
	$(input).css({
		"float":"left",				
		"background-repeat" : "repeat-x",
		"border": "none",
		"color": "white",
		"font-size" : "12px",
		"text-transform" : "uppercase",
		"height" : "27px",
		"margin" : "0",
		"padding": "0",
		"overflow": "visible",
		"font-weight" : "bold"		
	});				

	$(input).bind('disable', function(){		
		$(this).css("color", "#666666").attr("disabled", "disabled").css("cursor", "default");		
	})
	
	$(input).bind('enable', function(){		
		$(this).css("color", "#ffffff").removeAttr("disabled").css("cursor", "pointer");		
	})
	
	$(input).hover(
		function(){			
					
			if ($(this).attr("class").indexOf(" ")!=-1){
				className = $(this).attr("class").substr(0, $(this).attr("class").indexOf(" "));
			}	else	{
				className = $(this).attr("class");
			}	
					
			$(this).css("background" , "url(" + route +  className + "-back2.gif)")
					.css("color" , "#cccccc")
					.css("background-repeat" , "repeat-x");		
			
			$(this).prev().attr("src", route + className + "-left2.gif");
			$(this).next().attr("src", route + className + "-right2.gif");
			
		},
		function(){
			
			if ($(this).attr("class").indexOf(" ")!=-1){
				className = $(this).attr("class").substr(0, $(this).attr("class").indexOf(" "));
			}	else	{
				className = $(this).attr("class");
			}	
			
			$(this).css("background" , "url("  + route + className + "-back.gif)")
					.css("color" , "white")
					.css("background-repeat" , "repeat-x");

			$(this).prev().attr("src", route + className + "-left.gif");
			$(this).next().attr("src", route + className + "-right.gif");
		}
	);
}
//showRoundedButton shows rounded buttons of different classes