/*
[================= JavaScript Source File =================]
	
	 Developed with WebSoftware HotHTML 3 Professional  
	
	 AUTHOR: Thushan Fernando , 
	 DATE: 23/10/2003
	TIME: 2:18:19 PM
	COMPUTER: 
	
	 COMMENTS:

[==================================================] 

*/

		//---------------------------------------------------------------------||
		// FUNCTION:    MoneyFormat                                            ||
		// PARAMETERS:  Number to be formatted                                 ||
		// RETURNS:     Formatted Number                                       ||
		// PURPOSE:     Reformats Dollar Amount to #.## format                 ||
		//---------------------------------------------------------------------||
		function moneyFormat(input) {
		   var dollars = Math.floor(input);
		   var tmp = new String(input);
		
		   for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
		      if ( tmp.charAt(decimalAt)=="." )
		         break;
		   }
		
		   var cents  = "" + Math.round(input * 100);
		   cents = cents.substring(cents.length-2, cents.length)
		           dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;
		
		   if ( cents == "0" )
		      cents = "00";
		
		   return(dollars + "." + cents);
		}

		function HoverMenu(td) {
			td.style.background = "white"
			td.style.borderBottom = "#A6CAF0 1px solid"
			td.style.borderTop = "#A6CAF0 1px solid"
			td.style.borderLeft = "#A6CAF0 1px solid"
			td.style.borderRight = "#A6CAF0 1px solid"

		}
		function unHoverMenu(td) {
			td.style.background = ""
			td.style.borderBottom = "white 1px solid"
			td.style.borderTop = "white 1px solid"
			td.style.borderLeft = "white 1px solid"
			td.style.borderRight = "white 1px solid"
		}

		function HoverButton(td) {
			td.style.borderBottom = "gray 1px solid"
			td.style.borderTop = "white 1px solid"
			td.style.borderLeft = "white 1px solid"
			td.style.borderRight = "gray 1px solid"

		}
		
		function unHoverButton(td) {
			td.style.borderBottom = "none"
			td.style.borderTop = "none"
			td.style.borderLeft = "none"
			td.style.borderRight = "none"
		}
				
		function submenuVis(item, img) {

			if ( item.style.display == "none" ) { 
				item.style.display = ""; 
				img.src = "/images/sync_down.gif";
				img.alt= "Synchronise Page Applet";
			} 
			else 
			{ 
				item.style.display = "none";
				img.src = "/images/sync_up.gif"; 
				img.alt= "UnSynchronise Page Applet";
			}
		}
		
		function mainMenuFocus(tdMenu, fontMenu, divMenu) {
			fontMenu.style.color = "black"
			
			tdMenu.style.background = "#A6CAF0"
			tdMenu.style.borderBottom = "#A6CAF0 1px solid"
			tdMenu.style.borderTop = "#A6CAF0 1px solid"
			tdMenu.style.borderLeft = "#A6CAF0 1px solid"
			tdMenu.style.borderRight = "#A6CAF0 1px solid"

			divMenu.style.borderBottom = "#A6CAF0 1px solid"
			divMenu.style.borderLeft = "#A6CAF0 1px solid"
			divMenu.style.borderRight = "#A6CAF0 1px solid"
			
		}

		
		function mainMenuUnFocus(tdMenu, fontMenu, divMenu) {
			fontMenu.style.color = "gray"
			
			tdMenu.style.background = "#DCDBDA"
			tdMenu.style.borderBottom = "#DCDBDA 1px solid"
			tdMenu.style.borderTop = "#DCDBDA 1px solid"
			tdMenu.style.borderLeft = "#DCDBDA 1px solid"
			tdMenu.style.borderRight = "#DCDBDA 1px solid"

			divMenu.style.borderBottom = "#DCDBDA 1px solid"
			divMenu.style.borderLeft = "#DCDBDA 1px solid"
			divMenu.style.borderRight = "#DCDBDA 1px solid"
		
		}
		function backmainMenuFocus(tdMenu, fontMenu, titleMenu, divMenu) {
			tdMenu.style.borderBottom = "#A6CAF0 1px solid";
			tdMenu.style.borderLeft = "#A6CAF0 1px solid";
			tdMenu.style.borderRight = "#A6CAF0 1px solid";
			
			mainMenuFocus(titleMenu, fontMenu, divMenu);

			divMenu.style.borderBottom = "#A6CAF0 1px solid"
			divMenu.style.borderLeft = "#A6CAF0 1px solid"
			divMenu.style.borderRight = "#A6CAF0 1px solid"
			
		}

		
		function backmainMenuUnFocus(tdMenu, fontMenu, titleMenu, divMenu) {
			tdMenu.style.borderBottom = "white 1px solid";
			tdMenu.style.borderLeft = "white 1px solid";
			tdMenu.style.borderRight = "white 1px solid";
			
			mainMenuUnFocus(titleMenu, fontMenu, divMenu);
		
		}
		
		function getDownloadTimeUnits(nDLSize, bShowSize){
			/*
				Title: GetDownloadTime
				Author: Thushan Fernando
				Date: 24/12/2002 [ Last Update: 13/11/2003 ]
				Purpose: 
			 			For showing estimated downloadtime at 56kbps and 512kbps
			 			It may be possible to detect speed via ASP.NET and
						customise it but at this stage its not supported:P
			*/
			// ****** Lazzy Bum ALERT ********
			// Parsed argument will be in KB convert this to bytes
			// Dont ask why i wrote 1049 instead of 1024, the plus's
			// of writing stuff and not meeting face to face.. you
			// cant ask me anything:P
			nDLSize = nDLSize * 1049; 
			// *******************************

			var eta_56k = fnToFixed(nDLSize / 4500 / 60); // Estimated
			var eta_512k = fnToFixed(nDLSize / 50000 / 60); // Estimated
			var strDownloadTime, filesizeunit, timeunit_56k, timeunit_512k;
						
			if ( eta_56k < 1 )	{
				eta_56k = ' Less than 1';
				timeunit_56k = ' minute';
			}
			else
				timeunit_56k = ' minutes';	

			if ( eta_512k < 1 )	{
				eta_512k = ' Less than 1';
				timeunit_512k = ' minute';
			}
			else
				timeunit_512k = ' minutes';

			// document.all['fTotal'].innerHTML="Total selected: " + nNumComp+ ' (' + nDLSize + filesizeunit + '. ' + eta_56k + timeunit_56k + " @ 56 Kbps / " + eta_512k + timeunit_512k + " @ 512 Kbps )";
			if (bShowSize == 1){
				strDownloadTime = fnConvertFileSize( nDLSize );
			}else{
				strDownloadTime = "";
			}
			strDownloadTime = strDownloadTime + ' ' + eta_56k + timeunit_56k + " @ 56 Kbps / " + eta_512k + timeunit_512k + " @ 512 Kbps";
			return strDownloadTime;

		}
		
			/////////////////////////////////////////////
			// Additional Functions for getDownloadTime()
			/////////////////////////////////////////////
			function fnToFixed(n) 
			{
			// This function is to simulate the Javascript method "toFixed" 
			// to control the decimal place.
			// This function is hardcoded to 2 decimal place.
			if ((n.toString(10)).indexOf(".")>0) {
				n += 0.005;
				n = n.toString(10);
				n = n.substr(0,n.indexOf(".")+3);
			}
			return n;
			}
		
					
			
			function fnConvertFileSize( nDLSize )
			{
				var filsizeunit;
				
				if ( nDLSize < 1024 ) 	{
						filesizeunit = ' bytes';
					}
				else if ( nDLSize > 1024 && nDLSize < 1048576 )	{
					nDLSize = fnToFixed(nDLSize / 1024);
					filesizeunit = ' KB';
				}
				else 	{
					nDLSize = fnToFixed(nDLSize / 1048576);
					filesizeunit = ' MB';
				}
			
				return nDLSize + ' ' + filesizeunit;
			}
			
			
			function fnConvertDuration( nDuration )
			{
				var timeunit;
				
				if ( nDuration < 60 )	
					timeunit=' seconds';
			
				else if ( nDuration > 60 && nDuration < 60 * 60 )	{
					nDuration = fnToFixed(nDuration / 60);
					timeunit=' minutes';
				}
				else if ( nDuration > 60 * 60 )	{
					nDuration = fnToFixed( nDuration / 60 / 60 );
					timeunit='';
				}
			
				if ( !isFinite(nDuration) )
					nDuration = '';
					
				return nDuration + ' ' + timeunit;
				
			
				}
			
			//////////////////////////////////////
			// End Additional Functions
			//////////////////////////////////////
			
			
			
			wsFadeImageObjects = new Object();wsFadeImageTimers = new Object(); // Holds each Object -DONT REMOVE/PUT IN FUNCTION!-
			function wsFadeImage(object, destOp, rate, delta){
			/*
				Title: wsFadeImage
				Author: Thushan Fernando
				Date: 16/03/2003 [ Last Update: 20/08/2003 ]
				Comments:
						Fades an Object in and out when moving your mouse over it.
						customised for images(or best for) but can be used in most objects:D
						Requires IE.		
			*/			
			if (!document.all)
			return
			    if (object != "[object]"){setTimeout("wsFadeImage("+object+","+destOp+","+rate+","+delta+")",0);return;}			        
			    clearTimeout(wsFadeImageTimers[object.sourceIndex]);diff = destOp-object.filters.alpha.opacity;direction = 1;
			    if (object.filters.alpha.opacity > destOp){direction = -1;}delta=Math.min(direction*diff,delta);object.filters.alpha.opacity+=direction*delta;			
			    if (object.filters.alpha.opacity != destOp){wsFadeImageObjects[object.sourceIndex]=object;wsFadeImageTimers[object.sourceIndex]=setTimeout("wsFadeImage(wsFadeImageObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);}
			}
			
			// Alpha Transparency	
			// Usage:
			//		<img src=""  class="opacity1" onmouseover="this.className='opacity2'" onmouseout="this.className='opacity1'">		
			if ((navigator.appName.indexOf('Microsoft')+1)) {document.write('<style type="text/css"> .opacity1 {filter:alpha(opacity=50)} .opacity2 {filter:alpha(opacity=100)} </style>');}if ((navigator.appName.indexOf('Netscape')+1)) {document.write('<style type="text/css"> .opacity1 {-moz-opacity:0.5} .opacity2 {-moz-opacity:1} </style>'); }else {document.write('');}