if(!window.Interview){
	window.Interview = {

		showDetail: function(id){
			new Ajax.Request(window.contextPath+"/interview/detail.action", {
				parameters:{ id:id },
				onComplete: function(response){
					if(!Consulte.hasError(response)){
						$("content").innerHTML = response.responseText;
					}
				}.bind(this)
			});
		},

		initList: function(){
			Consulte.setBackOptions({
				url:window.contextPath+"/interview/list.action"
			});
			Consulte.clearPrompt();
		},

		initDetail: function(){
			Consulte.setBackOptions({
				url:window.contextPath+"/interview/detail.action"
			});
			Consulte.loadPrompt("interview-relatedContent");
		},

		listByOwner: function(ownerId){
			this.listAll({
				ownerId: ownerId
			});
		},

		listByCategory: function(categoryId){
			this.listAll({
				categoryId: categoryId
			});
		},

		listByOrder: function(order){
			this.listAll({
				order: order,
				categoryId: $("interviewFilterForm.categoryId").value
			});
		},

		listAll: function(filters){
			filters = Object.extend({
				categoryId:"", ownerId:"", order:"", pageIndex:"1"
			}, filters||{});

			if($("interviewFilterForm") != null){
				$("interviewFilterForm.categoryId").value = filters.categoryId;
				$("interviewFilterForm.ownerId").value = filters.ownerId;
				$("interviewFilterForm.order").value = filters.order;
				$("filter.pageIndex").value = filters.pageIndex;
			}
			this.list();
		},

		list: function(){
			var parameters = {};
			var form = $("interviewFilterForm");
			if(form != null){
				parameters = form.serialize({hash:true});
			}

			new Ajax.Request(window.contextPath+"/interview/list.action", {
				parameters:parameters,
				onComplete: function(response){
					if(!Consulte.hasError(response)){
						$("content").innerHTML = response.responseText;
					}
				}.bind(this)
			});
		},

		toggleListOrder: function(){
			var obj = $("ordenar_div");
			var arrow = $("img_ordenar");

			if(obj.visible()){
				obj.hide();
				arrow.className = "img_mostrar";
			}else{
				obj.show();
				arrow.className = "img_esconder";
			}
		},

		getContentEmail:function(){
			return Consulte.getContentEmail("txt.interview.subject");
		},

		truncate: function(){
			Consulte.truncateText($$("div.trunca"), 400);
		},
		
		truncateCover: function(){
			Consulte.truncateText($$("p.trunca"), 250);
		}
	};
}

