<!--
var vbold = 0;
var vitalic = 0;
var vunderline = 0;
var vcenter = 0;
var vurl = 0;
var vimage = 0;
var vquote = 0;
var vstrikethru = 0;
var vlist = 0;
var vlistitem = 0;

function SetUserOptions(sBlogID, sScreen)
{
	var name = "UserOptions"; // popup name
	var width = "360"; // popup width
	var height = "500"; // popup height
	var left = (screen.width - width) / 2 ;
	var top = (screen.height - height) / 2;
	var windowproperties = "fullscreen=0,scrollbars=0,toolbar=0,menubar=0,status=0,location=0,directories=0";
	newwin = window.open("UserOptions.php", name, windowproperties);
	newwin.resizeTo(width, height);
	newwin.moveTo(left, top);

    //window.open("UserOptions.php","User_Options","width=360,height=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
}

function DisplayResults(sForm, sTitle, sMsg)
{
	var sName = sTitle; // popup name
	var nWidth = "750"; // popup width
	var nHeight = "275"; // popup height
	var nLeft = (screen.width - nWidth) / 2 ;
	var nTop = (screen.height - nHeight) / 2;
	var windowproperties = "fullscreen=0,scrollbars=0,toolbar=0,menubar=0,status=0,location=0,directories=0";
	var sURL = sForm + "?Act=" + sMsg;
	newwin = window.open(sURL, sName, windowproperties);
	newwin.resizeTo(nWidth, nHeight);
	newwin.moveTo(nLeft, nTop);
}

function TwitterPop(sBlogID)
{
	var sName = "TwitterSubmitter"; // popup name
	var nWidth = "750"; // popup width
	var nHeight = "275"; // popup height
	var nLeft = (screen.width - nWidth) / 2 ;
	var nTop = (screen.height - nHeight) / 2;
	var windowproperties = "fullscreen=0,scrollbars=0,toolbar=0,menubar=0,status=0,location=0,directories=0";
	var sURL = "http://www.FourFreedomsBlog.com/Twitter.php?ID=" + sBlogID;
	newwin = window.open(sURL, sName, windowproperties);
	newwin.resizeTo(nWidth, nHeight);
	newwin.moveTo(nLeft, nTop);
}

function emo_pop()
{
    window.open("emoticons.php","Blog_Emoticons","width=250,height=500,resizable=yes,scrollbars=yes");
}

function sound_pop()
{
    window.open("sounds.php","AudiCons","width=500,height=500,resizable=yes,scrollbars=yes"); 
}

function InsertSmilie(Smilie)
{
    var txtarea = document.getElementById('MainEdit');
    var SmileCode = "";
    SmileCode = Smilie;
    txtarea.value=txtarea.value+" "+SmileCode+" ";
    txtarea.focus();
}

function FormatText(el,tagstart,tagend,btnFormat)
{
    var bAddCodes = 0;
    var newText = "";

    if (el.createTextRange)
    {
        // IE code here...
        var selectedText = document.selection.createRange().text; 
        
        if (selectedText == "")
	   {           
            bAddCodes=1;
	   }
        else
        {
            if (tagstart == "[url]")
            {       
                url = prompt("Enter the link URL", "http://");
	           if((url == '') || (url == null))
	           {
	                return;
	           }
	           else            
                {
                    newText = '[url="'+ url +'"]'+ selectedText + '[/url]'; 
                    document.selection.createRange().text = newText; 
                }
	        }
	        else
	        {
	            newText = tagstart + selectedText + tagend; 
                document.selection.createRange().text = newText;
	        } 
        }
    }
	else
    {
	    // Non-IE...
        var startPos = el.selectionStart;
        var endPos = el.selectionEnd;
	    if (startPos == endPos)
	   {
	        bAddCodes = 1;
	   }
       else
	   {
	        var selectedText = el.value.substring(startPos,endPos);
            if (tagstart == "[url]")
            {       
                url = prompt("Enter the link URL", "http://");
	           if((url == '') || (url == null))
	           {
	                return;
	           }
	           else            
                {
                    newText = '[url="'+ url +'"]'+ selectedText + '[/url]'; 
	               el.value = el.value.substring(0,startPos) + newText + el.value.substring(endPos,el.value.length);               
	            }
	       }
	        else
	        {
	           el.value = el.value.substring(0,startPos) + tagstart + selectedText + tagend + el.value.substring(endPos,el.value.length);
	        } 
       }
    }
	 

    if (bAddCodes==1)
    {
	    FormatButton(tagstart,btnFormat,el);
    }
}

