
	

var xMousePos = 0; // horizontal position of the mouse on the screen
var yMousePos = 0; // vertical position of the mouse on the screen

var currentEditLayer = null;
var theTimeout = null;

if (document.layers) {
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) {
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) {
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
}


// mh
function setLayerActive( layer ) {
	//alert('SET ACTIVE LAYER ' + layer + "  current:" + currentEditLayer);
	if (currentEditLayer != null) {
		MM_showHideLayers(currentEditLayer,'','hide');
		currentEditLayer = null;
	}
	if (layer != null) {
		MM_showHideLayers(layer,'','show');		
	}
	currentEditLayer = layer;
	if (theTimeout != null) {
		clearTimeout( theTimeout );
	}
}

// mh
function enteredEditLayer() {
	if (theTimeout != null) {
		clearTimeout( theTimeout );
	}
}

// mh
function leftEditLayer() {
	if (theTimeout != null) {
		clearTimeout( theTimeout );
	}
	theTimeout = setTimeout("setLayerActive(null);",2000);
}



function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.clientX + window.pageXOffset;
        yMousePos = e.clientY + window.pageYOffset;
    }
}



function moveLayerToMouse(layerId) {
    if (document.getElementById) {
		document.getElementById(layerId).style.top = yMousePos + 'px';
		document.getElementById(layerId).style.left = xMousePos + 'px';
    } else if (document.all) {
		document.all(layerId).style.top = yMousePos;
		document.all(layerId).style.left = xMousePos;
    } else if (document.layers) {
		document.layers[layerId].moveTo(xMousePos,yMousePos);
    }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function loadContentFrame(contentUrl) {
	top.contentFrame.location.replace(contentUrl);
}

function resetLayer(layerToReset) {
	var resetData = '<table cellpadding="2" cellspacing="0" border="0" bgcolor="#FFFF99" width="350"><tr><td align="center">...&nbsp;loading</td></tr></table>';
	if (document.getElementById) {
		layerToReset = document.getElementById(layerToReset);
		layerToReset.innerHTML = resetData;
	} else if (document.all) {
		layerToReset = document.all[layerToReset];
		layerToReset.innerHTML = resetData;
	} else if (document.layers) {
		layerToReset = document.layers[layerToReset];
		layerToReset.document.open();
		layerToReset.document.write(resetData);
		layerToReset.document.close();
	}
}

function cmsSwapCellStyle(cell,styleDef) {
	cell.className = styleDef;
}



function encodeTagsUrl(url) {
  var contextPath = '';

  var interactionId = '';

  var encodedUrl = url;
  
  if (url.charAt(0) == '/') {
    encodedUrl = contextPath + url;
  }
  
  if (interactionId != '') {
    if (url.indexOf('?') == -1) {
     	encodedUrl = encodedUrl + "?ixn=" + interactionId;
    } else {
      encodedUrl = encodedUrl + "&ixn=" + interactionId;
    }
  }
  
  return encodedUrl;
}

function aitOpenModalDialog( url, title, parameters ) {

	var isOpera = (navigator.userAgent.indexOf("Opera") > 0) ;
	var isCompatible = (!isOpera && navigator.appName == 'Microsoft Internet Explorer') ;
	if (isCompatible)
	{
		var browserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
		isCompatible = (browserVersion >= 5) ;
	}
	
	//if (isCompatible) {
		//alert('isCompatible:' + isCompatible);
		//var newWindow = window.showModalDialog( url, window, 'dialogWidth=550px;dialogHeight=220px' );
  //} else {
		var newWindow = window.open (url, title, parameters );
	//}

	return newWindow;
}



