$(document).ready(function () {

	$("#search").autocomplete({  
  
            delay: 100,
			source: function(req, add){  
  
                $.getJSON(base_url+'search/ajaxsearch?callback=?', req, function(data) {  

                    var suggestions = [];  

                    $.each(data, function(i, val){  
                    suggestions.push(val.name);  
                });  

                add(suggestions);  
            });  
        }  

	});
	
	$('#pright .bbody img').each(function () {
		var h = $(this).height();
		if($(this).width() > 245) { 
			$(this).height(h * (245/$(this).width()));
			$(this).width(245);
			$(this).css('display','block');
			}
	}
	);

		
	var lr = 'left';
	$('#pleft .abody img').each(function () {
		var h = $(this).height();
		if($(this).width() > 536) {
			$(this).height(h * (536/$(this).width()));
			$(this).width(536);

		} else if($(this).width() > 330) {
			$(this).css({clear: 'both', margin: 'auto', cssfloat: 'none'});
		} else if($(this).width() > 60 && $(this).attr('id') != 'captcha') {
			$(this).css({cssFloat:lr, padding: '0 10px 5px 0'});
			if(lr == 'left') lr = 'right'; else lr = 'left';
		}

		$(this).css({display:'block'});
	});
	
});

