function checkMail(value, name)
{
  var a = false;
  var result = false;
  if(typeof(RegExp) == 'function')
    {
      var b = new RegExp('abc');
      if(b.test('abc') == true){a = true;}
    }

  if(a == true)
    {
      reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)' + '(\\.)([a-zA-Z]{2,4})$');
      result = (reg.test(value));
    }
  else
    {
      result = (value.search('@') >= 1 && value.lastIndexOf('.') > value.search('@') && value.lastIndexOf('.') >= value.length-5)
    }
//  return(result);
  if (result == false)
  { 
    alert('Die interne E-Mail Adresse ist nicht korrekt.\n');
    var allesOK = false;
    $('saving').disabled = true;
    $('saving1').disabled = true;
  }
  else
  {
//    return(result);
    var allesOK = true;
   $('saving').disabled = false;
   $('saving1').disabled = false;
  }
}

function checkEMail(value)
{
  var a = false;
  var result = false;
  var allesOK = true;
  
  if(typeof(RegExp) == 'function')
    {
      var b = new RegExp('abc');
      if(b.test('abc') == true){a = true;}
    }

  if(a == true)
    {
      reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)' + '(\\.)([a-zA-Z]{2,4})$');
      result = (reg.test(value));
    }
  else
    {
      result = (value.search('@') >= 1 && value.lastIndexOf('.') > value.search('@') && value.lastIndexOf('.') >= value.length-5)
    }
  if (result == false)
  { 
    allesOK = true;
  }
  else
  {
   allesOK = false;
   $('pubMail').focus();
   Effect.Grow($('pubMail'));
   err = err + "Die interne E-Mail Adresse ist nicht korrekt.\n";
  }
}


