_editor_url = "/admin/htmlarea/";
        
function SetupEditor(TextBoxID)
{			
	// Create new config object
	var config = new Object();
	config.bodyStyle = 'font-family:Verdana, Arial; font-size:9pt; color:Black;';
	config.debug = 0;

	// NOTE:  You can remove any of these blocks and use the default config!

	config.toolbar = [
		['fontstyle'],
		['bold','italic','underline','separator'],
		['justifyleft','justifycenter','justifyright','separator'],
		['OrderedList','UnOrderedList','Outdent','Indent','separator'],
		['HorizontalRule','Createlink','htmlmode']
	];

	//config.stylesheet = "http://www.domain.com/sample.css";
    	
	config.fontstyles = [   // make sure classNames are defined in the page the content is being display as well in or they won't work!
	{ name: "Headline",     className: "Headline",  classStyle: "font-family:Verdana, Arial; font-size:20px; font-weight:900; color:#00409B;" },
	{ name: "Normal",		className: "Normal", classStyle: "font-family:Verdana, Arial; font-size:9pt; color:Black;" },
	];

	editor_generate(TextBoxID,config);
}

function SetDimensions()
{
    var WindowHeight = 0;
    var WindowWidth = 0;
    var MainRow = document.getElementById('MainRow');
    var MainContentCell = document.getElementById('MainContentCell');
    
    if(typeof(window.innerWidth) == 'number')
    {
        WindowWidth = window.innerWidth;
        WindowHeight = window.innerHeight;
    }
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        WindowWidth = document.documentElement.clientWidth;
        WindowHeight = document.documentElement.clientHeight;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        WindowWidth = document.body.clientWidth;
        WindowHeight = document.body.clientHeight;
    }
    
    MainRow.height = WindowHeight - 86;
    MainContentCell.width = WindowWidth - 200;
}

function SelectThumbnail()
{
    // Pulls the "PID" from the QueryString, and sets the focus to the form element with the id that starts with
    // "Thumbnail_" followed by that PID.
    var URL = window.location.toString();
    var StartIndex = URL.indexOf("PID=") + 4;
    
    var EndIndex = StartIndex;
    while(EndIndex < URL.length)
    {
        if(URL[EndIndex] == "&")
            break;
        
        EndIndex++;
    }
    
    var PID = URL.substring(StartIndex, EndIndex);
    var ElementID = "Thumbnail_" + PID;
    var SelectedPhoto = document.getElementById(ElementID);
    SelectedPhoto.className = "SelectedThumnail";    
    
	PhotoPos = GetPosition(SelectedPhoto);
	if(PhotoPos.X > 600)
	{
	    // The picture is pretty far to the right ... scroll the iframe to it.  NOTE: The iframe is actually
	    // 730px wide ... not 600.
	    //parent.frames["topframe"].scrollTo(PhotoPos.X, 0);
	    parent.frames["iframeGalleryThumbnails"].scrollTo(PhotoPos.X, 0);
	}
}

function GetPosition(e)
{
	var left = 0;
	var top  = 0;

	while (e.offsetParent)
	{
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {X:left, Y:top};
}

function OpenCenterPopUp(url, title, width, height)
{
	    var TopLeftX=screen.width / 2 - width/2;
	    var TopLeftY=screen.height / 2 - height/2;
	    var NewWindow = window.open(url,title,'top='+TopLeftY+', left='+TopLeftX+', width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');					
}

function MaxLength(field, maxlimit)
{
	// This function sets MaxLength for the MultiLine Textbox that it is passed.
	// It is called in the asp:TextBox tag like this: onKeyDown="MaxLength(this,500);" 
	// Created by Cal Zant
	if (field.value.length >= maxlimit)
		field.value = field.value.substring(0, maxlimit-1);
}

// This function looks for form element who's ClientID contains the given ElementID.  If a ContentPlaceHolderID
// parameter is provided it will also require that the ClientID also contain that value as well.  It returns the
// first match.
// Example: GetElement("btnSubmit");
// It would try to find an element who's ClientID contained the text "btnSubmit". Any of the following ClientIDs
// would result in a match: "ctl00_Header_btnSubmit", "ctl00_MainContent_btnSubmit", "k3hf75btnSubmitjfh493",
// "btnSubmit", "btnSubmitPage".
// Example: GetElement("btnSubmit", "MainContent");
// It would try to find an element who's ClientID contained the text "btnSubmit", and "MainContent".  An element
// with the ClientID of "ctl00_MainContent_btnSubmit" would result in a match, but "ctl00_Header_btnSubmit"
// would not.
function GetElement(ElementID, ContentPlaceHolderID)
{
    var FormCount = document.forms.length;
    for(FormIndex = 0; FormIndex < FormCount; FormIndex++)
    {
	    var ElementCount = document.forms[FormIndex].elements.length;
	    for(ElementIndex = 0; ElementIndex < ElementCount; ElementIndex++)
	    {
		    var ElementName = document.forms[FormIndex].elements[ElementIndex].name;
    		
            if(ContentPlaceHolderID == null)
            {
		        if(ElementName.indexOf(ElementID) >= 0)
			        return document.forms[FormIndex].elements[ElementIndex];
	        }
	        else
	        {
		        if(ElementName.indexOf(ElementID) >= 0 && ElementName.indexOf(ContentPlaceHolderID) > 0)
			        return document.forms[FormIndex].elements[ElementIndex];
	        }
	    }
    }

	return null;
}

function LoadMap()
{
    // Only allow this function to be ran on the Map.aspx page.    
    if(window.location.toString().indexOf("Map.aspx") < 0)
        return;

    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GScaleControl());
    map.setCenter(new GLatLng(33.4595, -101.0995), 13);
    map.openInfoWindowHtml(map.getCenter(), "<b>White River Youth Camp</b><br>Located just south of White River Lake,<br>between Post and Crosbyton");
    
    var polyline = new GPolyline([new GLatLng(33.4595, -101.0990), new GLatLng(33.4615, -101.1010)], "#ff0000", 15);
    map.addOverlay(polyline);
}

function Wait(MillisecondsToWait)
{
    var StartDateTime = new Date();
    var CurrentDateTime = new Date();
    
    while(MillisecondsToWait > (CurrentDateTime - StartDateTime))
    {
        CurrentDateTime = new Date();
    }
}
