﻿//---------------------------------------------------------------------------------
//  (c) 2007 Guardian Networks, Inc
//---------------------------------------------------------------------------------

GNgui.GNCheckBoxAcc = Class.create();
GNgui.GNCheckBoxAcc.prototype = 
{
	initialize : function ( parentElement, text, id, state, iconSrc, iconID, codes, assetType, monitoredFlag, input )
	{
    if ( state > 0 )
    {
        this.state = true;
    }
    else
    {
        this.state = false;
    }

    this.BaseID = id;
    this.Input = input;
    
    var DataTable = $e( parentElement );
    var row = DataTable.insertRow ( DataTable.rows.length );
    row.id = "row"+id;
    row.className = "MapOverlayRow";

    var Cell = row.insertCell ( 0 );
    Cell.width = "22";
    Cell.innerHTML = "<img src='./" + TARGET + "/images/c_checkbox_off.gif' width='22' height='18' border='0'>";
    Cell.id = id;
    Cell.style.cursor='pointer';

    
    Cell = row.insertCell ( 1 );
    Cell.width = "22";
    if ( iconSrc != "" )	
    { 
        Cell.innerHTML = "<img src='" + iconSrc + "' border='0' >";
        Cell.id = iconID;
    }
    Cell.className = "AssestFilterImg"
    Cell.style.cursor='pointer';
   
    Cell = row.insertCell ( 3 );
    Cell.className = "MapOverlayTextOff";
    Cell.innerText = text;
    Cell.id = "Cell"+id;
    Cell.style.cursor='none';

    row = DataTable.insertRow ( DataTable.rows.length );
    Cell = row.insertCell ( 0 );
    Cell.colspan="2";
    Cell.innerHtml = "<img src='./" + TARGET + "/images/c_div.gif' width='201' height='2' border='0'>"; 

    Event.observe ( id, 'click', GNgui.GNCheckBoxAcc.prototype.MouseClick.bindAsEventListener ( this ) );
    
    this.codes = codes;
    this.assetType = assetType;
    this.monitoredFlag = monitoredFlag; 	    

    this.ChangeState();
	},
	
	ID : function ()
	{
		return this.newdiv.id;
	},
	
	MouseClick : function ()
	{ 
	  if ( this.state )
	  {
	    this.state = false;
	  }
	  else
	  {
	    this.state = true;
	  }	  
	  this.ChangeState();
	  
	  if ( this.Input )
	  {
	    this.CheckAccordionCheckBoxes();  
	  }
  },

  ChangeState : function ()
  {
  	if ( this.state )
	  {
	    $e( "row" + this.BaseID ).bgColor = "#1d1d1c";
	    $e( "Cell" + this.BaseID ).className = "MapOverlayTextOn";
	    $e( this.BaseID ).innerHTML = "<img src='./" + TARGET + "/images/c_checkbox_on.gif' width='22' height='18' border='0'>";
	  }
	  else
	  {
	    $e( "row" + this.BaseID ).bgColor = "#292a28";
	    $e( "Cell" + this.BaseID ).className = "MapOverlayTextOff";
	    $e( this.BaseID ).innerHTML = "<img src='./" + TARGET + "/images/c_checkbox_off.gif' width='22' height='18' border='0'>";
	  }
	  $e( this.BaseID ).state = this.state;
  },
  
  CheckAccordionCheckBoxes : function ()
  {
		var aInput = this.Input.split(',');

		switch ( aInput[0] )
    {
			case "SAM":
				mySAMView.SAMBoxWasChecked();
				break;
        
			case "Parking":   
      
        switch ( aInput[1] )
        { 
          case "divAssetFiltersViolationsContent":
            myPMView.EnforcementBoxWasChecked();
            break;

          case "divAssetFiltersOperationsContent":
            myPMView.OperationBoxWasChecked();
            break;

          case "divAssetFiltersCollectionsContent":                  
            myPMView.CollectionBoxWasChecked();
            break;

          case "divAssetFiltersWOMPMContent":
            myPMView.WorkOrderBoxWasChecked();
            break;
        }
        break;

       case "WaterOptimizer":

         switch ( aInput[1] )
         {
          case "divAssetFiltersIRStatusContent":
            myIRView.IRStatusBoxWasChecked();
            break;

          case "divAssetFiltersIROperationsContent":
            myIRView.IROperationsBoxWasChecked();
            break;

          case "divAssetFiltersIRWeatherStationContent":
            myIRView.IRWeatherStationBoxWasChecked();
            break;

          case "divAssetFiltersIRPressureStationContent":
            myIRView.IRPressureStationBoxWasChecked();
            break;
         }
         break;
		}	  
	}  
}
