	function handleResponse(id, type) {
		
		res = id.split("|");
		id = res[1];
		hash = res[0];
		if (type == 'video') {
			counter = parseInt($("#counter").val()) + 1;
			$("#counter").val(counter);
			var oDiv = document.createElement('div');
			html = '<div class="newEmbedItem" id="emb'+counter+'"><div style="float: left">'+id+'<input type="hidden" value="'+hash+'" name="ev'+counter+'" id="ev'+counter+'"></div><div style="float: right" id="rm'+counter+'" class="embed_remove"><img src="/static/images/_icons/delete.gif" style="margin: 0px" /></div><div style="clear: both>&nbsp;</div></div>';
			$("#holdEmbeds").append(html);
			nId = '#emb'+counter;
			$(nId).fadeIn('slow');
		} else {
			big = res[2].replace('middle', 'big');
			iframe = document.getElementById("answer_area");
			//jQuery.fn.rte.insertText("answer_area", '<img src="'+res[2]+'" class=\"embedImage\" />', iframe);
			img = 	'<a class="gallerypic" href="'+big+'" title="'+res[1]+'">'+
	  				'<img src="'+res[2]+'" alt="'+res[1]+'" class="pic" />'+
	  				'<span class="zoom-icon"><img src="/static/images/magnifyGlass.jpg" width="30" height="36" alt="Zoom"></span>'+
					'</a>';
			jQuery.fn.rte.insertText("answer_area", img, iframe);
			//jQuery.fn.rte.formatText(iframe, 'InsertImage', res[2]);
		}
		$.fn.fancybox.close();
		
	}

	// general
    $(function (){  
        $(".send").livequery('click', function(ev) {
            $("#form_odgovori").submit();
        });

        $("#answerButton").livequery('click', function(ev) {
            $(".bottomPostAnswerBox").show();
            var oIframe = document.getElementById("answer_area");
            var oDoc = oIframe.contentWindow || oIframe.contentDocument;
            oDoc.document.designMode = 'on';
            
			var $target = $("bottomPostAnswerBox");
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
			}
            
        });
        
        $(".dismiss").click(function() {
            $(".postAnswerBox").hide();
        });

        
        // vote

        $('.thumbUp').livequery('click', function() {
            var id = $(this).attr('id');
            $.getJSON('/kutak/response.html?ajax=1&i=' + id, function (data) {
                $res = data['response'];
                $("#"+id).attr('innerHTML',$res);
            });
            return false;            

        });
        
        $('.thumbDown').livequery('click', function() {
            var id = $(this).attr('id');
            $.getJSON('/kutak/response.html?ajax=1&i=' + id, function (data) {
                $res = data['response'];
                $("#"+id).attr('innerHTML',$res);
            });
            return false;
        });
        
        //
        $('.showHiddenPost').livequery('click', function() {
            var id = $(this).attr('name');
            $("#post_"+id).toggle();
            $("#show_"+id).toggle();
            $("#hide_"+id).toggle();
            return false;
        });
        
        // add image/video
	    if (jQuery.fn.fancybox) {
		    $(".gallerypic").fancybox({
				'frameWidth' : 700,
				'frameHeight' :	490,
		        'zoomSpeedIn': '0', 
		        'zoomSpeedOut': '0', 
		        'hideOnContentClick': true,
		        'overlayShow': true,
		        'overlayOpacity': 0.8
		    }); 
	    }
	   	$(".embed_remove").livequery('click', function(event) { 
	    	id = $(this).attr('id');
	    	id = id.replace('rm', '');
	    	$("#ev"+id).remove();
	    	$("#emb"+id).fadeOut(1000, function () {
	    		$(this).remove();
	    	});
	    });
	    
	    
        
                   

    });