function FormatButton(sTag,btnFormat, el)
{
    var BName = "";
    var url = "";
    var title = "";

    if (sTag == "[b]")
        vbold=InsertFormatText("b",vbold,btnFormat,el);
    if (sTag == "[u]")
        vunderline=InsertFormatText("u",vunderline,btnFormat,el);
    if (sTag == "[i]")
        vitalic=InsertFormatText("i",vitalic,btnFormat,el);
    if (sTag == "[s]")
        vstrikethru=InsertFormatText("s",vstrikethru,btnFormat,el);
    if (sTag == "[c]")
        vcenter=InsertFormatText("c",vcenter,btnFormat,el);
    if (sTag == "[ulist]")
        vlist=InsertFormatText("ulist",vlist,btnFormat,el);
    if (sTag == "[olist]")
        vlist=InsertFormatText("olist",vlist,btnFormat,el);
    if (sTag == "[li]")
        vlistitem=InsertFormatText("li",vlistitem,btnFormat,el);
    if (sTag == "[Quote]")
        vquote=InsertFormatText("Quote",vquote,btnFormat,el);
    if (sTag == "[url]")
        {
	   url = prompt("Enter the link URL", "http://");
	   if((url == '') || (url == null))
	       return;
	   else            
	       {
	       title = prompt("Enter the text you want displayed:", "");
	       if((title == '') || (title == null))
	           return;
	       else
	           url = '[url="'+ url +'"]'+ title + '[/url]';
            }
       InsertFormatURL(url,el);
       }
    if (sTag == "[img]")
        {
	   url = prompt("Enter the URL for the image:", "http://");
	   if((url == '') || (url == null))           
	       return;
	   else
	       {
	       url="[img]"+url+"[/img]";           
            InsertFormatURL(url,el);
            }
        }
    
    if (sTag == "[YouTube]")
        {
	   url = prompt("Enter the complete URL for the YouTube video:", "http://");
	   if((url == '') || (url == null))           
	       return;
	   else
	       {
	       url="[YouTube]"+url+"[/YouTube]";           
            InsertFormatURL(url,el);
            }
        }

    if (sTag == "[FlashVid]")
        {
	   url = prompt("Enter the complete URL for the video:", "http://");
	   if((url == '') || (url == null))           
	       return;
	   else
	       {
	       url="[FlashVid]"+url+"[/FlashVid]";           
            InsertFormatURL(url,el);
            }
        }
}

function InsertFormatText(textvalue, textflag, formatbutton,el)
{
    var txtarea = el;
    var BText = formatbutton.value;

    if (textflag==0)
    {
        txtarea.value=txtarea.value+"["+textvalue+"]";
        textflag=1;
        BText = BText + "*";
    }
    else
    {
        txtarea.value=txtarea.value+"[/"+textvalue+"]";
        textflag=0;
        BText = BText.substring(0,BText.length-1);
    }
    
    formatbutton.value=BText;
    txtarea.focus();
    return(textflag);
}

function InsertFormatURL(textvalue,el)
{
    var txtarea = el;
    
    txtarea.value=txtarea.value+textvalue;
    txtarea.focus();

}

function SetCommentsControls()
{
    if (document.UserOptions.ShowComments.checked)
        {
        document.UserOptions.NumOfComments[0].disabled=false;
        document.UserOptions.NumOfComments[1].disabled=false;
        document.UserOptions.TotComments.disabled=false;
        document.UserOptions.NumOfComments[1].checked=true;
        }
    else
        {
        document.UserOptions.NumOfComments[0].disabled=true;
        document.UserOptions.NumOfComments[1].disabled=true;
        document.UserOptions.TotComments.disabled=true;
        }
}
    
