NS6				= (document.getElementById&&!document.all);
IE				= (document.all);
IE4				= (document.all&&!document.getElementById);
NS				= (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4");
OP				= (navigator.userAgent.indexOf('Opera')>-1);
var jquery_api 	= jQuery.noConflict();


function PageOnLoad()
{	local_PageOnLoad();			}

function PageOnUnLoad()
{	local_PageOnUnLoad();		}

function OpenNewPicture(new_pix)
{	winNewPix = window.open('/scripts/site/show.picture?pix=' + new_pix, 'winNewPix', 'width=400,height=400,scrollbars=0,status=0,resize=1'); winNewPix.focus(); return false;		}

function MM_findObj(n, d) 
{	// v4.0
	var p, i, x;  
	
	if (!d) { d=document; }
	if((p = n.indexOf("?")) > 0 && parent.frames.length) 
	{	d = parent.frames[n.substring(p+1)].document; 
		n = n.substring(0,p);
	}
	if (!(x = d[n]) && d.all) { x=d.all[n]; 	}
	for (i = 0; !x && i < d.forms.length; i++) { x = d.forms[i][n];		}
	for (i = 0; !x && d.layers && i < d.layers.length; i++) { x = MM_findObj(n,d.layers[i].document);	}
	if (!x && document.getElementById) { x=document.getElementById(n); }
	return x;
}

var ar_OpenPopupMenus = new Array();

function MM_showHideLayers() 
{	//v3.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	
	for (i = 0; i < (args.length-2); i += 5) 
	{	if ((obj = MM_findObj(args[i])) != null) 
		{	st_object_name = args[i+0];
			e = args[i+1];
			v = args[i+2];
			dx = args[i+3];
			dy = args[i+4];
			offsetLeft = args[i+5];
			offsetTop = args[i+6];
			if (obj.style) 
			{	obj = obj.style; 
				if (v == 'show')
				{	obj.left = offsetLeft + dx;
					obj.top = offsetTop + dy; 
					for (in_popup_menu = 1; in_popup_menu <= ar_OpenPopupMenus.length; in_popup_menu++) 		// clear all timeouts and also close open menus
					{	if (ar_OpenPopupMenus[in_popup_menu-1] != "Processed")
						{	popup_to_close = ar_OpenPopupMenus[in_popup_menu-1];
							popup_to_close.visibility = 'hidden';
							ar_OpenPopupMenus[in_popup_menu-1] = "Processed";	// mark element as processed
						}
					}
					ar_OpenPopupMenus[ar_OpenPopupMenus.length] = obj;
//					setTimeout("document.all." + st_object_name + ".style.visibility = 'hidden';", 20000); 
					setTimeout("document.getElementById(" + st_object_name + ").style.visibility = 'hidden';", 20000); 
				}
				v = ((v == 'show' || v == 'nochange')? 'visible' : (v == 'hide') ? 'hidden' : v ); 
			}
			obj.visibility = v; 
		}
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function resize_browser_to_limits()
{	this.resizeTo(window.screen.availWidth, window.screen.availHeight);		}

function confirmMessageBox(st_message, st_name, st_url, st_next_page) 
{	switch(confirm(st_message + " '" + st_name + "'?"))
	{	case true:
			location.href = st_url;
			if (st_next_page == "undefined")
			{	st_connector = ((st_url.search("/?/i") > -1)? "?" : "&");
				location.href = (st_url + st_connector + "st_next_page=" + st_next_page);
			}
			break;
		case false:
			break;
	}
}

function confirmDelete(iname, delURL, referer) 
{	if (confirm("Are you sure you wish to delete '" + iname + "'?")) 
	{	location.href = (delURL + "&referer_page=" + referer);		}
}

//for popup windows e.g to display zipcodes
function PopUp(st_popupURL, st_name, in_width, in_height, bo_scroll) 
{	window.open(st_popupURL, st_name,'width=' + in_width + ',' + 'height=' + in_height + ',' + 'scrollbars=' + bo_scroll);		}

function PopUpPage(st_popupURL, st_name, st_parameters) 
{	window.open(st_popupURL, st_name, st_parameters);																			}

function openPage(pageURL)
{	location = pageURL;																											}

// will close the current window and reload the parent window
function reload_parent_form(in_index)
{	switch (in_index)
	{	case 0:									// open the formMemberProfile form 
			opener.formMemberProfile.submit();
			break;
		case 1:									// open the formMemberProfile form 
			opener.formProject.submit();
			break;
		default:
			self.opener.submit();
	}
	window.close();
}

function test()
{	alert('function test called');
}

function parent_redirect(url)
{	self.opener.location = url;
}

function refreshParent()
{	self.opener.location.reload();
	window.close();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function moveOut() {
	if(parseInt(ssm.left)<0&&mPos||parseInt(ssm.left)>0&&!mPos){
		clearTimeout(moving);
		moving=setTimeout('moveOut()', slideXSpeed);
		slideMenu((!mPos)?"out":"out");
		}
	else {
		clearTimeout(moving);
		moving=setTimeout('null',1);
	}
}
function moveBack() {
	clearTimeout(moving);
	moving=setTimeout('moveBack1()',waitTime);
}
function moveBack1() {
	if(parseInt(ssm.left)>-(menuWidth+1)&&mPos||parseInt(ssm.left)<menuWidth+1&&!mPos) {
		clearTimeout(moving);
		moving=setTimeout('moveBack1()',slideXSpeed);
		slideMenu((!mPos)?"in":"in");
	}
	else{
		clearTimeout(moving);
		moving=setTimeout('null',1);
	}
}
function slideMenu(way){
	fHow=(NS6)?0.4:0.2;
	if(way=="out")flow=fHow*-(parseInt(ssm.left));
	if(way=="in"&&!mPos)flow=fHow* (menuWidth+1-parseInt(ssm.left));
	else if(way=="in")flow=fHow*-(menuWidth+1+parseInt(ssm.left));
	if(flow>0)flow=Math.ceil(flow);
	else flow=Math.floor(flow);
	if(IE||NS6){
		lastX+=flow;
		bssm.clip="rect(0 "+((!mPos)?(barWidth+menuWidth+3):(barWidth+2+lastX))+" "+(((IE4)?document.body.clientHeight:0)+tssm.offsetHeight)+" "+((!mPos)?(lastX+1):0)+")";
		}
	ssm.left=parseInt(ssm.left)+flow;
	if(NS){
		if(!mPos){
			bssm.clip.left+=flow;
			bssm2.clip.left+=flow;
		}
		else{
			bssm.clip.right+=flow;
			bssm2.clip.right+=flow;
		}
		if(bssm.left+bssm.clip.right>document.width)document.width+=flow;
	}
}

function makeStatic() {
	winY=(IE)?document.body.scrollTop:window.pageYOffset;
	sHow=(NS6)?0.4:0.2;
	if(winY!=lastY&&winY>YOffset-staticYOffset)smooth=sHow*(winY-lastY-YOffset+staticYOffset);
	else if(YOffset-staticYOffset+lastY>YOffset-staticYOffset&&winY<=YOffset-staticYOffset)smooth=sHow*(winY-lastY-(YOffset-(YOffset-winY)));
	else smooth=0;
	if(smooth>0)smooth=Math.ceil(smooth);
	else smooth=Math.floor(smooth);
	bssm.top=parseInt(bssm.top)+smooth;
	lastY=lastY+smooth;
	setTimeout('makeStatic()',slideYSpeed);
}

function menuClick(id) { 
	obj=(document.all)?document.all(id):document.getElementById(id);
	with(obj){
		if(event.srcElement.id!=id){
			if(target=="_top")top.location=href;
			else if(target=="_parent")parent.location=href;
			else if(target=="_blank")window.open(href);
			else if(target>""&&top.frames[target])top.frames[target].location=href;
			else if(target>"")eval('window.open("'+href+'","'+target+'")');
			else location=href;
		}
	}
}

function buildBar() {
	if(!barType)tempBar='<IMG SRC="'+barText+'" BORDER="0">';
	else{
		for(b=0;b<barText.length;b++)tempBar+=barText.charAt(b)+"<BR>"
	}
	ssmHTML+='<td align="center" rowspan="100" width="'+barWidth+'" bgcolor="'+barBGColor+'" valign="'+barVAlign+'" align="'+barAlign+'" class="ssmBar" NOWRAP>'+tempBar+'</td>';
}

function initSlide() {
	if (!mPos)lastX=menuWidth
	if ((NS6||IE)&&!OP||(operaFix!=2&&OP)){
		ssm=(NS6)?document.getElementById("thessm").style:document.all("thessm").style;
		tssm=(NS6)?document.getElementById("thessm"):document.all("thessm");
		bssm=(NS6)?document.getElementById("basessm").style:document.all("basessm").style;
		bssm.clip="rect(0 "+(barWidth+2+((!mPos)?menuWidth+1:0))+" "+(((IE4)?document.body.clientHeight:0)+tssm.offsetHeight)+" "+((!mPos)?(menuWidth+1):0)+")";
		if (OP&&operaFix==1)XOff=(!mPos)?document.body.clientWidth-barWidth-3:0;
		bssm.left=(!mPos)?XOff-menuWidth:XOff;
		if(OP)ssm.left=ssm.left;
		bssm.visibility="visible";
		if(NS6&&!OP){
			bssm.top=YOffset;
			if(menuOpacity!=100)ssm.MozOpacity=menuOpacity/100;
			slideIsGo=window.innerHeight>tssm.offsetHeight+staticYOffset;
		}
		else{
			if(menuOpacity!=100)ssm.filter="alpha(opacity="+menuOpacity+")";
			slideIsGo=((OP)?window.innerHeight:document.body.clientHeight)>parseInt(tssm.offsetHeight)+staticYOffset;
			}
		if(autoHideXOverflow&&((IE?document.body.clientWidth:window.innerWidth-16)<parseInt(bssm.left)+parseInt(ssm.left)+menuWidth+barWidth+3)){
			document.body.style.overflowX="hidden";
			document.body.style.overflowY="scroll";
		}
	}
	else if(NS){
		bssm=document.layers["basessm1"];
		bssm2=bssm.document.layers["basessm2"];
		ssm=bssm2.document.layers["thessm"];
		bssm.clip.left=(!mPos)?menuWidth+1:0;
		bssm.clip.right=(!mPos)?(menuWidth+barWidth+3):barWidth+2;
		bssm.left=(!mPos)?XOff-menuWidth:XOff;
		ssm.visibility="show";
		slideIsGo=window.innerHeight>ssm.clip.bottom+staticYOffset;
	}
	if(slideY&&(slideOnYOverflow||(!slideOnYOverflow&&slideIsGo)))makeStatic();
	if(!slideX)moveOut();
}

function getXOff() {
	return (((!XAlign)?((IE||OP)?document.body.clientWidth-barWidth-3:window.innerWidth-barWidth-3-17):(XAlign==1)?Math.floor(((IE||OP)?document.body.clientWidth/2-barWidth/2-1.5:window.innerWidth/2-barWidth/2-1.5)):0)+XOffset);
}

function buildMenu() { 
	if('undefined' !== typeof menuPosition)
	{	mPos=menuPosition;
		ssmHTML="";
		XOff=getXOff();
		if(IE||NS6)ssmHTML+='<DIV ID="basessm" style="visibility:hidden;Position : Absolute ;Top : '+YOffset+' ;Z-Index : 20;width:'+(barWidth+2)+';"><DIV ID="thessm" style="Position : Absolute ;Left : '+((!mPos)?menuWidth+1:-menuWidth-1)+' ;Top : 0px ;Z-Index : 30;'+((IE)?"width:1px":"")+'" '+((slideX)?'onmouseover="moveOut()" onmouseout="moveBack()")':'')+'>';
		if(NS)ssmHTML+='<LAYER name="basessm1" top="'+YOffset+'" visibility="show" onload="initSlide()"><ILAYER name="basessm2"><LAYER visibility="hide" name="thessm" bgcolor="'+menuBGColor+'" left="'+((!mPos)?menuWidth+1:-menuWidth-1)+'" '+((slideX)?'onmouseover="moveOut()" onmouseout="moveBack()")':'')+'>';
		if(NS6)ssmHTML+='<table border="0" cellpadding="0" cellspacing="0" width="'+(menuWidth+barWidth+3)+'"><TR><TD>';
		ssmHTML+='<table border="0" cellpadding="0" cellspacing="1" width="'+(menuWidth+barWidth+3)+'" bgcolor="'+((!NS)?menuBGColor:"")+'">';
		for(i=0;i<sI.length;i++){
			ssmHTML+='<TR>';
			if(barBuilt==0&&!mPos){
				buildBar();
				barBuilt=1
			}
			if(sI[i][3]>1)ssmHTML+='<TD BGCOLOR="'+hdrBGColor+'" ALIGN="'+hdrAlign+'" WIDTH="'+menuWidth+'"'+((NS6)?' style="padding:'+hdrPadding+'px"':'><TABLE CELLPADDING="'+hdrPadding+'" CELLSPACING="0" BORDER="0"><TR><TD')+' CLASS="ssmHdr" VALIGN="'+hdrVAlign+'">'+((sI[i][3]==3)?'<a HREF="'+((sI[i][1].indexOf("://")==-1&&sI[i][1].indexOf("../")==-1)?targetDomain:'')+sI[i][1]+'" target="'+sI[i][2]+'" class="ssmHdr">':'')+sI[i][0]+((sI[i][3]==3)?'</a>':'')+((NS6)?'':'</TD></TR></TABLE>')+'</TD>';
			else{
				if(!sI[i][2])sI[i][2]=targetFrame;
				ssmHTML+='<TD WIDTH="'+menuWidth+'"'+(NS&&!sI[i][3]?'':'BGCOLOR="'+linkBGColor+'"')+' '+((NS6)?'CLASS="ssmItem" style="padding:'+linkPadding+'px;" ALIGN="'+linkAlign+'"':'')+' '+((sI[i][3])?'>':'onmouseover="style.backgroundColor=\''+linkOverBGColor+'\'" onmouseout="style.backgroundColor=\''+linkBGColor+'\'" onclick="menuClick(\'item_'+i+'\');"'+(IE?' style="cursor:hand;"':'')+'><ILAYER><LAYER onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'" WIDTH="100%" ALIGN="'+linkAlign+'" bgcolor="'+linkBGColor+'">')+((NS6)?'':'<DIV ALIGN="'+linkAlign+'" CLASS="ssmItem"><TABLE CELLPADDING="'+linkPadding+'" CELLSPACING="0" BORDER="0"><TR><TD VALIGN="'+linkVAlign+'" CLASS="ssmItem">')+((sI[i][3])?'':'<A HREF="'+((sI[i][1].indexOf("://")==-1&&sI[i][1].indexOf("../")==-1)?targetDomain:'')+sI[i][1]+'" target="'+sI[i][2]+'" CLASS="ssmItem" id="item_'+i+'">')+sI[i][0]+''+((sI[i][3])?'':'</A>')+((NS6)?'':'</TD></TR></TABLE></DIV>')+((sI[i][3])?'':'</LAYER></ILAYER>')+'</TD>';
			}
			if(barBuilt==0&&mPos){
				buildBar();
				barBuilt=1;
			}
			ssmHTML+='</TR>';
		}
		ssmHTML+='</table>';
		if(NS6)ssmHTML+='</TD></TR></TABLE>';
		if(IE||NS6){
			ssmHTML+='</DIV></DIV>';
			setTimeout('initSlide();',1);
		}
		if(NS)ssmHTML+='</LAYER></ILAYER></LAYER>';
		
		jquery_api('body').append(ssmHTML);
	}
}

function addHdr(text){sI[sI.length]=[text, '', '', 2]}
function addLink(text, link, target){if(!link)link="javascript://";sI[sI.length]=[text, link, target, 3]}
function addItem(text, link, target){if(!link)link="javascript://";sI[sI.length]=[text, link, target, 0]}
function addText(text){sI[sI.length]=[text, '', '', 1]}

function MakeIELinksBlink() 
{	if (!document.all) return;
	else 
	{	for(i=0;i<document.all.tags('blink').length;i++)
		{	s=document.all.tags('blink')[i];
			s.style.visibility=(s.style.visibility=='visible')  ?'hidden':'visible';
		}
	}
}

setInterval('MakeIELinksBlink()', 1000);

function findInPage() 
{ 	if (parseFloat(navigator.appVersion) >= 4) 
	{ 	if (document.all) 
		{ 	st_text_to_find = window.prompt('Enter a search string', '');
			if (st_text_to_find == '') exit;
			var rng = document.body.createTextRange(); 
			var found = rng.findText(st_text_to_find); 
			if (found != false)
			{	rng.select(); 
				rng.scrollIntoView(); 
			}else { alert('Sorry, no matching information found.');	}
		} else {	window.find(); 	} 
	} 
}


// Specify speed of scroll. Larger=faster (ie: 5)
var scrollspeed=cache=2

// Specify intial delay before scroller starts scrolling (in miliseconds):
var initialdelay=500

function initializeScroller()
{	dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer")
	if (dataobj != null) 
	{	dataobj.style.top="5px"			
		setTimeout("getdataheight()", initialdelay) 
	}
}

function getdataheight()
{	thelength=dataobj.offsetHeight
	if (thelength==0) setTimeout("getdataheight()",10)
	else scrollDiv()
}

function scrollDiv()
{	dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
	if (parseInt(dataobj.style.top)<thelength*(-1)) dataobj.style.top="5px"
	setTimeout("scrollDiv()",40)
}

if (window.addEventListener) window.addEventListener("load", initializeScroller, false)
else if (window.attachEvent) window.attachEvent("onload", initializeScroller)
else window.onload=initializeScroller

// -- PUT THIS CODE AROUND THE CONTENT TO SCROLL IN AN HTML FILE LOADED IN AN IFRAME OBJECT
// <div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache">
// </div>
// 
// -- SAMPLE IFRAME CODE THAT CAN BE USED
// <iframe src="url-to-page-to-load" name="frmEvents" id="frmEvents" width="100%" height="100" marginwidth="0" marginheight="0" frameborder="0" style="border: 0px solid groove;" border="0" scrolling="no"></iframe>

// *********************************************************************

function reformat_date(st_date)
{	ar_date = st_date.split("-");
	return ar_date[1] + "/" + ar_date[2] + "/" + ar_date[0];
}

var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);

function ShowHelp(obj,field)
{	//Get help object
	var helpObj;
	if (document.all) { helpObj = document.all[field+"_help"];	}
	else if (document.getElementById)
	{	helpObj = document.getElementById(field+"_help");		}
	if (helpObj) 
	{	//if help object is shown, hide it ; if object hidden, show it
		if (helpObj.style.display == "")
		{	helpObj.style.display = "none";		}
		else
		{	helpObj.style.display = "";			}

		//Get location of mouseover object, move help object to the left if will display off-screen
		var divWidth = 340;
		var offsetLeft = getOffsetLeft(obj);
		var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
		if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
		newX = offsetLeft;
	
		//Get location of mouseover object, move help object on top if will display off-screen
		var divHeight = helpObj.offsetHeight;
		var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
		var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
//		if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
		newY = offsetTop;	
	
		helpObj.style.top = newY;
		helpObj.style.left = newX;

		if (helpObj.style.display == "")
		{
		  qh_hideElement("select",helpObj);  
		  qh_hideElement("object",helpObj);  
		  qh_hideElement("embed",helpObj);  
		}else
		{
		  qh_showElement("select");  
		  qh_showElement("object");  
		  qh_showElement("embed");
		}
	}
}

function getOffsetTop (elm) 
{	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) 
	{	mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}

function getOffsetLeft (elm) 
{	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) 
	{	mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function getScrollY() 
{	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) 
	{	//Netscape
	    scrOfY = window.pageYOffset;
	}else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
	{	//DOM
	    scrOfY = document.body.scrollTop;
	}else if( document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	{	//IE6
	    scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}

function qh_hideElement( elmID, overDiv ) 
{	if(document.all) 
	{	for(i = 0; i < document.all.tags( elmID ).length; i++) 
		{	obj = document.all.tags( elmID )[i];
			if(!obj || !obj.offsetParent) continue;

			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			
			while(objParent.tagName.toUpperCase() != 'BODY') 
			{	objLeft  += objParent.offsetLeft;
		        objTop   += objParent.offsetTop;
		        objParent = objParent.offsetParent;
			}
			
			objHeight = obj.offsetHeight;
			objWidth  = obj.offsetWidth;
			
			if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
			else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
			else if(overDiv.offsetTop >= (objTop + objHeight));
			else if(overDiv.offsetLeft >= (objLeft + objWidth));
			else { obj.style.visibility = 'hidden';		    }
		}
	}
}

function qh_showElement(elmID) 
{	if(document.all) 
	{	for(i = 0; i < document.all.tags( elmID ).length; i++) 
		{	obj = document.all.tags(elmID)[i];
			if(!obj || !obj.offsetParent) continue;
			obj.style.visibility = '';
		}
	}
}

function checkDomain(searchForm)
{	var canSubmit = false;
	var searchValue;
	if (searchForm.domainToCheck)
	{	searchValue = searchForm.domainToCheck.value;
		if (searchValue != '')
		{	var regExInvalidChars = /[^a-zA-Z0-9-\s.]+/;
			if (regExInvalidChars.test(searchValue))
			{	alert('Invalid character in domain.\n\nOnly letters, numbers or hyphens are allowed.')
			}else
			{	canSubmit = true;
			}
		}
	}
	if (canSubmit) 
	{	return true;				}
	else
	{	return false;				}
}

function execute_code(response)
{	
	eval(response);
}

function setCookie(c_name,value,expiredays)
{	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function build_content(url, callback_function, return_xml, st_return_mode, st_parameters, bo_sync, st_username, st_password) 
{	var http_request 		= false; 

	bo_sync					= ((bo_sync != null)? bo_sync : true);
	
	if (window.XMLHttpRequest) 
	{	// Mozilla, Safari,... 
		http_request = new XMLHttpRequest(); 
		if (http_request.overrideMimeType) 
		{	http_request.overrideMimeType('text/xml'); 		} 
	} else if (window.ActiveXObject) 
	{	// IE 
		try 
		{	http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) 
		{ 	try 
			{ 	http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (e) {} 
		} 
	} 

	if (!http_request) 
	{	alert('Unfortunatelly you browser doesn\'t support this feature.'); 
		return false; 
	} 
	http_request.onreadystatechange = function() 
	{ 	if (http_request.readyState == 4) 
		{	if (http_request.status == 200) 
			{	
				if (st_return_mode == 'VARIABLE')		// st_return_mode == 'VARIABLE'
				{	if (return_xml == true) 
					{	eval(callback_function + ' = (http_request.responseXML)'); 
	               	} else 
	               	{	// eval(callback_function + ' = (http_request.responseText)'); 
	               		
	               		// need to execute the javascript returned
	               		var va_container = explode(".", callback_function);
	               		
	               		jquery_api("#" + va_container[0]).prop(va_container[1], "");
	               		jquery_api(get_webpage_content(http_request.responseText)).appendTo("#" + va_container[0]);
					} 
				}else									// st_return_mode == 'CALLBACK-FUNCTION'
				{	if (return_xml == true) 
					{	eval(callback_function + '(http_request.responseXML)'); 
	               	} else 
	               	{	eval(callback_function + '(http_request.responseText)'); 
					} 
				}
			} else 
			{ 
               // alert('There was a problem with the request.(Code: ' + http_request.status + ')'); 
			} 
       } 
   } 
   
   if (st_parameters == null)
   {	http_request.open('GET', url, bo_sync, st_username, st_password); 
		http_request.send(null); 
   }else
   {	http_request.open('POST', url, bo_sync, st_username, st_password); 
  		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.send(st_parameters); 
   }
}

function get_webpage_content(data)
{
	if (data.search('<!-- START: PAGE CONTENT -->') != -1)
	{	
		data 		= jquery_api('#globalPageContentContainer', data).prop('innerHTML');
	}
	
	return data;
}

// PAGEBUILDER INTEGRATION STARTS
function pbPreviewDocument()
{	// note, cannot preview stylesheets.
	var ob_pattern = new RegExp("Site Design");
	if (ob_pattern.test(document.getElementById('file_name').value) == true)
	{	st_site_design = document.getElementById('file_name').value; 
		st_site_design = st_site_design.replace("Site Design", "").replace("[", "").replace("]", "").replace(" ", "").replace(" ", "");
		docPreview = window.open(document.getElementById('default_page').value + "/vts/" + st_site_design + "/vtsaction/preview/", "docPreview", "", true);
	}else 
	{	docPreview = window.open(documentURL.replace("/documents/", "/viewer/").replace("//", "/") ,"docPreview", "", true);		}
	docPreview.focus();
}

function pbInsertNavigationBar()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.navigationWin.asd/vts/pagebuilder");
}

function pbInsertTextGroup()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertTextGroup.asd/vts/pagebuilder");
}

function pbInsertTextFieldTemplateObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertTemplateItem.asd/vts/pagebuilder");
}

function pbInsertAccessControlObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertAccessControlObject.asd/vts/pagebuilder");
}

function pbInsertMemberProfileFieldObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertMemberProfileField.asd/vts/pagebuilder");
}

function pbInsertConfigurationFieldObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertConfigurationField.asd/vts/pagebuilder");
}

function pbInsertPhotoAlbumObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertPhotoAlbumObject.asd/vts/pagebuilder");
}

function pbInsertSearchEngineObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertSearchEngineObject.asd/vts/pagebuilder");
}

