	function submitgroup(){
		var fields = document.getElementById("cbocategoryadd[]");

		for( i=0; i < fields.length; i++) {
			fields.options[i].selected = "selected";
		}


		var fields2 = document.getElementById("cbokeywordadd[]");

		for( i=0; i < fields2.length; i++) {
			fields2.options[i].selected = "selected";
		}
	}

	/**
	 * Javascript function to aid with CRUD actions
	 */
	
	function add(controller){
		window.location = "/"+controller+"/add/";
	}

	function modify(id, controller){

		document.getElementById('txtid').value=id;

		document.getElementById('txttipo').value="update";

		document.getElementById('frm').submit();

	}

	function deleterecords(controller){
	
		if (!seleccion(document.getElementById('frm'))){

			alert("Please Select a Record to Delete");

			return false;

		}

		response=confirm("Delete selected records...?");

		if (response==false) return false;

		document.getElementById('frm').submit();

	}
	
	function cancel(controller){
		window.location='/'+controller+'/';
	}
	
	
	/**
	 * grabs area and location for the form
	 */
	function reload(form){
		var val=form.cbodep.options[form.cbodep.options.selectedIndex].value;
		self.location='/user/groups/add/'+ val ;
	}
	





 function AddItem(Origen, Destino) 

 {
	var destList = Destino;

	var srcList = Origen; 

	var len = destList.length;

	for(var i = 0; i < srcList.length; i++) 

	{

		if ((srcList.options[i] != null) && (srcList.options[i].selected)) 

		{

		  var found = false;

		  for(var count = 0; count < len; count++) 

		  {

			if (destList.options[count] != null) 

			{

				if (srcList.options[i].text == destList.options[count].text) 

				{

					found = true;

					break;

      			}

   			}

		  }

		  if (found != true && len<5) 

		  {
				
			destList.options[len] = new Option(srcList.options[i].text, srcList.options[i].value); 

			destList.options[len].selected = true;
			
			len++;

         	}

      }

   }

}	



	function DelItem(Lista) 

	{

	  var destList  = Lista;

	  var len = destList.options.length;

		for(var i = (len-1); i >= 0; i--) 

		{

			if ((destList.options[i] != null) && (destList.options[i].selected == true)) destList.options[i] = null;

      	}

	}
	
	
	

	function validate()
	{
		document.forma.submit();
		if(document.forma.therapistfirstname.value == "")
		{
			alert("Please write your First name");
			document.forma.therapistfirstname.focus();
			return false;
		}
		if(document.forma.therapistlastname.value == "")
		{
			alert("Please write your Last name");
			document.forma.therapistlastname.focus();
			return false;
		}
		if(document.forma.therapistuserid.value == "")
		{
			alert("Please write your therapistuserid");
			document.forma.therapistuserid.focus();
			return false;
		}
		if(document.forma.therapistpassword.value == "")
		{
			alert("Please write your password");
			document.forma.therapistpassword.focus();
			return false;
		}
		if(document.forma.therapistpassword.value != document.forma.repassword.value || document.forma.repassword.value == "")
		{
			alert("Please confirm your password");
			document.forma.repassword.focus();
			return false;
		}
		if(document.forma.therapistemail.value == "")
		{
			alert("Please write your E-mail");
			document.forma.therapistemail.focus();
			return false;
		}
		if(document.forma.therapistlicensenumber.value == "")
		{
			alert("Please write your License number");
			document.forma.therapistlicensenumber.focus();
			return false;
		}

		if(document.forma.reqsupe.value == "Y")
		{
			if(document.forma.supervisor.value == "")
			{
				alert("Please provide the name of your supervisor");
				document.forma.supervisor.focus();
				return false;
			}

			if(document.forma.supervisorlicensenumber.value == "")
			{
				alert("Please write the License number of the supervisor");
				document.forma.supervisorlicensenumber.focus();
				return false;
			}
		}
		//type = document.forma.licensetypecombo.value;
		//Id = type.substr(0, 3);
		//document.forma.licensetypetherapist.value = Id;
		document.forma.submit();
	}

	function changePaymentDetails() {
		//paypalInfo = document.getElementById("paypalInfo");
		var checkInfo = document.getElementById("checkInfo");

		if(document.forma.payment_method.options[document.forma.payment_method.selectedIndex].value == '2') {
			//paypalInfo.style.display = 'block';
			checkInfo.style.display = 'none';
		} else if(document.forma.payment_method.options[document.forma.payment_method.selectedIndex].value == '1') {
			//paypalInfo.style.display = 'none';
			checkInfo.style.display = 'block';
		} else {
			//paypalInfo.style.display = 'none';
			checkInfo.style.display = 'none';
		}

	}

	function change_licensetype(ltypeid){
		if(licenseList[ltypeid] == "S"){
			DisableSupervisor(false);
		} else{
			DisableSupervisor(true);
		}
	}

	function DisableSupervisor(mode)
	{
		if(mode == true){
			document.forma.supervisor.disabled = true;
			document.forma.supervisorlicensetypeid.disabled = true;
			document.forma.supervisorlicensenumber.disabled = true;
			document.getElementById('supreq').style.visibility = "hidden";
		} else{
			document.forma.supervisor.disabled = false;
			document.forma.supervisorlicensetypeid.disabled = false;
			document.forma.supervisorlicensenumber.disabled = false;
			document.getElementById('supreq').style.visibility = "visible";					
		}
	}
	
	function showEmail(new_status){
		if(new_status == 0){
			//show email fields in case an email is desired
			document.getElementById('emailopt').style.visibility = "visible";
		}
	}
	
function addRow() {
    /* Declare variables */
    var elements, templateRow, rowCount, row, className, newRow, element;
    var i, s, t;
    
    /* Get and count all "tr" elements with class="row".    The last one will
     * be serve as a template. */
    if (!document.getElementsByTagName)
        return false; /* DOM not supported */
    elements = document.getElementsByTagName("tr");
    templateRow = null;
    rowCount = 0;
    for (i = 0; i < elements.length; i++) {
        row = elements.item(i);
        
        /* Get the "class" attribute of the row. */
        className = null;
        if (row.getAttribute)
            className = row.getAttribute('class')
        if (className == null && row.attributes) {    // MSIE 5
            /* getAttribute('class') always returns null on MSIE 5, and
             * row.attributes doesn't work on Firefox 1.0.    Go figure. */
            className = row.attributes['class'];
            if (className && typeof(className) == 'object' && className.value) {
                // MSIE 6
                className = className.value;
            }
        } 
        
        /* This is not one of the rows we're looking for.    Move along. */
        if (className != "row_to_clone")
            continue;
        
        /* This *is* a row we're looking for. */
        templateRow = row;
        rowCount++;
    }
    if (templateRow == null){
     	alert("no template");
        return false; /* Couldn't find a template row. */
    }
    
    /* Make a copy of the template row */
    newRow = templateRow.cloneNode(true);

    /* Change the form variables e.g. price[x] -> price[rowCount] */
    elements = newRow.getElementsByTagName("input");
    for (i = 0; i < elements.length; i++) {
        element = elements.item(i);
        s = null;
        s = element.getAttribute("name");
        if (s == null)
            continue;
        t = s.split("[");
        if (t.length < 2)
            continue;
        s = t[0] + "[na" + rowCount.toString() + "][" + i +"]";
        element.setAttribute("name", s);
        element.value = "";
    }
    
    /* Add the newly-created row to the table */
    templateRow.parentNode.appendChild(newRow);
    return true;
}

	