function DelComment(sBlogID, sCommentID, sHide)
{

   var sURL = "Blog.php?Act=DeleteComment&BlogID=" + sBlogID + "&CommentID=" + sCommentID + "&Hide=" + sHide;
	
    // redirect to screen to confirm delete
    window.location = sURL;
	
}

function EditComment(sBlogID, sCommentID, sHide)
{

   var sURL = "Blog.php?Act=EditComment&BlogID=" + sBlogID + "&CommentID=" + sCommentID + "&Hide=" + sHide;

    // redirect to screen to confirm delete
    window.location = sURL;
	
}

function InsertFold()
{
 	var txtarea = document.EditArea.MainEdit;
    var sFoldCode = "###FOLD###";

    var newText = "";
	txtarea.focus()
    if (txtarea.createTextRange)
    {
        // IE code here...
        document.selection.createRange().text = sFoldCode; 
    }
	else
    {
	    // Non-IE...
        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd;
	    txtarea.value = txtarea.value.substring(0,startPos) + sFoldCode + txtarea.value.substring(endPos,txtarea.value.length);
    }

    txtarea.focus();
}

function ToggleSettings()
{
 	var oFlag = document.getElementById('ShowOptions');
	if (oFlag.value == "1")
	   oFlag.value = "0";
	else
	   oFlag.value = "1";
	   
	document.UserOptions.submit();
	
}

function VerifyValues()
{
 	var e1 = document.getElementById('MainEdit').value;
	if (e1 == "")
	   return false;
	else 
		 document.getElementById('submit').disabled=true;
}

function SearchUpdate()
{
 	var e1 = document.getElementById('SearchVal').value;
	if (e1 == "")
	   return false;
	else 
		 document.getElementById('submit').disabled=true;
}

function AddTZOffset()
{
 	var d = new Date()
	var nOffset = d.getTimezoneOffset();
 	var aDates = document.getElementsByTagName("SPAN");
	var dNewDate = new Date();
	var nSeconds = (nOffset * 60 * 1000);
	
	for (var i=0;i<document.anchors.length;i++)
  	{ 
  	  	if (document.anchors[i].name=="Comments")
		{
		    document.anchors[i].href = document.anchors[i].href + "&TZOffset=" + nOffset;
		} 
	}

	var formatOpt = 0;
	try
	{
	    formatOpt = document.getElementById("TimeFormat").value;
	}
	catch(er)
	{
		 ;
	}

	for (var i=0;i<aDates.length;i++)
  	{
	    sDate = aDates[i].innerHTML;
		nDate = Date.parse(sDate);
		nDate = nDate - nSeconds;
		dNewDate.setTime(nDate);
		/*
		nHrs = dNewDate.getHours()
		if (formatOpt==0)
		{
		   	if (nHrs < 12)
		        sAMPM = " AM";
			else
			{
		 	 	sAMPM = " PM";
				nHrs = nHrs - 12;
				if (nHrs == 0) nHrs = 12;
			}
		}
		else
			sAMPM = "";

		sDate = '' + (dNewDate.getMonth()+1)+'/'+dNewDate.getDate()+'/'+dNewDate.getFullYear()+' '+nHrs+':'+dNewDate.getMinutes()+':'+dNewDate.getSeconds()+sAMPM;
		*/
		if (formatOpt==0)
			sDate = DateToString(dNewDate, true);
		else
			sDate = DateToString(dNewDate, false);
		aDates[i].innerHTML = sDate;
  	}
}

function UpdateDocument()
{
 	AddTZOffset();
 	//sBlogName = document.getElementById("BlogTitle").value;
	//document.title = "FourFreedoms Blog - " + sBlogName;
}