function pbGetStatusBoardObject()
{	var d = "\n";
	d += "<input name='PageBuilderObject' pbotype='status-board' "
	d += "type='button' style='border=0; background-color: #FFFEC2; font-weight:normal; font-size:10px; font-family: Verdana; color: Black; text-align: center;' value='\n";
	d += "Status Board Object (DO NOT EDIT)\n";
	d += "'>";
	return d;
}

function pbGetGuestbookObject()
{	var d = "\n";
	d += "<input name='PageBuilderObject' pbotype='guestbook' "
	d += "type='button' style='border=0; background-color: #FFFEC2; font-weight:normal; font-size:10px; font-family: Verdana; color: Black; text-align: center;' value='\n";
	d += "Guest Book Object (DO NOT EDIT)\n";
	d += "'>";
	return d;
}

function pbInsertGuestBookFieldTemplateObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertGuestBookField.asd/vts/pagebuilder");
}

function pbGetRecordStartObject()
{	var d = "\n";
	d += "<input name='PageBuilderObject' pbotype='record-start' "
	d += "type='button' style='border=0; background-color: #FFFEC2; font-weight:normal; font-size:10px; font-family: Verdana; color: Black; text-align: center;' value='\n";
	d += "Record Start Object\n(DO NOT EDIT)\n";
	d += "'>";
	return d;
}

