/***** editor functions *****/

function setTemplate(data) {
	if (CKEDITOR.instances.advertisement_content.checkDirty()) {
		if (!confirm('Loading the template will cause the current text in the editor be replaced! Do you wish to continue?')) {
			document.getElementById("template").value = "";
			return;
		}
	}
	CKEDITOR.instances.advertisement_content.setData(data);
}

function navHover(elem, imageName) {
	img = new Image();
	path = elem.src.substr(0, elem.src.lastIndexOf('/')) + '/';
	suffix = elem.src.substr(elem.src.lastIndexOf('.'));
	img.src = path + imageName + suffix;
	elem.src = img.src;
	
}

function swap(id1)
{
  if (document.getElementById(id1).style.display != 'none')
    document.getElementById(id1).style.display = 'none';
  else 
    document.getElementById(id1).style.display = 'block';
}

function swap2(id1)
{
  document.getElementById(id1).disabled = !document.getElementById(id1).disabled;
}

function selectFirst(id1)
{
  document.getElementById(id1).selectedIndex = 0;
}

function checkAll(field)
{
  for (i = 0; i < field.length; i++)
    field[i].checked = true ;
}

function uncheckAll(field)
{
  for (i = 0; i < field.length; i++)
    field[i].checked = false ;
}

function clearText(field)
{
	if (field.style.color != "") {
		field.style.color = "";
		field.value = "";
	}
}

