
function get_radio_group_value(radioGrp)
{
	for (var i = 0; i< radioGrp.length; i++) {
		if (radioGrp[i].checked) {
			return  radioGrp[i].value;
		}
	}
	return -1;
}
function turn_off_notifications() {
	xajax_turnOffNotifications();
}

function validate_email(email) {
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function cleanDiv(div_id) {
	document.getElementById(div_id).innerHTML = '';
}

function view_profile_in_div(id, target_div) {
	xajax_viewProfile(id, target_div);
}

function view_file(filename) {
	window.open(SITE_BASE + "ver_archivo/" + filename , "", "toolbar=YES,menubar=YES,location=YES,directory=NO,width=940,height=920,scrollbars=YES,resizeable=YES,status=YES");
}

function view_profile(id) {
	window.open(SITE_BASE + "ver_perfil/" + id , "", "toolbar=YES,menubar=YES,location=YES,directory=NO,width=920,height=700,scrollbars=YES,resizeable=YES,status=YES");
}

function getSelectionsArray(items) {
	items_array = new Array();
	var array_index = 0;
	for (var i = 0; i < items.options.length; i++)   {
		if (items.options[i].selected == true) {			
			items_array[array_index] = items.options[i].value;

			++array_index;
		}
	}
	return items_array;
}

function reset_select(items) {
	for (var i = 0; i < items.options.length; i++)   {
		items.options[i].selected = false;
	}
}

function get_edit_groups() {
	document.register_form.edit_groups.value = 1;
	xajax_getEditGroups();
}

function get_all_data(suffix) {
	zip = eval("document.register_form.zip" + suffix + ".value");
	xajax_getAllData(zip, suffix);
}

function get_all_data_select(zone, suffix) {
	zip = eval("document.register_form.zip_stored" + suffix + ".value");
	if (zip >= 1000 && zip <= 100000)
		xajax_getAllData(zip, suffix, zone);
}

function get_city(suffix) {
	zip = eval("document.register_form.zip" + suffix + ".options[document.register_form.zip" + suffix + ".selectedIndex].value");
	if (zip != -1) {
		xajax_getCity(zip, suffix);
	}
	else document.getElementById('view_city' + suffix ).innerHTML = "&nbsp;";
}

function get_zips(suffix) {
	municipality_key = eval("document.register_form.municipality" + suffix + ".options[document.register_form.municipality" + suffix + ".selectedIndex].value");
	zone = eval("document.register_form.zone" + suffix + ".options[document.register_form.zone" + suffix + ".selectedIndex].value");
	if (state_key != -1 && zone != -1) {
		xajax_getZips(zone, municipality_key, suffix);
	}
	else document.getElementById('view_zips' + suffix ).innerHTML = "&nbsp;";
}

function get_zones(suffix) {
	municipality_key = eval("document.register_form.municipality" + suffix +".options[document.register_form.municipality" + suffix + ".selectedIndex].value");
	if (state_key != -1) {
		xajax_getZones(municipality_key, suffix); 
	}
	else document.getElementById('view_zones' + suffix ).innerHTML = "&nbsp;";
}

function get_municipalities(suffix) {
	state_key = eval("document.register_form.state" + suffix + ".options[document.register_form.state" + suffix + ".selectedIndex].value");
	if (state_key != -1) {
		xajax_getMunicipalities(state_key, suffix);
	}
	else document.getElementById('view_municipalities' + suffix).innerHTML = "";
}


function view_municipalities_of_birth_select(municipality) {
	state_key = document.register_form.state_of_birth.options[document.register_form.state_of_birth.selectedIndex].value;
	if (state_key != -1) {
		xajax_getMunicipalitiesFromBirth(state_key, municipality)
	}
	else document.getElementById('view_municipalities_of_birth').innerHTML = "";
}

function view_municipalities_of_birth() {
	view_municipalities_of_birth_select("")
}

function view_municipalities_of_birth_new() {
	state_key = document.search_form.from_state_key.options[document.search_form.from_state_key.selectedIndex].value;
	xajax_getMunicipalitiesFromBirthNew(state_key);
}

function run_basic_search(offset, first_name, middle_name, last_name, school_key, campus_key, from_state_key, semester, email, roll, level, course_key, age, sex, nationality_key, from_municipality_key, photo_search, only_with_photos, disable_filters, sorting, direction ) {
	xajax_runBasicSearch(offset, first_name, middle_name, last_name, school_key, campus_key, from_state_key, semester, email, roll, level, course_key, age, sex, nationality_key, from_municipality_key, photo_search, only_with_photos, disable_filters, sorting, direction);
}

function send_invitation_from_search()
{
	xajax_send_invitation_from_search(document.getElementById('invite_name').value, document.getElementById('invite_email').value);
}

function showLoading() {

	document.getElementById('loading').style.display = 'block';
};

function hideLoading() {

	document.getElementById('loading').style.display = 'none';
};

