function bookmarksite(title,url)
{
	if (window.sidebar)
	{ // firefox
		alert("Press CTRL+D To Bookmark This Page");
	}
	else if(window.opera)
	{ // opera
		alert("Press CTRL+D To Bookmark This Page");
	} 
	else if(document.all)
	{// ie
		window.external.AddFavorite(url, title);
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function stripNonNumbers( _input ) {
	
	var result = "";
	var l = _input.length;
	var i = 0;

	for ( i=0; i<l; i++ ) {
		var c = _input.substr(i,1);
		if ( !isNaN( parseInt( c ) ) ) { result += c; }
	}

	return result;
}

function valid_phone( _currentValue ) {

	_currentValue = stripNonNumbers( _currentValue );
	if ( (_currentValue.length < 8) || (_currentValue.length > 32) ) { return false; }
	else { return true; }
}

function valid_phone( _currentValue, _min, _max ) {
	_currentValue = stripNonNumbers( _currentValue );
	if ( ( _currentValue.length < _min ) || ( _currentValue.length > _max ) ) { return false; }
	else { return true; }
}

function valid_email( _currentValue, min, max ) {

	var _emailError = isEmail( _currentValue );
	if ( _emailError.length > 0 ) { return false; }
	else { return true; }
}

function isEmail( _input, min, max ) {
	
	var err = "";
	var blankSpace = " ";
	var foundAt = false;
	var foundDot = false;

	var l = _input.length;
	var i = 0;

	if ( ( _input.length < (min*1) ) || ( _input.length > (max*1) ) ) {
		err = "Email address must use between " + min + " and " + max + " characters.";
		return err;
	}

	for ( i=0; i<l; i++ ) {
		var c = _input.substr(i,1);

		if ( c == blankSpace ) { 
			err = "Email address cannot contain spaces."	
			result = false;
		}
		if ( c == "@" ) { foundAt = true; }
		if ( c == "." ) { foundDot = true; }
	}

	if ( foundAt == false ) { err = "Email address must contain an \'@\' symbol to be valid.";  }
	if ( foundDot == false ) { err = "Email address must contain a \'.\' symbol to be valid.";  }

	return err;
}

function trimLeadingZeros( n ) {

	while ( true ) {

		if ( ( n.length > 1 ) && ( n.indexOf( "0" ) == 0 ) ) n = n.substr( 1 );
		else break;
	}
	return n;
}

function validateInt( n ) {

	if ( ( n == null ) || ( n == undefined ) || ( n.length < 1 ) ) return false;
	n = trimLeadingZeros( n );
	return ( "" + parseInt(n) ) == n;
}

function isValidDate() {
	
	if( validateInt(this.year) == false ) return false;
	if( validateInt(this.month) == false ) return false;
	if( validateInt(this.date) == false ) return false;
	
	if ( ( this.year > 0 ) && ( this.year < 3000 ) ) {;}
	else { return false; }
	if ( ( this.month >= 0 ) && ( this.month <= 12 ) ) {;}
	else { return false; }
	if ( ( this.date >= 0 ) && ( this.date <= 31 ) ) {;}
	else { return false; }
	
	return true;
}

function dateToString() {

	return this.year + "/" + this.month + "/" + this.date;
}

function compareDate( _date ) {

	if ( ( this.year*1 == _date.year*1 ) && ( this.month*1 == _date.month*1 ) && ( this.date*1 == _date.date*1 ) ) return 0;
	
	if ( this.year*1 < _date.year*1 ) return -1;
	if ( this.year*1 > _date.year*1 ) return 1;
	
	if ( this.month*1 < _date.month*1 ) return -1;
	if ( this.month*1 > _date.month*1 ) return 1;
	
	if ( this.date*1 < _date.date*1 ) return -1;
	if ( this.date*1 > _date.date*1 ) return 1;
	
	return 0;
}

function getGIIDateNow() {

	var now = new Date();
	var newDate = new GIIDate( now.getFullYear(), now.getMonth() + 1, now.getDate() );
	return newDate;
}

function GIIDate( y, m, d ) {

	y += ""; m += ""; d += "";
	this.year = y;
	this.month = trimLeadingZeros( m );
	this.date = trimLeadingZeros( d );
	
	this.compareDate = compareDate;
	this.isValidDate = isValidDate;
	this.getGIIDateNow = getGIIDateNow;
	this.toString = dateToString;
}


function validateNewsletterForm( f, min, max ) {

	var _error_start = "Sorry, but there was a problem with the information you entered.  Please correct the following errors:\n\n";
	var _error_mid = "";
	var _error_end = "Click OK to continue.";
	var _tab = "- ";
	var _focusField = null;

	if ( !valid_email( f.email.value, min, max ) ) {
		if ( _focusField == null ) _focusField = f.email;
		_error_mid += _tab + 'Please enter a valid e-mail address where where the newsletter will be sent.\n';
	}

	if ( _error_mid.length > 0 ) {
		alert ( _error_start + _error_mid + "\n" + _error_end );
		_focusField.focus();
		return false;
	}
	
	return true;
}

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();
}
