// JavaScript Document

function editPage(id)
{
	document.getElementById('pageid').value=id;
	document.getElementById('pageimageid').value=-1;
	document.admin.submit();
}

function editImages(id)
{
	document.getElementById('pageid').value=0;
	document.getElementById('pageimageid').value=id;
	document.admin.submit();
}

///////////////////////////////////////////////////
////////Trying To Figure Out How This Works////////
///////////////////////////////////////////////////

/*function editKeywords(id)
{
	document.getElementById('pageid').value=id;
	document.getElementById('keywords').value=id;
	document.admin.submit();
}*/

function getSourcePara()
{
	el = event.srcElement;
	while( el.tagName != "P" ) 
	{
		el = el.parentNode;
	}
	return el;
}

function selectParagraph()
{
	els = document.getElementsByTagName("P");
	for( i=0; i<els.length; i++ )
		els[i].className = els[i].className.replace('AdminBorderSelected','AdminBorder');
	
	el = getSourcePara();
//	document.getElementById('Debug').innerHTML = el.id;
	el.className = el.className.replace('AdminBorder','AdminBorderSelected');
	document.admin.paraid.value=el.id;
}

function saveKeywords()
{
	document.admin.command.value="savekeywords";
	document.admin.submit();
}

function saveGlobals()
{
	document.admin.command.value="saveglobals";
	document.admin.submit();
}

function moveLeft()
{
	document.admin.command.value="moveleft";
	document.admin.submit();
}

function moveRight()
{
	document.admin.command.value="moveright";
	document.admin.submit();
}

function moveUp()
{
	document.admin.command.value="moveup";
	document.admin.submit();
}

function moveDown()
{
	document.admin.command.value="movedown";
	document.admin.submit();
}

function addPara()
{
	
}

function editPara()
{
}

function deletePara()
{
	if( confirm("Are you sure you wish to delete this item?") )
	{
		document.admin.command.value="delete";
		document.admin.submit();
	}
}

function showDialog(id)
{
	el = document.getElementById(id);
	if( el ) 
	{
		el.style.display = 'block';
		document.admin.command.value = id;
		el = document.getElementById('DialogMask');
		if( el ) 
			el.style.display = 'block';
	}
}

function hideDialog(id)
{
	el = document.getElementById(id);
	if( el ) 
	{
		el.style.display = 'none';
		document.admin.command.value = id;
		el = document.getElementById('DialogMask');
		if( el ) 
			el.style.display = 'none';
	}
}

function removePage(id)
{
	if( confirm("Are you sure you wish to delete this page?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removepage";
		document.admin.submit();
	}
}

function removePicture(id)
{
	if( confirm("Are you sure you wish to delete this picture?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removepicture";
		document.admin.submit();
	}
}

function removeBannerImage(id)
{
	if( confirm("Are you sure you wish to delete this banner image?") )
	{
		document.admin.pageimageid.value = id;
		document.admin.command.value="removebannerimage";
		document.admin.submit();
	}
}
function removeDocument(id)
{
	if( confirm("Are you sure you wish to delete this document?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removedocument";
		document.admin.submit();
	}
}

function removeEvent(id)
{
	if( confirm("Are you sure you wish to delete this event?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removeevent";
		document.admin.submit();
	}
}

function removeCategory(id)
{
	if( confirm("Are you sure you wish to delete this category?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removecategory";
		document.admin.submit();
	}
}

function removeForm(id)
{
	if( confirm("Are you sure you wish to delete this contact form?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removeform";
		document.admin.submit();
	}
}

function removeProduct(id)
{
	if( confirm("Are you sure you wish to delete this product?") )
	{
		document.admin.pageid.value = id;
		document.admin.command.value="removeproduct";
		document.admin.submit();
	}
}

function ShowTab(name)
{
	els = document.getElementsByTagName("DIV");
	for( i=0; i<els.length; i++ )
	{
		if( els[i].id.substring(0,4) == "TAB_" )
		{
			if( els[i].id == "TAB_"+name ) els[i].style.display = "block";
			else els[i].style.display = "none";
		}
	}
	
	els = document.getElementsByTagName("A");
	for( i=0; i<els.length; i++ )
	{
		if( els[i].id.substring(0,4) == "TAB_" )
		{
			if( els[i].id == "TAB_"+name ) els[i].className = "TabSelector_Selected";
			else els[i].className = "TabSelector";
		}
	}
}

function ChangeDialogImage(selectorid)
{
	elimg = document.getElementById('DialogImage');
	elsel = document.getElementById(selectorid);
	
	if( elimg && elsel ) 
		elimg.src = "image.php?thumb="+elsel.value;
}

function showinserttextrows()
{
	el = document.getElementById('type');
	if(el)
	{
		elURL = document.getElementById('urlrow');
		if( el.value == "hyperlink" ) {
			if( elURL ) elURL.style.display = 'block';
		}
		else {
			if( elURL ) elURL.style.display = 'none';
		}
	}
}