// JavaScript Document
function addComentario(container,articulo,usuario) {
	
	var comentario = jQuery("#texto_comentario").val();
	
	if (comentario.trim().length <= 0) {
		jQuery("#texto_comentario").focus();
		return false;
	}
	
	jQuery.ajax({ 
   		type: "POST", 
   		url: "system/savecomentario.php", 
   		data: "articulo=" + articulo + "&usuario=" + usuario + "&comentario=" + comentario, 
   		success: function(html){ 
		jQuery("#" + container).append(html); 
		
		jQuery("#texto_comentario").val("");
		jQuery("#texto_comentario").focus();
		
   } 
 });		
}



 function SetFormInscripcion(id,object) {
 	var container = jQuery("#" + id);
	 ShowHideForm(container,object,"6px");
  }
	
function ShowHideForm(container,object,position) {		  		  		  
	 if (jQuery(container).is(':visible')) {
		jQuery(container).slideUp("slow");	
		jQuery(object).css("background-image","url(images/opensecction.png)");
	  } else {
	  	jQuery(container).slideDown("slow");
		jQuery(object).css("background-image","url(images/closesecction.png)");
	  }
		  
	  jQuery(object).css("background-position","100% " + position + ";");
	  jQuery(object).css("background-repeat","no-repeat;");		
		  
}

function validaClave(formname,pwd1,pwd2) {
	
	var clave = document.forms[formname][pwd1].value;
	var confirmar = document.forms[formname][pwd2].value;
	var value = true;
	
	if (clave != confirmar) {	
		value = false;
		window.alert("La clave no coindice. Por favor revise el campo clave y confirmar clave");
		document.forms[formname][pwd2].focus();
	}
	
	return value;
	
}


function lTrim(sStr){
	while (sStr.charAt(0) == " ") 
      sStr = sStr.substr(1, sStr.length - 1);
     return sStr;
}
 
function rTrim(sStr){
     while (sStr.charAt(sStr.length - 1) == " ") 
     sStr = sStr.substr(0, sStr.length - 1);
     return sStr;
}
 
function trim(sStr){
     return rTrim(lTrim(sStr));
}

