// global.js
//

function floatingObjects() {
	var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
	var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
	var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop;
	var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft;
	
	for (i=0; i < TotObjectsVis; i++){
		sy = Speed[i]*Math.sin(90 * Math.PI / nSustained); 
		sx = Speed[i]*Math.cos(Cstep[i]);
		Ypos[i] += sy;
		Xpos[i] += sx; 

		if (Ypos[i] > WinHeight){
			Ypos[i] = -60;
			Xpos[i] = Math.round(Math.random() * WinWidth);
			Speed[i] = (Math.random() * 5) +3;
		}

		if (ns){
			if (bShowObjects) 
				document.layers['sn'+i].left = Xpos[i];
			else
				document.layers['sn'+i].left = 3000;
			
			document.layers['sn'+i].top = Ypos[i]+hscrll;
		}
		else if (ns6) {
			if (bShowObjects) 
				document.getElementById("si"+i).style.left = Math.min(WinWidth,Xpos[i]);
			else
				document.getElementById("si"+i).style.left = 3000;
				
			document.getElementById("si"+i).style.top = Ypos[i]+hscrll;
		}
		else{
			if (bShowObjects)
				eval("document.all.si"+i).style.left = Xpos[i];
			else	
				eval("document.all.si"+i).style.left = 3000;
				
			eval("document.all.si"+i).style.top = Ypos[i]+hscrll;
		} 
		Cstep[i] += Step[i];
	}
	setTimeout("floatingObjects()", 20);
}

function killObjects() {
	bShowObjects = false;
}


//-----------------------------------------------------------------------------
// prints the page that has focus
// 
function printReport() {  
	window.print();  
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// launches the datepicker calendar -- see datepicker.php
// 
function launchCalendar( called_by ) {

	document.form_summary.cargo.value = called_by;	

	win2=window.open('datepicker.php','','width=196,height=170,top=60,left=175,status=no,scrollbars=no,location=no,directories=no,menubar=no,toolbar=no,resizable=no');
	win2.creator=self;
	win2.focus();
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// input checker used for usernames and promo codes etc.
// 
function isBadChar( test, ignore ) {

	var valid = false;
	var junk  = '!@#$%^&*()_-+=/?\\\'";:.,|]}[{~ ';
	var char  = '';
	
	// allow an empty field but not a space within a field unless specifically ignored
	if ( test.substring(0,1) != ' ' ) {
	
		for ( var i = 0; i < test.length; i++ ) {
		
			char = test.substring(i,i+1); 
	
			if ( (char != ignore) && (junk.indexOf( char ) > -1) ) {
				valid = true;
				break;
			}
		}
	}
	
	return valid;
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// date formatter -> Month da, year
// 
var today_date= new Date();
var month=today_date.getMonth();
var today=today_date.getDate();
var year=today_date.getYear();

var months = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December');

/* INSERT this code into the body of file

	<p align='center'><strong>
	<script language=Javascript>
		document.write(months[month]+' '+today+', '+year)
	</script></strong>
	</p>

*/
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// no right click
//
var message='';

function clickIE() {
	if (document.all) {
		(message);
		return false;
	}
}

function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if ( e.which == 2 || e.which == 3 ) {
			(message);
			return false;
		}
	}
}

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown = clickNS;
} else {
	document.onmouseup = clickNS;
	document.oncontextmenu = clickIE;
}

document.oncontextmenu = new Function('return false')
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// bookmark site
//
function addbookmark( url, title ) {
if (document.all)
	window.external.AddFavorite(url,title)
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// popup window
var popup = null;
function newWindow( mypage, myname, w, h, pos, infocus, myscrollbars, myresizable ){
	
	if( pos == 'random' ){
		myleft = (screen.width) ? Math.floor(Math.random()*(screen.width-w)) : 100;
		mytop = (screen.height) ? Math.floor(Math.random()*((screen.height-h)-75)) : 100;
	
	} else if ( pos == 'center' ){
		myleft = (screen.width) ? (screen.width-w)/2 : 100;
		mytop = (screen.height) ? (screen.height-h)/2 : 100;
	
	} else {  
		myleft=20;
		mytop=20;
	}
	
	if(myresizable == '')
		myresizable = 'no';
		
	settings='width=' + w + ',height=' + h + ',top=' + mytop + ',left=' + myleft + ',scrollbars=' + myscrollbars + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=' + myresizable;
	
	popup=window.open( mypage, myname, settings );
	popup.focus();
}
//-----------------------------------------------------------------------------

