
/*viser den første side*/
function vis_oversigt(row_start,filter)
 {
var str = "row_start="+row_start+"&filter="+filter;
$.ajax({
data: str,
type: "POST", 
url: "vis_oversigt.php", 
cache: false,
dataType: "html",
beforeSend: function(){
$("div#my_main").html("<span class='overskrift'>Data hentes, vent venligst</span>");
},
 success: function(data){
  $("div#my_main").html(data);
  vis_menu_adm('start');
   vis_menu_bruger('start');
 	  }
}); 
}

//kalder sidenavigationen
function ajax_makepagenav(row_start, poster_side, rows, bokse, script_navn, filter)
 { 
var str = "row_start="+row_start+"&poster_side="+poster_side+"&rows="+rows+"&bokse="+bokse+"&script_navn="+script_navn+"&filter="+filter;
$.ajax({
data: str,
type: "POST", 
url: "ajax_makepagenav.php", 
cache: false,
dataType: "html",
 success: function(data){
  $("div#page_nav").html(data);
   
 	  }
}); 
}

/*viser bruger menuen*/
function vis_menu_bruger(menu_valg,id)
 { 
var str = "menu_valg="+menu_valg+"&id="+id;
$.ajax({
data: str,
type: "POST", 
url: "menu_bruger.php", 
cache: false,
dataType: "html",
 success: function(data){
  $("div#bruger_menu").html(data);
 	  }
}); 
}

/*viser adm menuen*/
function vis_menu_adm(menu_valg,id)
 { 
var str = "menu_valg="+menu_valg+"&id="+id;
$.ajax({
data: str,
type: "POST", 
url: "menu_adm.php", 
cache: false,
dataType: "html",
 success: function(data){
  $("div#adm_menu").html(data);
 	  }
}); 
}

//bruges i send email
function showHint_1(str)
{ 
$.ajax({
data: "q="+str,
type: "POST", 
url: "getkontakter_1.php", 
cache: false,
dataType: "html",
beforeSend: function(){
document.getElementById("til_gruppe_id").value="ingen";
document.getElementById("txtHint").innerHTML="<b>Data hentes, vent venligst</b>"; 
},
 success: function(data){
   $("div#txtHint").html(data);

 	  }
}); 
}

//bruges i send email
function showHint_2(str)
{ 
$.ajax({
data: "q="+str,
type: "POST", 
url: "getkontakter_2.php", 
cache: false,
dataType: "html",
beforeSend: function(){
document.getElementById("til_kontakt_id").value="ingen";
document.getElementById("txtHint").innerHTML="<b>Data hentes, vent venligst</b>"; 
},
 success: function(data){
   $("div#txtHint").html(data);
 	  }
}); 
}

//bruges i send sms
function showHint_3(str)
{ 
$.ajax({
data: "q="+str,
type: "POST", 
url: "getkontakter_3.php", 
cache: false,
dataType: "html",
beforeSend: function(){
document.getElementById("til_gruppe_id").value="ingen";
document.getElementById("txtHint").innerHTML="<b>Data hentes, vent venligst</b>"; 
},
 success: function(data){
   $("div#txtHint").html(data);

 	  }
}); 
}

//bruges i send sms
function showHint_4(str)
{ 
$.ajax({
data: "q="+str,
type: "POST", 
url: "getkontakter_4.php", 
cache: false,
dataType: "html",
beforeSend: function(){
document.getElementById("til_kontakt_id").value="ingen";
document.getElementById("txtHint").innerHTML="<b>Data hentes, vent venligst</b>"; 
},
 success: function(data){
   $("div#txtHint").html(data);
 	  }
}); 
}


// If the length of the element's string is 0 then display helper message
function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

// If the element's string matches the regular expression it is all numbers
function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

//længden skal være mellem max og min
function lengthRestriction(elem, min, max, helperMsg){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

function valueRestriction(elem, min, max, helperMsg){
	if(elem >= min && elem <= max){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

function lengthMax(elem, len, helperMsg){
	var uInput = elem.value;
	if(uInput.length <= len ){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

function lengthMin(elem, len, helperMsg){
	var uInput = elem.value;
	if(uInput.length >= len ){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}

function lengthSkal(elem, len, helperMsg){
	var uInput = elem.value;
	if(uInput.length == len ){
		return false;
	}else{
		alert(helperMsg);
		elem.focus();
		return true;
	}
}


//sætter edit ruden forrest
function  index_edit()
{
document.getElementById("edit").style.zIndex="3";
document.getElementById("edit_3").style.zIndex="2";
document.getElementById("edit_2").style.zIndex="1";
document.getElementById("my_main").style.zIndex="0";
}

/*funktion der skjuler edeit ruden, men samtidig gør den klar på ny, med header og tekstrude*/
function hide_edit()
{
$('#edit').hide('slow');
}

function show_edit()
{
$('#edit').fadeIn('slow');
}

function hide_edit_2()
{
$('#edit_2').hide('slow');
}

function show_edit_2()
{
$('#edit_2').fadeIn('slow');
}

function hide_edit_3()
{
$('#edit_3').hide('slow');
}

function show_edit_3()
{
$('#edit_3').fadeIn('slow');
}

/*viser message message ruden*/
function show_message(tekst)
{
document.getElementById("tekst_message").innerHTML=tekst;
document.getElementById("message").style.zIndex="4";
$('#message').fadeIn('slow');
}

/*Skjuler message message ruden*/
function hide_message()
{
 $('#message').hide('slow');
 document.getElementById("tekst_message").innerHTML="";
}

/*viser popup message ruden*/
function show_popup(tekst)
{
 document.getElementById("tekst_popup").innerHTML=tekst;
 document.getElementById("popup").style.zIndex="4";
 $('#popup').fadeIn('slow');

}

/*Skjuler popup message ruden*/
function hide_popup()
{
$('#popup').hide('slow');
 document.getElementById("tekst_popup").innerHTML="";
}

//sætter edet_2 ruden forrest
function  index_edit_2()
{
document.getElementById("edit_2").style.zIndex="3";
document.getElementById("edit_3").style.zIndex="2";
document.getElementById("edit").style.zIndex="1";
document.getElementById("my_main").style.zIndex="0";

}

//sætter edit_3 ruden forrest
function  index_edit_3()
{
document.getElementById("edit_3").style.zIndex="3";
document.getElementById("edit_2").style.zIndex="2";
document.getElementById("edit").style.zIndex="1";
document.getElementById("my_main").style.zIndex="0";

}

//sætter hovedruden forrest
function  index_main()
{
document.getElementById("my_main").style.zIndex="3";
document.getElementById("edit_3").style.zIndex="2";
document.getElementById("edit_2").style.zIndex="1";
document.getElementById("edit").style.zIndex="0";

}