function getpage(URL, poststr)
{	getashupdate(URL, poststr);
	window.scrollTo(0,0);
}

function gethistorydiv(URL, poststr, div)
{   getashdivupdate(URL, poststr, div);
    window.scrollTo(0,0);
}

function postnewform(formname, poststr)
{	new Ajax.Updater('ajaxcontent', 'page.cfm', {evalScripts: true, parameters: $(formname).serialize(true)});
	$('newajaxcontent').remove();
	$('overlay').remove();
	document.location.hash = 'page.cfm/' + poststr;
	window.scrollTo(0,0);
}

function postform(formname, poststr, paramstr, div)
{
	// alert($(formname).serialize());
	new Ajax.Updater(div, 'page.cfm', {evalScripts: true, parameters: $(formname).serialize() + paramstr });
	// document.location.hash = 'page.cfm/' + poststr;
	window.scrollTo(0,0);
}

function getnew(URL, poststr, div)
{	overheight = $(document.body).getHeight();
	if(overheight < document.viewport.getHeight())
		overheight = document.viewport.getHeight();
	$$('.video').each(Element.hide);
	$(document.body).insert(new Element('div', { 'id': 'overlay' }).setStyle({ opacity: 0.6, height: overheight + 'px', 'zIndex': 50 }));
	$(document.body).insert(new Element('div', { 'id': div }).setStyle({ 'position': 'absolute', 'top': document.viewport.getScrollOffsets().top + 200 + 'px', 'zIndex': 500 }).addClassName('newajaxform'));
	new Ajax.Updater(div, URL, {parameters: poststr});
}

function getnewdiv(URL, poststr, div)
{	$(div).style.display = 'block';
	new Ajax.Updater(div, URL, {parameters: poststr});
}

function getdiv(URL, poststr, div)
{	new Ajax.Updater(div, URL, {parameters: poststr});
}

function closediv(div)
{	$$('.video').each(Element.show);
	$(div).remove();
	$('overlay').remove();
}

function deletepage(URL, poststr, div) 
{	var delconf = confirm("Are you sure you want to delete this record?");
	if(delconf == true)
		new Ajax.Updater(div, URL, {parameters: poststr});
}

function deleteitem(URL, poststr, div) 
{	var delconf = confirm("Are you sure you want to delete this record?");
	if(delconf == true)
		new Ajax.Updater(div, URL, {parameters: poststr});
}

function postselect(URL, selectval, div) 
{	poststr = selectval.name + '=' + selectval.value;
	new Ajax.Updater(div, URL, {parameters: poststr});
}

function postparamselect(URL, selectval, postvals, div) 
{	poststr = selectval.name + '=' + selectval.value + postvals;
	new Ajax.Updater(div, URL, {parameters: poststr});
}

function startcallback() 
{	return true;
}

function completecallback(response, div, poststr)
{	$(div).innerHTML = response;
	getashpage('page.cfm', poststr);
	window.scrollTo(0,0);
}

function completenewcallback(response, div, poststr)
{	$('newajaxcontent').remove();
	$('overlay').remove();
	$(div).innerHTML = response;
	window.scrollTo(0,0);
}

function toggleshow(div, formval, formfield)
{	if(formfield.value == formval)
		$(div).style.display = 'block';
	else
		$(div).style.display = 'none';
}

function dosort(div, table)
{	$(div + 'newimg').toggle();
	$(div + 'sort').toggle();
	$(div + 'endsort').show();
	Sortable.create(div + table, 
	{	tag:'div',overlap:'horizontal',constraint: false,
		onUpdate:function()
		{	new Ajax.Request('sort.cfm', 
			{asynchronous:true, onComplete:function(request) { new Effect.Highlight(div, {});}, parameters:Sortable.serialize(div + table) + '&table=' + table + '&div=' + div + table})}});
	$(div + table).setStyle({ cursor: 'move' });
}

function endsort(div, table, poststr)
{	Sortable.destroy(div + table);
	new Ajax.Updater(div, 'imgs/imglist.cfm', {parameters: poststr});
}

function sendmail()
{	var content = FCKeditorAPI.GetInstance('message').GetXHTML();
	new Ajax.Updater('mailer', 'sendmail.cfm', {parameters: { subject: $('subject').value, sendTo: $('sendTo').value, content: content}});
}
