function hideAll(currCont) {
	if(currCont != 'PagesList') { document.getElementById('PagesList').style.visibility = 'hidden'; }
}
function showDropdown(name) {
	var visi = document.getElementById(name);
	hideAll(name);
	if(visi.style.visibility == 'visible') {
		visi.style.visibility = 'hidden';
	} else {
		visi.style.visibility = 'visible';
	}
	return false;
}
function CloseDropDown(name) {
	var visi = document.getElementById(name);
	visi.style.visibility = 'hidden';
	return false;
}
function cCategorySelector_Select(pagename) {
	var cCategorySelector = document.forms[0].cCategorySelector;
	var destination = cCategorySelector.options[cCategorySelector.selectedIndex].value;
	if (destination) {
		location.href = pagename + "?catID=" + destination;
	}
}

// SELECTIR SCRIIPT //
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function runSubmit (form)  {
	var tmpID = "";
	for (var i = 0; i < document.forms[0].PromotionOffice2.options.length; i++) {
		tmpID += document.forms[0].PromotionOffice2.options[i].value.toString()+"|";
	}
	document.forms[0].PromotionOffice.value=tmpID;
// JJ - taken out as it did not work using netscape or FF on the Mac
//		document.forms[0].submit();
	return;
}
function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}
function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0) { theSel.options[theIndex] = null; } 
}

function moveAllOptions(theSelFrom, theSelTo)
{
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  var i;
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
	  selectedText[selectedCount] = theSelFrom.options[i].text;
	  selectedValues[selectedCount] = theSelFrom.options[i].value;
	  deleteOption(theSelFrom, i);
	  selectedCount++;
  }
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
	addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  if(NS4) history.go(0);
}

function moveOptions(theSelFrom, theSelTo)
{
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  var i;
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
	if(theSelFrom.options[i].selected)
	{
	  selectedText[selectedCount] = theSelFrom.options[i].text;
	  selectedValues[selectedCount] = theSelFrom.options[i].value;
	  deleteOption(theSelFrom, i);
	  selectedCount++;
	}
  }
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
	addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  if(NS4) history.go(0);
  theSelFrom.focus();
}

// Image controllers
var currentID = 0;
var offID = 0;
function viewUpload (divID) {document.getElementById(divID).style.visibility='visible';}
function hideUpload (divID) {document.getElementById(divID).style.visibility='hidden';}
function setImageID(ImgID, OfficeID){
	currentID = ImgID;
	offID = OfficeID;		
}
function changeImage(img_src, ImgID, ItemsID) {	
	document.getElementById('mainPic').src = img_src; document.getElementById('btnViewFullsize').href = img_src; 
	currentID = ImgID; offID = ItemsID;		
}
function changeCaption(picCaption) { document.getElementById('mainCaption').innerHTML = picCaption; }
function runDeleteBtn() {		document.form1.action='officeImageRoutines.asp?action=deleteImage&OfficeID='+offID+'&GeneralImageID='+currentID;
	document.form1.submit();
}
function confirmMsg(targetPage,msg) {
	if (confirm(msg)) {
		window.location.href=targetPage;
	}
}
function isNull(val){return(val==null);}
function reasonToAmend(targetForm) {
	AmendReason = (prompt("Please enter the reason that you wish to amend this office.", ""));
	targetForm.AmendReason.value = AmendReason;
	if (AmendReason == null) {
	} else if (AmendReason != '' && AmendReason != null) {
		runSubmit(targetForm);
	} else {
		alert ("To amend the item you have to enter a valid reason."); 
		reasonToAmend(targetForm)
	}
}
function hideAll(currCont) {
	if(currCont != 'PagesList') { document.getElementById('PagesList').style.visibility = 'hidden'; }
}
function showDropdown(name) {
	var visi = document.getElementById(name);
	hideAll(name);
	if(visi.style.visibility == 'visible') {
		visi.style.visibility = 'hidden';
	} else {
		visi.style.visibility = 'visible';
	}
	return false;
}
function CloseDropDown(name) {
	var visi = document.getElementById(name);
	visi.style.visibility = 'hidden';
	return false;
}