<?php
//CONSIDER not using this rendered when you need direct access to array data, i.e. for data grids (this rendered is intended for HTML render to JSON)
//will not encode arrays
//echo 'Debug';
require_once 'library/jQuery/jQuery.php';
$debugString = '';

if( isset($this->jsonIdsToRender) && is_array($this->jsonIdsToRender) ) {

	try {
		foreach( $this->jsonIdsToRender as $key => $value ) {

		//allow this method to also clear id content
		if($value == false || $value == null || strlen($value) < 1)
			jQuery('#' . $key)->html( false );
		else
			jQuery('#' . $key)->html($this->render($value));

		unset($this->jsonIdsToRender[$key]);

		}
	} catch ( Exception $e ) {
		$this->errors[] = 'unable to render id ' . $key;
	}
}		

if( !isset($this->errors) )
	
	jQuery('#errors')->html( false );

elseif( is_array($this->errors) )
	
	jQuery('#errors')->html( implode('<br />', $this->errors) );

else
	
	jQuery('#errors')->html( $this->errors );


if( !isset($this->notices) )
	
	jQuery('#notices')->html( false );    

elseif( is_array($this->notices) )
	
	jQuery('#notices')->html( implode('<br />', $this->notices) );

else
	
	jQuery('#notices')->html( $this->notices );
	

if( !isset($this->debug) )
	
	jQuery('#debug')->html( false );    

elseif( is_array($this->debug) )
	
	jQuery('#debug')->html( dump($this->debug, '', true) );

else
	
	jQuery('#debug')->html( $this->debug );
	

if( !isset(jQuery::$jQuery) )
 	jQuery::$jQuery = new jQuery(); //should only be needed for empty requests
echo Zend_Json::encode(jQuery::$jQuery->response);