function VerifyPswdValues()
{
 	var sOldPswd = document.getElementById('OldPswd').value;
	var sPswd1 = document.getElementById('Pswd').value;
	var sPswd2 = document.getElementById('PswdC').value;

	if (sOldPswd == "")
	   {	  
	   alert('Old password value not supplied!');
	   return false;
	   }
	
	if (sPswd1 == "")
	   {	  
	   alert('New Password value not supplied!');
	   return false;
	   }
	if (sPswd2 == "")
	   {	  
	   alert('Confirmation password not supplied!');
	   return false;
	   }
	if (sPswd1 != sPswd2)
	   {	  
	   alert('New and Confirmation Passwords do not match!');
	   return false;
	   }
	
	// whew! If we're here, then we can submit the password change
}

function PreviewAction()
{
 	var oAction = document.getElementById('DoThis');	
	oAction.value="Preview";
	document.EditArea.submit();
	
}

function PostAction()
{
 	var oAction = document.getElementById('DoThis');	
	oAction.value="Save";
	document.EditArea.submit();
}

function UpdateCharCount()
{
	var oSummary =  document.getElementById('Summary');
	var sSummary = oSummary.value;
	var nChars = 350 - sSummary.length;

 	var oCountTag = document.getElementById('CharsLeft');

 	oCountTag.value = nChars;
}

function VerifyRegisterValues()
{
 	var sLogin = document.getElementById('RegLogin').value;
	var sPswd1 = document.getElementById('RegPswd').value;
	var sPswd2 = document.getElementById('RegPswdC').value;
	var sCode = document.getElementById('RegImgVal').value;
	var sEmail = document.getElementById('RegEmailAddy').value;

	if (sLogin == "")
	   {
	   alert('No Login value supplied!');
	   return false;
	   }

	if (sPswd1 == "")
	   {
	   alert('No Password value supplied!');
	   return false;
	   }
	if (sPswd2 == "")
	   {
	   alert('No confirmation password supplied!');
	   return false;
	   }
	if (sEmail == "")
	   {
	   alert('No email value supplied!');
	   return false;
	   }
	if (sCode == "")
	   {
	   alert('No comfirmation code supplied!');
	   return false;
	   }
	if (sPswd1 != sPswd2)
	   {
	   alert('Passwords do not match!');
	   return false;
	   }

	var bGoodEmail = 0;
	for (var i=0; i<sEmail.length-1; i++)
	{
	 	if (sEmail.substring(i, i+ 1) == "@")
		    bGoodEmail = 1;
	}
	if (bGoodEmail == 0)
	   {
	   alert('Email address value is not a proper email address!');
	   return false;
	   }

	if (InjectionCheck(sLogin, 1) == false)
		return false;
	if (InjectionCheck(sPswd1, 1) == false)
		return false;

	// whew! If we're here, then we can submit the registration
	return true;
	//document.4FRegistration.submit();
	//window.location.href="Register.php?Act=Register";
}

function VerifyLoginValues()
{
 	var sLogin = document.getElementById('Login').value;
	var sPswd = document.getElementById('Pswd').value;
	if (InjectionCheck(sLogin, 0) == false)
		return false;
	if (InjectionCheck(sPswd, 0) == false)
		return false;
	return true;
}

function CancelAction()
{
 	window.history.back();
}

function fbs_click()
{
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;
}

function JumpToBlog()
{
	sBlogID = document.getElementById('DestBlogID').value;
	sURL = "Blog.php?Act=ShowComments&BlogID=" + sBlogID;
	window.location.href = sURL;
}

