/*
   Deletes the selected comment	 
 */
function del(id, lid) {
  if ( window.confirm("Are you sure you want to Remove this Entry?") ) {
			window.location.href = "deletecomment.php?id="+id+"&lid="+lid 
	} // Yes remove
} // del

/*
   Deletes the selected entry	 
 */
function delBlog(id) {
  if ( window.confirm("Are you sure you want to Remove this Entry?") ) {
			window.location.href = "deleteblog.php?id="+id 
	} // Yes remove
} // del

/*
   Updates the "Mood" image dynamcially based on what is selected.	 
 */
function updateImage(myImage,id,loc){
	document.getElementById(id).innerHTML = "<img src='../" + loc + "/" + myImage.value + ".gif' border='0'>";
} // updateImage

/*
   Inserts a selected BBCode command in the comment field	 
 */
function insertBBCode(myCode){
	curPos = document.selection.createRange().duplicate();	
	if ( curPos.text == "" ) {
		blSelected = false;
	} // no text selected
	
	if ( myCode == "B" ) {

	 if ( !blSelected ) {
	 	var myText = prompt("Text to be shown in BOLD",'');
	  if ( myText ) {
			document.getElementById('sub_content').value=document.getElementById('sub_content').value + " [B]" + myText + "[/B]";
		} // text given
	 } else {
  	curPos.text="[B]" + curPos.text + "[/B]";
	 } // Highlight selected
	 
	} // Bold
	
	if ( myCode == "I" ) {

	 if ( !blSelected ) {
	 	var myText = prompt("Text to be shown in ITALIC",'');
	  if ( myText ) {
			document.getElementById('sub_content').value=document.getElementById('sub_content').value + " [I]" + myText + "[/I]";
		} // text given
	 } else {
  	curPos.text="[I]" + curPos.text + "[/I]";
	 } // Highlight selected
	 
	} // Italic
	
	if ( myCode == "U" ) {

	 if ( !blSelected ) {
	 	var myText = prompt("Text to be shown UNDERLINED",'');
	  if ( myText ) {
			document.getElementById('sub_content').value=document.getElementById('sub_content').value + " [U]" + myText + "[/U]";
		} // text given
	 } else {
  	curPos.text="[U]" + curPos.text + "[/U]";
	 } // Highlight selected
	 
	} // Underline

	if ( myCode == "url" ) {

	 	var myText = prompt("Text for this URL");
		var myLink = prompt("URL","http://");
	  if ( myText && myLink ) {
			document.getElementById('sub_content').value=document.getElementById('sub_content').value + " [url=" + myLink + "]" + myText + "[/url]";
		} // text and link given given
	 
	} // url
	
	if ( myCode == "img" ) {

	 	var myLink = prompt("Image link","http://");
	  if ( myLink ) {
			document.getElementById('sub_content').value=document.getElementById('sub_content').value + " [img]" + myLink + "[/img]";
		} // text and link given given
	 
	} // img

	if (myCode == "flash") {
    var myLink   = prompt("Enter the flash file URL", "http://");
    var flashWidth = prompt("Enter the flash width", "250");
    var flashHeight = prompt("Enter the flash height", "250");
    if ( myLink && flashWidth && flashHeight ) {
      document.getElementById('sub_content').value=document.getElementById('sub_content').value + "[flash width="+flashWidth+" height="+flashHeight+" "+myLink+" "+myLink+" width="+flashWidth+" height="+flashHeight+"[/flash]";
    } // link width and height given
  } // flash
    
} // insertBBCode

/*
 * Loads a page into the iframe on the edit or add blog pages
*/
function loadPage(myPage) {
	document.getElementById('filemod').src=myPage;
	if ( myPage == "addfile.php" ) {
		document.getElementById('filemod').scrolling="No";
	} else {
		document.getElementById('filemod').scrolling="Auto";
	}
} // loadPage

/*
 * Delete the file
*/
function deleteFile(myPage) {
  myLink = "deletefile.php?file="+myPage;  
  
	location.href=myLink;
} // deleteFile