function pbGetRecordEndObject()
{	var d = "\n";
	d += "<input name='PageBuilderObject' pbotype='record-end' "
	d += "type='button' style='border=0; background-color: #FFFEC2; font-weight:normal; font-size:10px; font-family: Verdana; color: Black; text-align: center;' value='\n";
	d += "Record End Object\n(DO NOT EDIT)\n";
	d += "'>";
	return d;
}

function pbInsertTemplate()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertTemplate.asd/vts/pagebuilder");
}

function pbInsertLinkFieldTemplateObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertLinkTemplateItem.asd/vts/pagebuilder");
}

function pbInsertNewsletterFieldObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertNewsletterField.asd/vts/pagebuilder");
}

function pbInsertNewsletterObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertNewsletterObject.asd/vts/pagebuilder");
}

function pbInsertUpdateMemberProfileObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertUpdateMemberProfileObject.asd/vts/pagebuilder");
}

function pbInsertWebsiteLogo()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertSiteLogoObject.asd/vts/pagebuilder");
}

function pbInsertDateObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertCurrentDateObject.asd/vts/pagebuilder");
}

function pbInsertCopyrightObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertCopyrightObject.asd/vts/pagebuilder");
}

function pbInsertAudioHyperlink(editor)
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertPlayMusicLink.asd/vts/pagebuilder" + ((editor != null)? "/editor/" + editor : "") );
}

function pbInsertVideoHyperlink(editor)
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertPlayVideoLink.asd/vts/pagebuilder" + ((editor != null)? "/editor/" + editor : "") );
}

function pbPublishGenericContent(editor)
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertGenericContent.asd/vts/pagebuilder" + ((editor != null)? "/editor/" + editor : "") );
}

function pbInsertFlashMovie()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertFlashObject.asd/vts/pagebuilder" );
}

function pbInsertForm()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertFormObject.asd/vts/pagebuilder" );
}

function pbInsertRSSFeed()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertRSSFeed.asd/vts/pagebuilder");
}

function pbGetPageViewObject()
{	var d = "\n";
	d += "<input name='PageBuilderObject' pbotype='page-view' "
	d += "type='button' style='height=250; width=250; border=0; background-color: #FFFEC2; font-weight:normal; font-size:10px; font-family: Verdana; color: Black; text-align: center;' value='\n";
	d += "Page View Object (DO NOT EDIT)\n\n";
	d += "The page view is the part of the page\n";
	d += "that changes from page to page on the\n";
	d += "the site.\n";
	d += "'>";
	return d;
}

function pbGetStoreAdd2CartButton()
{   var d = "\n";
    d += "<FORM action=/viewer/mgr.shop/shoppingcart.asd/scaction/add method=post style='display: inline;'><INPUT style='WIDTH: 79px; HEIGHT: 22px' type=hidden size=9 value=PRODUCT_ID name=scspid><INPUT class=button type=submit value='Add to Cart'></FORM>";
    return d;
}

function pbGetStoreAdd2CartButtonWithQuantityOptions()
{   var d = "\n";
    d += "<FORM action=/viewer/mgr.shop/shoppingcart.asd/scaction/add method=post style='display: inline;'><INPUT style='WIDTH: 79px; HEIGHT: 22px' type=hidden size=9 value=PRODUCT_ID name=scspid>Qty: <INPUT style='WIDTH: 23px; HEIGHT: 22px' type=text size=1 value=1 name=qty><INPUT class=button type=submit value='Add to Cart'></FORM>";
    return d;
}

function pbGetStoreAdd2CartButtonWithListPricesOptions()
{   var d = "\n";
    d += "<FORM action=/viewer/mgr.shop/shoppingcart.asd/scaction/add method=post style='display: inline;'><select name=scspid><option value='0'>-- Make Selection --</option><option value='PRODUCT_ID_1'>DESCRIPTION1</option><option value='PRODUCT_ID_2'>DESCRIPTION2</option><option value='PRODUCT_ID_3'>DESCRIPTION3</option></select><INPUT class=button type=submit value='Add to Cart'></FORM>";
    return d;
}

function pbInsertAccountLoginObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertLoginObject.asd/vts/pagebuilder" );
}

function pbInsertAccountRegistrationObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertRegisterObject.asd/vts/pagebuilder" );
}

function pbInsertNewPasswordObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertNewPasswordObject.asd/vts/pagebuilder" );
}

function pbInsertChangePasswordObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertChangePasswordObject.asd/vts/pagebuilder" );
}

function pbInsertGetPasswordObject()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertGetPasswordObject.asd/vts/pagebuilder" );
}

function methodX00017()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.openWebDoc.asd/vts/pagebuilder" );
}

function methodX00018()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.openWebImage.asd/vts/pagebuilder" );
}

function methodX00019()
{	document.pagebuilder_form.file_name.value = pbReturnNewDocumentDefaultName();					
	document.pagebuilder_form.page_title.value = document.pagebuilder_form.page_description.value = document.pagebuilder_form.page_keywords.value = "";			
}

function pbInsertEmailHyperlink()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertEmailLink.asd/vts/pagebuilder" );
}

function pbReturnNewDocumentDefaultName()
{	return "new_document.asd";			}

function pbSetEditorFileName(filename)
{	document.pagebuilder_form.file_name.value = filename; 		}

function pbInsertInsertImage() 
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.selectImage.asd/vts/pagebuilder" );
}

