// JavaScript Document
var $showSize=0;
var $showColor=0;
var $ActionCounter=0;
var $stop=0;

function CMSinit(){
	if(document.getElementById("CMSeditor")){
		//document.body.innerHTML="<div style='width:100%; height:40px;'></div>"+document.body.innerHTML;
		CMSiterator();
	}
}

function CMSactivate(){
	if (document.all){
		$frameSize=document.frames("CMSeditor").document.documentElement.scrollHeight;
	} else {
		$frameSize=document.getElementById("CMSeditor").contentDocument.body.scrollHeight;
	}
	if ($frameSize<150){
		document.getElementById("CMSeditor").style.height=150+"px";
	} else {
		document.getElementById("CMSeditor").style.height=$frameSize+50+"px";
	}
	
	document.getElementById("CMSeditor").contentWindow.document.designMode="on";
}

function CMSiterator(){
	if(document.getElementById("CMStoolbar")){
		$ActionCounter++;
		if($ActionCounter>5 && $stop==0){
			CMSactivate();
			$stop=1;
		}
		if(document.all){
			document.getElementById("CMStoolbar").style.top=document.documentElement.scrollTop;
		} else {
			document.getElementById("CMStoolbar").style.top=document.body.scrollTop;
		}

// -------------------- TOOLBAR SCRIPTS ------------------------		
		if($showSize>1){
			$showSize+=1;
		}
		if($showSize>50){
			document.getElementById("CMStextsize").style.display="none";
			$showSize=0;
		}
		if($showColor>1){
			$showColor+=1;
		}
		if($showColor>50){
			document.getElementById("CMStextcolor").style.display="none";
			$showColor=0;
		}
// -------------------------------------------------------------		
	}
	setTimeout("CMSiterator();", 1);
}

function CMSshowSize(){
	$showSize=1;
	document.getElementById("CMStextsize").style.display="block";	
}
function CMShideSize(){
	$showSize=2;
}

function CMSshowColor(){
	$showColor=1;
	document.getElementById("CMStextcolor").style.display="block";	
}
function CMShideColor(){
	$showColor=2;
}