function cdate(){
    b = new Date();
    return b.getSeconds() + b.getMinutes()*60 + b.getHours()*12*60;
}
function resize(){}
var newwindow;
function pophelp(url)
{
	newwindow=window.open(url,'name','height=400,width=300,resizable=yes, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
// www.sean.co.uk

function pausecomp(millis) 
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); } 
while(curDate-date < millis);
} 

function preload()
{
}

function gvi(a){
cntr = 0;
  for (var i = 0; i < a.length; i++){
   cntr=i;
    if (a.options[i].selected == true)
      {return i;}
  }
  return null;
  }
function Trim (InString) {
  return lTrim(rTrim(InString));
}

function cms_swapImgRestore() { //v3.0
  var i,x,a=document.cms_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function cms_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.cms_p) d.cms_p=new Array();
    var i,j=d.cms_p.length,a=cms_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.cms_p[j]=new Image; d.cms_p[j++].src=a[i];}}
}

function cms_findObj(n, d) { //v3.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=cms_findObj(n,d.layers[i].document); return x;
}

function cms_swapImage() { //v3.0
  var i,j=0,x,a=cms_swapImage.arguments; document.cms_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=cms_findObj(a[i]))!=null){document.cms_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function flip(l)
{
	var on = (document.all(l).style.display == 'none') ? 1 : 0;
	document.images['i'+l].src = (on) ? '/cms_images/cmsicons/minus.gif' : '/cms_images/cmsicons/plus.gif';
	document.all(l).style.display = (on) ? 'block' : 'none';
	resize();
	if(parent.resize!=null)
	{
	parent.resize();
	//alert(1);
	}
}
function treeviewselectfile(a,b,c)
	{
	document.getElementById("span_" + b).innerHTML="<b>" + c + a + "</b>";
	document.getElementById( b).value = a
	document.getElementById( b + "_location").value = c
	}
	
	
// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();



// singleton class constructor
function Logger() {
	// fields
	this.req;

	// methods
	this.errorToXML = errorToXML;
	this.log = log;
}
// map an error to an XML document
function errorToXML(err) {
    var now = new Date();

	var xml = '<?xml version="1.0"?>\n' +
		'<error>\n' +
		'<name>' + err.name + '</name>\n' +
		'<timeOfError>' + now + '</timeOfError>\n' +
		'<message>'  + err.message + '</message>\n';
	if (err.location) xml += '<location>' + err.location +
		'</location>';
	xml += '</error>';
	 
	return xml;
}
function log(err) {
	// feature sniff
 
	if (window.XMLHttpRequest) this.req = new XMLHttpRequest();
	else if (window.ActiveXObject) this.req =
		new ActiveXObject("Microsoft.XMLHTTP");
	else return; // throw up our hands in despair
	// set the method and URI
	this.req.open("POST", "../log/FuzionCMSErrorLog.asp");
	// set the request headers. REFERER will be the top-level
	// URI which may differ from the location of the error if
	// it occurs in an included .js file
	this.req.setRequestHeader('REFERER', location.href);
	this.req.setRequestHeader('content-type', 'text/xml');
	// function to be called when the request is complete
	this.req.onreadystatechange = errorLogged;
	this.req.send(this.errorToXML(err));
	 
	// if the request doesn't complete in 10 seconds,
	// something is up
	this.timeout = window.setTimeout("abortLog();", 10000);
}
// should only be one instance of the logger
var logger = new Logger();

// we tried, but if there is a connection error, it is hopeless
function abortLog() {
	logger.req.abort();
	alert("Attempt to log the error timed out.");
}

// called when the state of the request changes
function errorLogged() {
	if (logger.req.readyState != 4) return;
	window.clearTimeout(logger.timeout);
	// request completed
	if (logger.req.status >= 400)
		alert('Attempt to log the error failed.');
}