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>';
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);
}

}


// Google Adwords Functionality

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function getRef()
{
	ref = document.referrer;
	re = /(\?|&)(q|p)=([^&]*)/;
	searchq = re.exec(ref);
	if(searchq) {
		__utmSetVar(searchq[3]);
	}
}

function sleuth()
{
	if (document.cookie.indexOf("__utmz=") != -1)
	{
		z = readCookie('__utmz');
		za = z.split('|');
		t = za[0].split('.');
		za[0] = t[t.length - 1];
		for (i = 0; i < za.length; i++)
		{	
			t2 = za[i].split('=');
			if (t2[0] == 'utmgclid' || t2[1] == 'cpc' || t2[1] == 'ppc')	{
				getRef();
			}
		}
	}
}

/*
var popunder=new Array()
popunder[0]="http://www.compareandsave.com/surveys/barclays.cfm"

// Specify the width and height of new popunder window (in pixels).
var width = '580';
var height = '800';

var p = 'scrollbars=yes,resizable=yes,toolbar=no,menubar=yes,status=yes,location=no,left=85,top=20,height=' + height + ',width=' + width;



function getCookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadornot(){
if (getCookie('popunder')==''){
popUnder()
document.cookie="popunder=yes"
}
}
function popUnder(){
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
win2.blur()
window.focus()
}


*/