//<![CDATA[
/*==========================================================================# 
# * Function for adding a Filter to an Input Field                          # 
# * @param  : [filterType  ] Type of filter 0=>Alpha, 1=>Num, 2=>AlphaNum   # 
# * @param  : [evt         ] The Event Object                               # 
# * @param  : [allowDecimal] To allow Decimal Point set this to true        # 
# * @param  : [allowCustom ] Custom Characters that are to be allowed       # 
#==========================================================================*/ 
function filterInput(filterType, evt, allowDecimal, allowCustom){ 
    var keyCode, Char, inputField, filter = ''; 
    var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
    var num   = '0123456789'; 
    // Get the Key Code of the Key pressed if possible else - allow 
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
    }else if (evt)keyCode = evt.which; 
    else return true; 
    // Setup the allowed Character Set 
    if(filterType == 0) filter = alpha; 
    else if(filterType == 1) filter = num; 
    else if(filterType == 2) filter = alpha + num; 
    if(allowCustom)filter += allowCustom; 
    if(filter == '')return true; 
    // Get the Element that triggered the Event 
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; 
    // If the Key Pressed is a CTRL key like Esc, Enter etc - allow 
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
    // Get the Pressed Character 
    Char = String.fromCharCode(keyCode); 
    // If the Character is a number - allow 
    if((filter.indexOf(Char) > -1)) return true; 
    // Else if Decimal Point is allowed and the Character is '.' - allow 
    else if(filterType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)return true; 
    else return false; 
}
// centers an element passed to it in the center of the screen
// both horiztontally and vertically
function centerElement(element) {
	var obj = document.getElementById(element);
	var ypos = 0;
	var xpos = 0;
	if (window.pageYOffset) {
	 ypos = window.pageYOffset;
	 xpos = window.pageXOffset;
	}
	else {
	 ypos = document.documentElement.scrollTop;
	 xpos = document.documentElement.scrollLeft;
	}
	
	var frameWidth;
	var frameHeight;
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	obj.style.position = 'absolute';
	obj.style.display = "block";
	var top = ypos + (frameHeight/2) - (obj.offsetHeight/2);
	var left = xpos + (frameWidth/2) - (obj.offsetWidth/2);
	obj.style.top = top + "px";
	obj.style.left = left + "px";
}

//open new pop up
var WindowObjectReference; // global variable

function popupWindow(url, name, width, height, menu, toolbar, location, resizable, scrollbars, status)
{
  WindowObjectReference = window.open(url,
        name,
        "width="+width+",height="+height+",menu="+menu+",toolbar="+toolbar+",location="+location+",resizable="+resizable+",scrollbars="+scrollbars+",status="+status);
}

/*
//Article List Functions
function deleteArticle(theId) {
  if (confirm("Are you sure you want to delete this article?")==true)
	document.location = "process.php?remove=1&id=" + theId;
  else
    return false;
}
function activateArticle(theId, theOption) {
  document.location = "process.php?activate=1&id=" + theId + "&status=" + theOption;
}
function changeStatus(theId, theStatus) {
  document.location = "process.php?changestatus=1&id=" + theId + "&status=" + theStatus;	
}
function modifyArticle(theId) {
  document.location = "articleedit.php?modify=1&id=" + theId;	
}

//Article Editor Functions
function changeArticleType(content) {
	if(confirm("Are you sure you want to change the article type?\n\nDoing so will delete the contents of the current content type.")==true) 
		document.form1.contentchange.click();
	else {
		document.getElementById("content"+content).checked = true;
		return false;
	}
}
function checkNotUploadedBeforeSubmit() {
	if((document.form1.file.value != "") || (document.form1.downloadfile && document.form1.downloadfile.value != "")) {
		message =  "You have ";
		if(document.form1.file.value != "") {
			message += "an image ";
			singularOrPlural = "it";
			singularOrPlural2 = "field ";
			singularOrPlural3 = "path.";		
			image = true;
		} 
		else image = false;
		if(document.form1.downloadfile) {
			if(document.form1.downloadfile.value != "") {
				if(image) {
					message += "and ";
					singularOrPlural = "them";
					singularOrPlural2 = "fields ";
					singularOrPlural3 = "paths.";				
				}
				else {
					singularOrPlural = "it";
					singularOrPlural2 = "field ";
					singularOrPlural3 = "path.";		
				}
				message += "a file ";
			}
		}
		message += "path entered but have not uploaded " + singularOrPlural;
		message += ", are you sure you want to continue?\n\nDoing so will clear the " + singularOrPlural2;
		message += "of the chosen " + singularOrPlural3;
		if(confirm(message)==true) {
			document.form1.submit.click();
		}
		else return false;
}
	else document.form1.submit.click();
}

//Section List Functions
function deleteSection(theId) {
  if (confirm("Are you sure you want to delete this section?")==true)
	document.location = "sectionremove.php?remove=1&id=" + theId;
  else
    return false;
}

function modifySection(theId) {
  document.location = "sectionedit.php?modify=1&id=" + theId;	
}

//Team List Functions
function deleteTeam(theId) {
  if (confirm("Are you sure you want to delete this team?")==true)
	document.location = "teamremove.php?remove=1&id=" + theId;
  else
    return false;
}

function modifyTeam(theId) {
  document.location = "teamedit.php?modify=1&id=" + theId;	
}
*/
//User List Functions
function confirmAndRedirect(url, msg) {
  if (confirm(msg)==true) {
	  document.location = url;	  
	  return true;
  }
  else return false;
}

/*
//spotlight List Functions
function modifySpotlight(theId) {
  document.location = "spotlightedit.php?id=" + theId;	
}

//spotlight Edit Functions
function removeImage() {
  if (confirm("Are you sure you want to remove this image?\n\nThis will remove the image from the server, this cannot be cannot be undone!")==true)
	document.getElementById('removeimage').click();
  else return false;
}

//Gallery Category List Functions
function deleteCategory(theId) {
  if (confirm("Are you sure you want to delete this category?")==true)
	document.location = "categoryremove.php?remove=1&id=" + theId;
  else
    return false;
}

function modifyCategory(theId) {
  document.location = "categoryedit.php?modify=1&id=" + theId;	
}

function activateCategory(theId, theOption) {
  document.location = "categoryremove.php?activate=1&id=" + theId + "&status=" + theOption;
}

//Gallery Media List Functions
function deleteImage(theId) {
  if (confirm("Are you sure you want to delete this image?")==true)
	document.location = "mediaremove.php?image&remove=1&id=" + theId;
  else
    return false;
}

function deleteVideo(theId) {
  if (confirm("Are you sure you want to delete this video?")==true)
	document.location = "mediaremove.php?video&remove=1&id=" + theId;
  else
    return false;
}

//Menu Edit Functions
function changeEditItem(url) {
	document.form1.action = url + '?modify=1';
	document.getElementById('changeitem').click();
}

function deleteMenuItem(theId) {
  if (confirm("Are you sure you want to delete this menu item?\n\nThis will also delete all children of this item!")==true)
	document.getElementById('deleteitem').click();
  else
    return false;
}

function changeItemType() {
	obj = document.getElementById('menuURL');
	optionlist = document.getElementsByName('itemtype');
	br1 = document.getElementById('menuBR1');
	br2 = document.getElementById('menuBR2');
	if(optionlist[0].checked==true) {
		obj.style.display = "none";
		obj.value= "";
		br2.style.display = "none";
		br1.style.display = "none";

		obj.value = "";
	}
	else if(optionlist[1].checked==true) {
		obj.style.display = "";
		br2.style.display = "";
		br1.style.display = "";	
	}
}
*/
//]]>