// used in index.php
function get_info(name)
{
  new Ajax.Request('get_info.php?name=' + name,
				{
					onSuccess: function(t)
					{
            $('response').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

// used in index.php
function get_result(name)
{
  new Ajax.Request('get_result.php?name=' + name,
				{
					onSuccess: function(t)
					{
//            $('content').style.display = 'none';
            $('ergebnis').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function get_region_result(name)
{
    new Ajax.Request('get_region_result.php?name=' + name,
				{
					onSuccess: function(t)
					{
//            $('content').style.display = 'none';
            $('ergebnis').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function toggleUpload()
{
  if ($('upload').style.display == 'none')
  {
    Effect.BlindDown($('upload'));
  }
  else
  {
    Effect.BlindUp($('upload'));
  }
}


// search 4 company
function getcompany(string)
{
new Ajax.Request('get_company_result.php?text=' + string,
				{
          
					onSuccess: function(t)
					{
//            alert(t.responseText);
//						$('AutocompleteChoices').innerHTML = t.responseText;
						$('ergebnis').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						$('AutocompleteChoices').innerHTML = 'Failure';
					}
				}
			)
}
// ###############################################################
// Free seachrstrings
function getfreesearch(string)
{
  ajaxus = new XMLHttpRequest();
new Ajax.Request('get_freesearch_result.php?text=' + string,
				{
          
					onSuccess: function(t)
					{
  					$('ergebnis').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						$('AutocompleteChoices').innerHTML = 'Failure';
					}
				}
			)
}

function togglediv(id)
{
  if ($(id).style.display == 'none')
  {
    Effect.BlindDown($(id));
  }
  else
  {
    Effect.BlindUp($(id));
  }
}

// delete bni rezensions in intern_bnirezension.php
function del_reference(id)
{
  new Ajax.Request('delete_rezension.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

// statuschange used in mod_rezension.php
function change_stat(id, stat)
{
  new Ajax.Request('change_rez_stat.php?id=' + id + '&stat=' + stat,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

// statuschange used in intern_admin_jobsparten.php
function change_jobstat(id, stat)
{
  new Ajax.Request('change_job_stat.php?id=' + id + '&stat=' + stat,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

// delete jobs in intern_admin_jobsparten.php
function del_job(id)
{
  new Ajax.Request('delete_job.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

// delete global admins in global_adminlist.php and global_new_admin.php
function delete_globAdmin(id, name)
{
if (confirm(name + " wirklich löschen ?")) 
    {
      new Ajax.Request('global_admin_delete.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.href='global_adminlist.php';
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);   
    } 
    else 
    {
//
    }
}

// get chapternames in global_portallist.php
function admin_get_chapter(id, count)
{
  if ($('chapter_' + count).innerHTML == '')
  {
    $('sign_' + count).innerHTML = '-';
    new Ajax.Request('global_get_chapter.php?id=' + id,
  				{
  					onSuccess: function(t)
  					{
              $('chapter_' + count).innerHTML = t.responseText;
              Effect.BlindDown($('chapter_' + count));          
  //            location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
  }
  else
  {
    $('sign_' + count).innerHTML = '+';
    $('chapter_' + count).innerHTML = '';
  }
}



function delete_direktor(region, id)
{
  new Ajax.Request('global_delete_director.php?id=' + id + '&region=' + region,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function set_region_mail(region, value, email)
{
  new Ajax.Request('global_set_regionemail.php?region=' + region + '&value=' + value + '&email=' + email,
				{
					onSuccess: function(t)
					{
            if (t.responseText == 0) 
            {
              $('change1_' + region).style.display = 'block';
              $('save1_' + region).style.display = 'none';
              $('email1_' + region).readOnly = true;
              location.reload();
            }
            else {
              $('error_' + region).innerHTML = 'Fehler beim schreiben in die Datenbank';
            }
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function global_get_chapter(region ,id, count)
{
  if ($(region + '_' + count).innerHTML == '')
  {
    $('sign_' + count).innerHTML = '-';
    new Ajax.Request('global_chapter_details.php?region=' + region + '&id=' + id + '&count=' + count,
  				{
  					onSuccess: function(t)
  					{
              $(region + '_' + count).innerHTML = t.responseText;
              Effect.BlindDown($('region_' + count));          
  //            location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
  }
  else
  {
    $('sign_' + count).innerHTML = '+';
    $(region + '_' + count).innerHTML = '';
  }
}

//del starttext aus global_starttext.php
function del_starttext(id)
{
  new Ajax.Request('delete_starttext.php?id=' + id,
  				{
  					onSuccess: function(t)
  					{
              location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function change_starttext(id, stat)
{
  new Ajax.Request('change_starttext_stat.php?id=' + id + '&stat=' + stat,
  				{
  					onSuccess: function(t)
  					{
              location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function get_chapter(region, portal)
{
   new Ajax.Request('get_chapter.php?region=' + region,
  				{
  					onSuccess: function(t)
  					{
              $('chapter').innerHTML = t.responseText;
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function get_chapterort(region, chapter)
{
   new Ajax.Request('get_chapterort.php?region=' + region + '&chapter=' + chapter,
  				{
  					onSuccess: function(t)
  					{
              $('chapterort').value = '';
              $('chapterort').value = t.responseText;
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function publish_event(stat, id)
{
   new Ajax.Request('global_publish_event.php?stat=' + stat + '&id=' + id,
  				{
  					onSuccess: function(t)
  					{
              location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function delete_event(extid, eventid, regionid)
{
   new Ajax.Request('global_delete_event.php?eventid=' + eventid + '&regionid=' + regionid + '&extid=' + extid,
  				{
  					onSuccess: function(t)
  					{
              location.reload();
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
}

function show_event(id)
{
  if ($('event_' + id).style.display == 'block')
  {
    $('event_' + id).style.display = 'none';
  }
  else
  {
   new Ajax.Request('global_show_event.php?id=' + id,
  				{
  					onSuccess: function(t)
  					{
              $('event_' + id).innerHTML = t.responseText;
              $('event_' + id).style.display = 'block';
  					},
  					onFailure: function(t)
  					{
  						alert('Es ist ein Fehler aufgetreten.');
  					}
  				}
  			);
  }
}

// delete jobcategories in intern_jobsparten.php
function delete_link(id)
{
  new Ajax.Request('delete_global_link.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function publish_link(stat, id)
{
    new Ajax.Request('global_publish_link.php?id=' + id + '&stat=' + stat,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						alert('Es ist ein Fehler aufgetreten.');
					}
				}
			);
}

function get_jobs(name)
{
    new Ajax.Request('get_jobs.php?name=' + name,
				{
					onSuccess: function(t)
					{
            $('jobs').innerHTML = t.responseText;
					},
					onFailure: function(t)
					{
						$('jobs').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}

function edit_region_data(id)
{
  $('names_' + id).style.display = 'none';
  $('address_' + id).style.display = 'none';
  $('address2_' + id).style.display = 'none';
  $('telefon_' + id).style.display = 'none';
  $('telefax_' + id).style.display = 'none';    
  $('mail_' + id).style.display = 'none';  
  $('web2_' + id).style.display = 'none';  
  
  
  $('name_' + id).style.display = 'block';
  $('street_' + id).style.display = 'block';
  $('ort_' + id).style.display = 'block';
  $('fon_' + id).style.display = 'block';
  $('fax_' + id).style.display = 'block';
  $('email_' + id).style.display = 'block';
  $('web_' + id).style.display = 'block';
}

function save_region_data(vname, name, str, hnummer, plz, ort, fon, fax, email, web, id)
{
  new Ajax.Request('save_region_data.php?vname=' + vname + '&name=' + name + '&str=' + str + '&hnummer=' + hnummer + '&plz=' + plz + '&ort=' + ort + '&fon=' + fon + '&fax=' + fax + '&email=' + email + '&web=' + web + '&id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						$('error').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}

function delete_region_data(id)
{
  new Ajax.Request('delete_region_data.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						$('error').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}

function delete_download(id)
{
    new Ajax.Request('global_delete_download.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						$('error').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}

function delete_fteam(id)
{
    new Ajax.Request('global_delete_fteam.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						$('error').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}

function delete_trainee(id)
{
    new Ajax.Request('global_delete_trainee.php?id=' + id,
				{
					onSuccess: function(t)
					{
            location.reload();
					},
					onFailure: function(t)
					{
						$('error').innerHTML = 'Es ist ein Fehler aufgetreten.';
					}
				}
			);
}
