﻿function getContent(a, b)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
   		{
    		document.getElementById("innerContent").innerHTML=xmlhttp.responseText;
			if (b == true)
			{
				tb_reinit('a.thickbox, area.thickbox, input.thickbox')
			}
		}
    }
 
	url =  "http://" + window.location.host + window.location.pathname + "/";
	switch(a)
	{
		case 1:
			xmlhttp.open("GET",url + "sites/start.txt",true);
			break;
		case 2:
			xmlhttp.open("GET",url + "sites/meny.txt",true);
			break;
		case 3:
			xmlhttp.open("GET",url + "sites/catering.txt",true);
			break;
		case 4:
			xmlhttp.open("GET",url + "sites/hittahit.txt",true);
			break;
		case 5:
			xmlhttp.open("GET",url + "sites/omoss.txt",true);
			break;
		case 6:
			xmlhttp.open("GET",url + "sites/skicka.txt",true);
			break;
		case 7:
			xmlhttp.open("GET",url + "sites/foretag.txt",true);
			break;
		case 8:
			xmlhttp.open("GET",url + "sites/vartkaffe.txt",true);
			break;
		case 9:
			xmlhttp.open("GET",url + "sites/shop.txt",true);
			break;
	}
	xmlhttp.send();
	shop();
}

function apply()
{
  document.sendMail.sub.disabled=true;
  if(document.sendMail.chk.checked==true)
  {
    document.sendMail.sub.disabled=false;
  }
  if(document.sendMail.chk.checked==false)
  {
    document.sendMail.sub.enabled=false;
  }
}

function validateForm()
{
  var x=document.forms["sendMail"]["namn"].value
  if (x==null || x=="")
  {
    alert("Du måste ange fylla i ett namn");
    return false;
  }
  
  var y=document.forms["sendMail"]["epost"].value
  var atpos=y.indexOf("@");
  var dotpos=y.lastIndexOf(".");
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=y.length)
  {
    alert("Du måste ange en giltig e-postadress");
    return false;
  }
}

function ReplaceContentInContainer(id,content) 
{
	var container = document.getElementById(id);
	container.innerHTML = content;
}

function shop() {
	$('.accordionButton').click(function() {
		$('.accordionButton').removeClass('on');
 	 	$('.accordionContent').slideUp('normal');
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('on');
			$(this).next().slideDown('normal');
		 } 		  
	 });
	$('.accordionButton').mouseover(function() {
		$(this).addClass('over');
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	$('.accordionContent').hide();
};

function shop2() {
	// Hide all the content except the first
	$('.accordian li:odd:gt(0)').hide();
	
	// Add a padding to the first link
	$('.accordian li:first').animate( {
		paddingLeft:"30px"
	} );
	
	// Add the dimension class to all the content
	$('.accordian li:odd').addClass('dimension');
	
	// Set the even links with an 'even' class
	$('.accordian li:even:even').addClass('even');
	
	// Set the odd links with a 'odd' class
	$('.accordian li:even:odd').addClass('odd');
	
	// Show the correct cursor for the links
	$('.accordian li:even').css('cursor', 'pointer');
	
	// Handle the click event
	$('.accordian li:even').click( function() {
		// Get the content that needs to be shown
		var cur = $(this).next();
		
		// Get the content that needs to be hidden
		var old = $('.accordian li:odd:visible');
		
		// Make sure the content that needs to be shown 
		// isn't already visible
		if ( cur.is(':visible') )
			return false;
		
		// Hide the old content
		old.slideToggle(500);
		
		// Show the new content
		cur.stop().slideToggle(500);
		
		// Animate (add) the padding in the new link
		$(this).stop().animate( {
			paddingLeft:"30px"
		} );
		
		// Animate (remove) the padding in the old link
		old.prev().stop().animate( {
			paddingLeft:"10px"
		} );
	} );
}
