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 usrfunc(usr,page_id,mode,querystring)
{
	
	if((mode=="edit" || mode=="preview" || mode=="audit") && (window.name!="page_frame" && window.name!="history_frame" && window.name!="current_content_frame") && usr!=0)
	{
		window.parent.location.href=url_address + 'index.php?page=' + page_id + '&mode=normal';
	}
	
	if(window.name=="page_frame" && mode!="edit" && mode!='audit') {
		
		window.parent.location.href = url_address + "_refresh/frame_main.php?module=sites&module_page=site_edit_page&page_id=" + page_id;		
	}
	
}

function searchEffect(element,state) {

	if(state == 'on' && element.value=='Enter search criteria') {
		element.value='';
		element.style.color='#000000';
	} else if(state == 'off' && element.value=='') {
		element.value='Enter search criteria';
		element.style.color='#a2aec0';
	}

}
