function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}

// Forms
function goBack(thisform)
{
thisform.step.value = thisform.step.value - 1;
var new_form_action = 'thisform.' + thisform.name + '_action'
eval(new_form_action).value="back";
thisform.submit();
}


function RunContent(file,width,height)
{
var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '"><param name="movie" value="' + file + '" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><embed src="' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="' + width + '" height="' + height + '"></embed></object>';
// many thanks to gareth livingstone for his transparency testing on firefox.
document.write(str);
}


function UpdateFrame(page_id,mode)
{
if(mode=="preview"){
parent.frames[0].location.href = url_address + "admin/website_admin/edit_page_tabs.cfm?dsp=preview&web_page_id=" + page_id;
}
else
{
parent.frames[0].location.href = url_address + "admin/website_admin/edit_page_tabs.cfm?dsp=edit_page&web_page_id=" + page_id;
}
}

function usrfunc(usr,page_id,mode)
{
if((mode=="edit" || mode=="preview" || mode=="audit") && (window.name!="edit_page" && window.name!="preview_page" && window.name!="audit" && window.name!="current" && window.name!="preview" && window.name!="mainFrame") && usr!=0)
{
window.parent.location.href=url_address + 'index.cfm?page=' + page_id + '&mode=normal';
}
if(window.name=="edit_page" && mode!="edit")
{
window.location.href=url_address + 'index.cfm?page=' + page_id + '&mode=edit';
}

if(window.name=="edit_page" || window.name=="preview_page")
{
UpdateFrame(page_id,mode);
}

}

function searchEffect(element,state) {

            if(state == 'on' && element.value=='Search site') {
                        element.value='';
                        element.style.color='#00257b';
            } else if(state == 'off' && element.value=='') {
                        element.value='Search site';
                        element.style.color='#00257b';
            }

}
