// Þetta er fall til að skipta út myndum og dropa niður í left_menu
var STR_ENTER_USERNAME= "Sláðu inn notendanafn";
var STR_ENTER_PASSWORD= "Sláðu inn lykilorð";
var B_CONTENT_HAS_CHANGED =false;

function hasChanged()
{
	B_CONTENT_HAS_CHANGED = true;
	alert(true);
}


function HideShow(ID,ImageName)
{

	var image = "";
	document.all[ID].style.display  = (document.all[ID].style.display == "block") ? "none" : "block" ;
	image = (document.all[ID].style.display == "block") ? "or_upp.gif" : "or_nidur.gif";
	document.images[ImageName].src = "/admin/images/" + image;

}
function LeftHideShowOperations( ID, ImageName )
{
	var image = "";
	document.all[ID].style.display  = (document.all[ID].style.display == "block") ? "none" : "block" ;
	image = (document.all[ID].style.display == "block") ? "xpmenu_or_up2.gif" : "xpmenu_or_down2.gif";
	document.images[ImageName].src = "/admin/images/" + image;
	
	var strState = document.all[ID].style.display;
	document.cookie = ID + "=" +strState;
}
function LeftHideShow(ID,ImageName)
{
	var image = "";
	document.all[ID].style.display  = (document.all[ID].style.display == "block") ? "none" : "block" ;
	image = (document.all[ID].style.display == "block") ? "litil_or_upp.gif" : "litil_or_nidur.gif";
	document.images[ImageName].src = "/admin/images/" + image;
	
	var strState = document.all[ID].style.display;
	document.cookie = ID + "=" +strState;
}

function HideShowForm(ID,ImageName)
{

	var image = "";
	document.all[ID].style.display  = (document.all[ID].style.display == "block") ? "none" : "block" ;
	image = (document.all[ID].style.display == "block") ? "../../images/or_upp.gif" : "../../images/or_nidur.gif";
	document.images[ImageName].src = "/admin/images/" + image;
	//alert ("bIsHidden = " +bIsHidden);
	bIsHidden = (document.all[ID].style.display == "block") ? false : true ;
	//alert("breytti bIsHidden í " +bIsHidden);
}


function checkAuthenticationForm()
{
  if(document.loginAuthenticationForm.Username.value =="" )
  {
		
    alert(STR_ENTER_USERNAME);
    return false;
  }
  if(document.loginAuthenticationForm.Password.value =="")
  {
    alert(STR_ENTER_PASSWORD);
    return false;
  }	
return true;
}
function moveSelection(source, destination)
{
	if (source.selectedIndex < 0) 
	{
		return;
	}
	addOption(source, destination)
	deleteOption(source);
	if(source.length != 0)
	{
		source.selectedIndex = 0;
	}
}

function deleteOption(selectbox) 
{
    var Current = selectbox.selectedIndex;
    selectbox.options[Current] = null;
}
function addOption(source, destination) 
{
    var defaultSelected = false;
    var selected = false;
    var Current = source.selectedIndex
    var optionName = new Option(source.options[Current].text, source.options[Current].value, defaultSelected, selected)
    var length = destination.length;
    destination.options[length] = optionName;
}
function selectall(form) 
{
    for(var i = 0; i < form.front_out.length; i++)
    {
    	form.front_out.options[i].selected = true;
    }
    for(var i = 0; i < form.front_in.length; i++)
    {
    	form.front_in.options[i].selected = true;
    }
    for(var i = 0; i < form.back_in.length; i++)
    {
    	form.back_in.options[i].selected = true;
    }
    for(var i = 0; i < form.back_out.length; i++)
    {
    	form.back_out.options[i].selected = true;
    }
}
function checkEmpty(source, destination, movebutton, otherbutton)
{
	if(source.length == 0 ) 
	{
		movebutton.disabled = true;
	}
	if(destination.length != 0)
	{
		otherbutton.disabled= false;
	}
}
function checkForm(form)
{
	
	if (document.theForm.strCategoryName.value=="")
	{
		alert("Vinsamlegast sláið inn nafn fréttarflokks.")
		document.theForm.strCategoryName.focus();
		return false;
	}
	if(document.theForm.nCategoryDisplayCount.value == "") 
	{
		alert("Vinsamlega sláið inn fjölda færslna á forsíðu");
		document.theForm.nCategoryDisplayCount.focus();
		return false;
	}
	if (isNaN ( parseInt(document.theForm.nCategoryDisplayCount.value) ) )
	{
		alert("Vinsamlegast sláið inn fjölda færslna á forsíðu í tölustöfum")
		document.theForm.nCategoryDisplayCount.focus();
		return false;
	}
	if( !(document.theForm.nCategoryDisplayCount.value > 0) )
	{
			alert("Athugið að fjölda færslna á forsíðu þarf að vera jákvæð heiltala.");
			document.theForm.nCategoryDisplayCount.focus();
			return false;
	}
	if (document.theForm.front_in.length== 0 )
	{
		alert("Vinsamlegast veljið svæði sem birtast eiga á forsíðu.")
		return false;
	}
	if (document.theForm.back_in.length== 0)
	{
		if(confirm ('Athugið að ef ekkert svæði er valið í nánar síðuna þá mun nánar hlekkur ekki birtast.'))
			return true;
		else
			return false;
	}
		
	return true;
}

