$(function(){
function changeStringCase(str) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = str.toLowerCase();
	strLen = tmpStr.length;
		if (strLen > 0) {
			for (index = 0; index < strLen; index++) {
				if (index == 0) {
					tmpChar = tmpStr.substring(0,1).toUpperCase();
					postString = tmpStr.substring(1,strLen);
					tmpStr = tmpChar + postString;
				}else {
					tmpChar = tmpStr.substring(index, index+1);
					
				}
			}
		}
	return tmpStr;
}		   
if($.browser.msie){
	$(".createbox").css({height:"500px"});
	}
$(".createbox").find(".editHelp").find("a").each(function(){
						$(this).parent().after('<input type="button" name="button" id="button" value="'+$(this).text()+'" onclick="javascript:window.location.href=\''+this.href+'\'" />');						
						$(this).hide();
														  })
//change buttonStyle
var mxst = 15;
if($.browser.msie){
	mxst = 27;
	}
function changeStyle(){
		  var buttonConn = $(".mxbutton");
			buttonConn.each(function(){
			var aButton = null;
			if($(this).find("a").size()>0)						 
			aButton = $(this).find("a").get(0);
			if(aButton){
			var href = $(aButton).attr('href');
	   		var text = aButton.innerHTML;
	   		var newAbuttons =  document.createElement('a');
	    	var width = "10px"
			this.style.width = "";
	    	if(this.style.width)width =  this.style.width
			newAbuttons.style.width = $(aButton).width()+mxst+"px";
			if(href.indexOf('#')!=-1)href='javascript:;';
			newAbuttons.href = href;
			newAbuttons.className = "EditButtonStyle";
		 	this.appendChild(newAbuttons);
		 	var abuttonDIV = document.createElement('span');
			abuttonDIV.innerHTML = changeStringCase(text);
		 	newAbuttons.appendChild(abuttonDIV);
	    	$(aButton).remove();
			}
			})
		}
	function hiddenButton(){
			  var buttonConn = $(".mxbutton");
			  buttonConn.each(function(){
			  var aButton = null;
			  if($(this).find("a").size()>0)						 
			  aButton = $(this).find("a").get(0);
			  if(aButton){
			  if(this.className.indexOf("private")!=-1){
			 		 this.style.display="none";
			  }else{
			  	 var aButton = $(this).find("a").get(0);
			     var href = $(aButton).attr('href');
	         var text = aButton.innerHTML;
	         var newAbuttons =  document.createElement('a');
	         var width = "10px"
	         if(this.style.width)width =  this.style.width
	
		      newAbuttons.style.width = $(aButton).width()+mxst+"px";
			if(href.indexOf('#')!=-1)href='javascript:;';
		       newAbuttons.href = href;
		       newAbuttons.className = "EditButtonStyle";
		       this.appendChild(newAbuttons);
		       var abuttonDIV = document.createElement('span');
		       abuttonDIV.innerHTML = changeStringCase(text);
		       newAbuttons.appendChild(abuttonDIV);
	         $(aButton).remove();	
			  }
			  }	
			})
		}	
	if(isMyPage===undefined){
		;
	}else{
		if(!isMyPage){ //hidden button
				hiddenButton();
			}else{
				changeStyle();
				}
	}
 	
	   	
		
	//if right dom is none	
	
	if($("#contents .right").size()==0)
	$(".centers").get(0).style.width="812px";
	
	if($("#hideRight").size()>0){
			$("#hideRight").hide();
			$("#rightContent").hide();
			$(".centers").get(0).style.width="812px";
		}
	if($("#hideContentSub").size()>0){
			$("#contentSub").hide();
		}	
	if($("#hideFirstHeading").size()>0){
			$(".firstHeading").hide();
		}		
	
	
	//change edit button color
	if($("#ca-edit").size()>0){
	var o = $("#ca-edit").get(0);
	/*if(!$(o).hasClass("selected")){
		$(o).css("opacity","0.4");
		
		$(o).bind("mouseover",function(){
			$(o).css("opacity","1");						   
									})
		$(o).bind("mouseout",function(){
			$(o).css("opacity","0.4");						   
									})
	}*/
	o.className="";	
	o.style.backgroundColor = "#E70072";
	o.style.color = "#FFFFFF";
	$(o).find("div").get(0).style.fontWeight = "bold";
	o.style.fontFamily  = "Arial, Helvetica, sans-serif";
	}
})




