<?php 	
 //hook the Ajax call
add_action('wp_ajax_get_product_action', 'ayi_get_product_action');
add_action('wp_ajax_nopriv_get_product_action', 'ayi_get_product_action');

function ayi_get_product_action( $custom_search = null ){

     if( check_ajax_referer( 'filter_nonce', 'security', false) || $custom_search ){		
		if( $custom_search ){
			$_POST['s'] = $custom_search;
		}
			
		$pxml_arr =  ayi_get_back_object( $_POST['s'] )	;

		
			
		
		
		$out_li = array();
		
		for($i=0; $i<=5; $i++){
			if( count($pxml_arr[$i]->Items->Item) > 0 )
			foreach( $pxml_arr[$i]->Items->Item as $single_item ){

			if( $custom_search ){
				$out_li[] =  '
				<div class="single_prod"><a href="'.(string)$single_item->DetailPageURL.'" target="_blank" ><img src="'.(string)$single_item->LargeImage->URL.'" /></a><div class="prod_title"><a href="'.(string)$single_item->DetailPageURL.'" target="_blank" >'.(string)$single_item->ItemAttributes->Title.'</a></div></div>
				';
			}else{
			
				$out_li[] =  '
				<tr> 				
					<td>'.( COUNT($query_res) > 0 ? '' : '<input type="checkbox" class="item_check" name="ids[]" value="'.$video_id.'" />' ).'
					<input type="hidden" value="'.(string)$single_item->ASIN.'" class="asin_id" />
					</td>  
					<td><img style="width:50px;" src="'.(string)$single_item->LargeImage->URL.'" />
					</td>
					<td>'.(string)$single_item->ItemAttributes->Title.'</td>  	
					<td class="cont_block hide"><div class="single_prod"><a href="'.(string)$single_item->DetailPageURL.'" target="_blank" ><img src="'.(string)$single_item->LargeImage->URL.'" /></a><div class="prod_title"><a href="'.(string)$single_item->DetailPageURL.'" target="_blank" >'.(string)$single_item->ItemAttributes->Title.'</a></div></div></td>
				  </tr>
				';
			}
				
			}
		}
		if( $custom_search ){
			return implode( '', array_slice($out_li, 0, 3) );		
		}else{
			echo implode( '', $out_li );		
		}
		
	} 

	die();

} 

?>