function ChangeDisplayDate()
{
 	var d = new Date()
	var nOffset = d.getTimezoneOffset();
	var nSeconds = (nOffset * 60 * 1000);
	//nDate = Date.parse(sDate);
	//nDate = nDate - nSeconds;
	//dNewDate.setTime(nDate);

	// Get date value from control
	oDisplayDate = document.getElementById('DisplayDate');
	oDisplayDateUI = document.getElementById('DisplayDateUI');
	dLocalTime = new Date();
	dGMTDate = new Date();
	sGMTDate = oDisplayDate.value;
	nGMTDate = Date.parse(sGMTDate);

	// Convert to local time
	nLocalTime = nGMTDate - nSeconds;
	dLocalTime.setTime(nLocalTime);
	sLocalTime = DateToDBDate(dLocalTime, true);

	// Get changed value from user
	sLocalTime = prompt("Enter earliest Date/Time for displaying this post: ", sLocalTime);
	if(sLocalTime == null)
		return;

	// Set into SPAN
	oDisplayDateUI.value = sLocalTime;

	// Convert to GMT
	nLocalTime = Date.parse(sLocalTime);
	nGMTDate = nLocalTime + nSeconds;
	dGMTDate.setTime(nGMTDate);
	sGMTDate = DateToDBDate(dGMTDate, false);

	// Set value back into control
        oDisplayDate.value = sGMTDate;
}

function DateToDBDate(dDate, bIsForDisplay)
{
	sMonth = PadZero(dDate.getMonth() + 1);
	sDay = PadZero(dDate.getDate());
	sYear = PadZero(dDate.getFullYear());
	sMins = PadZero(dDate.getMinutes());
	sSecs = PadZero(dDate.getSeconds());

	sHrs = PadZero(dDate.getHours());
	if(bIsForDisplay)
        	sTime = sMonth + "/" + sDay + "/" + sYear + " " + sHrs + ":" + sMins + ":" + sSecs;
	else
	       	sTime = sYear + "-" + sMonth + "-" + sDay + " " + sHrs + ":" + sMins + ":" + sSecs;

 	return sTime;
}

function DateToString(dDate, bIs24HrClock)
{
	sMonth = PadZero(dDate.getMonth() + 1);
	sDay = PadZero(dDate.getDate());
	sYear = PadZero(dDate.getFullYear());
	sMins = PadZero(dDate.getMinutes());
	sSecs = PadZero(dDate.getSeconds());

	if (bIs24HrClock)
	{
		nHrs = dDate.getHours();
		sHrs = "00";
		sAMPM = "";
		if ((nHrs == 0) || (nHrs == 24))
		{
			sHrs = "12";
			sAMPM = "AM";
		}
		if ((nHrs > 0) && (nHrs < 12))
		{
			sHrs = PadZero(nHrs);
			sAMPM = "AM";
		}
		if (nHrs > 11)
		{
			if (nHrs != 12)
			    nHrs = nHrs - 12;
			sHrs = PadZero(nHrs);
			sAMPM = "PM";
		}
        	sTime = sMonth + "/" + sDay + "/" + sYear + " " + sHrs + ":" + sMins + ":" + sSecs + " " + sAMPM;
	}
	else
	{
		sHrs = PadZero(dDate.getHours());
        	sTime = sMonth + "/" + sDay + "/" + sYear + " " + sHrs + ":" + sMins + ":" + sSecs;
 	}

 	return sTime;
}

function PadZero(valToPad)
{
	nVal = parseInt(valToPad);
	sVal = "";
	if (nVal < 10)
	    sVal = "0" + nVal.toString();
	else
	    sVal = nVal.toString();

	return sVal;
}

function InjectionCheck(sValue, bCheckForSpace)
{
	var sString = "";
	sString = sValue;
	if(bCheckForSpace == 1)
	{
		if(sString.indexOf(" ") > -1)
		{
			alert("Cannot have a space in the value!");
			return false;
		}
	}

	if(sString.indexOf("=") > -1)
	{
		alert("Cannot have '=' in the value!");
		return false;
	}
	
	sUpString = sString.toUpperCase();
	if(sUpString.indexOf(" AND ") > -1)
	{
		alert("Cannot have ' AND ' in the value!");
		return false;
	}

	sUpString = sString.toUpperCase();
	if(sUpString.indexOf(" OR ") > -1)
	{
		alert("Cannot have ' OR ' in the value!");
		return false;
	}

	return true;
}
//-->