/* * * * * GLOBAL * * * * */
globalURL = 'http://www.ballyneal.com/';
optionTree ="";//use for tree category in positions
currentPage = "";//set current page for paginate
hideAjaxWork = false;//for hide events that not show ajax loading
/* * * * * END GLOBAL * * * * */

/* * * * * EVENTOS CUANDO TRABAJA EL AJAX * * * * */
function ajaxWorks(){
	$(".ajaxWork").ajaxStop(function(){
    $(this).hide();
	$("#mask").hide();
	//loadTinyMCE();
  });

	$(".ajaxWork").ajaxStart(function(){
		if(!hideAjaxWork){
			$(this).show();
			$("#mask").show();
			}
	});
};
/* * * * * END EVENTOS CUANDO TRABAJA EL AJAX * * * * */


/* * * * * GENERAL * * * * */
function formEdit(controller,id){
	globalID = id;//Define global for each method that need it use
	var garbage = randomvar();//Retorna un string con un valor aleatorio para evitar la cache de IE
	var url = globalURL+controller+"/ajax_edit/"+id+garbage;
  $.get(url,{},function(data){
		loadView(controller,'edit',data);
	});
}

function formView(controller,id){
	globalID = id;//Define global for each method that need it use
	var garbage = randomvar();//Retorna un string con un valor aleatorio para evitar la cache de IE
	var url = globalURL+controller+"/ajax_view/"+id+garbage;
  $.get(url,{},function(data){
		loadView(controller,'view',data);
	});
}

function formAdd(controller){
	var garbage = randomvar();//Retorna un string con un valor aleatorio para evitar la cache de IE
	var url = globalURL+controller+"/ajax_add"+garbage;
	$.get(url,{},function(data){
		loadView(controller,'add',data);
	});
}

function formDel(controller,id){
	var url = globalURL+controller+"/delete/"+id;
	if(confirm("Are your sure of delete?")) {
		$.get(url,{},function(data){
			loadView(controller,'del',data);
		});
	}
}

function paginate(controller,url){ //Call loadView() with parameters for paginate
	if(typeof url =="undefined") return false;
	var data = url.split("/ajax_grid");
	loadView(controller,'paginate',data[1]);
}

