function IsFilled( f, n ) {
	if ( /\S/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsEmail( f, n ) {
	if ( /^[a-z\d][a-z\d\-\._%]*@([a-z\d][a-z\d\-]*)(\.[a-z\d][a-z\d\-]*)*$/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsInteger( f, n ) {
	if ( /^\+?\d{1,8}$/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsNumber( f, n ) {
	if ( /^\+?\d{1,8}(\.\d{1,8})?$/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsDate( f, n ) {
	if ( /^\d{4}\-\d{2}\-\d{2}$/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsDateTime( f, n ) {
	if ( /^\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}\:\d{2}$/i.test( f.value ) == false ) {
		alert( n ); f.focus( ); f.select( ); return false;
	}
	return true;
}

function IsSelected( f, n ) {
	if ( f.options.length == 0 || f.selectedIndex < 0 || f.options[ f.selectedIndex ].value == '' ) {
		alert( n ); f.focus( ); return false;
	}
	return true;
}

function IsChecked( f, n ) {
	if ( f.length ) {
		for ( var i = 0; i < f.length; i++ ) {
			if ( f[ i ].checked == true ) {
				return true;
			}
		}
		alert( n ); f[ 0 ].focus( ); return false;
	}
	else if ( f.checked == false ) {
		alert( n ); f.focus( ); return false;
	}
	return true;
}

function GetCbValue( f ) {
	if ( f.length ) {
		for ( var i = 0; i < f.length; i++ ) {
			if ( f[ i ].checked == true ) {
				return f[ i ].value;
			}
		}
		return "";
	}
	else {
		return f.checked == true ? f.value : "";
	}
}

function GetLbValue( f ) {
	if ( f.options.length == 0 || f.selectedIndex < 0 ) {
		return "";
	}
	else {
		return f.options[ f.selectedIndex ].value;
	}
}

function SelectLbItem( f, v ) {
	if ( f.options.length == 0 ) {
		return;
	}
	for ( var i = 0; i < f.options.length; i++ ) {
		if ( f.options[ i ].value == v ) {
			f.selectedIndex = i;
			return;
		}
	}
}

function ToggleLayer( l ) {
	if ( document.getElementById ) 	{
		var st = document.getElementById( l ).style;
	}
	else if ( document.all ) {
		var st = document.all[ l ].style;
	}
	else if ( document.layers ) {
		var st = document.layers[ l ].style;
	}
	st.display = st.display == "none" ? "block" : "none";
}

function DoPopup( u ) {
	var ww = 500;
	var hh = 320;
	var pp = window.open( u, "DoPopupWindow", "width=" + ww.toString( ) + ",height=" + hh.toString( ) + " ,scrollbars=yes" );
	pp.focus( );
}

//------------------------------------------------
// MM_ functions
//------------------------------------------------

function MM_swapImgRestore() {
	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_preloadImages() {
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
	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() {
	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];}
}
