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;		
	}
	
}


/* ASG CUSTOM */

var dg = function(elem) { return(document.getElementById(elem)); }
var i=0;

function resetFrags(){
	for(i=0;i<5;i++) {
		dg("fragment_"+(i+1)).style.display = "none";
		dg("btn"+(i+1)).innerHTML = '<a href="#" onClick="fragshow('+(i+1)+');"><img src="'+url_address+'media/image/home/tab-'+(i+1)+'-off.png" /></a>';
	}	
}

function fragshow(panelid){
	resetFrags();
	dg("fragment_"+panelid).style.display = "block";
	dg("btn"+panelid).innerHTML = '<img src="'+url_address+'media/image/home/tab-'+panelid+'-on.png" />';	
}

function preload(){	
	imageObj = new Image();	

	images = new Array();
	images[0]=url_address+"media/image/home/tab-1-off.png"
	images[1]=url_address+"media/image/home/tab-1-on.png"
	images[2]=url_address+"media/image/home/tab-2-off.png"
	images[3]=url_address+"media/image/home/tab-2-on.png"
	images[4]=url_address+"media/image/home/tab-3-off.png"
	images[5]=url_address+"media/image/home/tab-3-on.png"
	images[6]=url_address+"media/image/home/tab-4-off.png"
	images[7]=url_address+"media/image/home/tab-4-on.png"
	images[8]=url_address+"media/image/home/tab-5-off.png"
	images[9]=url_address+"media/image/home/tab-5-on.png"
	
	for(i=0; i<=9; i++) 
	{
	  imageObj.src=images[i];
	}
}

window.onload = function() {
	resetFrags();
	preload();
	dg("fragment_1").style.display = "block";
	dg("btn1").innerHTML = '<img src="'+url_address+'media/image/home/tab-1-on.png" />';
}
