//------------------------------------------//
//        Global Variables                  //
//------------------------------------------//
var popUp;
var tabsColors = new Array(2);
    tabsColors[0] = "#FFFFFF";
    tabsColors[1] = "#99FF33";    
    
//------------------------------------------//
// Show link for Help in case of error      //
//                  11/24/2004    (JEM)     //
//------------------------------------------//
function MailToError()
{
	document.write('<p align="right">');
	document.write('<a id="Mailto" href="mailto:jemarin@ci.miami.fl.us" style="FONT-SIZE:xx-small">To Report error</a></p>');
	return true;
}
//------------------------------------------------------------------------//
// Checks or Unchecks a checkbox group depend of the principal checkbox   //
//                  11/24/2004    (JEM)                                   //
//------------------------------------------------------------------------//
function check_All(frm){                                                               
   var OnOff;
   frm.CheckBox[0].checked ? OnOff=true : OnOff=false;
   for(var index = 1; index < frm.CheckBox.length; index++)
      if(!frm.CheckBox[index].disabled)
         frm.CheckBox[index].checked = OnOff;
}

function OpenCalendar(idname, postBack)
{
	popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name +
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack,
		'popupcal',
		'width=165,height=208,left=200,top=250');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}
//------------------------------------------//
// Show link for Help in case of error      //
//                  11/24/2004    JEM       //
//------------------------------------------//
function MailToError()
{
	document.write('<p align="right">');
	document.write('<a id="Mailto" href="mailto:jemarin@ci.miami.fl.us" style="FONT-SIZE:xx-small">To Report error</a></p>');
	return true;
}

//------------------------------------------//
// Restore the image on mouse out (v3.0)    //
//------------------------------------------//
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;
}
//------------------------------------------//
// Swap the image on mouse over (v3.0)      //
//------------------------------------------//
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];}
}

//------------------------------------------------------//
// Use to swap Image (function MM_swapImage() )
//------------------------------------------------------//
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;
}
//------------------------------------------------------//
// Changes the action property of a form and submit It  //
//								11/04/2004	JEM			//
//------------------------------------------------------//
function ChangeActionAndSubmit(form, FormAction){
   form.action = FormAction;
   form.submit();
}
//---------------------------------------------------------------------//
// Changes the color of a tag on the onMouseOver and onMouseOut events //
//                              12/28/2004  (JEM)                      //
//---------------------------------------------------------------------//
function changeTabColor(Tab, prmColorNumber){
   Tab.style.color = tabsColors[prmColorNumber];
}

//------------------------------------------------------------------------------//
// Hide the Mandatory field messages 'GarbageAddLoad.aspx,TrashAddLoad.aspx		//
//														11/04/2004  JEM			//
//------------------------------------------------------------------------------//
function HideMessages(){
	lblMsgArrived.style.visibility="hidden"; 
	lblMsgDepart.style.visibility="hidden"; 
	lblmsgTransaction.style.visibility="hidden"; 
	lblmsgTonnage.style.visibility="hidden"; 

	lblmsgOutSev.style.visibility="hidden"; 
	lblmsgRetSev.style.visibility="hidden"; 
	lblmsgReason.style.visibility="hidden"; 
}

//----------------------------------------------------------------------------------//
// Enable or Disable the Submit buttons, if the input fields are filled or empty	//
//														11/04/2004  JEM				//
//----------------------------------------------------------------------------------//
function CheckButtonStatus()
{
	if( Form.txtHrAt.value == "" && Form.txtMinAt.value =="" && Form.txtHrDepart.value == "" && 
	Form.txtMinDepart.value == "" && Form.txtTransaction.value == "" && Form.txtTonnage.value =="")
		Form.submitLoad.disabled = true;
	else	
		Form.submitLoad.disabled = false;

if( Form.txtHrOut.value == "" && Form.txtMinOut.value =="" && Form.txtHrReturn.value == "" && 
	Form.txtMinReturn.value == "" && Form.txtDescription.value == "")
		Form.submitDelay.disabled = true;
	else	
		Form.submitDelay.disabled = false;
}


//------------------------------------------------------------------------------//
// Validate the mandatory fields for 'GarbageAddLoad.aspx,TrashAddLoad.aspx		//
//														11/04/2004  JEM			//
//------------------------------------------------------------------------------//
function ValidateRequiredInput(){
var blnAllEmpty = true;
	if( Form.txtHrAt.value != "" || Form.txtMinAt.value !="" || Form.txtHrDepart.value != "" || 
		Form.txtMinDepart.value != "" || Form.txtTransaction.value != "" || Form.txtTonnage.value !="")
	{
		blnAllEmpty = false;
		if( Form.txtHrAt.value == "" || Form.txtMinAt.value =="" )
		{
			lblMsgArrived.style.visibility="visible"; 
			// This variable is declare at \Inetpub\wwwroot\aspnet_client\system_web\1_1_4322\WebUIValidation.js
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblMsgArrived.style.visibility="hidden"; 
		if( Form.txtHrDepart.value == "" || Form.txtMinDepart.value == "")
		{
			lblMsgDepart.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblMsgDepart.style.visibility="hidden"; 
		if( Form.txtTransaction.value == "")
		{
			lblmsgTransaction.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblmsgTransaction.style.visibility="hidden"; 
		if(Form.txtTonnage.value =="")
		{
			lblmsgTonnage.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblmsgTonnage.style.visibility="hidden"; 
	    
	}
	if( Form.txtHrOut.value != "" || Form.txtMinOut.value !="" || Form.txtHrReturn.value != "" || 
		Form.txtMinReturn.value != "" || Form.txtDescription.value != "")
	{
		blnAllEmpty = false;
		if( Form.txtHrOut.value == "" || Form.txtMinOut.value =="") 
		{
			lblmsgOutSev.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblmsgOutSev.style.visibility="hidden"; 
		if(Form.txtHrReturn.value == "" || Form.txtMinReturn.value == "")
		{
			lblmsgRetSev.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblmsgRetSev.style.visibility="hidden"; 
		if( Form.txtDescription.value == "")
		{
			lblmsgReason.style.visibility="visible"; 
			Page_BlockSubmit = true;
			event.returnValue = false;
		}
		else
			lblmsgReason.style.visibility="hidden"; 
	}
	if (blnAllEmpty){
		Page_BlockSubmit = true;
		event.returnValue = false;
		alert("Nothing to Submit");
		return false;
	}
}

