
try {
// function to register for event
  top.movementThreshold = 0;
} catch (e) {
}

function doUpdateTimer() {
  try {
      top.movementThreshold++;
      if (top.movementThreshold == 50) {
  	top.eventFired = true;
      }
  } catch (e) {
  }
}

//Detect mouse move and mouse click events.

try {

  if (document.layers) {
     document.captureEvents(Event.CLICK | Event.MOUSEMOVE);
  }
  document.onmousemove = doUpdateTimer;
} catch (e) {
}


function programChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	ProgramChooser = window.open(url,"ProgramChooser", props);
	ProgramChooser.focus();
}

function projectChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	ProjectChooser = window.open(url,"ProjectChooser", props);
	ProjectChooser.focus();
}

function templateChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	TemplateChooser = window.open(url,"TemplateChooser", props);
	TemplateChooser.focus();
}

function memberChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	MemberChooser = window.open(url,"memberChooser", props);
	MemberChooser.focus();
}

function collabDBChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	CollabDBChooser = window.open(url,"collabDBChooser", props);
	CollabDBChooser.focus();
}

function groupChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	GroupChooser = window.open(url,"groupChooser", props);
	GroupChooser.focus();
}

function skillsetChooser(url) {
	var props = getRestrictedWindowProperties(450,500, true,true);
	SkillsetChooser = window.open(url,"skillsetChooser", props);
	SkillsetChooser.focus();
}

function messengerWindow(url) {
	var props = getMinimalWindowProperties(700,500, true);
	var messengerWin = window.open(url,"messengerWin", props);
	messengerWin.focus();
}


function messengerPeopleWindow(url) {
	var props = getMinimalWindowProperties(260,500, true);

	var messengerPeopleWin = window.open(url,"messengerPeopleWin", props);
	messengerPeopleWin.focus();

}





function helpFrame(){
	var props = getFullWindowProperties(800,600);
	window.open( TC_BASE_URL+"helpRedirect.jsp" ,"HelpWin",props);
}


function printFrame(){
	if(isNS || isMac){
		//open in new window
		//alert("This will open the document in a new window that you can print using the 'Print' button.");
		var props = getFullWindowProperties(700,500);
		window.open( location.href ,"PrintWin",props);

	}else{
        window.focus();
		window.print();
	}
}

function launchWolfLink(url){
    var props = getRestrictedWindowProperties(800,600,true,true);

    var tsWin = window.open(url, "Workplace", props);
    tsWin.focus();
}


function showErrorDialog(title, message) {
 	 var props = getRestrictedWindowProperties(450,350,true,true);
    return(window.open(TC_BASE_URL+"errorMessage.jsp?title="+escape(title)+"&message="+escape(message),"errorWin",props));
}

function refreshFrame(){
	parent.parent.contentFrameset.content.location.reload( true );
	parent.parent.contentFrameset.content.focus();
}

function getScreenX(winWidth){
	var x = (screen.availWidth/2) - (winWidth/2);
	if(x >= 0)
		return x;
	return 0;
}

function getScreenY(winHeight){
	var y = (screen.availHeight/2) - (winHeight/2);
	if(y >= 0)
		return y;
}

// pass in any value to show the resize and status to true
function getRestrictedWindowProperties(width, height, resizeable,status){
	 var top = getScreenY(height);
	 var left = getScreenX(width);
	 var resize="0";
	 if(resizeable)
	 	resize="1";

	var stat="1";
	 //if(status)
	 	//stat="0";


	 return ("width="+ width+",height="+ height +",resizable="+resize+",status="+stat+",menubar=0,directories=0,toolbar=0,location=0,scrollbars=1,top="+top+",left="+left)
}

function getMinimalWindowProperties(width, height, resizeable){
	 var top = getScreenY(height);
	 var left = getScreenX(width);
	 var resize="0";
	 if(resizeable)
	 	resize="1";


	 return ("width="+ width+",height="+ height +",resizable="+resize+",status=0,menubar=0,directories=0,toolbar=0,location=0,top="+top+",left="+left)
}


function getFullWindowProperties(width, height){
	 var top = getScreenY(height);
	 var left = getScreenX(width);
	 return ("resizable=1,status=1,menubar=1,directories=1,toolbar=1,location=1,scrollbars=1,width="+ width+",height="+ height +",top="+top+",left="+left)
}

//formats a date into standard american format for sending to servlet components
function getDateString(theDate) {
  var retDateString = (theDate.getMonth() + 1) + "/";
  retDateString += theDate.getDate() + "/";
  retDateString += theDate.getFullYear();

  return(retDateString);
}


/**
	*This function trims the spaces form the start and the end of the String
	**/
	String.prototype.trim = function() {

	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
	};//end of String.prototype.trim = function()










var secondWindow = false;
function ProgressBar(sLength) {

var BarLength = 400;
var iLength = parseFloat(sLength);
var Bar = parseInt(iLength); 
if(Bar==0)Bar=1;
var Trough = (BarLength - Bar);
if(Trough==0){Trough=1;Bar=99;}

if(Bar >99) {Bar=99; Trough=1;}
if(Trough <0) {Trough=1;Bar=99;}

var leftVal = (screen.width-490) / 2;
var topVal = (screen.height-20) / 2;
var cellLayer="id1";


if(secondWindow == false) { 

if (navigator.appName=="Microsoft Internet Explorer"){

var theWindow = 

'width=490,height=20,left='+leftVal+',top='+topVal+',menubar=no,toolbar=no,location=no,personalbar=no,status=no,scrollbars=no,directories=no,resizable=no';
Window02 = window.open('','wind',theWindow);
Window02.document.open();
Window02.document.write('<html><head><script>window.onunload=function(){window.close();} <\/script><title>Please Wait......</title></head><body bgcolor="#eeeeee"><div id=t1 style="position:absolute; top:10; left:10; background-color:#800517; z-index:2; height:20px;"></DIV><div id=t2 style="position:absolute; top:10; left:10; background-color:#cccccc; z-index:1; height:20px; border:#ff0000 1px solid;"></div></body></html>');

Window02.document.close();
}
secondWindow = true;
}
if (secondWindow == true){
if (navigator.appName=="Microsoft Internet Explorer"){

if(!Window02.closed){
//if(Bar <0 || Trough<0) alert("hello");
Window02.document.getElementById("t1").style.width=(Bar * (BarLength/100)).toString();
Window02.document.getElementById("t2").style.width=BarLength;

}

}

secondWindow = true;
}

} 
function progressBarDisplay(){

	progressCounter=0;
	progressCount=parseFloat(100/250);
	for(i=0;i<250;i++){
	
	
		progressCounter+=progressCount;
		ProgressBar(progressCounter);
	}
	if (navigator.appName=="Microsoft Internet Explorer"){
	
		if(!Window02.closed)
			
			Window02.close(); 
		}
	secondWindow = false; 
}



var workingWin; 

function showWorking() { 

	x = screen.availWidth / 2 - 200; 
	y = screen.availHeight / 2 - 50; 
	workingWin = window.open(TC_BASE_URL + "working.jsp", "working", 
	"left=" + x + ",top=" + y + 
	",height=300,width=400,fullscreen=no,toolbar=no," + 
	"status=no,menubar=no,scrollbars=no,resizable=no," + 
	"directories=no,location=no"); 
}
	
function showProgressBar(){
 
 showWorking();
 self.setTimeout('clearWorking()', 4000);

}

	
function clearWorking() { 
	
	try { 
	
		workingWin.close(); 
	} catch (e) {} 
} 

