
function checkall()
{
	if(document.create_form.category.value==10)
	{
		alert("Checked all");
		document.create_form.category[0].checked==true;
		document.create_form.category[1].checked==true;
		document.create_form.category[2].checked==true;
		document.create_form.category[3].checked==true;
		document.create_form.category[4].checked==true;
		document.create_form.category[5].checked==true;
		document.create_form.category[6].checked==true;
		document.create_form.category[7].checked==true;
		document.create_form.category[8].checked==true;
		return;
		}
	}



function edit() {
        var email = $('#email').attr('value');
		var fullname = $('#fullname').attr('value');

        $.ajax({

		url: "/learn_ci/index.php/settings/update",
		type: "POST",
		data: "Emailadresse="+email+"&Fuldenavn="+fullname,
		success: function(r)
		{
			$("#response").html(r);
			$("#response").slideDown("slow");
			
		}

		});
}

var message="Test";

function clickIE4(){

	if(event.button==2)
	{
		alert(message);
		return false;
	}

}

///////////////////////////////////Breakline/////////////////////////////////////

function createUser() {
        var email = $('#email').attr('value');
		var fullname = $('#fullname').attr('value');
		var password = $('#password').attr('value');
		var password2 = $('#password2').attr('value');
		
        $.ajax({

		url: "/learn_ci/index.php/createuser/insert",
		type: "POST",
		data: "Emailadresse="+email+"&Fuldenavn="+fullname+"&Adgangskode="+password+"&Adgangskode2="+password2,
		success: function(r)
		{
			$("#response").html(r);
			$("#response").slideDown("slow");
			
		}

		});
}




/*
$(document).ready(function() {

	
	 $(".contact").hide();
	  $(".tilbud").hide();
	 $(".drop select").change(function () {
     	
     	var option = $(this).val();
     	var banner_input = $(".contact");
     	
     	var tilbud = $(".tilbud");
     	if(option == 'tilbyder'){
     		$(tilbud).slideDown('slow');
     		$(".contact").hide();

     	}else if(option == 'search'){
     		$(".tilbud").hide();
     		$(banner_input).slideDown('slow');
     	}else{
     		$(banner_input).slideUp('slow');
     	}
     	
     }).change();
     
     $('#tabs').tabs();


});
*/

$(document).ready(function(){

	//Adjust panel height
	$.fn.adjustPanel = function(){ 
		$(this).find("ul, .subpanel").css({ 'height' : 'auto'}); //Reset subpanel and ul height
		
		var windowHeight = $(window).height(); //Get the height of the browser viewport
		var panelsub = $(this).find(".subpanel").height(); //Get the height of subpanel	
		var panelAdjust = windowHeight - 100; //Viewport height - 100px (Sets max height of subpanel)
		var ulAdjust =  panelAdjust - 25; //Calculate ul size after adjusting sub-panel (27px is the height of the base panel)
		
		if ( panelsub >= panelAdjust ) {	 //If subpanel is taller than max height...
			$(this).find(".subpanel").css({ 'height' : panelAdjust }); //Adjust subpanel to max height
			$(this).find("ul").css({ 'height' : ulAdjust}); //Adjust subpanel ul to new size
		}
		else if ( panelsub < panelAdjust ) { //If subpanel is smaller than max height...
			$(this).find("ul").css({ 'height' : 'auto'}); //Set subpanel ul to auto (default size)
		}
	};
	
	//Execute function on load
	$("#chatpanel").adjustPanel(); //Run the adjustPanel function on #chatpanel
	$("#alertpanel").adjustPanel(); //Run the adjustPanel function on #alertpanel
	
	//Each time the viewport is adjusted/resized, execute the function
	$(window).resize(function () { 
		$("#chatpanel").adjustPanel();
		$("#alertpanel").adjustPanel();
	});
	
	//Click event on Chat Panel + Alert Panel	
	$("#chatpanel a:first, #alertpanel a:first").click(function() { //If clicked on the first link of #chatpanel and #alertpanel...
		if($(this).next(".subpanel").is(':visible')){ //If subpanel is already active...
			$(this).next(".subpanel").hide(); //Hide active subpanel
			$("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger
		}
		else { //if subpanel is not active...
			$(".subpanel").hide(); //Hide all subpanels
			$(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
			$("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
			$(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
		}
		return false; //Prevent browser jump to link anchor
	});
	
	//Click event outside of subpanel
	$(document).click(function() { //Click anywhere and...
		$(".subpanel").hide(); //hide subpanel
		$("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
	});
	$('.subpanel ul').click(function(e) { 
		e.stopPropagation(); //Prevents the subpanel ul from closing on click
	});
	
	//Delete icons on Alert Panel
	$("#alertpanel li").hover(function() {
		$(this).find("a.delete").css({'visibility': 'visible'}); //Show delete icon on hover
	},function() {
		$(this).find("a.delete").css({'visibility': 'hidden'}); //Hide delete icon on hover out
	});





	
});



function show_confirm()
{
var r=confirm("Er du sikker på du vil slette din ven.?");
if (r==true)
  {
  return true;
  }
else
  {
   return false;
  }
}