function loadView(controller,method,data){
	switch(controller){

		case 'forms':
			switch (method){

				case 'add':
					$("#forms").html(data);
					$('#FormAjaxAddForm').ajaxForm({
						success:showResponseForm
					});
					break;

				case 'edit':
					$("#forms").html(data);
					$('#FormAjaxEditForm').ajaxForm({
						success:showResponseForm
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'formsMessages':
			switch (method){

				case 'view':
					$("#formsMessages").html(data);

        	$('#FormsMessageAjaxViewForm').ajaxForm({
						success:showResponseFormsMessage
					});

					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'subscriptions':
			switch (method){

				case 'add':
					$("#subscriptions").html(data);
					$('#SubscriptionAjaxAddForm').ajaxForm({
						success:showResponseSubscription
					});
					break;

				case 'edit':
					$("#subscriptions").html(data);
					$('#SubscriptionAjaxEditForm').ajaxForm({
						success:showResponseSubscription
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'subscription_services':
			switch (method){

				case 'add':
					$("#subscriptionServices").html(data);
					$('#SubscriptionServiceAjaxAddForm').ajaxForm({
						success:showResponseSubscriptionService
					});
					break;

				case 'edit':
					$("#subscriptionServices").html(data);
					$('#SubscriptionServiceAjaxEditForm').ajaxForm({
						success:showResponseSubscriptionService
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'subscription_packs':
			switch (method){

				case 'add':
					$("#subscriptionPacks").html(data);
					$('#SubscriptionPackAjaxAddForm').ajaxForm({
						success:showResponseSubscriptionPack
					});
					break;

				case 'edit':
					$("#subscriptionPacks").html(data);
					$('#SubscriptionPackAjaxEditForm').ajaxForm({
						success:showResponseSubscriptionPack
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'users':
			switch (method){

				case 'add':
					$("#users").html(data);
					$('#UserAjaxAddForm').ajaxForm({
						success:showResponseUser
					});
					break;

				case 'edit':
					$("#users").html(data);
					$('#UserAjaxEditForm').ajaxForm({
						success:showResponseUser
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;

		case 'classifieds_categories':
			switch (method){

				case 'add':
					$("#classifieds_categories").html(data);
					$('#ClassifiedsCategoryAjaxAddForm').ajaxForm({
						success:showResponseClassifiedsCategory
					});
					break;

				case 'edit':
					$("#classifieds_categories").html(data);

					$('#ClassifiedsCategoryAjaxEditForm').ajaxForm({
						success:showResponseClassifiedsCategory
					});

					controlBox();
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;      

		case 'classifieds_supcategories':
			switch (method){

				case 'add':
					$("#classifieds_supcategories").html(data);
					$('#ClassifiedsSupcategoryAjaxAddForm').ajaxForm({
						success:showResponseClassifiedsSupcategory
					});
					break;

				case 'edit':
					$("#classifieds_supcategories").html(data);
					$('#ClassifiedsSupcategoryAjaxEditForm').ajaxForm({
						success:showResponseClassifiedsSupcategory
					});
					break;

				case 'del':
					location.reload(true);
					break;

			}
			break;
      
		case 'classifieds':
			switch (method){

				case 'add':
					$("#content").html(data);

					makeSublist('supcategory','category', false, '');

					selectClassifiedsAdd();

					break;

				case 'edit':

					$("#content").html(data);

					showClassifiedsArchiveImage(globalID,'image');

					controlBox();

					if($("#ClassifiedContent").length > 0)
					{
						tinyMCE.idCounter=0;//for one textarea only
						tinyMCE.execCommand("mceAddControl", false, "ClassifiedContent");
					}
					break;

				case 'del':
					location.reload(true);
					break;

				case 'paginate':
					gridContents(data);
				break;

			}
			break;      

		case 'events':
			switch (method){
			
				case 'add':
					$("#events").html(data);
					$('#EventAjaxAddForm').ajaxForm({
						success:showResponseEvent	
					});
					break;
					
				case 'edit':
					$("#events").html(data);
					
					$('#EventAjaxEditForm').ajaxForm({
						success:showResponseEvent	
					});
					
					eventsParticipants();
					eventsPlans();
          eventsSummary();
					
					controlBox();
					break;

				case 'view':
					$("#events").html(data);
					
					eventsParticipants();
					eventsPlansView();
          eventsSummary();
					
					controlBox();
					break;
					
				case 'del':
					location.reload(true);
					break;

			}
		
		case 'events_plans':
			switch (method){
					
				case 'del':
					eventsPlans();
					break;

			}
			break;
		
		case 'payments_configs':
			switch (method){
				
				case 'add':
					$("#grid").html(data);
					$('#PaymentsConfigAjaxAddForm').ajaxForm({
						success:showResponsePaymentConfig	
					});
					break;
				
				case 'edit':
					$("#grid").html(data);
					
					$('#PaymentsConfigAjaxEditForm').ajaxForm({
						success:showResponsePaymentConfig
					});
					
					controlBox();
					break;
					
				case 'del':
					location.reload(true);
					break;

			}
			break;
			
		case 'shipping_methods':
			switch (method){
				
				case 'add':
					$("#grid").html(data);
					$('#ShippingMethodsAjaxAddForm').ajaxForm({
						success:showResponseShippingMethods
					});
					break;
				
				case 'edit':
					$("#grid").html(data);
					
					$('#ShippingMethodsAjaxEditForm').ajaxForm({
						success:showResponseShippingMethods
					});
					
					controlBox();
					break;
					
				case 'del':
					location.reload(true);
					break;

			}
			break;

	}
}
/* * * * * END GENERAL * * * * */

/* * * * * * CLASSIFIEDS * * * * * */

function selectClassifiedsIndex(){

	var supcategory = $("#supcategory").val();
	var category = $("#category").val();
	var search = $("#search").val();

	gridClassifieds("supcategory:"+supcategory+"/category:"+category+"/search:"+search);

}

function gridClassifieds(params){
	if(typeof params == "undefined") params = "";
	var garbage = randomvar();
  var url = globalURL + "classifieds/ajax_grid/" + params + garbage;
  $.get(url, {}, function(data){
    $("#grid").html(data);
  });
}

function saveClassified(form){
	tinyMCE.triggerSave();
	$(form).ajaxSubmit({
    success:showResponseClassified
	});
}

function classifiedsFormAdd(controller){

	var garbage = randomvar();//Retorna un string con un valor aleatorio para evitar la cache de IE
	var supcategory = $("#supcategory").val();
	var category = $("#category").val();

	var url = globalURL+controller+"/ajax_add/supcategory:"+supcategory+"/category:"+category+garbage;

	$.get(url,{},function(data){
		loadView(controller,'add',data);
	});
}


function showResponseClassified(responseText, statusText)  {

	$("#content").html(responseText);

	globalID = $("#ClassifiedId").val();

	if($('#ClassifiedAjaxEditForm')) $('#selectClassifiedAdd').empty();

	showClassifiedsArchiveImage(globalID,'image');
  
	controlBox();
  
	if($("#ClassifiedContent").length > 0)
		{
			tinyMCE.idCounter = 0;
			tinyMCE.execCommand("mceAddControl", false, "ClassifiedContent");
		}
/*    
	if($("#ClassifiedDescription").length > 0)
		{
			tinyMCE.idCounter = 1;
			tinyMCE.execCommand("mceAddControl", false, "ClassifiedDescription");
		}
*/    
    
}

function selectClassifiedsAdd(){

	var category = $("#category").val();

  var url = globalURL+"classifieds/ajax_add_form/category:" + category;
  $.get(url,{},function(data){
      $("#grid").html(data);
      
	if($("#ClassifiedContent").length > 0)
		{
			tinyMCE.idCounter = 0;
			tinyMCE.execCommand("mceAddControl", false, "ClassifiedContent");
		}
/*    
	if($("#ClassifiedDescription").length > 0)
		{
			tinyMCE.idCounter = 1;
			tinyMCE.execCommand("mceAddControl", false, "ClassifiedDescription");
		}
*/    
  });

}

function classifiedsAddFormBack(){

	var garbage = randomvar();//Retorna un string con un valor aleatorio para evitar la cache de IE
	var supcategory = $("#supcategory").val();
	var category = $("#category").val();

	document.location = globalURL+"classifieds/index/supcategory:"+supcategory+"/category:"+category+garbage;;

}

function enClassified(controller,id){
	var url = globalURL + "classifieds/enClassified/" + id;

	$.post(url, {}, function(data){
		gridClassifieds();
  });
}

function disClassified(controller,id){
	var url = globalURL + "classifieds/disClassified/" + id;

	$.post(url, {}, function(data){
		gridClassifieds();
  });
}

    /* * * * * * CLASSIFIEDS ARCHIVES * * * * * */

    
function classifiedsUpLoadFile(target,id){

	var type = target.substring(4);//target ever is 'file....	'
	var url = globalURL + "classifieds_archives/ajaxarchiveadd/classified_id:" + id + "/type:" + type;

  $.get(url,{},function(data){

    $("#"+target).html(data);

		$("#"+target+" #ClassifiedsArchiveAddForm").ajaxForm({
      success:function(){
        showClassifiedsArchiveImage(id,type);
				$("#file"+type).empty();
      },
		resetForm:true
		});

  });

}


function showClassifiedsArchiveImage(id,type){

	var garbage = randomvar();
	var url = globalURL + "classifieds_archives/ajaxshowimages/" + id + "/" + type + garbage;

    $.get(url, {}, function(data){
			$("#" + type + "sBox").html(data);
    });

}


function classifiedsDeleteImage(url,type) {

		var url2 = url + '/' + type;

		if(confirm("żEsta seguro de borrar?")) {

      $.get(url2,{},function(data){
				showClassifiedsArchiveImage(globalID,type);
				$("#file"+type).empty();
      });

		}

}

function classifiedsEditImage(fileID,target) {

	var garbage = randomvar();
	var url = globalURL + "classifieds_archives/ajaxarchiveedit/" + fileID + "/content_id:" + globalID + garbage;

    $.get(url,{},function(data){

    $("#file"+target).html(data);

    $("#file" + target + " #ClassifiedsArchiveAjaxarchiveeditForm").ajaxForm({

      success:function(responseText){
        showClassifiedsArchiveImage(globalID,target);
        classifiedsEditImage(fileID,target);
      }

    });

  });

}    

    /* * * * * * END CLASSIFIEDS ARCHIVES * * * * * */







/* * * * * * END CLASSIFIEDS * * * * * */


/*	PAYMENTS CONFIGS	*/

function gridPaymentsConfigs(){
	
  var url = globalURL+"payments_configs/ajax_grid/";
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponsePaymentConfig(responseText, statusText)  {

	$("#grid").html(responseText);
	
	$('#PaymentsConfigAjaxAddForm').ajaxForm({
		success:showResponsePaymentConfig
	});
	
	$('#PaymentsConfigAjaxEditForm').ajaxForm({
		success:showResponsePaymentConfig
	});

}
/*	END PAYMENTS CONFIGS	*/

/*	Shipping methods 	*/

function gridShippingMethods(){
	
  var url = globalURL+"shipping_methods/ajax_grid/";
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseShippingMethods(responseText, statusText)  {

	$("#grid").html(responseText);
	
	$('#ShippingMethodsAjaxAddForm').ajaxForm({
		success:showResponseShippingMethods
	});
	
	$('#ShippingMethodsAjaxEditForm').ajaxForm({
		success:showResponseShippingMethods
		
	});

}
/*	END Shipping methods	*/

/* * * * * EVENTS  * * * * */

function gridEvents(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"events/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseEvent(responseText, statusText)  {

	$("#events").html(responseText);
	
	$('#EventAjaxAddForm').ajaxForm({
		success:showResponseEvent
	});
	
	$('#EventAjaxEditForm').ajaxForm({
		success:showResponseEvent
	});

	controlBox();
	
}

function eventsParticipants(){

	var url = globalURL+"events/participants/" + globalID;
	
  $.get(url,{},function(data){
			$("#participants").html(data);
  });

}

function deleteInscription(params){

  if(typeof params != "undefined") {
    
    var url = globalURL+"events/delete_inscription/" + params;
    
    $.get(url,{},function(data){

        var url = globalURL+"events/participants/" + globalID;
      
        $.get(url,{},function(data){
          
          $("#participants").html(data);
        
        });
        
    });
    
  }
}

function publishEvent(eventId, status){

  if(typeof eventId != "undefined") {
    
    var url = globalURL+"events/publish_event/" + eventId + "/" + status;
    
    $.get(url,{},function(data){

      gridEvents();
        
    });
    
  }
}

function paidInscription(inscrptionId, status){

  if(typeof inscrptionId != "undefined") {
    
    var url = globalURL+"events/paid_inscription/" + inscrptionId + "/" + status;
    
    $.get(url,{},function(data){

        var url = globalURL+"events/participants/" + globalID;
      
        $.get(url,{},function(data){
          
          $("#participants").html(data);
        
        });
        
    });
    
  }
}

function eventsPlans(){

	var url = globalURL+"events_plans/ajax_grid/" + globalID + randomvar() ;
	
  $.get(url,{},function(data){
			$("#gridplans").html(data);
  });

}

function eventsPlansView(){

	var url = globalURL+"events_plans/ajax_grid_view/" + globalID + randomvar() ;
	
  $.get(url,{},function(data){
			$("#gridplans").html(data);
  });

}


function savePlan(){

	$("form#EventsPlanAjaxAddForm").ajaxSubmit({
		success:eventsPlans
	});

}

function eventsSummary(){

	var url = globalURL+"events/summary/" + globalID;
	
  $.get(url,{},function(data){
			$("#summary").html(data);
  });

}

function eventsRegister(user) {

	var url = globalURL+"events/reregisterUser/" + globalID + "/" + user;
	
  $.get(url,{},function(data){

		eventsParticipants();
	
  });
	
}

function eventsUnregister(user) {

	var url = globalURL+"events/unregisterUser/" + globalID + "/" + user;

  $.get(url,{},function(data){

		eventsParticipants();
	
  });
	
}


/* * * * * END EVENTS  * * * * */

/* * * * * FORMS * * * * */
function gridForms(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"forms/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseForm(responseText, statusText)  {

	$("#forms").html(responseText);

	$('#FormAjaxAddForm').ajaxForm({
		success:showResponseForm
	});

	$('#FormAjaxEditForm').ajaxForm({
		success:showResponseForm
	});

}
/* * * * * END FORMS * * * * */

/* * * * * FORMS MESSAGES * * * * */

function gridFormsMessages(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"forms_messages/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseFormsMessage(responseText, statusText)  {

	$("#formsMessages").html(responseText);

	$('#FormsMessageAjaxAddForm').ajaxForm({
		success:showResponseFormsMessage
	});

	$('#FormsMessageAjaxEditForm').ajaxForm({
		success:showResponseFormsMessage
	});

  $('#FormsMessageAjaxViewForm').ajaxForm({
    success:showResponseFormsMessage
  });

}
/* * * * * END FORMS MESSAGES * * * * */

/* * * * * SUBSCRIPTIONS  * * * * */
function gridSubscriptions(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL + "subscriptions/ajax_grid/" + params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseSubscription(responseText, statusText)  {

	$("#subscriptions").html(responseText);

	$('#SubscriptionAjaxAddForm').ajaxForm({
		success:showResponseSubscription
	});

	$('#SubscriptionAjaxEditForm').ajaxForm({
		success:showResponseSubscription
	});

}

function gridSubscriptionServices(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL + "subscription_services/ajax_grid/" + params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseSubscriptionService(responseText, statusText)  {

	$("#subscriptionServices").html(responseText);

	$('#SubscriptionServiceAjaxAddForm').ajaxForm({
		success:showResponseSubscriptionService
	});

	$('#SubscriptionServiceAjaxEditForm').ajaxForm({
		success:showResponseSubscriptionService
	});

}

function gridSubscriptionPacks(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL + "subscription_packs/ajax_grid/" + params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseSubscriptionPack(responseText, statusText)  {

	$("#subscriptionPacks").html(responseText);

	$('#SubscriptionPackAjaxAddForm').ajaxForm({
		success:showResponseSubscriptionPack
	});

	$('#SubscriptionPackAjaxEditForm').ajaxForm({
		success:showResponseSubscriptionPack
	});

}

/* * * * * END SUBSCRIPTIONS  * * * * */

/* * * * * USERS * * * * */
function gridUsers(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"users/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseUser(responseText, statusText)  {

	$("#users").html(responseText);

	$('#UserAjaxAddForm').ajaxForm({
		success:showResponseUser
	});

	$('#UserAjaxEditForm').ajaxForm({
		success:showResponseUser
	});

}
/* * * * * END USERS * * * * */

/* * * * * CLASSIFIEDS CATEGORIES  * * * * */
function gridClassifiedsCategories(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"classifieds_categories/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseClassifiedsCategory(responseText, statusText)  {

	$("#classifieds_categories").html(responseText);

	$('#ClassifiedsCategoryAjaxAddForm').ajaxForm({
		success:showResponseClassifiedsCategory
	});

	$('#ClassifiedsCategoryAjaxEditForm').ajaxForm({
		success:showResponseClassifiedsCategory
	});

	controlBox();

}

/* * * * * END CLASSIFIEDS CATEGORIES  * * * * */

/* * * * * CLASSIFIEDS CATEGORIES  * * * * */
function gridClassifiedsSupcategories(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"classifieds_supcategories/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseClassifiedsSupcategory(responseText, statusText)  {

	$("#classifieds_supcategories").html(responseText);

	$('#ClassifiedsSupcategoryAjaxAddForm').ajaxForm({
		success:showResponseClassifiedsCategory
	});

	$('#ClassifiedsSupcategoryAjaxEditForm').ajaxForm({
		success:showResponseClassifiedsSupcategory
	});

	controlBox();

}

/* * * * * END CLASSIFIEDS SUPCATEGORIES  * * * * */

/* * * * * EVENTS  * * * * */

function gridEvents(params){
	if(typeof params == "undefined") params = "";
  var url = globalURL+"events/ajax_grid/"+params;
  $.get(url,{},function(data){
      $("#grid").html(data);
  });
}

function showResponseEvent(responseText, statusText)  {

	$("#events").html(responseText);

	$('#EventAjaxAddForm').ajaxForm({
		success:showResponseEvent
	});

	$('#EventAjaxEditForm').ajaxForm({
		success:showResponseEvent
	});

	controlBox();

}

function eventsParticipants(){

	var url = globalURL+"events/participants/" + globalID;

  $.get(url,{},function(data){
			$("#participants").html(data);
  });

}

function eventsRegister(user) {

	var url = globalURL+"events/reregisterUser/" + globalID + "/" + user;

  $.get(url,{},function(data){

		eventsParticipants();

  });

}

function eventsUnregister(user) {

	var url = globalURL+"events/unregisterUser/" + globalID + "/" + user;

  $.get(url,{},function(data){

		eventsParticipants();

  });

}


/* * * * * END EVENTS  * * * * */

/* * * * * FUNCIONES AUXILIARES * * * * */
function randomvar(){
	var rnd = Math.round((Math.random())*1000);
	var string = '?irnd='+rnd;
	return string;
}

function lifeSession(){
	hideAjaxWork = true;
	var url = globalURL+"contents/ajaxsearch";
	$.get(url,{},function(data){});
	hideAjaxWork = false;
}

function controlBox(){

	var first = $("ul#navleft li a").eq(0).attr("id");//Search first link id
	$("#right ."+first).css("display","block");//and show this

	$("ul#navleft li a").each(function(){//search all links of menu and add we the event to each one

		$(this).click(function(){

		$("#right .headerbox").css("display","none");
		$("#right ."+this.id).css("display","block");

		$("ul#navleft li").removeClass("active");
		$(this).parent("li").addClass("active");

		});

	});

}

function makeSublist(parent,child,isSubselectOptional,childVal){

	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));

	var parentValue = $('#'+parent).attr('value');
	$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');

	$('#'+parent).change(function(){
			var parentValue = $('#'+parent).attr('value');
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
			if(isSubselectOptional) $('#'+child).prepend("<option value='none'> -- Select -- </option>");
			$('#'+child).trigger("change");
      $('#'+child).focus();
	});

}

function closeShadow()
{
        $(".contentShadow").remove();
		$("#overShadow").remove();

		$("#shadow").fadeTo(1000, 0,function(){
                $("#shadow").css("display","none");
        });
}

function loadTree()
{
	$.get('tree.htm',{},function(data){

			$("#tree").html(data);

			});
}

function setUrl(val){
document.getElementById('href').value = val;
}


function loadTinyMCE() {
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			theme_advanced_buttons1 : "mybutton, bold,italic, underline,separator, strikethrough, justifyleft, justifycenter, justifyright, justifyfull, bullist, numlist, undo, redo, link, unlink, image",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			plugins : "paste, save",
			width:"100%",
			height:"227",
			editor_selector : "mceEditor",
			editor_deselector : "mceNoEditor"
   });
}

/* * * * * END FUNCIONES AUXILIARES * * * * */