function pbGetCurrentDocumentFilename()
{	return escape(	((document.pagebuilder_form.file_name.value.search(/^\/documents\//) == -1 && document.pagebuilder_form.file_name.value.search(/^Site Design/) == -1)		? 
						"/documents/" + ((document.pagebuilder_form.page_title.value.length > 0)		? 
											document.pagebuilder_form.page_title.value 					: 
											document.pagebuilder_form.file_name.value
										) 																: 
						document.pagebuilder_form.file_name.value
					)
				);	
}

function pbOpenDocument()
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.openDoc.asd/vts/pagebuilder" );
}

function pbSaveCurrentDocument(newdoc)
{	if (newdoc == null) newdoc = 0;
	window.open("/viewer/mgr.pagebuilder/pagebuilder.saveDoc.asd/vts/pagebuilder?newdoc=" + newdoc + "&fn=" + pbGetCurrentDocumentFilename() );
}

function pbInsertHTMLContent(obWindow, editor_name, contents)
{	if (editor_name == null) editor_name = 'pagebuilder';
	var oEditor = obWindow.FCKeditorAPI.GetInstance(editor_name);
	oEditor.InsertHtml(contents);
}

function methodX00043() 
{	var	winHelp = window.open("/viewer/mgr.pagebuilder/pagebuilder.aboutDialog.asd/vts/pagebuilder","winHelp","scrollbars=no,width=330,height=150,resizable=no");		}

function ASDWSA_PageBuilderPrettyPrint(st_code)
{	st_code_buffer = st_code;
	in_tab_count = in_previous_tabcount = 0;
	st_A = "";
	st_tag = st_previous_tag = "";
	st_tagSetA = "TABLE,TBODY,TR,TD,SCRIPT,OBJECT,EMBED,PARAM,FORM,SELECT,OPTION,OL,UL,";	// tags that must be open on a new line
	st_tagSetBA = "TABLE,TBODY,TR,FORM,SELECT,UL,OL,";								// tags that increment the indent count
	st_tagSetC = "TABLE,DIV,P,FORM,SELECT,UL,OL,LI,!--,";								// tags that must be closed on a new line
	st_tagSetD = "TABLE,TBODY,TR,TD,SCRIPT,OBJECT,EMBED,PARAM,FORM,SELECT,OPTION,LI,P,DIV,INPUT,";	// tags that must be indented
	st_tagSetE = "SCRIPT,!--,";																// tags that we will not pretty print
	st_tagSetF = "FORM,TD,DIV,P,";														// tags that can contain other tag blocks
	

	// find all the HTML tags in the code
	in_opening_pos = 0;
	// alert(st_code_buffer);
	while (in_opening_pos != -1)
	{	in_previous_tabcount = in_tab_count;
		// find the position of the key elements
		in_opening_pos = parseInt(st_code_buffer.search("<"));
		while (in_opening_pos != 0 && in_opening_pos != -1)
		{	// alert(st_code_buffer.substr(0, in_opening_pos));
			st_A += st_code_buffer.substr(0, in_opening_pos);
			// alert(st_A); 
			st_code_buffer = st_code_buffer.substr(in_opening_pos, st_code_buffer.length - in_opening_pos);
			// alert(st_code_buffer); // return "";
			in_opening_pos = parseInt(st_code_buffer.search("<"));
		}
		in_space_pos = parseInt(st_code_buffer.search(" "));
		in_closing_pos = parseInt(st_code_buffer.search(">"));	
		// alert(in_opening_pos + "," + in_space_pos + "," + in_closing_pos + "," + st_code_buffer.length); // return "";
		if (in_opening_pos == -1) 			// nothing found
		{	st_A += st_code_buffer; 		}
		else if (in_opening_pos >= 0)
		{	if (in_space_pos > in_closing_pos || in_space_pos < 0)
			{	st_tag = st_code_buffer.substr(in_opening_pos + 1, in_closing_pos - in_opening_pos - 1).toUpperCase();	}
			else
			{	st_tag = st_code_buffer.substr(in_opening_pos + 1, in_space_pos - in_opening_pos - 1).toUpperCase();	}
			st_tag_alone = st_tag;					// save the tag by itself without the delimiter
			st_full_tag = st_tag += ",";			// tag delimiter - required to match a tag
			if (st_full_tag == "!--,")
			alert("'" + st_full_tag +  "' TAB # P=" + in_previous_tabcount + " # C=" + in_tab_count); 	// return false;
			if (st_tag.charAt(0) == "/")			// this is a closing tag
			{	st_tag = st_tag.substr(1);			// remove the / from the tag name
				if (st_tagSetBA.search(st_tag) != -1) in_tab_count = in_tab_count - 1;
				st_A 	+= 	((st_tagSetA.search(st_tag) != -1)? "\n" : "") 
						+	((st_tagSetD.search(st_tag) != -1)? ASDWSA_PageBuilderPrettyPrint_Indent(in_tab_count) : "")  
						+	st_code_buffer.substr(in_opening_pos, in_closing_pos - in_opening_pos + 1)
						+ 	((st_tagSetC.search(st_tag) != -1)? "\n\n" : "");
			}else if (st_tagSetE.search(st_tag) != -1)
			{	// alert(st_tag_alone);
				if (st_tag_alone == "!--")	{	st_closing_tag = "-->"; 							}
				else 						{	st_closing_tag = "</" + st_tag_alone + ">"; 		}
				// alert(st_closing_tag);
				in_closing_pos = parseInt(st_code_buffer.search(st_closing_tag)) + st_closing_tag.length;	
				st_A 	+= 	((st_tagSetA.search(st_tag) != -1)? "\n" : "") 
						+	((st_tagSetD.search(st_tag) != -1)? ASDWSA_PageBuilderPrettyPrint_Indent(in_tab_count) : "")  
						+	st_code_buffer.substr(in_opening_pos, in_closing_pos - in_opening_pos + 1);
			}else									// this is an opening tag
			{	st_A 	+= 	((st_tagSetA.search(st_tag) != -1)? "\n" : "") 
						+	((st_tagSetD.search(st_tag) != -1)? ASDWSA_PageBuilderPrettyPrint_Indent(in_tab_count) : "")  
						+	st_code_buffer.substr(in_opening_pos, in_closing_pos - in_opening_pos + 1);
				if (st_tagSetBA.search(st_tag) != -1) in_tab_count = in_tab_count + 1;
			}
			in_tab_count = ((in_tab_count < 0)? 0 : in_tab_count);
			if (st_full_tag == ",") 
			{	alert("'" + st_full_tag +  "' TAB # P=" + in_previous_tabcount + " # C=" + in_tab_count); 	// return false;
				// alert(in_opening_pos + "," + in_space_pos + "," + in_closing_pos + "," + st_code_buffer.length); // return "";
				// alert(st_A);
				// alert(st_code_buffer);
			}
			st_code_buffer = st_code_buffer.substr(in_closing_pos + 1, st_code_buffer.length - in_closing_pos);
			st_previous_tag = st_tag;
		}
	}
	st_code_buffer = st_A;
	
	// insert the line returns on the <br> tags	
	var re = /((<br>)+)/ig;
	re.multiline = true;
	st_code_buffer = st_code_buffer.replace(re, "$1\n");
	
	return st_code_buffer;
}

function ASDWSA_PageBuilderPrettyPrint_Indent(in_indent_count)
{	st_pads_buffer = "";
	st_pads_tab = "     ";
	for (i = 0; i <= in_indent_count-1; i++)
	{	st_pads_buffer += st_pads_tab;		}
	return st_pads_buffer;
}

function pbGetCurrentEditorContents(obWindow, editor_name)
{	if (editor_name == null) editor_name = 'pagebuilder';
	var oEditor = obWindow.FCKeditorAPI.GetInstance(editor_name);
	return escape(oEditor.GetHTML());		
}

function pbSetCurrentEditorContents(obWindow, editor_name, contents)
{	if (editor_name == null) editor_name = 'pagebuilder';
	var oEditor = obWindow.FCKeditorAPI.GetInstance(editor_name);
	oEditor.SetHTML(contents);
}

function pbGetCurrentTextAreaEditorContents(obWindow)
{	ob_object = obWindow.document.getElementById('pagebuilder_textarea');
	return escape(ob_object.value);		
}

function pbInsertHyperlink() 
{	window.open("/viewer/mgr.pagebuilder/pagebuilder.insertHyperlink.asd/vts/pagebuilder" );
}

function pbGetWebpageURL(url)
{	return url.replace("/documents/", "/viewer/");				}

function pbCreateHyperLink(href, target, name) 
{	var href = "<a href='" + href + "' target='" + target + "'>" + name + "</a>";
	return href;
}

function function_name(f)
{	var s = f.toString().match(/function (\w*)/)[1];
	if ((s == null) || (s.length == 0)) return "anonymous";
	else return s;
}

function stacktrace()
{	var s = "";
	
	for (var a  = arguments.caller; a != null; a = a.caller)
	{	s += function_name(a.callee) + "\n";
		if (a.caller == a) break;
	}
	return s;
}

function resize_browser_to_limits()
{	this.resizeTo(window.screen.availWidth, window.screen.availHeight);		}

function addslashes(st_string)
{	st_string = st_string.replace(/\"/g, "\\\"").replace(/\(/g, "\\\(").replace(/\)/g, "\\\)");			
	st_string = st_string.replace(/\[/g, "\\\[").replace(/\]/g, "\\\]");			
	return st_string;
}

function save_pagebuilder_data()
{	// saves the content of the editor to disk / repository for backup.
	// alert('Saving page builder content');
	if (location.search.replace(/\?/, "").search(/st_object_to_edit/i) != -1)		// this is an object text
	{	winPageBuilderSaver = window.open('/viewer/mgr.pagebuilder/pagebuilder.autosave.asd/vts/pagebuilder', 'winPageBuilderSaver', 'width=100,height=40,menubar=no,scrollbars=no,status=no,toolbar=no,location=no,resizable=yes'); window.focus()
		winPageBuilderSaver.document.file.value = location.search.replace(/\?/, "").slice(location.search.replace(/\?/, "").search(/\./i)+1);
		winPageBuilderSaver.document.data.value = (deactivate_pagebuilder_object_code(pbGetCurrentEditorContents()));
		winPageBuilderSaver.document.frmTrigger.submit();
	}else if (document.file_name.value.search(/pagebuilder.backup/i) == -1)		// no need to backup the backup files
	{	winPageBuilderSaver = window.open('/viewer/mgr.pagebuilder/pagebuilder.autosave.asd/vts/pagebuilder', 'winPageBuilderSaver', 'width=100,height=40,menubar=no,scrollbars=no,status=no,toolbar=no,location=no,resizable=yes'); window.focus()
		winPageBuilderSaver.document.file.value = document.file_name.value;
		winPageBuilderSaver.document.data.value = (deactivate_pagebuilder_object_code(pbGetCurrentEditorContents()));
		winPageBuilderSaver.document.frmTrigger.submit();
	}
}

function reactivate_pagebuilder_object_code(st_file_data)
{	st_working_copy = st_file_data;
	var ar_pagebuilder_objects = new Array();
	var ob_pattern = new RegExp("SKIP");
	var ar_tags = [	"\\\[RECORD-START\\\]", "\\\[RECORD-END\\\]", "(\\\[GUESTBOOK:)(.*?)(\\\])",
					"(\\\[MEMBER PROFILE:)(.*?)(\\\])", "(\\\[CONFIGURATION:)(.*?)(\\\])", 
					"(\\\[TEXT:)(.*?)(\\\])", "(\\\[LINK:)(.*?)(\\\])", "(\\\[NEWSLETTER:)(.*?)(\\\])"
				];
	// find all the object functions, strip them away
	for (in_A = 1; in_A <= ar_tags.length; in_A++)
	{	ob_pattern.compile(ar_tags[in_A-1], "g");
		// alert(ob_pattern);
		while (ob_pattern.test(st_working_copy) == true)
		{	// alert(st_working_copy.replace(ob_pattern, ""));
			st_working_copy = st_working_copy.replace(ob_pattern, "");
		}
	}
	st_file_data = st_working_copy;									// save a copy of the clean data
	ob_pattern.compile("(<INPUT)(.*?)(name='?\"?PageBuilderObject'?\"?)(.*?)(>|\/>)", "i");
	while (ob_pattern.test(st_working_copy) == true)
	{	ar_A = st_working_copy.match(ob_pattern);
		index = ar_pagebuilder_objects.length;
		// make sure this object is not already in the array
		if (index > 0)
		{	for (bo_already_in_array = false, in_A = 1; in_A <= index; in_A++)
			{	if (ar_pagebuilder_objects[in_A-1] == ar_A[0]) bo_already_in_array = true;		}
			if (bo_already_in_array == true) 
			{	st_working_copy = st_working_copy.replace(ar_A[0], "");
				continue;											// skip this object
			}
		}
		ar_pagebuilder_objects[index] = ar_A[0]; 
		st_working_copy = st_working_copy.replace(ar_pagebuilder_objects[index], "");
	}
	st_working_copy = st_file_data;									// get a working copy of the data
	for (in_A = 1; in_A <= ar_pagebuilder_objects.length; in_A++)
	{	ob_pattern.compile(addslashes("<!--" + ar_pagebuilder_objects[in_A-1] + "-->"), "g");
		st_working_copy = st_working_copy.replace(ob_pattern, ar_pagebuilder_objects[in_A-1]);
	}
	return st_working_copy;
}

function deactivate_pagebuilder_object_code(st_file_data)
{	// scan the whole text for PageBuilderObject tags, process each tag.
	st_working_copy = st_file_data;									// get a working copy of the data
	var ar_pagebuilder_objects = new Array();
	var ob_pagebuilder_pattern = new RegExp("(<INPUT)(.*?)(name='?\"?PageBuilderObject'?\"?)(.*?)(>|\/>)", "i"); 	// alert(ob_pagebuilder_pattern);
	while (ob_pagebuilder_pattern.test(st_working_copy) == true)
	{	ar_A = st_working_copy.match(ob_pagebuilder_pattern);
		index = ar_pagebuilder_objects.length;
		// make sure this object is not already in the array
		if (index > 0)
		{	for (bo_already_in_array = false, in_A = 1; in_A <= index; in_A++)
			{	if (ar_pagebuilder_objects[in_A-1] == ar_A[0]) bo_already_in_array = true;		}
			if (bo_already_in_array == true) 
			{	st_working_copy = st_working_copy.replace(ar_A[0], "");
				continue;											// skip this object
			}
		}
		ar_pagebuilder_objects[index] = ar_A[0]; 	// alert(ar_A[0]);
		st_working_copy = st_working_copy.replace(ar_pagebuilder_objects[index], "");
	}
	// next process each object, and replace code with appropriate PHP equivalent
	st_working_copy = st_file_data;									// get a working copy of the data
//	alert(ar_pagebuilder_objects.length);
	for (in_A = 1; in_A <= ar_pagebuilder_objects.length; in_A++)
	{	// now we create the replacement code; first determine type of object
		st_object_code = ar_pagebuilder_objects[in_A-1];
		ob_pagebuilder_pattern.compile(addslashes(st_object_code), "g");
		if (/(pbotype='?"?record-start'?"?)/i.test(st_object_code) == true)
		{	st_repacement_code = "<!--" + st_object_code + "-->" + "[RECORD-START]";
			st_working_copy = st_working_copy.replace(ob_pagebuilder_pattern, st_repacement_code);
		}else if (/(pbotype='?"?record-end'?"?)/i.test(st_object_code) == true)
		{	st_repacement_code = "<!--" + st_object_code + "-->" + "[RECORD-END]";
			st_working_copy = st_working_copy.replace(ob_pagebuilder_pattern, st_repacement_code);
		}else if (/pbotype='?"?form-object:(.*)('?"?)/i.test(st_object_code) == true)
		{	ar_A = st_object_code.match(/pbohashkey='?"?(.*[^'"])'?"?/i);
			// alert(ar_A[1]);
			st_repacement_code = "<!--" + st_object_code + "-->" + "<? echo @publish_form('" + ar_A[1]() + "'); ?>";
			st_working_copy = st_working_copy.replace(ob_pagebuilder_pattern, st_repacement_code);
		}else
		{	ar_A = st_object_code.match(/pbotype='?"?([\w\:\-\ ]*)'?"?/i);
			// alert(ar_A[1]); 
			st_repacement_code = "<!--" + st_object_code + "-->" + "[" + ar_A[1].toUpperCase() + "]";
			st_working_copy = st_working_copy.replace(ob_pagebuilder_pattern, st_repacement_code);
		}

	}
	return st_working_copy;
}
// PAGEBUILDER INTEGRATION ENDS


function doRedirectMenu(menu) 
{	window.location = menu.options[menu.selectedIndex].value;
}


// TREE LIB INTEGRATION
var _id = 0, _pid = 0, _lid = 0, _pLayer;
var _mLists = new Array();
var image_plus = "/images/admin/plus1.gif";
var image_minus = "/images/admin/minus1.gif";

document.lists = _mLists;
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav4 = (navigator.appName == "Netscape") ? true : false;
  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}
function expandG(nd)
{	expand(nd.id);
	
	for (i=1;i<_mLists.length;i++)
	{	_mLists[i].visible = false;
	}
}

function displayListNone(list, str, bgColor, layer) 
{	expandG(list.id);
	addList(list, str, bgColor, layer);
}

function List(visible, width, height, bgColor) {
  this.setIndent = setIndent;
  this.addItem = addItem;
  this.addList = addList;
  this.displayListNone = displayListNone;
  this.build = build;
  this.rebuild = rebuild;
  this.setFont = _listSetFont;
  this._writeList = _writeList;
  this._showList = _showList;
  this._updateList = _updateList;
  this._updateParent = _updateParent;
  this.onexpand = null; 
  this.postexpand = null;
  this.lists = new Array(); // sublists
  this.items = new Array(); // layers
  this.types = new Array(); // type
  this.strs = new Array();  // content
  this.x = 0;
  this.y = 0;
  this.visible = visible;
  this.id = _id;
  this.i = 18;
  this.space = true;
  this.pid = 0;
  this.fontIntro = false;
  this.fontOutro = false;
  this.width = width || 350;
  this.height = height || 22;
  this.parLayer = false;
  this.built = false;
  this.shown = false;
  this.needsUpdate = false;
  this.needsRewrite = false;
  this.parent = null;
  this.l = 0;
  if(bgColor) this.bgColor = bgColor;
  else this.bgColor = null;
  _mLists[_id++] = this;
}
function _listSetFont(i,j) {
  this.fontIntro = i;
  this.fontOutro = j;
}
function setIndent(indent) { this.i = indent; if(this.i < 0) { this.i = 0; this.space = false; } }
function setClip(layer, l, r, t, b) {
  if(isNav4) {
    layer.clip.left = l; layer.clip.right = r;
    layer.clip.top = t;  layer.clip.bottom = b;
  } else {
    layer.style.pixelWidth = r-l;
    layer.style.pixelHeight = b-t;
    layer.style.clip = "rect("+t+","+r+","+b+","+l+")";
  }
}
function _writeList() {
  self.status = "List: Writing list...";
  var layer, str, clip;
  for(var i = 0; i < this.types.length; i++) { 
    layer = this.items[i];
    if(isNav4) layer.visibility = "hidden";
    else layer.style.visibility = "hidden";
    str = "";
    if(isNav4) layer.document.open();
    str += "<TABLE WIDTH="+this.width+" BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
    if(this.types[i] == "list") {
      str += "<TD WIDTH=15><A TARGET='_self' HREF=\"javascript:expand("+this.lists[i].id+");\"><IMG BORDER=0 SRC=\"../../images/minus1.gif\" NAME=\"_img"+this.lists[i].id+"\"></A></TD>";
      _pid++;
    } else if(this.space)
      str += "<TD WIDTH=15 NOWRAP>&nbsp;</TD>";
    if(this.l>0 && this.i>0) str += "<TD WIDTH="+this.l*this.i+" NOWRAP>&nbsp;</TD>";
    str += "<TD HEIGHT="+(this.height-3)+" WIDTH="+(this.width-15-this.l*this.i)+" VALIGN=MIDDLE ALIGN=LEFT>";
    if(this.fontIntro) str += this.fontIntro;
    str += this.strs[i];
    if(this.fontOutro) str += this.fontOutro;
    str += "</TD></TABLE>";
    if(isNav4) {
      layer.document.writeln(str);
      layer.document.close();
    } else layer.innerHTML = str;
    if(this.types[i] == "list" && this.lists[i].visible)
      this.lists[i]._writeList();
  }
  this.built = true;
  this.needsRewrite = false;
  self.status = '';
}
function _showList() {
  var layer;
  for(var i = 0; i < this.types.length; i++) { 
    layer = this.items[i];
    setClip(layer, 0, this.width, 0, this.height-1);
    var bg = layer.oBgColor || this.bgColor;
    if(isIE4) {
      if((bg == null) || (bg == "null")) bg = "";
      layer.style.backgroundColor = bg;
    } else layer.document.bgColor = bg;
    if(this.types[i] == "list" && this.lists[i].visible)
      this.lists[i]._showList();
  }
  this.shown = true;
  this.needsUpdate = false;
}
function _updateList(pVis, x, y) {
  var currTop = y, layer;
  for(var i = 0; i < this.types.length; i++) { 
    layer = this.items[i];
    if(this.visible && pVis) {
      if(isNav4) {
        layer.visibility = "visible";
        layer.top = currTop;
        layer.left = x;
      } else {
        layer.style.visibility = "visible";
        layer.style.pixelTop = currTop;
        layer.style.pixelLeft = x;
      }
      currTop += this.height;
    } else {
      if(isNav4) layer.visibility = "hidden";
      else layer.style.visibility = "hidden";
    }
    if(this.types[i] == "list") {
      if(this.lists[i].visible) {
        if(!this.lists[i].built || this.lists[i].needsRewrite) this.lists[i]._writeList();
        if(!this.lists[i].shown || this.lists[i].needsUpdate) this.lists[i]._showList();
        if(isNav4) layer.document.images[0].src = "http://sc01.ajiboye.com/images/admin/minus1.gif";
        else eval('document.images._img'+this.lists[i].id+'.src = image_minus');
      } else {
        if(isNav4) layer.document.images[0].src = "http://sc01.ajiboye.com/images/admin/plus1.gif";
        else eval('document.images._img'+this.lists[i].id+'.src = image_plus');
      }
      if(this.lists[i].built)
        currTop = this.lists[i]._updateList(this.visible && pVis, x, currTop);
    }
  }
  return currTop;
}
function _updateParent(pid, l) {
  var layer;
  if(!l) l = 0;
  this.pid = pid;
  this.l = l;
  for(var i = 0; i < this.types.length; i++)
    if(this.types[i] == "list")
      this.lists[i]._updateParent(pid, l+1);
}
function expand(i) {
  _mLists[i].visible = !_mLists[i].visible;
  if(_mLists[i].onexpand != null) _mLists[i].onexpand(_mLists[i].id);
  _mLists[_mLists[i].pid].rebuild();
  if(_mLists[i].postexpand != null) _mLists[i].postexpand(_mLists[i].id);
}
function build(x, y) {
  this._updateParent(this.id);
  this._writeList();
  this._showList();
  this._updateList(true, x, y);
  this.x = x; this.y = y;
}
function rebuild() { this._updateList(true, this.x, this.y); }
function addItem(str, bgColor, layer) {
  var testLayer = false;
  if(!document.all) document.all = document.layers;
  if(!layer) {
    if(isIE4 || !this.parLayer) testLayer = eval('document.all.lItem'+_lid);
    else {
      _pLayer = this.parLayer;
      testLayer = eval('_pLayer.document.layers.lItem'+_lid);
    }
    if(testLayer) layer = testLayer;
    else {
      if(isNav4) {
        if(this.parLayer) layer = new Layer(this.width, this.parLayer);
        else layer = new Layer(this.width);
      } else return;
    }
  }
  if(bgColor) layer.oBgColor = bgColor;
  this.items[this.items.length] = layer;
  this.types[this.types.length] = "item";
  this.strs[this.strs.length] = str;
  _lid++;
}
function addList(list, str, bgColor, layer) {
  var testLayer = false;
  if(!document.all) document.all = document.layers;
  if(!layer) {
    if(isIE4 || !this.parLayer) testLayer = eval('document.all.lItem'+_lid);
    else {
      _pLayer = this.parLayer;
      testLayer = eval('_pLayer.document.layers.lItem'+_lid);
    }
    if(testLayer) layer = testLayer;
    else {
      if(isNav4) {
        if(this.parLayer) layer = new Layer(this.width, this.parLayer);
        else layer = new Layer(this.width);
      } else return;
    }
  }
  if(bgColor) layer.oBgColor = bgColor;
  this.lists[this.items.length] = list;
  this.items[this.items.length] = layer;
  this.types[this.types.length] = "list";
  this.strs[this.strs.length] = str;
  list.parent = this;
  _lid++;
}

/* 
if(!window.saveInnerWidth) 
{	
  window.onresize = resize;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}
*/

function resize() 
{	if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}

function stop_website_music()
{
	if ( navigator.appName == "Netscape")
	{	parent.frames.frame1.winplayer.Stop(); 
	} else 
	{	parent.frmMusicPlayer.winplayer.Stop(); }
}

function selectStoreDescriptionTab(in_tab_number)
{	if (in_tab_number != null) 
	{	descriptionTabs.selectTab(in_tab_number-1); location.href = '#FullProductDesccriptionTabsTop';			}
}

function explode (delimiter, string, limit) 
{	// Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.  
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function array_merge () {
    // Merges elements from passed arrays into one array  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/array_merge
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Nate
    // -    depends on: is_int
    // %          note: Relies on is_int because !isNaN accepts floats     
    // *     example 1: arr1 = {"color": "red", 0: 2, 1: 4}
    // *     example 1: arr2 = {0: "a", 1: "b", "color": "green", "shape": "trapezoid", 2: 4}
    // *     example 1: array_merge(arr1, arr2)
    // *     returns 1: {"color": "green", 0: 2, 1: 4, 2: "a", 3: "b", "shape": "trapezoid", 4: 4}
    // *     example 2: arr1 = []
    // *     example 2: arr2 = {1: "data"}
    // *     example 2: array_merge(arr1, arr2)
    // *     returns 2: {1: "data"}
    
    var args = Array.prototype.slice.call(arguments);
    var retObj = {}, k, j = 0, i = 0;
    var retArr;
    
    for (i=0, retArr=true; i < args.length; i++) {
        if (!(args[i] instanceof Array)) {
            retArr=false;
            break;
        }
    }
    
    if (retArr) {
        return args;
    }
    var ct = 0;
    
    for (i=0, ct=0; i < args.length; i++) {
        if (args[i] instanceof Array) {
            for (j=0; j < args[i].length; j++) {
                retObj[ct++] = args[i][j];
            }
        } else {
            for (k in args[i]) {
                if (this.is_int(k)) {
                    retObj[ct++] = args[i][k];
                } else {
                    retObj[k] = args[i][k];
                }
            }
        }
    }
    
    return retObj;
}

function is_int (mixed_var) {
    // !No description available for is_int. @php.js developers: Please update the function summary text file.
    // 
    // version: 912.1423
    // discuss at: http://phpjs.org/functions/is_int
    // +   original by: Alex
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Matt Bradley
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: WebDevHobo (http://webdevhobo.blogspot.com/)
    // %        note 1: 1.0 is simplified to 1 before it can be accessed by the function, this makes
    // %        note 1: it different from the PHP implementation. We can't fix this unfortunately.
    // *     example 1: is_int(23)
    // *     returns 1: true
    // *     example 2: is_int('23')
    // *     returns 2: false
    // *     example 3: is_int(23.5)
    // *     returns 3: false
    // *     example 4: is_int(true)
    // *     returns 4: false
    if (typeof mixed_var !== 'number') {
        return false;
    }
 
    return !(mixed_var % 1);
}

function get_html_translation_table (table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Frank Forte
    // +   bugfixed by: T.Wild
    // +      input by: Ratheous
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js, meaning the constants are not
    // %          note: real constants, but strings instead. Integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, hash_map = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
 
    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
 
    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');
        // return false;
    }
 
    entities['38'] = '&amp;';
    if (useTable === 'HTML_ENTITIES') {
        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';
        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';
        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';
        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';
        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';
        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';
        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';
        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';
        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';
        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';
        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';
        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';
        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';
        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';
        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';
        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';
        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';
        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';
        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';
        entities['255'] = '&yuml;';
    }
 
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';
 
 
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }
    
    return hash_map;
}

function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/htmlentities
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    hash_map["'"] = '&#039;';
    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

function html_entity_decode (string, quote_style) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 912.1423
    // discuss at: http://phpjs.org/functions/html_entity_decode
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Ratheous
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Nick Kolosov (http://sammy.ru)
    // +   bugfixed by: Fox
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');
    // *     returns 2: '&lt;'
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
 
    // fix &amp; problem
    // http://phpjs.org/functions/get_html_translation_table:416#comment_97660
    delete(hash_map['&']);
    hash_map['&'] = '&amp;';
 
    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    tmp_str = tmp_str.split('&#039;').join("'");
    
    return tmp_str;
}

function echo () {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: echo is bad
    // +   improved by: Nate
    // +    revised by: Der Simon (http://innerdom.sourceforge.net/)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Eugene Bulkin (http://doubleaw.com/)
    // +   input by: JB
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: EdorFaus
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // %        note 1: If browsers start to support DOM Level 3 Load and Save (parsing/serializing),
    // %        note 1: we wouldn't need any such long code (even most of the code below). See
    // %        note 1: link below for a cross-browser implementation in JavaScript. HTML5 might
    // %        note 1: possibly support DOMParser, but that is not presently a standard.
    // %        note 2: Although innerHTML is widely used and may become standard as of HTML5, it is also not ideal for
    // %        note 2: use with a temporary holder before appending to the DOM (as is our last resort below),
    // %        note 2: since it may not work in an XML context
    // %        note 3: Using innerHTML to directly add to the BODY is very dangerous because it will
    // %        note 3: break all pre-existing references to HTMLElements.
    // *     example 1: echo('<div><p>abc</p><p>abc</p></div>');
    // *     returns 1: undefined
    // Fix: This function really needs to allow non-XHTML input (unless in true XHTML mode) as in jQuery
    var arg = '',
        argc = arguments.length,
        argv = arguments,
        i = 0,
        holder, win = this.window,
        d = win.document,
        ns_xhtml = 'http://www.w3.org/1999/xhtml',
        ns_xul = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'; // If we're in a XUL context
    var stringToDOM = function (str, parent, ns, container) {
        var extraNSs = '';
        if (ns === ns_xul) {
            extraNSs = ' xmlns:html="' + ns_xhtml + '"';
        }
        var stringContainer = '<' + container + ' xmlns="' + ns + '"' + extraNSs + '>' + str + '</' + container + '>';
        var dils = win.DOMImplementationLS,
            dp = win.DOMParser,
            ax = win.ActiveXObject;
        if (dils && dils.createLSInput && dils.createLSParser) {
            // Follows the DOM 3 Load and Save standard, but not
            // implemented in browsers at present; HTML5 is to standardize on innerHTML, but not for XML (though
            // possibly will also standardize with DOMParser); in the meantime, to ensure fullest browser support, could
            // attach http://svn2.assembla.com/svn/brettz9/DOMToString/DOM3.js (see http://svn2.assembla.com/svn/brettz9/DOMToString/DOM3.xhtml for a simple test file)
            var lsInput = dils.createLSInput();
            // If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
            lsInput.stringData = stringContainer;
            var lsParser = dils.createLSParser(1, null); // synchronous, no schema type
            return lsParser.parse(lsInput).firstChild;
        } else if (dp) {
            // If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
            try {
                var fc = new dp().parseFromString(stringContainer, 'text/xml');
                if (fc && fc.documentElement && fc.documentElement.localName !== 'parsererror' && fc.documentElement.namespaceURI !== 'http://www.mozilla.org/newlayout/xml/parsererror.xml') {
                    return fc.documentElement.firstChild;
                }
                // If there's a parsing error, we just continue on
            } catch (e) {
                // If there's a parsing error, we just continue on
            }
        } else if (ax) { // We don't bother with a holder in Explorer as it doesn't support namespaces
            var axo = new ax('MSXML2.DOMDocument');
            axo.loadXML(str);
            return axo.documentElement;
        }
/*else if (win.XMLHttpRequest) { // Supposed to work in older Safari
            var req = new win.XMLHttpRequest;
            req.open('GET', 'data:application/xml;charset=utf-8,'+encodeURIComponent(str), false);
            if (req.overrideMimeType) {
                req.overrideMimeType('application/xml');
            }
            req.send(null);
            return req.responseXML;
        }*/
        // Document fragment did not work with innerHTML, so we create a temporary element holder
        // If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
        //if (d.createElementNS && (d.contentType && d.contentType !== 'text/html')) { // Don't create namespaced elements if we're being served as HTML (currently only Mozilla supports this detection in true XHTML-supporting browsers, but Safari and Opera should work with the above DOMParser anyways, and IE doesn't support createElementNS anyways)
        if (d.createElementNS && // Browser supports the method
        (d.documentElement.namespaceURI || // We can use if the document is using a namespace
        d.documentElement.nodeName.toLowerCase() !== 'html' || // We know it's not HTML4 or less, if the tag is not HTML (even if the root namespace is null)
        (d.contentType && d.contentType !== 'text/html') // We know it's not regular HTML4 or less if this is Mozilla (only browser supporting the attribute) and the content type is something other than text/html; other HTML5 roots (like svg) still have a namespace
        )) { // Don't create namespaced elements if we're being served as HTML (currently only Mozilla supports this detection in true XHTML-supporting browsers, but Safari and Opera should work with the above DOMParser anyways, and IE doesn't support createElementNS anyways); last test is for the sake of being in a pure XML document
            holder = d.createElementNS(ns, container);
        } else {
            holder = d.createElement(container); // Document fragment did not work with innerHTML
        }
        holder.innerHTML = str;
        while (holder.firstChild) {
            parent.appendChild(holder.firstChild);
        }
        return false;
        // throw 'Your browser does not support DOM parsing as required by echo()';
    };


    var ieFix = function (node) {
        if (node.nodeType === 1) {
            var newNode = d.createElement(node.nodeName);
            var i, len;
            if (node.attributes && node.attributes.length > 0) {
                for (i = 0, len = node.attributes.length; i < len; i++) {
                    newNode.setAttribute(node.attributes[i].nodeName, node.getAttribute(node.attributes[i].nodeName));
                }
            }
            if (node.childNodes && node.childNodes.length > 0) {
                for (i = 0, len = node.childNodes.length; i < len; i++) {
                    newNode.appendChild(ieFix(node.childNodes[i]));
                }
            }
            return newNode;
        } else {
            return d.createTextNode(node.nodeValue);
        }
    };

    var replacer = function (s, m1, m2) {
        // We assume for now that embedded variables do not have dollar sign; to add a dollar sign, you currently must use {$$var} (We might change this, however.)
        // Doesn't cover all cases yet: see http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
        if (m1 !== '\\') {
            return m1 + eval(m2);
        } else {
            return s;
        }
    };

    this.php_js = this.php_js || {};
    var phpjs = this.php_js,
        ini = phpjs.ini,
        obs = phpjs.obs;
    for (i = 0; i < argc; i++) {
        arg = argv[i];
        if (ini && ini['phpjs.echo_embedded_vars']) {
            arg = arg.replace(/(.?)\{?\$(\w*?\}|\w*)/g, replacer);
        }

        if (!phpjs.flushing && obs && obs.length) { // If flushing we output, but otherwise presence of a buffer means caching output
            obs[obs.length - 1].buffer += arg;
            continue;
        }

        if (d.appendChild) {
            if (d.body) {
                if (win.navigator.appName === 'Microsoft Internet Explorer') { // We unfortunately cannot use feature detection, since this is an IE bug with cloneNode nodes being appended
                    d.body.appendChild(stringToDOM(ieFix(arg)));
                } else {
                    var unappendedLeft = stringToDOM(arg, d.body, ns_xhtml, 'div').cloneNode(true); // We will not actually append the div tag (just using for providing XHTML namespace by default)
                    if (unappendedLeft) {
                        d.body.appendChild(unappendedLeft);
                    }
                }
            } else {
                d.documentElement.appendChild(stringToDOM(arg, d.documentElement, ns_xul, 'description')); // We will not actually append the description tag (just using for providing XUL namespace by default)
            }
        } else if (d.write) {
            d.write(arg);
        }
/* else { // This could recurse if we ever add print!
            print(arg);
        }*/
    }
}

function var_dump () {
    // http://kevin.vanzonneveld.net
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Zahlii
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: echo
    // %        note 1: For returning a string, use var_export() with the second argument set to true
    // *     example 1: var_dump(1);
    // *     returns 1: 'int(1)'

    var output = '',
        pad_char = ' ',
        pad_val = 4,
        lgth = 0,
        i = 0,
        d = this.window.document;
    var _getFuncName = function (fn) {
        var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
        if (!name) {
            return '(Anonymous)';
        }
        return name[1];
    };

    var _repeat_char = function (len, pad_char) {
        var str = '';
        for (var i = 0; i < len; i++) {
            str += pad_char;
        }
        return str;
    };
    var _getInnerVal = function (val, thick_pad) {
        var ret = '';
        if (val === null) {
            ret = 'NULL';
        } else if (typeof val === 'boolean') {
            ret = 'bool(' + val + ')';
        } else if (typeof val === 'string') {
            ret = 'string(' + val.length + ') "' + val + '"';
        } else if (typeof val === 'number') {
            if (parseFloat(val) == parseInt(val, 10)) {
                ret = 'int(' + val + ')';
            } else {
                ret = 'float(' + val + ')';
            }
        }
        // The remaining are not PHP behavior because these values only exist in this exact form in JavaScript
        else if (typeof val === 'undefined') {
            ret = 'undefined';
        } else if (typeof val === 'function') {
            var funcLines = val.toString().split('\n');
            ret = '';
            for (var i = 0, fll = funcLines.length; i < fll; i++) {
                ret += (i !== 0 ? '\n' + thick_pad : '') + funcLines[i];
            }
        } else if (val instanceof Date) {
            ret = 'Date(' + val + ')';
        } else if (val instanceof RegExp) {
            ret = 'RegExp(' + val + ')';
        } else if (val.nodeName) { // Different than PHP's DOMElement
            switch (val.nodeType) {
            case 1:
                if (typeof val.namespaceURI === 'undefined' || val.namespaceURI === 'http://www.w3.org/1999/xhtml') { // Undefined namespace could be plain XML, but namespaceURI not widely supported
                    ret = 'HTMLElement("' + val.nodeName + '")';
                } else {
                    ret = 'XML Element("' + val.nodeName + '")';
                }
                break;
            case 2:
                ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')';
                break;
            case 3:
                ret = 'TEXT_NODE(' + val.nodeValue + ')';
                break;
            case 4:
                ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')';
                break;
            case 5:
                ret = 'ENTITY_REFERENCE_NODE';
                break;
            case 6:
                ret = 'ENTITY_NODE';
                break;
            case 7:
                ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')';
                break;
            case 8:
                ret = 'COMMENT_NODE(' + val.nodeValue + ')';
                break;
            case 9:
                ret = 'DOCUMENT_NODE';
                break;
            case 10:
                ret = 'DOCUMENT_TYPE_NODE';
                break;
            case 11:
                ret = 'DOCUMENT_FRAGMENT_NODE';
                break;
            case 12:
                ret = 'NOTATION_NODE';
                break;
            }
        }
        return ret;
    };

    var _formatArray = function (obj, cur_depth, pad_val, pad_char) {
        var someProp = '';
        if (cur_depth > 0) {
            cur_depth++;
        }

        var base_pad = _repeat_char(pad_val * (cur_depth - 1), pad_char);
        var thick_pad = _repeat_char(pad_val * (cur_depth + 1), pad_char);
        var str = '';
        var val = '';

        if (typeof obj === 'object' && obj !== null) {
            if (obj.constructor && _getFuncName(obj.constructor) === 'PHPJS_Resource') {
                return obj.var_dump();
            }
            lgth = 0;
            for (someProp in obj) {
                lgth++;
            }
            str += 'array(' + lgth + ') {\n';
            for (var key in obj) {
                var objVal = obj[key];
                if (typeof objVal === 'object' && objVal !== null && !(objVal instanceof Date) && !(objVal instanceof RegExp) && !objVal.nodeName) {
                    str += thick_pad + '[' + key + '] =>\n' + thick_pad + _formatArray(objVal, cur_depth + 1, pad_val, pad_char);
                } else {
                    val = _getInnerVal(objVal, thick_pad);
                    str += thick_pad + '[' + key + '] =>\n' + thick_pad + val + '\n';
                }
            }
            str += base_pad + '}\n';
        } else {
            str = _getInnerVal(obj, thick_pad);
        }
        return str;
    };

    output = _formatArray(arguments[0], 0, pad_val, pad_char);
    for (i = 1; i < arguments.length; i++) {
        output += '\n' + _formatArray(arguments[i], 0, pad_val, pad_char);
    }

    if (d.body) {
        this.echo(output);
    } else {
        try {
            d = XULDocument; // We're in XUL, so appending as plain text won't work
            this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">' + output + '</pre>');
        } catch (e) {
            this.echo(output); // Outputting as plain text may work in some plain XML
        }
    }
}

function show_calendar_dialog()
{
	var bo_debug 				= false;
	var va_object_name 			= arguments[0];	
	var date_format				= arguments[1];
	date_format					= ((typeof date_format != 'undefined')? date_format : 'yy-mm-dd');
	
	jquery_api(function() {
		jquery_api( "#".concat(va_object_name) ).datepicker({ dateFormat: date_format, changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
	});
}

function show_calendar()
{	var bo_debug = false;
	var va_object_name = arguments[0];																					if (bo_debug == true) { alert(va_object_name);									}
	
	ar_object_name = explode('.', va_object_name);																		if (bo_debug == true) { alert(ar_object_name[0]); alert(ar_object_name[1]);		}
	
	show_calendar_dialog(ar_object_name[1], arguments[1]);
	jquery_api('#'.concat(ar_object_name[1])).datepicker('show'); 
	return false;					// PREVENT LEGACY CODE BELOW FROM EXECUTING.... WE NEED TO PHASE CODE OUT
	
//	ar_object_name = explode('.', va_object_name);																		if (bo_debug == true) { alert(ar_object_name[0]); alert(ar_object_name[1]);		}
//	ob_text_box = MM_findObj('date_selected');																			if (bo_debug == true) { alert(ob_text_box.value);								}
	
	winCalendar = window.open("", "Calendar", "width=250,height=250,status=no,resizable=no,top=200,left=200");
	winCalendar.opener = self;
	winCalendar.document.open();

	if (IE) 
	{	// Setup the page...
		winCalendar.document.writeln("<html>");
		winCalendar.document.write("<head>");
			winCalendar.document.writeln ("<title>Calendar | Select Date</title>");
				winCalendar.document.writeln ("<script type=\"text/javascript\" >");	
			winCalendar.document.writeln ("location.href = '/viewer/mgr.cp/select.date.asd/vts/blank/va_object_name/" + va_object_name + "';");	
			winCalendar.document.writeln ("</script>");
		winCalendar.document.writeln ("</head>");
		winCalendar.document.writeln ("<body>");
		winCalendar.document.writeln ("</body>");
		winCalendar.document.writeln ("</html>");
	}else
	{	// Setup the page...
		winCalendar.document.writeln("<html>");
		winCalendar.document.write("<head>");
			winCalendar.document.writeln ("<title>Calendar | Select Date</title>");
			winCalendar.document.writeln ("<link rel=\"stylesheet\" type=\"text/css\" href=\"/includes/common/thirdparty/yui/build/calendar/assets/calendar.css\">");
			winCalendar.document.writeln ("<script type=\"text/javascript\" src=\"/includes/common/thirdparty/yui/build/yahoo-dom-event/yahoo-dom-event.js\"></script> ");
			winCalendar.document.writeln ("<script type=\"text/javascript\" src=\"/includes/common/thirdparty/yui/build/calendar/calendar-min.js\"></script>");
		winCalendar.document.writeln ("</head>");
		winCalendar.document.writeln ("<body style=\"margin: 16 16 16 16;\">");	
			winCalendar.document.writeln ("<div id=cal1Container></div>");
				winCalendar.document.writeln ("<script type=\"text/javascript\" >");
					winCalendar.document.writeln ("var newCalendarDisplay = new YAHOO.widget.Calendar('cal1Container'); ")
					winCalendar.document.writeln ("newCalendarDisplay.render(); ")
					winCalendar.document.writeln ("")
					winCalendar.document.writeln ("function handleSelect(type,args,obj) ");
					winCalendar.document.writeln ("{ ");
					winCalendar.document.writeln ("var date_range = args[0]; ");
					winCalendar.document.writeln ("var fist_date = date_range[0]; ");
					winCalendar.document.writeln ("var year = fist_date[0], month = fist_date[1], day = fist_date[2]; ");
					winCalendar.document.writeln ("var ob_destination_textbox = opener.document." + va_object_name + "; ");
					winCalendar.document.writeln ("ob_destination_textbox.value = year + '-' + month + '-' + day; ");
					winCalendar.document.writeln ("window.close();");
					winCalendar.document.writeln ("} ");
					winCalendar.document.writeln ("newCalendarDisplay.selectEvent.subscribe(handleSelect, newCalendarDisplay, true); ");
			winCalendar.document.writeln ("</script>");
		winCalendar.document.writeln ("</body>");
		winCalendar.document.writeln ("</html>");
	}
}

function show_time() 
{	bo_debug = false;
	va_object_name = arguments[0];																						if (bo_debug == true) { alert(va_object_name);									}
	
	ar_object_name = explode('.', va_object_name);																		if (bo_debug == true) { alert(ar_object_name[0]); alert(ar_object_name[1]);		}
	
	jquery_api('#'.concat(ar_object_name[1])).timepicker({  hours: { starts: 0, ends: 23 }, minutes: { starts: 0, ends: 59, interval: 1 }, rows: 4, showNowButton: true, showCloseButton: true   });
	
	jquery_api('#'.concat(ar_object_name[1])).focus();
	
	return false;					// PREVENT LEGACY CODE BELOW FROM EXECUTING.... WE NEED TO PHASE CODE OUT
	
	
	winClock = window.open("", "Time", "width=340,height=100,status=no,resizable=no,top=200,left=200");
	winClock.opener = self;
	winClock.document.open();
	
	var now = new Date();
	current_hours_selection 		= now.getHours();				
	current_ampm_selection 			= ((current_hours_selection >= 12)? 'PM' : 'AM');
	current_hours_selection 		= ((current_hours_selection >= 12)? current_hours_selection - 12 : current_hours_selection);
	current_minutes_selection 		= now.getMinutes();
	current_seconds_selection 		= now.getSeconds();

	// Setup the page...
	winClock.document.write("<html>\n");
	winClock.document.write("<head>\n");
		winClock.document.write("\t<title>Time | Select Time</title>\n");
	winClock.document.write("</head>\n");
	winClock.document.write("<body style=\"margin: 16 16 16 16;\">\n");	
		winClock.document.write("\t<div style='background-color: #f0f0f0; padding: 6 6 6 6; font-weight: bold; color: black; font-size: 14px;'>\n");
			winClock.document.write("\t\t<select id=hours>\n");
				for (i = 1; i <= 12; i++)
				{	if (i < 10) i_display = '0' + i;
					else i_display = i;
					winClock.document.write("\t\t<option value=" + i_display + ((i == current_hours_selection)? ' selected' : '') + ">" + i_display + "</option>\n");
				}
			winClock.document.write("\t\t</select>\n");
			winClock.document.write("\t\t:\n");
			winClock.document.write("\t\t<select id=minutes>\n");
				for (i = 0; i <= 59; i++)
				{	if (i < 10) i_display = '0' + i;
					else i_display = i;
					winClock.document.write("\t\t<option value=" + i_display + ((i == current_minutes_selection)? ' selected' : '') + ">" + i_display + "</option>\n");
				}
			winClock.document.write("\t\t</select>\n");
			winClock.document.write("\t\t<select id=ampm>\n");
				winClock.document.write("\t\t<option value=AM" + ((current_ampm_selection == 'AM')? ' selected' : '') + ">AM</option>\n");
				winClock.document.write("\t\t<option value=PM" + ((current_ampm_selection == 'PM')? ' selected' : '') + ">PM</option>\n");
			winClock.document.write("\t\t</select>\n");
			winClock.document.write("\t\t<input type=button id=cmdSelect value=Select onclick=\"handleselect();\">\n");
			winClock.document.write("\t\t<input type=button id=cmdExit value=X onclick=\"window.close();\">\n");
		winClock.document.write("\t</div>\n");
			winClock.document.write("<script type=\"text/javascript\" language=\"JavaScript\" >\n");
				winClock.document.write("\tfunction handleselect() \n");
				winClock.document.write("\t{ \n");
				winClock.document.write("\tvar ob_destination_textbox = opener.document." + va_object_name + "; \n");
				winClock.document.write("\tin_hours 	= ((ampm.value == 'PM' && hours.value != '12')? 12 : 0) + ((ampm.value == 'AM' && hours.value == '12')? 0 : parseFloat(hours.value)); \n");
				winClock.document.write("\tin_minutes 	= parseFloat(minutes.value); \n");
				winClock.document.write("\tin_seconds 	= 0; \n");
				winClock.document.write("\tob_destination_textbox.value = ((in_hours < 10)? '0' : '') + in_hours + ':' + ((in_minutes < 10)? '0' : '') + in_minutes + ':' + ((in_seconds < 10)? '0' : '') + in_seconds; \n");
				winClock.document.write("\twindow.close();\n");
				winClock.document.write("\t} \n");
		winClock.document.write("</script>\n");
	winClock.document.write("</body>\n");
	winClock.document.write("</html>\n");
}

function trim (str, charlist) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // *     example 1: trim('    Kevin van Zonneveld    ');
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'
    // *     example 3: trim(16, 1);
    // *     returns 3: 6

    var whitespace, l = 0, i = 0;
    str += '';
    
    if (!charlist) {
        // default list
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
    }
    
    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }
    
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}


function copy_text_to_clipboard_init(button, container, text)
{	if (!IE)
	{	// Instantiate the Text Copy object
		ZeroClipboard.setMoviePath( '/includes/common/thirdparty/zeroclipboard/ZeroClipboard.swf' );
		copyTextToClipboard = new ZeroClipboard.Client();
		copyTextToClipboard.setHandCursor( true );
		copyTextToClipboard.setText( text );
		copyTextToClipboard.addEventListener( 	'complete', 
												function ()
												{	alert('Content copied to your clipboard.\n\nYou can now paste anywhere you want.\n\nTo paste, press the following keys at the same time:\n\nOn Windows : CTRL + V keys \nOn Macs       : CMD + V keys');	}
									 );
		copyTextToClipboard.glue( button, container );
	}
}

function select_and_copy_content(st_object_name) 
{	obj = document.getElementById(st_object_name);
	if (obj != null)
	{	obj.focus();
		obj.select();
		if (IE) 					// on works in IE
		{	therange 	= obj.createTextRange();
			therange.execCommand("Copy");		 
		}
		alert('Content copied to your clipboard.\n\nYou can now paste anywhere you want.\n\nTo paste, press the following keys at the same time:\n\nOn Windows : CTRL + V keys \nOn Macs       : CMD + V keys');
	}
	
	return true;
}

function check_toggle(form_number, current_value, variable_name)
{	obj = document.forms[form_number].elements[variable_name];
	if (obj)
	{	for (i = 1; i <= obj.length; i++)
		{	obj[i-1].checked = current_value;			}
	}
}

function get_checked_values(form_number, variable_name, delimiter)
{	var va_data = "";
	
	obj = document.forms[form_number].elements[variable_name];
	if (obj)
	{	for (i = 1; i <= obj.length; i++)
		{	if (obj[i-1].checked == true)
			{	va_data = va_data + ((va_data.length > 0)? delimiter : '') + obj[i-1].value;	}
		}
																		
	}
		
	return va_data;
}

function get_value_of_radio_options(form_number, radio_name) 
{	var oRadio = document.forms[form_number].elements[radio_name];
        
    for(var i = 0; i < oRadio.length; i++) 
    {       if(oRadio[i].checked) 
            {       return oRadio[i].value;                 }
    }
    
    return '';
}

function get_value_of_list_options(form_number, list_name) 
{	var oList = document.forms[form_number].elements[list_name];
        
	return oList.options[oList.selectedIndex].value;
}

function multimedia_manager_variation_type_processor(data, delimiters, data_type)
{	switch(data_type.toUpperCase())
	{	case 'VALUE':
			var ar_delimiters 	= explode(',', delimiters);
			if(ar_delimiters.length >= 2)
			{	data			= data.replace(/ ,/g, ar_delimiters[1]);
				data			= data.replace(/,/g, ar_delimiters[1]);
				data			= data.replace(' (', ar_delimiters[0]);
				data			= data.replace('(', ar_delimiters[0]);
				data			= data.replace(' )', '').replace(')', '');
			}
			break;
			
		case 'CAPTION':
			data				= data.replace('(', ' ( ');
			data				= data.replace(/,/g, ' , ');
			data				= data.replace(')', ' )');
			data				= data.replace('  ', ' ');
			break;
		
		default:
			break;
		
	}
	return data;
}

function show_dialog(dialog_content_handle, dialog_title, dialog_width, dialog_height, dialog_modal, dialog_resizable, dialog_animation, focus_handle )
{
	jquery_api(dialog_content_handle).dialog
		(	{	title: dialog_title, 
				closeOnEscape: true, 
				height: dialog_height, 
				width: dialog_width, 
				modal: dialog_modal, 
				resizable: dialog_resizable, 
				show: dialog_animation, 
				close: function(event, ui) { jquery_api(this).prop('innerHTML', ''); },
				buttons: 
				{	'Exit': 		function() 			{ jquery_api(this).dialog('close'); if (focus_handle != null) { jquery_api(focus_handle).focus(); } } 
				}  
			}
		);
}

function alert_dialog(message, container_handle, focus_handle, title)
{	
	if (container_handle != null)
	{
		jquery_api(container_handle).prop('innerHTML', message);
		show_dialog(container_handle, ((title != null)?  title : 'Message Board'), 400, 250, true, false, 'slide', focus_handle);
		
	}else
	{
		alert(message);
	}
}

function local_wait(ms) 
{	ms += new Date().getTime();
	while (new Date() < ms){}
} 

function simulate_flash_navigation(mode)
{
	switch(mode)
	{	case true:
			jquery_api('#globalPageContentContainer A').bind('click', function (event) { simulate_flash_navigation_hyperlinks( event, this); } ); 
			break;
			
		case false:
			jquery_api('A').bind('click', function (event) { simulate_flash_navigation_hyperlinks( event, this); } ); 
			break;
	}
}

function simulate_flash_navigation_hyperlinks (event, element)
{	
	st_host_name							= window.location.hostname;
	st_destination 							= jquery_api(element).prop('href');
	ob_destination							= parseUri(st_destination);
//	alert(st_destination);
//	alert(ob_destination.relative);
//	alert(ob_destination.anchor);
	if (	(st_destination.length > 0) 																										&& 
			(ob_destination.relative.search('#') == -1) 																						&& 
			(ob_destination.host == st_host_name)
		)
	{	
//		alert('OK');
		
		// stop default link action
//		jquery_api(element).parent().off('click');						
		jquery_api(element).parent().prop('onclick', 'return false;');						
		event.preventDefault();	
//		alert(jquery_api(element).parent().prop('innerHTML'));						
		
		// perform any local pre-animation setups
		if(typeof local_simulate_flash_navigation == 'function') { local_simulate_flash_navigation(event, element, ob_destination);			}
		
		// implement load animation
		jquery_api('#globalPageContentContainer').prop('innerHTML', '<div>Loading, please wait ...</div><div><center><img src=/images/preloaders/loading1.gif border=0></center></div>'); 
		
		// get the new page content
		var ajaxRequestData = '/documents/scripts/ajax.payload.asd'.concat('?plpage=', encodeURI(st_destination)); 
		build_content(ajaxRequestData, 'globalPageContentContainer.innerHTML', false, 'VARIABLE');
		
	}
	
}

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

