function pagefunctions(){
	var keyuser = localStorage.getItem('keyuser');
}

$('#creategroup-cr').click(function() {
  	namegr = $('#namegroup-cr').val();
  	if ($('#namegroup-cr').val()) {
   	 	descgr = $('#descriptiongroup-cr').val();
    	locgr = $('#location-cr').val();
    	if ($('#privategroup-cr').is(':checked')) {
      		privategr = 'yes';
    	}else{
      		privategr = 'no';
    	}
    	if ($('#showcreator-cr').is(':checked')) {
      		showcreatr = 'yes';
    	}else{
      		showcreatr = 'no';
    	}
    	$.ajax({
      		type: "POST",
      		crossDomain: true,
      		url: "http://m2s.es/app/api/connect/creategroup.php",
      		data: {
        		'name': namegr,
        		'description': descgr,
        		'location': locgr,
        		'private': privategr,
        		'showcreator': showcreatr
      		},
      		cache: false,
      		dataType: 'json',
      		success: function(data) {
        		if (data.mensaje == 'ok') {
          			document.location.href = 'groups.html';
        		}
        		if(data.mensaje == 'e2'){
          			errormod(Language.errormatchgroup);
        		}
      		},
      		error: function(XMLHttpRequest, textStatus, errorThrown) {
        		console.error(textStatus + ' ' + XMLHttpRequest.status);
        		errormod(Language.errorpetitionm2s);
      		}
    	})
  	}else{
    	errormod(Language.erroremptygroup);
  	}
})
	
$('#sharelocat-cr').click(function() {
  if ($('#sharelocat-cr').hasClass("btn-default")) {
    if (navigator.geolocation) {
      $('#sharelocat-cr').attr('disabled', 'disabled');
      $('#sharelocat-cr').html(Language.locationloading);
      navigator.geolocation.getCurrentPosition(function(pods) {
        var latitud = pods.coords.latitude;
        var longitud = pods.coords.longitude;
        $('#location-cr').val(latitud + ' ' + longitud);
        $('#sharelocat-cr').removeAttr('disabled');
        $('#sharelocat-cr').addClass('btn-desactivate');
        $('#sharelocat-cr').removeClass('btn-default');
        $('#sharelocat-cr').html(Language.removelocation);
      });
    } else {
      alert("Your browser doesn't the location API");
    }
  } else {
    $('#sharelocat-cr').html(Language.sharelocation);
    $('#sharelocat-cr').removeClass('btn-desactivate');
    $('#sharelocat-cr').addClass('btn-default');
    $('#location-cr').val('');
  }
})
