function errorHandler(message)
{
	$('disabledZone').style.visibility = 'hidden';
    if (typeof message == "object" && message.name == "Error" && message.description)
    {
        alert("Error: " + message.description);
    }
    else
    {
        alert(message);
    }
}

function toggle(theID) {
foo = document.getElementById(theID);
if (foo.style.display == 'none') foo.style.display = 'inline';
else foo.style.display = 'none';
return;
}
// this function puts the dark screen over the entire page
function dark()
{
   var myHeight = document.body.scrollHeight;
   if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
   var page_screen = document.getElementById('page_screen');
   page_screen.style.height = myHeight + 'px';
   page_screen.style.display = 'block';
}

// this function removes the dark screen and the page is light again
function light()
{
   var page_screen = document.getElementById('page_screen');
   page_screen.style.display = 'none';
}

function stripNonAlphaNumeric(str) {
  var r = str.replace(/[^a-zA-Z0-9]+/g,'');
  return r;
}

function fixString(str) {
  var r = str.replace(/"/g,"'");
  r = r.replace(/#/g, "");
  r = r.replace(/''/g,"' '");
  return r;
}

function editContent(groupID,blockID,instanceID,wysiwyg) {
	//DWRUtil.useLoadingMessage();
	DWREngine._execute(_cfscriptLocation,null,'makeEditContent',groupID,blockID,instanceID,wysiwyg,showEdit);
	return false;
}

function editHeader(groupID,blockID,instanceID) {
	//DWRUtil.useLoadingMessage();
	DWREngine._execute(_cfscriptLocation,null,'makeEditHeader',groupID,blockID,instanceID,showEdit);
	return false;
}

function showEdit(editContent) {
	var foo = document.getElementById('editWindow');
	var bar = document.getElementById('editContent');
	    w = 850;
	    h = 600;
	    xc = Math.round((document.body.clientWidth/2)-(w/2))
	    yc = Math.round((document.body.clientHeight/2)-(h/2))
	    
	    foo.style.left = xc + "px";
	    foo.style.top  = yc + "px";
	    foo.style.display = 'block';
		bar.innerHTML = editContent;
	
		dark();
}
function hideEdit() {
	var foo = document.getElementById('editWindow');
	var bar = document.getElementById('editContent');
	bar.innerHTML = '';
	foo.style.display='none';
	light();
}

function updateContent (groupID,blockID,instanceID,new_Content) {
	//DWRUtil.useLoadingMessage();
	DWREngine._execute(_cfscriptLocation,null,'update_Content',groupID,blockID,instanceID,escape(new_Content),doneEdit);
	return false;
}

function updateHeader (groupID,blockID,instanceID,new_Content) {
	//DWRUtil.useLoadingMessage();
	DWREngine._execute(_cfscriptLocation,null,'update_Header',groupID,blockID,instanceID,new_Content,doneEdit);
	return false;
}

function doneEdit(doneArray) {
	// array is [groupID,blockID,instanceID,newContent]
	var foo = document.getElementById('miniCMS_' + doneArray[0] + '_' + doneArray[1] + '_' + doneArray[2]);
	foo.innerHTML = doneArray[3];
	hideEdit();
}

