    var browserName;
    var fieldIDToReplyEntityIDTo = "";

    // Declaring valid date character, minimum year and maximum year
	var dtCh= "/";
	var minYear=1850;
	var maxYear=2150;

	if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
      browserName="IE";  
    else if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null)
      browserName="Netscape"
    else
      browserName="IE";

	//--------------------------------------------------------------------
	function doSubmit() 
	{
		var theform;
		if (browserName == "Netscape") 
		{
			theform = document.forms["Form1"];
		}
		else 
		{
			theform = document.Form1;
		}
		
		theform.submit();
	}		
	//--------------------------------------------------------------------
	function toggleItemsVisibility(itemsID)
	{
		if(document.getElementById(itemsID).style.visibility == 'visible')
			document.getElementById(itemsID).style.visibility = 'hidden';	
		else
			document.getElementById(itemsID).style.visibility = 'visible';	
	}
    //--------------------------------------------------------------------    
    function showEmailRecipients(emailID)
    {          
      //save the chosen eventID to a hidden field, so netscape users
      //can access it from the eventNotes page that will pop up.
      //document.Form1.chosenEventID.value=eventID;
      var myObj = new Object();
      
      //myObj.screenObj = this.window;
      myObj.id = emailID;  //pass the email recipients screen the id of the email you want
                           //to view recipients of
                      
      var urlpath = "EmailRecipients.aspx?receivedEmailID=" + emailID;
      if(browserName=="IE")
        newwin=window.showModalDialog(urlpath,myObj,"status:no;help:no;dialogWidth:370px;dialogHeight:299px;");    
      else
        newwin=window.open(urlpath,"_new","width=3701,height=299,left=5,top=5,scrollbars=yes,resizable=no"); 
    }	
    //--------------------------------------------------------------------
    function displayIndividualScreen(entityID)
    {
      var screenURL = "ViewIndividual.aspx?personID=" + entityID;
    
	  try
	  {
	    //if called from menu frame link then this will apply
		window.parent.main.location.href = screenURL;
	  }
	  catch(anError)
	  {	   
	    location.href = screenURL;
	  }
    }
    //--------------------------------------------------------------------
    function displayInstitutionScreen(entityID)
    {
      var screenURL = "ViewInstitution.aspx?institutionID=" + entityID;
      
      try
      {
       //if called from menu frame link then this will apply
        window.parent.main.location.href = screenURL;
      }
	  catch(anError)
	  {
	    location.href = screenURL;
	  }
    }
    //--------------------------------------------------------    
    function openEmailSearchWindow(fieldsID, ownerOrPublic, draftOrSent)
    {
      //this opens the email search function in a new window.
      //the search function will call a javascript function on
      //the calling page called 'emailSearchReply(String)' and will pass
      //it the ID of the chosen email. You can then use that value
      //in this pages Javascript, or reload the page and save it as 
      //an ASP variable. The findEmail page will automatically submit
      //the form so ASP will be able to collect the newly entered value  
      
      var newwin;     
      var destinationURLPath;
      var newWindowHeight;
      var newWindowWidth;      
      
      fieldIDToReplyEntityIDTo = fieldsID; 
      newWindowHeight = 589;
      newWindowWidth = 785;
      destinationURLPath = "FindEmail.aspx";
      
      if(ownerOrPublic > 0)
		destinationURLPath += "?emailStatus=" + ownerOrPublic;
      
      if( (draftOrSent > 0) && (ownerOrPublic > 0))
		destinationURLPath += "&ownershipType=" + draftOrSent;		
      else if( (draftOrSent > 0) && (ownerOrPublic <= 0))
		destinationURLPath += "?ownershipType=" + draftOrSent;	
      //alert(destinationURLPath);
      if(browserName=="IE")
        newwin=window.showModalDialog(destinationURLPath,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(destinationURLPath,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",left=5,top=5,scrollbars=yes,resizable=no");    
    }
    //--------------------------------------------------------------------
    function openPersonSearchWindow(fieldsID,accessTypeID)
    {
      //this opens the person search function in a new window.
      //the search function will call a javascript function on
      //the calling page called 'personSearchReply(String)' and will pass
      //it the ID of the chosen person. You can then use that value
      //in this pages Javascript, or reload the page and save it as 
      //an ASP variable. The findPerson page will automatically submit
      //the form so ASP will be able to collect the newly entered value     
      
      var newwin;     
      var destinationURLPath;
      var newWindowHeight;
      var newWindowWidth;
      
      fieldIDToReplyEntityIDTo = fieldsID; 
      newWindowHeight = 589;
      newWindowWidth = 785;
      destinationURLPath = "FindIndividual.aspx?accessTypeID=" + accessTypeID;
      
      if(browserName=="IE")
        newwin=window.showModalDialog(destinationURLPath,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(destinationURLPath,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",left=5,top=5,scrollbars=yes,resizable=no");
    }
    //--------------------------------------------------------------------
    function openPersonSearchWindow(fieldsID,accessTypeID,loadInternal)
    {
      //this opens the person search function in a new window.
      //the search function will call a javascript function on
      //this page called 'personSearchReply(String)' and will pass
      //it the ID of the chosen person. You can then use that value
      //in this pages Javascript, or reload the page and save it as 
      //an ASP variable. The findPerson page will automatically submit
      //the form so ASP will be able to collect the newly entered value     
      
      var newwin;     
      var destinationURLPath;
      var newWindowHeight;
      var newWindowWidth;
      
      fieldIDToReplyEntityIDTo = fieldsID; 
      newWindowHeight = 589;
      newWindowWidth = 785;
      destinationURLPath = "FindIndividual.aspx?loadInternal=" + loadInternal + "&accessTypeID=" + accessTypeID;
      
      if(browserName=="IE")
        newwin=window.showModalDialog(destinationURLPath,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(destinationURLPath,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",left=5,top=5,scrollbars=yes,resizable=no");
    }    
    //--------------------------------------------------------------------
    function openWindowWithURL(url,newWindowWidth,newWindowHeight)
    {
		var newwin;
		var xMax;
		var yMax;
		var xOffset;
		var yOffset;
		
		if (document.all)
		{
			xMax = screen.width;
			yMax = screen.height;
		}
		else
		{
			if (document.layers)
			{
				xMax = window.outerWidth;
				yMax = window.outerHeight;
			}
			else
			{
				xMax = 900
				yMax=800;
			}
		}
	
		xOffset = (xMax - newWindowWidth)/2;
		yOffset = (yMax - newWindowHeight)/2;					
		
      if(browserName=="IE")
        newwin=window.showModalDialog(url,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(url,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",screenX=" + xOffset + ",screenY=" + yOffset + ",top=" + yOffset + ",left=" + xOffset + ",scrollbars=yes,resizable=yes");
		
    }   
    //--------------------------------------------------------------------
    function openWindowWithURLFromMenu(url,newWindowWidth,newWindowHeight)
    {
		var newwin;
		var xMax;
		var yMax;
		var xOffset;
		var yOffset;
		
		if (document.all)
		{
			xMax = screen.width;
			yMax = screen.height;
		}
		else
		{
			if (document.layers)
			{
				xMax = window.outerWidth;
				yMax = window.outerHeight;
			}
			else
			{
				xMax = 900
				yMax=800;
			}
		}
	
		xOffset = (xMax - newWindowWidth)/2;
		yOffset = (yMax - newWindowHeight)/2;					
		
      if(browserName=="IE")
        newwin=window.showModalDialog("../" + url,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(url,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",screenX=" + xOffset + ",screenY=" + yOffset + ",top=" + yOffset + ",left=" + xOffset + ",scrollbars=yes,resizable=yes");		
    }       
	//--------------------------------------------------------------------
    //This function is called by the 'findPerson' Screen.
    //It puts a value in a hidden field, then submits that form so its
    //value can be saved to an ASP.NET variable
    function personSearchReply(returnedPersonID,isLoadInternal)
    {  
		var tmpOb = new Object();
      
		tmpOb = document.getElementById(fieldIDToReplyEntityIDTo);
		tmpOb.value = returnedPersonID;
      
		fieldIDToReplyEntityIDTo = "";
      
		if(isLoadInternal == 1)
		{
			document.Form1.submit();
		}
		else
		{
			document.storeReturnedValuesForm.submit();
		}
        //submit the form with personID on it so ASP will know the new value	  
	    //and make sure you don't have a form object (button) named "submit"
	    //or this will cause problems
    }  
    //-------------------------------------------------------------------- 
    //This function is called by the 'findPerson' Screen.
    //It puts a value in a hidden field, then submits that form so its
    //value can be saved to an ASP.NET variable
    function emailSearchReply(returnedEmailID)
    {  
		var tmpOb = new Object();
      
		tmpOb = document.getElementById(fieldIDToReplyEntityIDTo);
		tmpOb.value = returnedEmailID;
      
		fieldIDToReplyEntityIDTo = "";
      
		document.Form1.submit();
		
        //submit the form with emailID on it so ASP will know the new value	  
	    //and make sure you don't have a form object (button) named "submit"
	    //or this will cause problems
    }  
    //-------------------------------------------------------------------- 
	function showCustomMessageDisplayer(message)
	{
		//---------------------------------------
		var URL = 'messagepage.asp?';
		var topPosn = 0;
		var leftPosn = 0;        
		try
		{
			//add the message and status as parameters to the IFrame
			URL += 'message=' + message;
			URL += '&status=good';
	                
			topPosn = (screen.height /2)-290;
			leftPosn = (screen.width /2)-139-254; //165 is menu frame
	  
			if(document.getElementById("customMessageFrame") == null)
			{      
				iframeHTML='\<iframe src="blank2.htm" id="customMessageFrame" style="';
				iframeHTML+='border:0px;';
				iframeHTML+='width:579px;';
				iframeHTML+='height:449px;';
				iframeHTML+='top:' + topPosn + 'px;'; 
				iframeHTML+='left:' + leftPosn + 'px;';
				iframeHTML+='POSITION: absolute;"';
				iframeHTML+=' onclick="closeMessageDisplayer()"';        
				iframeHTML+='><\/iframe>';
				document.body.innerHTML+=iframeHTML;    
			}
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('customMessageFrame');
			IFrameObj.document.location.replace = function(location) {
			this.iframe.src = location; }
	        
			document.getElementById('customMessageFrame').style.visibility = 'visible';
		  
			if (IFrameObj.contentDocument) 
			{
				// For NS6
				IFrameDoc = IFrameObj.contentDocument; 
			}
			else if (IFrameObj.contentWindow) 
			{
				// For IE5.5 and IE6
				IFrameDoc = IFrameObj.contentWindow.document;
			}
			else if (IFrameObj.document) 
			{
				// For IE5
				IFrameDoc = IFrameObj.document;
			}  
			IFrameDoc.location.replace(URL);  
		}catch(erra){}    
			  
	}
	//-------------------------------------------------------- 
	function closeCustomMessageDisplayer()
	{
		var messageBox = new Object();

		messageBox = document.getElementById('customMessageFrame');
		if(messageBox != null)
		{
			messageBox.style.visibility='hidden';    
		}  
	}
	//--------------------------------------------------------------------
    function showMessageDisplayer(withreload)
    {    		
		//---------------------------------------
		var URL = 'messagepage.asp?';
		var topPosn = 0;
		var leftPosn = 0;
		var doReload = 1;
  
		//status is either 'good' or 'bad' and changes the
		//font color
		var status = "blank";
		var message = document.Form1.successLabel.value;
		var message2 = document.Form1.failLabel.value;
		
		if(withreload == null)
			doReload = 1;
		else
			doReload = withreload;
      
		if((message != "")||(message2 != ""))
		{             
			if(message == "")
			{          
				message = document.Form1.failLabel.value;
				if(message != "")
		        {          
		            status = "bad";
				}      
			}
			else
			{
				status = "good";
			}           
			if(status != "blank")
			{
				//add the message and status as parameters to the IFrame
				URL += 'message=' + message;
				URL += '&status=' + status;                
       
		        topPosn = (screen.height /2)-249;
				leftPosn = (screen.width /2)-179-165; //165 is menu frame                
     
				iframeHTML='\<iframe src="blank2.htm" id="messageFrame" style="';
				iframeHTML+='border:0px;';
				iframeHTML+='width:249px;';
				iframeHTML+='height:179px;';
				iframeHTML+='top:' + topPosn + 'px;'; 
				iframeHTML+='left:' + leftPosn + 'px;';
				iframeHTML+='POSITION: absolute;"';
				iframeHTML+=' onclick="closeMessageDisplayer()"';        
				iframeHTML+='><\/iframe>';
				document.body.innerHTML+=iframeHTML;
				IFrameObj = new Object();
				IFrameObj.document = new Object();
				IFrameObj.document.location = new Object();
				IFrameObj.document.location.iframe = document.getElementById('messageFrame');
				IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location; }
       
				if (IFrameObj.contentDocument) 
				{
					// For NS6
					IFrameDoc = IFrameObj.contentDocument; 
				}
				else if (IFrameObj.contentWindow) 
				{
					// For IE5.5 and IE6
					IFrameDoc = IFrameObj.contentWindow.document;
				}
				else if (IFrameObj.document) 
				{
					// For IE5
					IFrameDoc = IFrameObj.document;
				}
		  
				IFrameDoc.location.replace(URL);					
				//---------------------------------------
		        
				if(status == "good")
				{
					window.setTimeout("closeMessageDisplayer(" + doReload + ")",3000);
				}
				else //close the message box after five seconds if error
				{
					window.setTimeout("closeMessageDisplayer(" + doReload + ")",5000);
				}
			}      
		}
    }
	//--------------------------------------------------------------------
	function closeMessageDisplayer(withreload)
	{		
		var messageBox = new Object();
		var doReload = 1;
		
		if(withreload == null)
			doReload = 1;
		else
			doReload = withreload;
	  
		messageBox = document.getElementById('messagedisplayer');
		if(messageBox != null)
		{
			messageBox.style.visibility='hidden';	  
			messageBox = null;
		}
	  
		messageBox = document.getElementById('messageFrame');
		if(messageBox != null)
		{
			messageBox.style.visibility='hidden';	        	  
		}
	  
		if(doReload == 1)
		{			
			//resubmit the form so that the rte boxes are repopulated
			document.Form1.submit();
		}
	}	
    //--------------------------------------------------------       
    //If you call this from within your HTML, make sure to pass any ampersands and so forth in
    //html format, eg. use '&amp;' instead of '&'
    function openInstitutionSearchWindow(fieldsID,accessTypeID)
    {
      var newwin;     
      var destinationURLPath;
      var newWindowHeight;
      var newWindowWidth;
      
      fieldIDToReplyEntityIDTo = fieldsID; 
      newWindowHeight = 589;
      newWindowWidth = 785;
      destinationURLPath = "findinstitution.aspx?accessTypeID=" + accessTypeID;
      
      if(browserName=="IE")
        newwin=window.showModalDialog(destinationURLPath,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(destinationURLPath,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",left=5,top=5,scrollbars=yes,resizable=no");       
    }    
    //--------------------------------------------------------   
    //If you call this from within your HTML, make sure to pass any ampersands and so forth in
    //html format, eg. use '&amp;' instead of '&'        
    function openInstitutionSearchWindow(fieldsID,accessTypeID,loadInternal)
    {
      var newwin;     
      var destinationURLPath;
      var newWindowHeight;
      var newWindowWidth;
      
      fieldIDToReplyEntityIDTo = fieldsID; 
      newWindowHeight = 589;
      newWindowWidth = 785;
      destinationURLPath = "findinstitution.aspx?loadInternal=" + loadInternal + "&accessTypeID=" + accessTypeID;

      if(browserName=="IE")
        newwin=window.showModalDialog(destinationURLPath,this.window,"status:no;help:no;dialogWidth:" + newWindowWidth + "px;dialogHeight:" + newWindowHeight + "px;");    
      else
        newwin = window.open(destinationURLPath,"_new","width=" + newWindowWidth + ",height=" + newWindowHeight + ",left=5,top=5,scrollbars=yes,resizable=no");       
    }        	
	//--------------------------------------------------------------------
    function institutionSearchReply(returnedInstitutionID,isLoadInternal)
    {   
		tmpOb = document.getElementById(fieldIDToReplyEntityIDTo);
		tmpOb.value = returnedInstitutionID;
      
		fieldIDToReplyEntityIDTo = "";
		if(isLoadInternal == 1)
		{
			document.Form1.submit();
		}
		else
		{
			document.storeReturnedValuesForm.submit();
		}
            
		//submit the form with entityID on it so ASP will know the new value	  
		//and make sure you don't have a form object (button) named "submit"
		//or this will cause problems
    }		
  function showResultMessage()
  {
    //  Get the success or failure message.
    var message   = document.Form1.successLabel.value;
    var message2  = document.Form1.failLabel.value;

    //  Reset them to blanks.
    document.Form1.successLabel.value = "";
    document.Form1.failLabel.value    = "";

    //  If the success message is blank set the message to the failure one.
    if (message == "")
      message = message2;

    //  If we have a message display it.
    if (message != "")
      return alert(message);
  }
	//--------------------------------------------------------------------
	function hasNoValue(fieldID)
	{		
		if( document.getElementById(fieldID) == null )
		{
			//if the object does not exist then do not worry about its value
			return false;					
		}
		else
		{
			try
			{		
				if( document.getElementById(fieldID).value != "" )
				{
					return false;
				}
			}catch(anerr1){}					
				
			try
			{
				if( document.getElementById(fieldID).innerText != "" )
				{
					return false;		
				}
			}catch(anerr2){}
			
			try
			{	
				if( document.getElementById(fieldID).innerHTML != "" )
				{
					return false;
				}
			}catch(anerr3){}		
		}	
		
		return true;
	}  
	//--------------------------------------------------------------------
	function confirmDate(dateValue, fieldName) 
	{
		var errMsg = "";
		
		errMsg = isDate(dateValue, fieldName);
		
		if(errMsg == "")
			return true;
		else
		{
			alert(errMsg);
			return false;
		}
	}
	//--------------------------------------------------------------------
  /**
  * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
  */
	  
	function isInteger(s){
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}

	function stripCharsInBag(s, bag){
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}

	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	} 
	return this
	}

	function isDate(dtStr, fieldName){
		var daysInMonth = DaysArray(12);
		var pos1=dtStr.indexOf(dtCh);
		var pos2=dtStr.indexOf(dtCh,pos1+1);
		var strDay=dtStr.substring(0,pos1);
		var strMonth=dtStr.substring(pos1+1,pos2);
		var strYear=dtStr.substring(pos2+1);
		var strTmpDay = strDay;
		var strTmpMonth = strMonth;
		var strTmpYear = strYear;
		var errorMessage = "";
		
		strYr = strYear;
	
		if (strDay.charAt(0)=="0" && strDay.length>1) strTmpDay = strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strTmpMonth = strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1)
				strYr = strYr.substring(1);
		}
		
		month = parseInt(strTmpMonth);
		day = parseInt(strTmpDay);
		year = parseInt(strYr);		
		
		if(dtStr.length != 10){
			errorMessage += "\n" + fieldName + " - The date format should be : dd/mm/yyyy";
		}		
		else if (pos1==-1 || pos2==-1){
			errorMessage += "\n" + fieldName + " - The date format should be : dd/mm/yyyy";
		}
		
		if (strMonth.length != 2 || month<1 || month>12){
			errorMessage += "\n" + fieldName + " - Please enter a valid 2 digit month (eg 01)";
		}
		if (strDay.length != 2 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			errorMessage += "\n" + fieldName + " - Please enter a valid 2 digit day (eg 01)";
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			errorMessage += "\n" + fieldName + " - Please enter a valid 4 digit year between " + minYear + " and " + maxYear;
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			errorMessage += "\n" + fieldName + " - Please enter a valid date";
		}
		return errorMessage;
	}
  //--------------------------------------------------------------------
  function SmartSelect(oInput, oSelect)
  {
    var sInput = String(oInput.value).toUpperCase();
    var iLength = sInput.length;

    if (iLength <= 0)
    return -1;

    var oOptions = oSelect.options;
    var i, diff, bFound, sTemp;

    var iHigh = oOptions.length - 1;
    var iLow = 0;
    var iCurrent = Math.floor((iHigh + 1) / 2);

    bFound = false;
    do
    {
      // Get the current option
      sTemp = oOptions(iCurrent).value.toUpperCase();
      var sSubstr = sTemp.substr(0, iLength);

      if (sSubstr < sInput)         // Search the upper half of the branch
          iLow = iCurrent + 1;
      else if (sSubstr > sInput)    // Search the lower half of the branch
          iHigh = iCurrent - 1;
      else
        {
        bFound = true;
        break;
        }

      // Pick the middle of the branch again
      iCurrent = Math.floor(iLow + ((iHigh + 1) - iLow) / 2);

    } while (iHigh >= iLow)

    // Is there a better prefix match?
    if (iLength < sTemp.length)
    {
      // Store the current old value
      var iOld = iCurrent--;

      // Now go back until we find one that doesn't match the prefix
      while (iCurrent >= 0)
      {
        // Gone too far -- the prefix no longer matches.
        if (oOptions(iCurrent).value.toUpperCase().substr(0, iLength) != sInput)
          break;
        iOld = iCurrent--;
      }

      iCurrent = iOld;
    }

    if (bFound)
      return iCurrent;
    else
      return -1;
  }
//=====================================================================================  
// xp_progressbar
// Copyright 2004 Brian Gosselin of ScriptAsylum.com
//
// v1.0 - Initial release
// v1.1 - Added ability to pause the scrolling action (requires you to assign
//        the bar to a unique arbitrary variable).
//      - Added ability to specify an action to perform after a x amount of
//      - bar scrolls. This requires two added arguments.
// v1.2 - Added ability to hide/show each bar (requires you to assign the bar
//        to a unique arbitrary variable).

// var xyz = createBar(
// total_width,
// total_height,
// background_color,
// border_width,
// border_color,
// block_color,
// scroll_speed,
// block_count,
// scroll_count,
// action_to_perform_after_scrolled_n_times
// )
//=====================================================================================  

var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write(t);
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;
bA.showBar=function(){
this.N=0;
this.bar.style.visibility="visible";
}
bA.hideBar=function(){
this.bar.style.visibility="hidden";
}
bA.isPaused=isPaused;
bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
t.style.left=-(t.h*2+1)+'px';
t.ctr++;
if(t.ctr>=t.count){
eval(t.action);
t.ctr=0;
}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function isPaused(){
return (this.tid==0);
}

