var SelectedGroup = null;
function GroupHover(obj)
{
    if(obj == SelectedGroup)
	    obj.className = "GroupHover";
    else
	    obj.className = "GroupHover";
}
function GroupOut(obj)
{	
    if(obj == SelectedGroup)
	    obj.className = "GroupHover";
    else
	    obj.className = "Group";
}
function GroupClick(obj)
{	
    if(SelectedGroup != null)
	    SelectedGroup.className = "Group";

    obj.className = "GroupHover";
    ShowGroup(obj);
    SetCookie("LastGroup", obj.id);
    SelectedGroup = obj;
}
function SetCookie(name, value)
{
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
	    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	    ((path == null) ? "" : ("; path=" + path)) +
	    ((domain == null) ? "" : ("; domain=" + domain)) +
	    ((secure == true) ? "; secure" : "");
}
function GetCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
	    var j = i + alen;
	    if (document.cookie.substring(i, j) == arg)
	    return GetCookieVal (j);
	    i = document.cookie.indexOf(" ", i) + 1;
	    if (i == 0) break; 
    }
    return null;
}
function GetCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
	    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
function ShowGroup(obj)
{
    if(SelectedGroup != null)
    {
	    document.getElementById(SelectedGroup.id + "Items").style.display = "none";
    }
    document.getElementById(obj.id + "Items").style.display = "";
}
function Start()
{
    var LastGroup = GetCookie("LastGroup");
    if (LastGroup != null)
        GroupClick(document.getElementById(LastGroup));
    else
        GroupClick(document.getElementById("Group0"));
}
function ValidateForm()
{
    var NameBox = document.getElementById('ctl00_ContentPlaceHolder1_Name');
    var Address1Box = document.getElementById('ctl00_ContentPlaceHolder1_Address1');
    var PostCodeBox = document.getElementById('ctl00_ContentPlaceHolder1_PostCode');
    var CityBox = document.getElementById('ctl00_ContentPlaceHolder1_City');
    var EmailBox = document.getElementById('ctl00_ContentPlaceHolder1_Email');
    
    var retValue = true;
    retValue = ValidateField(NameBox, "Navn");
    
    if (retValue)
        retValue = ValidateField(Address1Box, "Adresse 1");
    if (retValue)
        retValue = ValidateField(PostCodeBox, "Post nr");
    if (retValue)
        retValue = ValidateField(CityBox, "By");
    if (retValue)
        retValue = ValidateField(EmailBox, "E-mail");
    
    return retValue;
}
function ValidateField(Field, Name)
{
    if(Field.value == "")
    {
        alert("Du skal udfylde " + Name);
        Field.focus();
        return false;
    }
    return true;
}
