
var changing=false;function EnableEditMode(control,contentKey){if(!changing){var width=widthEl(control.id)+20;var height=heightEl(control.id)+2;if(width<100)width=150;if(height<14)height=14;var fontSize=control.style.fontSize;if(height<40)
control.innerHTML="<input contentKey=\""+contentKey+"\" id=\""+control.id+"_field\" style=\"width: "+width+"px; height: "+height+"px; font-size:"+fontSize+"px;\" maxlength=\"254\" type=\"text\" value=\""+control.innerHTML+"\" onkeypress=\"return fieldEnter(this,event,'"+control.id+"')\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'"+control.id+"');\" />";else
control.innerHTML="<textarea contentKey=\""+contentKey+"\" name=\"textarea\" id=\""+control.id+"_field\" style=\"width: "+width+"px; height: "+height+"px;\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'"+control.id+"');\">"+control.innerHTML+"</textarea>";changing=true;}
control.firstChild.focus();}
function widthEl(span){var w;if(document.layers){w=document.layers[span].clip.width;}else if(document.all&&!document.getElementById){w=document.all[span].offsetWidth;}else if(document.getElementById){w=document.getElementById(span).offsetWidth;}
return w;}
function heightEl(span){var h;if(document.layers){h=document.layers[span].clip.height;}else if(document.all&&!document.getElementById){h=document.all[span].offsetHeight;}else if(document.getElementById){h=document.getElementById(span).offsetHeight;}
return h;}
function fieldEnter(input,evt,idfld){evt=(evt)?evt:window.event;if(evt.keyCode==13&&input.value!=""){var elem=document.getElementById(idfld);noLight(elem);elem.innerHTML=input.value;updateContent(input);changing=false;return false;}else{return true;}}
function fieldBlur(input,idfld){if(input.value!=""){var elem=document.getElementById(idfld);var value=input.value;elem.innerHTML=value;input.value=value;updateContent(input);changing=false;return false;}}
function updateContent(input)
{var value=input.value;var contentKey=input.getAttribute("contentKey");var onComplete=new Function("response","textUpdateComplete(response, \""+input.id+"\");");var onError=new Function("response","textUpdateError(response, \""+input.id+"\");");try
{TextResourceUpdateService.UpdateResourceText(contentKey,value,onComplete,onError);}
catch(e)
{alert("The webservice reference cannot be found. Please make sure that the TextResourceUpdateService.asmx is included in your web project, and that there is a reference to it in your ScriptManager control.");}}
function textUpdateComplete(response,id)
{id=id.replace("_field","");var el=document.getElementById(id);var message="&nbsp;<span style=\"color: rgb(84,206,67);\">&#10003;Changes saved!</span>";el.innerHTML=response+message;setTimeout("document.getElementById('"+id+"').innerHTML = document.getElementById('"+id+"').innerHTML.substring(0,"+response.length+");",500);}
function textUpdateError(response,id)
{var el=document.getElementById(id.replace("_field",""));var message="&nbsp;<span style=\"color:#b30006\">&#10006;There was an error saving your changes.</span>";el.onclick="";el.innerHTML=message;}
function highLight(span){span.parentNode.style.border="2px solid #D1FDCD";span.parentNode.style.padding="0";span.style.border="1px solid #54CE43";}
function noLight(span){span.parentNode.style.border="0px";span.parentNode.style.padding="2px";span.style.border="0px";}
