//specify speed of scroll (greater=faster)
var speed = 5
var rate = 30

function alertMesg (width, height, popupName)
{
  
  var winl = (screen.width - width) / 2;
  var wint = (screen.height - height) / 2;

  settings = 'width='+width+',height='+height+',top='+wint+',left='+winl+',resizable=yes,scrollbars=no,menubar=no,status=no,directories=no,location=no,titlebar=no,toolbar=no,dependent=no';

  var Win = window.open (popupName, "", settings);

  // Create a new property for the newly open window
  Win.creator = self;

  if (parseInt (navigator.appVersion) >= 4)
  {
    Win.window.focus ();
  }

}

function movedown(){	

if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100)){
crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
}
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",rate)
}

function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",rate)	
}

function movetop(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top="0px"
else if (ns4&&crossobj.top<=0)
crossobj.top=0
//moveupvar=setTimeout("moveup()",rate)	
}

function setCrossObjMoveTop(divNo){
	crossobj = testing[divNo]
	getcontent_height()
	movetop()
}

function setCrossObjMoveUp(divNo){
	crossobj = testing[divNo]
	getcontent_height()
	moveup()
}

function setCrossObjMoveDown(divNo){
	crossobj = testing[divNo]	
	getcontent_height()
	movedown()
}


function getcontent_height(){	
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4){
for (i=1; i<=4; i++){
crossobj = testing[i]
crossobj.visibility="show"
}
}
}

function changeCursorHand() {

// document.body.style.cursor = 'move' 
}

function changeCursorDefault() {

// document.body.style.cursor = 'default' 
}

// drag-drop code
// This code adds drag-drop to images using the core library only.

var curEl = null  // Track current item.

function doMouseMove() {
  
  
  // Check if mouse button is down
  //if ((1 == event.button) && (curEl != null)) {
    // Move the element
    /*if (null != curEl) {

	  var mouseY = event.clientY + document.body.scrollTop;
	  curTop = curEl.style.pixelTop;
	  MM_oldY = mouseY - curTop;
     
	  newTop  = mouseY-MM_oldY;  
      
      if (newtop < 0) newtop = 0
      if (newtop=0) curEl.style.pixelTop = newtop      
      event.returnValue = false
    }*/
  //}
}

function doMouseDown() {
	
  // Store element on mousedown.  Called from click handler in code below .
  // All images that begin with "drag" in their name and are in a positioned DIV
  // are draggable.

  //alert(event.srcElement.id)
  if (null!=event.srcElement.id) 
    if (event.srcElement.id.substring(0,9)=="container")  {
      curEl = event.srcElement.offsetParent;
      curEl.style._zIndex = curEl.style.zIndex
      curEl.style.zIndex = 100

    }
}

function doMouseUp() {
  if (curEl) 
    curEl.style.zIndex = curEl.style._zIndex
  curEl=null
}      


// Process mouse
document.onmousedown = doMouseDown
//document.onmousemove = doMouseMove
document.onmouseup = doMouseUp


function popupWindow(URL, winName, width, height, shift1, shiftt)
{  
  if (!shift1)
      shift1 = 0;
  if (!shiftt)
      shiftt = 0;
	
  var winl = (screen.width - width) / 2 - shift1;
  var wint = (screen.height - height) / 2 - shiftt;

  settings = 'width='+width+',height='+height+',top='+wint+',left='+winl+',resizable=yes,scrollbars=yes,menubar=no,status=yes,directories=no,location=no,titlebar=no,toolbar=no,dependent=no';

  var Win = window.open (URL, winName, settings);

  // Create a new property for the newly open window
  //Win.creator = self;

  if (parseInt (navigator.appVersion) >= 4)
  {
    Win.window.focus ();
  }

}

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_preloadImages() { //v3.0
  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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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 submitIt(theForm,target){
	theForm.action=target;
	theForm.submit();
}

function testcookie(){
	if (window.navigator.cookieEnabled==false){
		alert('Please enable your Cookie setting in your browser first before logging into the system!');
		return false;
		}
}
	
function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
datefield.select();
alert("That date is invalid. Please try again.");
datefield.focus();
return false;
}
else {
return true;
}
}
function chkdate(objName) {
var strDatestyle = "US"; //United States date style Month Day Year
//var strDatestyle = "EU"; //European date style Day Month Year
var runTime = new Date();
var strCurrentYear = runTime.getYear();
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if ((strDateArray.length < 2) || (strDateArray.length > 3)) {
err = 1;
alert('X');
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
if (strDateArray.length == 2) 
strYear = strCurrentYear
else
strYear = strDateArray[2];
}
booFound = true;
}
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}

if (strYear == null || strYear.length>4) {
  return false;
}

if (strYear.length == 1) {
strYear = '0' + strYear
}

if (strYear.length == 2) {
strYear = '20' + strYear;
}

// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}

intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}

intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}

if (isNaN(intMonth)) {
err = 3;
return false;
}
}

intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}

if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}

if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
{
err = 6;
return false;
}

if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}

if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}

if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + "/" + strMonthArray[intMonth-1] + "/" + strYear;
}
return true;
}

function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

//	function validateForm() {
//	alert(window.document.forms(0).item(0).name);
//	window.document.forms(0).item(0).focus();
//	return false;
//	}

function validateStr(control) {	
	if (eval("document.forms[0].elements['" + control + "'].value")=="") {
		alert("Please enter the '" + control + "'");
		eval("document.forms[0].elements['" + control + "'].focus()")
		return false
		}
}

function validateStrMemberEditForm(control) {	
	if (eval("document.memberForm.elements['" + control + "'].value")=="") {
		alert("Please enter the '" + control + "'");
		eval("document.memberForm.elements['" + control + "'].focus()")
		return false
		}
}


function validateStrN(control) {
	if (eval("document.forms[0].elements['" + control + "'].value")=="") {
		alert("Please enter the '" + control + "'");
		//return false
		}
}

function validateStrLen(control, strLen) {
	if (parseInt(eval("document.forms[0].elements['" + control + "'].value.length"))>parseInt(strLen)) {
		alert("'" + control + "' length cannot exceed " + strLen + "!");
		eval("document.forms[0].elements['" + control + "'].focus()")
		return false
		}
}
function validateStrLenMemberEditForm(control, strLen) {
	if (parseInt(eval("document.memberForm.elements['" + control + "'].value.length"))>parseInt(strLen)) {
		alert("'" + control + "' length cannot exceed " + strLen + "!");
		eval("document.memberForm.elements['" + control + "'].focus()")
		return false
		}
}

function newWindow(link) {
	window.open(link,'LUA','width=400,height=300')
}