﻿// vars
var adHeight = 0;
var linkWidth = "";
var linkHeight = "";
var linkCount = 0;
var linkHides = new Array();
var show_hide = "no";
var topOfDiv = 0;
var divTops = new Array();

// link vars
if(!maxAdHeight)
var maxAdHeight = 0;
var linkWidth = '';
var linkHeight = '';
var link_heights = new Array();
var linkTop = '';
window.link_actions = new Array();
window.num_pictures = new Array();
window.animated_stories = new Array();
window.animated_stops = new Array();
window.ccc = 0;
//window.mostRecentParentID = 0;

// animation
var animateSpeed = 8;
var object = null;
var fX= null;
var fY= null;
var cX = null;
var cY = null;
var dX = null;
var dY = null;
var stepX= null;
var stepY = null;
var slope = null;

// more link vars
var linkHeight = '';
var linkTop = '';
var linkDepth = '';
var deepestLink = '';
var maskHeight = 1;
var adMaskHeight = 1;
if(!maxAdMaskHeight)
var maxAdMaskHeight = 1;

// new from select fns
var open_panels = new Array()
open_panels[""]= "choiceid_";
var open_panel = "choiceid_";

// new for setVisiblity by form, contact page
window.open_panel = "";
//window.open_panel_vbf = "";
//var open_panel = "";
window.open_link = "";

window.maxZ = 300;
window.heightsRecorded = '';

// new
window.imageEditing = '';
window.textEditing = '';
window.sidebarEditing = '';
window.linkEditing = '';
window.storyEditing = '';
window.linkSliding = '';
window.loadTries = 0;

// test:ok
//alert("OK to js66");

function setTop(objectID,y) {
var object = document.getElementById(objectID);
if(object)
object.style.top = y + "px";
}

function findHeight(objectID) {

	var object = document.getElementById(objectID);
	if(object && object.offsetHeight)
//	if(object.offsetHeight)
	return object.offsetHeight;
	return (null);
}

function findWidth(objectID) {

	var object = document.getElementById(objectID);
	if(object.offsetWidth)
	return object.offsetWidth;
	else	
	return (null);
}

function findTop(objectID, offsets){
	var object = document.getElementById(objectID);

	if(offsets == 'one')
	{
	if(object.offsetParent.offsetTop)
	return object.offsetTop + object.offsetParent.offsetTop;
	}
	else if(object.offsetTop)
	return object.offsetTop;
	return(null);
}

function findLivePageWidth()
{
if(window.innerWidth)
return window.innerWidth;
if(document.body.clientWidth)
return document.body.clientWidth;
return (null);
}

function findLivePageHeight()
{
if(window.innerHeight)
return window.innerHeight;
if(document.body.clientHeight)
return document.body.clientHeight;
return (null);
}

function setMargin(objectID,margin)
{
var object = document.getElementById(objectID);
object.style.left = margin+"px";
}

function setHeight(objectID,height)
{
var object = document.getElementById(objectID);
object.style.height = height+"px";
}

function setWidth(objectID,width)
{
var object = document.getElementById(objectID);
object.style.width = width+"px";
}


function setVisibilityA(objectID,state)
{
var object = document.getElementById(objectID);
if(object)
object.style.visibility = state;
else
return (null);
}


function setVisibility(objectID,state,x,y)
{

// test
//alert("show_hide js153: " + show_hide);

if(show_hide == "yes")
{
var object = document.getElementById(objectID);
if(object)
{
object.style.visibility = state;

// test
//alert(x);

if(x)
object.style.left = x + "px";
if(y)
object.style.top = y + "px";

if(state == 'visible')
{
object.style.zIndex = window.maxZ;
window.maxZ++;
// new
open_panel = objectID;
}
}
}
}

var show_hide = "no";

function setVisibility1(objectID,state)
{
var object = document.getElementById(objectID);
if (show_hide == "yes")
{
object.style.visibility = state;
open_panel = objectID;
}
}


function setVisibilityAndPosition(objectID,state,thisX,thisY,thisW,xAdj,yAdj,trigger)
{

var object = document.getElementById(objectID);
if(object)
{
if(trigger == "click" && object.style.visibility.toLowerCase() == 'visible')
object.style.visibility = 'hidden';
else
{
object.style.left = Math.round(thisX+thisW+xAdj) + 'px'; //
object.style.top = Math.round(thisY+yAdj) + 'px';
object.style.visibility = state;
}
}
else
return (null);
}

function setClass(objectID,newClass)
{
var object = document.getElementById(objectID);
if(object)
object.className = newClass;
else
return (null);
}

function setDisplayOnly(objectID,state)
{
var object = document.getElementById(objectID);
if(object)
object.style.display = state;
}

function setDisplay(objectID,state,imageID,width,height,open_panel, xShift, yShift, shows, hides)
{

// test: undef, then ok
//alert("shows at js185: " + shows);

// test
var shiftLeft = 'Yes';

// try
if(state == "none")
window.open_panel_iv = '';

if((objectID != window.open_panel_iv) || state == "none")
{
var object = document.getElementById(objectID);
if(object)
object.style.display = state;

if(state == 'inline')
{
window.open_panel_iv = objectID;
if(width && height)
initExpand(imageID, width, height, '', '', shiftLeft, '', '', '', '', objectID, xShift, yShift, shows, hides);
}
}
else
{
window.open_panel_iv = '';
initExpand(imageID, width, height, objectID, '', shiftLeft, '', '', '', 'visibility', objectID, xShift, yShift, shows, hides);
}
}

function setVisibilityExpand(objectID,state,imageID,width,height,open_panel,status)
{
if((objectID != window.open_panel_iv) || state == "hidden" || status == "notYetExpanded")
{
var object = document.getElementById(objectID);
if(object)
{
object.style.visibility = state;
object.style.zIndex = window.maxZ;
window.maxZ++;
}
if(state == 'visible')
{
if(status != 'notYetExpanded')
window.open_panel_iv = objectID;
if(width && height)
initExpand(imageID, width, height,'','','','','','','visibility',objectID);
}
}
else
{
window.open_panel_iv = '';
initExpand(imageID, '12', '9', objectID, '','','','',1,'visibility',objectID);
}
}


function setVisibilityByForm(name)
{

//alert(name); // ok, stories

objectID_prev = open_panel;
//alert(objectID_prev);
if(objectID_prev)
{
var object = document.getElementById(objectID_prev);
object.style.visibility = "hidden";
}
objectID = name;
var object = document.getElementById(objectID);
object.style.visibility = "visible";
open_panel = objectID;
}

function setVisibilityByForm1()
{

// test:ok
//alert("OK to js302");  // ok
//alert("open_panel: " + open_panel);  // choiceid_

if(open_panel)
setVisibility1(open_panel,'hidden');

// test:fail;ok
//alert("OK to js309");  // 

var objectIDno = document.edit_select_input.parent_selectid.value;
//var objectIDno = document.forms[0].parent_selectid.value;
var objectID = "select_"+objectIDno;

var object = document.getElementById(objectID);
if(show_hide == "yes")
{
object.style.visibility = "visible";
open_panel = objectID;
}
}

// consolidate w above w care, if at all
function setVisibilityByForm2(name, label, parent, grandparent_db, grandparentid)
{
objectID_prev = open_panels[parent+grandparent_db+grandparentid];
if(!(objectID_prev))
objectID_prev = label+parent;
if(objectID_prev)
setVisibility(objectID_prev,'hidden');

iobjectID_prev = open_panels["i"+parent+grandparent_db+grandparentid];
if(iobjectID_prev)
setVisibility(iobjectID_prev,'hidden');

if(name)
objectID = label+name+grandparent_db+grandparentid;
else
objectID = label+parent;

var object = document.getElementById(objectID);
if (show_hide == "yes" && object)
{
object.style.visibility = "visible";
open_panels[parent+grandparent_db+grandparentid]= objectID;
open_panel = objectID;
}

objectID = "i"+label+name+grandparent_db+grandparentid;
var object = document.getElementById(objectID);
if(object)
{
object.style.visibility = "visible";
open_panels["i"+parent+grandparent_db+grandparentid]= objectID;
}
}


function setBackground(objectID,state)
{
var object = document.getElementById(objectID);
if(object)
object.style.background = state;
}

function initAnimate(objectID,x,y,animateSpeed)
{
if(!animateSpeed)
var animateSpeed = 8;
var cX = 0;
var cY = 0;
var dX = 0;
var dY = 0;

var stepX = 0;
var stepY = 0;
var slope = 0;
var object = document.getElementById(objectID);
var fX = x;
var fY = y;
	
var cX = object.offsetLeft;

var cY = object.offsetTop;

var dX = Math.abs(fX-cX);
var dY = Math.abs(fY-cY);

if((dX ==0) || (dY == 0)) slope = 0;

else slope = dX/dY;
	if(dX>=dY){
		if(cX<fX) stepX = animateSpeed;
		else if (cX>fX) stepX = -animateSpeed;
		if(cY<fY) stepY = animateSpeed*slope;
		if(cY>fY) stepY = -animateSpeed*slope;
	}
	else if (dX<dY) {
		if(cY<fY) stepY =animateSpeed;
		else if (cY>fY) stepY = -animateSpeed;
		if(cX<fX) stepX = animateSpeed/slope;
		else if (cX>fX) stepX = -animateSpeed/slope;
	}

animateObject(objectID,cX,cY,dX,dY,stepX,stepY,slope,fX,fY);
}

function showHideLink(objectID,show_hide,size)
{
var object = document.getElementById(objectID);
var cX = object.offsetLeft;
var cY = object.offsetTop;

// try:no change
//if(!animateSpeed)
//var animateSpeed = 8;

var stepX = 0;
var stepY = 0;

if(show_hide == 'show')
{
if(size == 'min')
var fX = -617;
else if(size == 'small')
var fX = -487;
else if(size == 'medium')
var fX = -325;
else if(size == 'above_ad')
var fX = -247;
else if(size == 'vertical')
var fX = -175;
else
var fX = -125;
}
else if(size == 'above_ad')
var fX = -605;
else
var fX = -770;
var fY = cY;
	
var dX = Math.abs(fX-cX);
var dY = Math.abs(fY-cY);
if((dX ==0) || (dY == 0)) 
var slope = 0;
else 
var slope = dX/dY;

	if(dX>=dY){
		if(cX<=fX) stepX = animateSpeed;
		else if (cX>fX) stepX = -animateSpeed;
		if(cY<=fY) stepY = animateSpeed*slope;
		if(cY>fY) stepY = -animateSpeed*slope;
	}
	else if (dX<dY) {
		if(cY<=fY) stepY =animateSpeed;
		else if (cY>fY) stepY = -animateSpeed;
		if(cX<=fX) stepX = animateSpeed/slope;
		else if (cX>fX) stepX = -animateSpeed/slope;
	}
animateObject(objectID,cX,cY,dX,dY,stepX,stepY,slope,fX,fY)
}

function animateObject(objectID,cX,cY,dX,dY,stepX,stepY,slope,fX,fY)
{
var object = document.getElementById(objectID);

	if((dX > 0) || (dY > 0)) {
		object.style.left = Math.round(cX) + 'px';
		object.style.top = Math.round(cY) + 'px';
	cX = cX + stepX;
	cY = cY + stepY;
	dX = dX - Math.abs(stepX);
	dY = dY - Math.abs(stepY);

	window.setTimeout('animateObject(\''+objectID+'\', '+cX+','+cY+','+dX+','+dY+','+stepX+','+stepY+','+slope+','+fX+','+fY+')',0);
	}
	else
	{
	object.style.left = fX + 'px';
	object.style.top = fY + 'px';
	linkSliding = 'off';
	}
return;
}

// animation objects (plural) one after another
function animateObjects(p,storyIdOrig)
{

// if called from ind. story at end, do that only
if(storyIdOrig)
{
var numStories = 1;
var start = 'No';
}
else
{
var numStories = window.animated_stories.length;
var start = 'Yes';
}

// abort if none on firt time through
if(numStories == 0)
return true;

for(var s=0;s<numStories;s++)
{
if(storyIdOrig)
var storyId = storyIdOrig;
else
var storyId = window.animated_stories[s];

var numPictures = window.num_pictures[storyId];

if(p == numPictures)
p = 0;

var arrayVar = storyId+"_"+p;
if(window.link_actions[arrayVar] && start != 'Yes' && window.animated_stops[storyId] != 'Yes')
window.setTimeout(window.link_actions[arrayVar],0);
window.setTimeout('animateObjects('+(p+1)+','+storyId+')',5000);

}

return;
}

function toggleStop(storyId)
{
//if(window.animated_stops[storyId] == 'Yes')
//window.animated_stops[storyId] = 'No';
//else
window.animated_stops[storyId] = 'Yes';
}

function pause(milliseconds) {
	var dt = new Date();
	while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}


function openWindow(contentURL, windowName, windowWidth, windowHeight){
	widthHeight = 'height=' + windowHeight +
	 'width=' + windowWidth;
	newWindow = window.open(contentURL, windowName, widthHeight);
	newWindow.focus()
}

function closeWindow(){
if(newWindow != null) {
newWindow.close();
newWindow = null;
}
}

function initExpand(objectID, target_width, target_height, closeWhenDone, destUrl, shiftLeft, position, animateSpeed, hideWhenDone, styleToChange, divID, xShift, yShift, shows, hides){

// test:undefined;ok
//alert("shows at js436: " + shows);

object = document.getElementById(objectID);

if(typeof divID != 'undefined')
objectDiv = document.getElementById(divID);

// defaults
if(typeof xShift == 'undefined')
var xShift = 'even';
if(typeof yShift == 'undefined')
var yShift = 'up';

var currentX;
var currentY;

fX = target_width;
fY = target_height;

fZ = closeWhenDone;

if(typeof hideWhenDone != 'undefined')
gZ = hideWhenDone;
else
gZ = '';

if(typeof styleToChange != 'undefined')
jZ = styleToChange;
else
jZ = '';

hZ = shiftLeft;
iZ = position;

cX = object.offsetWidth;
cY1 = object.offsetHeight;

// tests: hides undefined when needed
//alert("fX, target_width, at js474: " + fX);
//alert("cX, current width, at js475: " + cX);
//alert("hides, current width, at js476: " + hides);

// hide links if shrinking
if(hides && fX < cX)
{

// test: fail; ok
//alert("hides at js477: " + hides);

hides = unescape(hides);
setTimeout(hides,0);
}

dXr = fX-cX;
dYr = fY-cY1;

if(!animateSpeed)
animateSpeed = 8;

dYorig = dYr;
stepX = dXr/animateSpeed;
stepY = dYr/animateSpeed;

dX = Math.abs(dXr);
dY = Math.abs(dYr);

var appName = navigator.appName;
var browserVer = navigator.appVersion;

var isEight = browserVer.indexOf('MSIE 8.0');

if(jZ == 'visibility' || hZ == 'Yes')
{

if(appName == 'Netscape' || isEight > 0)
{
currentX = objectDiv.offsetLeft;
}
else
{
currentX = objectDiv.offsetLeft - objectDiv.offsetParent.offsetLeft;
}

currentY = objectDiv.offsetTop;

}
else
{
currentX = object.offsetLeft;
currentY = object.offsetTop;
}

if(yShift == 'up')
finalY = currentY - dYr;
else
finalY = currentY;


if(xShift == 'even')
finalX = currentX - dXr/2;
else if(xShift == 'left')
finalX = currentX - dXr;
else if(xShift == 'right')
finalX = currentX - dXr;  // dXr neg.?
else
finalX = currentX;

expandObject(hZ,iZ,xShift,yShift,currentX,currentY,shows,hides)
}

function expandObject(hZ,iZ,xShift,yShift,currentX,currentY,shows,hides) {

// test:fail before; undefined; ok several times, then fail
//alert("shows at js533: " + shows);

// defaults
if(typeof xShift == 'undefined')
var xShift = 'even';
if(typeof yShift == 'undefined')
var yShift = 'up';

	if((dX > 0) && (dY > 0)) {
		object.style.width = Math.round(cX) + 'px';
		object.style.height = Math.round(cY1) + 'px';

if(jZ == 'visibility' || hZ == 'Yes')
{

// test
objectDiv.style.top = Math.round(currentY) + 'px';
objectDiv.style.left = Math.round(currentX) + 'px';

}


		if(hZ == "Yes")
		{
		object.style.left = currentX + 'px';
		}

		if(iZ == "bottom")
		{
		object.style.top = currentY + 'px';
		}

	cX = cX + stepX;
	cY1 = cY1 + stepY;

if(xShift == 'even')
currentX = currentX - stepX/2;
else if(xShift == 'left')
currentX = currentX - stepX;

else if(xShift == 'right')
currentX = currentX - stepX;  // stepX negative

else if(xShift == 'none')
currentX = currentX;

else if(jZ == 'visibility')
currentX = currentX - stepX/2;
else
currentX = currentX - stepX;

if(yShift == 'up')
currentY = currentY - stepY;
else
currentY = currentY;

	dX = dX - Math.abs(stepX);
	dY = dY - Math.abs(stepY);

//	setTimeout('expandObject(\''+hZ+'\',\''+iZ+'\',\''+xShift+'\',\''+yShift+'\','+currentX+','+currentY+')',0);
	setTimeout('expandObject(\''+hZ+'\',\''+iZ+'\',\''+xShift+'\',\''+yShift+'\','+currentX+','+currentY+',\''+shows+'\',\''+hides+'\')',0);
	}
	else {

		object.style.width = fX + 'px';
		object.style.height = fY + 'px';

if(jZ == 'visibility' || hZ == 'Yes')
{
objectDiv.style.top = Math.round(finalY) + 'px';
objectDiv.style.left = Math.round(finalX) + 'px';

shows = unescape(shows);

// test
//alert("shows at js608: " + shows);

setTimeout(shows,0);
}

	if(fZ)
	{
	object = document.getElementById(fZ);
	if(object)
	{

	if(gZ)
	object.style.visibility = 'hidden';
	else
	object.style.display = 'none';

//setTimeout(hides,0);

// tested; not working
window.open_panel_iv = '';

	}
	}
	if(jZ != 'visibility')
	adjustFooter(dYorig);
	}
return;
}

function swapText(objectID, text)
{
object = document.getElementById(objectID);
if(object)
object.innerHTML=text;
}

function getDocHeight()
{

// test
//alert("document.height, ie, at jsf671: " + document.height);
//alert("document.body.scrollHeight, saf, at jsf672: " + document.body.scrollHeight);
//alert("document.documentElement.scrollHeight, ff, at jsf673: " + document.documentElement.scrollHeight);

var docHeight;
// IE
if (typeof document.height != 'undefined' && (document.height > 0) && navigator.appName != 'Netscape') {
docHeight = document.height;
}
// Safari: footer too low; 50, now 100,200 to keep site border set sites out of here 
else if (document.body && typeof document.body.scrollHeight != 'undefined' && document.body.scrollHeight > 200  ) {
docHeight = document.body.scrollHeight;
}
// Firefox
else if (document.compatMode && document.compatMode != 'BackCompat') {
docHeight = document.documentElement.scrollHeight;  // no
}

return docHeight;
}

function adjustFooter(dYorig, type, skipLinks)
{
// reset to null 
if(typeof type == 'undefined' || !type || type == 'undefined' || type == 'null')
var type = '';

// reset to null 
if(typeof skipLinks == 'undefined' || !skipLinks || skipLinks == 'undefined' || skipLinks == 'null')
var skipLinks = '';

if(dYorig > 0)
var changeHeight = dYorig + 25;
else
var changeHeight = dYorig - 25;
object = document.getElementById("footer");
if(object)
{
if(window.heightsRecorded != 'Yes' || type != 'onDeck')
window.footerHeight = object.offsetTop;
var footerHeight = window.footerHeight + changeHeight;
if(footerHeight > window.adHeight)
object.style.top = footerHeight+"px";
else
object.style.top = window.adHeight+"px";
}

// page bottom links
object = document.getElementById("page_bottom_links");
if(object && skipLinks != 'Yes')
{
if(window.heightsRecorded != 'Yes' || type != 'onDeck')
window.pblHeight = object.offsetTop;
var pblHeight = window.pblHeight + changeHeight;
if(pblHeight > window.adHeight)
object.style.top = pblHeight+"px";
else
object.style.top = window.adHeight+"px";
}

// whole site
object = document.getElementById("whole_site");
if(object)
{
if(window.heightsRecorded != 'Yes' || type != 'onDeck')
window.pageHeight = object.offsetHeight;
var pageHeight = window.pageHeight + changeHeight;
object.style.height = pageHeight+"px";
}

// page
object = document.getElementById("site_border_left");
if(object)
{
object.style.height = pageHeight+"px";
}
object = document.getElementById("site_border_right");
if(object)
{
object.style.height = pageHeight+"px";
}

var siteBottomHeight = pageHeight + Number(window.topMargin); 

object = document.getElementById("site_border_bottom");
if(object)
{
object.style.top = siteBottomHeight+"px";
}

// record that heights recorded on first execution
if(window.heightsRecorded != 'Yes')
window.heightsRecorded = 'Yes';

}

/********************************************************
REPOSITION FOOTER - main fn to set end of page correctly
*********************************************************/
function repositionFooterOpEd(paperCode, scrollSpeed, edit, stripeWidth, footerBelowMainDiv)
{

// new: do not run unless or until stylesheet loaded
var handle = window.setInterval( function(){
if( document.getElementById('beacon').clientWidth==42 ) {
//alert('script file has loaded');
// ... do stuff

// reset to null 
if(typeof stripeWidth == 'undefined' || !stripeWidth || stripeWidth == 'undefined' || stripeWidth == 'null')
var stripeWidth = 0;
// reset to null 
if(typeof footerBelowMainDiv == 'undefined' || !footerBelowMainDiv || footerBelowMainDiv == 'undefined' || footerBelowMainDiv == 'null')
var footerBelowMainDiv = '';

docHeight = getDocHeight();

if(!window.adHeight)
	var adHeight = 0;

var mainHeight = findHeight("main_content");
object = document.getElementById("page_bottom_links");
if(window.storyDisplay == "on_deck" && !window.areRegularStories)
{
docHeight = getDocHeight();
if (typeof window.orientation != 'undefined' && window.orientation == 'vertical')
mainHeight = docHeight - window.menuHeight - window.topMargin;
else
mainHeight = docHeight - window.bannerHeight - window.menuHeight - window.topMargin;
}
else if(window.menuOrientation != 'vertical')
{
mainHeight = docHeight - window.bannerHeight - window.menuHeight - window.topMargin;
if(window.adHeight > docHeight)
mainHeight = window.adHeight;
}

if(window.linksTopMargin)
mainHeight += window.linksTopMargin;

if(object && mainHeight)
object.style.top = mainHeight+"px";
if(object) object.style.display = 'inline';

// doc height
docHeight = getDocHeight();

// get footer object
object = document.getElementById("footer");

if(!window.footerAdj)
window.footerAdj = 0;

if(!window.safariAdj)
window.safariAdj = 0;

// calculate
if(window.scrollMain == 'Yes' && window.menuOrientation == 'vertical')
var footerHeight = docHeight - window.footerAdj;
else
if(window.menuOrientation == 'vertical_image' || window.menuOrientation == 'vertical')
var footerHeight = docHeight - window.bannerHeight - window.topMargin - window.footerAdj;
else if (typeof window.orientation != 'undefined' && window.orientation == 'vertical')
var footerHeight = docHeight - window.menuHeight - window.topMargin - window.footerAdj;
else
var footerHeight = docHeight - window.bannerHeight - window.menuHeight - window.topMargin - window.footerAdj;

// safari
if (navigator.appName == 'Netscape')
footerHeight = footerHeight - window.safariAdj;

if(!window.siteWidth)
window.siteWidth = 783;

// set new height
if(object) object.style.top = footerHeight+"px";
if(window.menuOrientation != 'vertical_image' && window.menuOrientation != 'vertical')
if(object) object.style.width = window.siteWidth+"px";
if(object) object.style.display = 'inline';

// doc height
if(footerBelowMainDiv == 'Yes')
var newDocHeight = getDocHeight();
else
docHeight = getDocHeight();

// last link mask
if(window.lastMask)
{
object = document.getElementById(window.lastMask);
if(object)
{

if((window.storyDisplay == "on_deck" && !window.areRegularStories) || window.storeLink == 'Yes')
var linkMaskHeight = docHeight  -  window.bannerHeight - window.menuHeight - window.topMargin - window.adHeight;
else if(stripeWidth)
var linkMaskHeight = docHeight - window.bannerHeight - window.menuHeight - window.topMargin ;  
else
var linkMaskHeight = docHeight - window.adHeight -  window.bannerHeight - window.menuHeight - window.topMargin ;  

if(window.borderSize)
linkMaskHeight += 2*window.borderSize;

object.style.height = linkMaskHeight+"px";

}
}

// page
if(footerBelowMainDiv == 'Yes')
var wholeSiteHeight = newDocHeight - window.topMargin;
else
var wholeSiteHeight = docHeight - window.topMargin;
object = document.getElementById("whole_site");
if(object)
{
var browserVer = navigator.appVersion;

var isSeven = browserVer.indexOf('MSIE 7.0');
var isSix = browserVer.indexOf('MSIE 6.0');
var isFirefox = browserVer.indexOf('Firefox');

if(isSeven > 0 || isSix > 0)
var isSevenOrSix = 1;

if(top == self || isSevenOrSix != 1  || navigator.appName.indexOf('Netscape') > -1) 
{
object.style.height = wholeSiteHeight+"px";
}

object.style.visibility = "visible";
}

// ad mask too
object = document.getElementById("mask");
if(object)
{
if(window.menuOrientation == 'vertical_image' || window.menuOrientation == 'vertical')
var maskHeight = docHeight;
else
var maskHeight = docHeight - window.bannerHeight - window.topMargin
object.style.height = maskHeight+"px";
}

// main content, try if not vertical
object = document.getElementById("main_content");
if(object && window.menuOrientation != 'vertical_image' &&  window.menuOrientation != 'vertical')
{

if(window.menuTopMargin < 0)  // superimposed on banner, don't subtract menu height
var contentHeight = docHeight - window.bannerHeight - window.topMargin - window.paddingTop - window.paddingBottom;
else
var contentHeight = docHeight - window.bannerHeight - window.topMargin - window.menuHeight - window.paddingTop - window.paddingBottom;

// new adj
if(window.borderSize)
contentHeight += window.borderSize;
object.style.height = contentHeight+"px";
}

// top
object = document.getElementById("site_border_top");
if(object)
object.style.visibility = "visible";

// sides
if(footerBelowMainDiv == 'Yes')
var sideHeight = newDocHeight - 0*Number(window.siteBorderSize) + 2*Number(window.siteBorderPadding) - 1*(window.topMargin); 
else
var sideHeight = docHeight - 0*Number(window.siteBorderSize) + 2*Number(window.siteBorderPadding) - 1*(window.topMargin); 
object = document.getElementById("site_border_left");
if(object)
{
object.style.height = sideHeight+"px";
object.style.visibility = "visible";
}
object = document.getElementById("site_border_right");
if(object)
{
object.style.height = sideHeight+"px";
object.style.visibility = "visible";
}

// bottom
if(footerBelowMainDiv == 'Yes')
var siteBottomHeight = newDocHeight + 0*Number(window.siteBorderSize) + 1*Number(window.siteBorderPadding) - window.topMargin; 
else
var siteBottomHeight = docHeight + 0*Number(window.siteBorderSize) + 1*Number(window.siteBorderPadding) - window.topMargin; 
object = document.getElementById("site_border_bottom");
if(object)
{
object.style.top = siteBottomHeight+"px";
object.style.visibility = "visible";
}

// start scroll, if set
if(scrollSpeed > 0 && edit != 'Yes')
pageScroll(scrollSpeed,docHeight);

// end if stylesheet loaded
window.clearInterval(handle);
}
else if(window.loadTries > 300){
// show footer as is
object = document.getElementById("footer");
if(object) object.style.display = 'inline';
// follow below example for exceptions needed to force acceptable inline display during stylesheet failure
object = document.getElementById("vertical_menu");
if(object) object.style.position = 'relative';
window.clearInterval(handle);
alert("Note: stylesheet not loaded; page links, menu and contents displayed inline; refresh page to re-attempt normal view");
}
window.loadTries++;
}, 30 );

}

function setTextOfTextfield(objName,newText)
{ 
var object = document.getElementById(objName);
if (object)
object.value = newText;
}

function Set_Cookie( name, value, expires, path, domain, secure )
{

// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function ajaxFunction(myForm,myField,productid,minQtyType)
{
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  	if(myField == 'new_product_qty0')
  	 	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty0.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
      	}
      	document.qo_form.new_product_qty0.value=xmlHttp.responseText;
		Set_Cookie('qoQty0',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty0',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty1')
    	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty1.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty1.value=xmlHttp.responseText;
		Set_Cookie('qoQty1',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty1',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty2')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty2.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty2.value=xmlHttp.responseText;
		Set_Cookie('qoQty2',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty2',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty3')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty3.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty3.value=xmlHttp.responseText;
		Set_Cookie('qoQty3',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty3',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty4')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty4.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty4.value=xmlHttp.responseText;
		Set_Cookie('qoQty4',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty4',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty5')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty5.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty5.value=xmlHttp.responseText;
		Set_Cookie('qoQty5',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty5',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty6')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty6.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty6.value=xmlHttp.responseText;
		Set_Cookie('qoQty6',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty6',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty7')
      	{
		if(minQtyType == 'select')
		{
 		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty7.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
	   	document.qo_form.new_product_qty7.value=xmlHttp.responseText;
		Set_Cookie('qoQty7',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty7',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty8')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty8.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty8.value=xmlHttp.responseText;
		Set_Cookie('qoQty8',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty8',xmlHttp.responseText, '', '/');
		}
		else if(myField == 'new_product_qty9')
      	{
		if(minQtyType == 'select')
		{
		for (var i = 0; i < 51; i++)
		document.qo_form.new_product_qty9.options[i]=new Option(i*(xmlHttp.responseText), i*(xmlHttp.responseText));
		}
      	document.qo_form.new_product_qty9.value=xmlHttp.responseText;
		Set_Cookie('qoQty9',xmlHttp.responseText, '', '/');
		Set_Cookie('qoMinQty9',xmlHttp.responseText, '', '/');
		}
      }
    }
  xmlHttp.open("GET","../subscribe/cart_get_min_qty.php?productid="+productid,true); 
  xmlHttp.send(null);     
}

function ajaxFunction1(myDiv,productid,thisX,thisY,thisW) //
{

// only show xmlHttp if this current id - when mousing quickly over multiple items, only show last
currentProductId = productid;

// old, default offset width
if(typeof thisW == 'undefined' || !thisW)
var thisW = 38;

// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="/images/timer.gif">';
//document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.left = Math.round(thisX+thisW) + 'px'; //
document.getElementById(myDiv).style.top = Math.round(thisY) + 'px';
document.getElementById(myDiv).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4 && currentProductId == productid)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","/subscribe/product_details.php?productid="+productid,true); 
//  xmlHttp.open("GET","../subscribe/product_details.php?productid="+productid,true); 
  xmlHttp.send(null);     
}

function ajaxFunction2(myDiv,pageid)
{

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","../content/story_details.php?pageid="+pageid,true); 
  xmlHttp.send(null);     
}

// customer list
function ajaxFunction3(selectName,selectDiv,categoryId,flagId,onChange)
{

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(selectDiv).innerHTML=xmlHttp.responseText;
      }
    }

  xmlHttp.open("GET","../subscribe/customer_list.php?categoryid="+categoryId+"&flagid="+flagId+"&select_name="+selectName+"&onchange="+onChange,true); 

xmlHttp.send(null);     

}

function ajaxFunction4(myDiv,parentid,grandparentid,position,sectionid,text_only,thisX,thisY,thisW,ss,ps,gps,parentDb,namePrefix,currentid,currentParentid,currentGrandparentid,currentDb) //
{

// test
//alert("currentDb: " + currentDb);

// only show xmlHttp if this current id - when mousing quickly over multiple items, only show last
currentParentId = parentid;

// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="/images/timer.gif">';
//document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.left = Math.round(thisX+thisW) + 'px'; // -1
document.getElementById(myDiv).style.top = Math.round(thisY) + 'px';
document.getElementById(myDiv).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4 && currentParentId == parentid)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }
xmlHttp.open("GET","/content/child_pages.php?parentid="+parentid+"&position="+position+"&text_only="+text_only+"&sectionid="+sectionid+"&ss="+ss+"&ps="+ps+"&gps="+gps+"&parent_db="+parentDb+"&name_prefix="+namePrefix+"&currentid="+currentid+"&current_parentid="+currentParentid+"&current_grandparentid="+currentGrandparentid+"&grandparentid="+grandparentid+"&current_db="+currentDb,true); 
//xmlHttp.open("GET","../content/child_pages.php?parentid="+parentid+"&position="+position+"&text_only="+text_only+"&sectionid="+sectionid+"&ss="+ss+"&ps="+ps+"&gps="+gps+"&parent_db="+parentDb+"&name_prefix="+namePrefix+"&currentid="+currentid+"&current_parentid="+currentParentid+"&current_grandparentid="+currentGrandparentid+"&grandparentid="+grandparentid+"&current_db="+currentDb,true); 
xmlHttp.send(null);     
}

function ajaxFunctionSB(myDiv,parentid,grandparentid,position,sectionid,text_only,thisX,thisY,thisW,ss,ps,gps,parentDb,namePrefix,currentid,currentParentid,currentGrandparentid,numPages,endCaps,thisH,singlePageDrop) //
{
// only show xmlHttp if this current id - when mousing quickly over multiple items, only show last
currentParentId = parentid;

// test
//alert("parentid at js1260: " + parentid);
//alert("window.mostRecentParentID: " + window.mostRecentParentID);

// just show already obtained results; more work needed to work
//if(parentid == window.mostRecentParentID)
//{
//document.getElementById(myDiv).style.visibility = 'visible';
//return true;
//}

if(typeof thisH == 'undefined' || !thisH)
var thisH = 0;

// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.left = Math.round(thisX+thisW) + 'px'; // -1
document.getElementById(myDiv).style.top = Math.round(thisY+thisH) + 'px';  // -1
document.getElementById(myDiv).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4 && currentParentId == parentid)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
//	  window.mostRecentParentID = parentid;
      }
    }
xmlHttp.open("GET","../content/story_buttons.php?parentid="+parentid+"&position="+position+"&text_only="+text_only+"&sectionid="+sectionid+"&ss="+ss+"&ps="+ps+"&gps="+gps+"&parent_db="+parentDb+"&name_prefix="+namePrefix+"&currentid="+currentid+"&current_parentid="+currentParentid+"&current_grandparentid="+currentGrandparentid+"&grandparentid="+grandparentid+"&num_pages="+numPages+"&end_caps="+endCaps+"&single_page_drop="+singlePageDrop,true); 
xmlHttp.send(null);     
}

// customer record update
function ajaxFunction5(customerId,field,data)
{

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//	  document.getElementById(selectDiv).innerHTML=xmlHttp.responseText;
      }
    }

xmlHttp.open("GET","../subscribe/customer_field_update.php?customerid="+customerId+"&field="+field+"&data="+data,true); 

xmlHttp.send(null);     

}

function ajaxFunction6(myDiv,start,fieldName,formName,method) //
//function ajaxFunction6(myDiv,start,parentDb,fieldName,formName,method) //
{

// visibility first, works above
document.getElementById(myDiv).style.visibility = 'visible';

//if(status == 'startOver' && start.length > 4)
//return true;

// ok
//alert("myDiv: "+myDiv);
//alert("start: "+start);
//alert("parentDb: "+parentDb);
//alert("fieldName: "+fieldName);

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4 && (xmlHttp.responseText))
      {

// test:fail,ok
//alert(xmlHttp.responseText);

		
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }

// test:ok
//alert("OK to just before get statement");

  xmlHttp.open("GET","../email/find_records.php?start="+start+"&field_name="+fieldName+"&div_name="+myDiv+"&form_name="+formName+"&method="+method,true); 

// test:ok
//alert("OK to just after get statement");


  xmlHttp.send(null);     
}


function ajaxFunction7(myDiv, linkType, link, linkId, editMode, linkAjaxHolder, timer, linkDiv, assignId, x, y, css, from, updateOnly, parentDb, parentId, linkStatus, linkDisplayType, paperCode) //
{
// reset to null 
if(typeof editMode == 'undefined' || !editMode || editMode == 'undefined')
var editMode = '';

// reset to null 
if(typeof linkAjaxHolder == 'undefined' || !linkAjaxHolder || linkAjaxHolder == 'undefined')
var linkAjaxHolder = '';

// reset to null 
if(typeof timer == 'undefined' || !timer || timer == 'undefined')
var timer = '';

// reset to null 
if(typeof linkDiv == 'undefined' || !linkDiv || linkDiv == 'undefined')
var linkDiv = '';

// reset to null 
if(typeof assignId == 'undefined' || !assignId || assignId == 'undefined')
var assignId = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = '';

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined')
var parentId = '';

// reset to null 
if(typeof linkStatus == 'undefined' || !linkStatus || linkStatus == 'undefined')
var linkStatus = '';

// reset to null 
if(typeof linkDisplayType == 'undefined' || !linkDisplayType || linkDisplayType == 'undefined')
var linkDisplayType = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined')
var paperCode = '';

// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;

	  // try
	  if(linkType == 'download' && editMode == 'ajax_detail')
	  startFileUploadify('links', linkId, 'link_assignments', assignId, parentDb, parentId, timer, from, myDiv, x, y, linkDisplayType, paperCode);

      }
    }
  xmlHttp.open("GET","../content/link_types.php?link_type="+linkType+"&link="+link+"&linkid="+linkId+"&edit_mode="+editMode+"&link_ajax_holder="+linkAjaxHolder+"&timer="+timer+"&link_div="+linkDiv+"&assignid="+assignId+"&x="+x+"&y="+y+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&parent_db="+parentDb+"&parentid="+parentId+"&link_status="+linkStatus+"&link_display_type="+linkDisplayType,true); 
  xmlHttp.send(null);     
}


function ajaxFunction8(myDiv,field,data,taskId,view,return_url,showDone,thisPage,updateOnly,search,newOnly,fromNewOnly,startDate,endDate,ChildNoteList,parentDb,parentId,hideRowOnChangeId) //
{
// reset to null 
if(typeof ChildNoteList == 'undefined' || !ChildNoteList || ChildNoteList == 'undefined')
var ChildNoteList = null;

// reset to null 
if(typeof fromNewOnly == 'undefined' || !fromNewOnly || fromNewOnly == 'undefined')
var fromNewOnly = null;

// timer - list changing; id'd timer may not be there
if(!field && !data)
var timer = "timer" + view;
else
var timer = "timer" + taskId + view;

document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';

// ajax
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
// response
xmlHttp.onreadystatechange=function()
{
    if(xmlHttp.readyState==4)
      {
      document.getElementById(timer).style.visibility = 'hidden';
	  if(field == 'status')
	  {		 

	// test: leftover parentDb set
	// alert("startDate at jsf1432: " + startDate);
	// alert("parentDb at jsf1433: " + parentDb);
	
	  if((!startDate || startDate == 0 || typeof startDate == 'undefined') && (!parentDb || parentDb == '' || typeof parentDb == 'undefined') )
	  document.getElementById(myDiv).style.display = 'none';
	  }
	  if(field == 'parentid' && hideRowOnChangeId)
	  document.getElementById(hideRowOnChangeId).style.display = 'none';

	  else if(field == 'highlight' && data == true)
	  document.getElementById(myDiv).style.background='#ffff00';
	  else if(field == 'highlight' && data != true)
	  document.getElementById(myDiv).style.background='#ffffff';
      else if(updateOnly);
	  else
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	  }
}

// update/new options
if(field && field == 'task')
{
// switching to POST for large data strings
var url = "../notes/task_update.php";
var params = "field="+field+"&data="+data+"&taskidA="+taskId+"&view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
else if(!taskId && search)
xmlHttp.open("GET","../notes/task_update.php?view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&search="+search+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!taskId)
xmlHttp.open("GET","../notes/task_update.php?view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(field)
xmlHttp.open("GET","../notes/task_update.php?field="+field+"&data="+data+"&taskidA="+taskId+"&view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate,true); 
else
xmlHttp.open("GET","../notes/task_update.php?taskid="+taskId+"&view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 

// don't send get method unless using one of last three above
if(!field || field != 'task' )
xmlHttp.send(null);     

// child note list
var myDivn = "notes" + view;
if(taskId && !field && ChildNoteList == 'show')
{
ajaxFunction9(myDivn, '', '', '', view, '','','','','','','','', 'tasks', taskId);
}
else if(ChildNoteList == 'hide')
ajaxFunction9(myDivn, '', '', '', view);
}

function ajaxFunction9(myDiv, field, data, noteId, view, return_url, showDate, thisPage, updateOnly, search, newOnly, fromNewOnly, createdOn, parentDb, parentId, startDate, endDate) //
{
// reset to null 
if(typeof fromNewOnly == 'undefined' || !fromNewOnly || fromNewOnly == 'undefined')
var fromNewOnly = null;

var timer = "timern" + noteId + view;

if(updateOnly || field == 'start_stop')
{
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';
}
else
{
// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
if(newOnly != 'Yes')
document.getElementById(myDiv).style.visibility = 'visible';
}

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  if(updateOnly)
      document.getElementById(timer).style.visibility = 'hidden';
	  else
	  {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      if(field == 'start_stop')
      document.getElementById(timer).style.visibility = 'hidden';
      }
      }
    }

if(field)
{
// switching to POST for large data strings
var url = "../notes/note_update.php";
var params = "field="+field+"&data="+data+"&noteidA="+noteId+"&view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&created_on="+createdOn+"&parent_db="+parentDb+"&parentid="+parentId+"&start_date="+startDate+"&end_date="+endDate;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
else if(!noteId && !search)
xmlHttp.open("GET","../notes/note_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!noteId)
xmlHttp.open("GET","../notes/note_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&search="+search+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else
xmlHttp.open("GET","../notes/note_update.php?noteid="+noteId+"&view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 

// don't send get methos unless using one of last three above
if(!field)
xmlHttp.send(null);     
}

// parent list
function ajaxFunctionPL(myDiv, parentDb, parentId, childDb, childId, view, selectName, hideRowOnChangeId, assignId)
{

// test:ok, calendar, 4825
//alert("childDb at jsf1573: " + childDb);
//alert("assignId at jsf1573: " + assignId);

if(childDb == 'calendar')
var timer = "timere" + assignId + view;
else if(childDb == 'notes')
var timer = "timern" + childId + view;
else
var timer = "timer" + childId + view;

// test:fail
//alert("timer at jsf1580: " + timer);

document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	  document.getElementById(timer).style.visibility = 'hidden';
      }
    }

xmlHttp.open("GET","../admin/parent_list.php?ajax_holder="+myDiv+"&select_name="+selectName+"&parent_db="+parentDb+"&parentid="+parentId+"&child_db="+childDb+"&childid="+childId+"&view="+view+"&hide_row_on_change_id="+hideRowOnChangeId+"&assignid="+assignId,true); 
xmlHttp.send(null);     
}

function ajaxFunction10(myDiv,productId,qty,stage,mode,name) //
{
// try visibility first, so not delayed and countermanding hide from exit during scanning of page
var startHeight = document.getElementById(myDiv).offsetHeight;
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.visibility = 'visible';


var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

//		alert(xmlHttp.responseText);

	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	  var endHeight = document.getElementById(myDiv).offsetHeight;
	  var changeHeight = endHeight - startHeight;
	  adjustFooter(changeHeight);
      }
    }

xmlHttp.open("GET","../subscribe/cart_item_update.php?productid="+productId+"&qty="+qty+"&stage="+stage+"&mode="+mode+"&name="+name,true); 
xmlHttp.send(null);     
}

// for showing select of option primarily
function ajaxFunctionShowSelect(myDiv,parentDb,parentId,subscriptionId,qty,name) //
{
// try visibility first, so not delayed and countermanding hide from exit during scanning of page
var startHeight = document.getElementById(myDiv).offsetHeight;
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	  var endHeight = document.getElementById(myDiv).offsetHeight;
	  var changeHeight = endHeight - startHeight;
	  adjustFooter(changeHeight);
      }
    }

xmlHttp.open("GET","../subscribe/show_select.php?parent_db="+parentDb+"&parentid="+parentId+"&subscriptionid="+subscriptionId+"&qty="+qty+"&name="+name,true); 
xmlHttp.send(null);     
}



// updates one field in a database; secure doesn't work
function ajaxFunction11(myDiv,field,data,parentDb,parentId,idField,securePath,paperCode,encrypt) //
{
// try visibility first, so not delayed and countermanding hide from exit during scanning of page
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';

if(!encrypt)
var encrypt = '';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }

if(field)
{
var url = securePath + "/admin/field_update.php";
var params = "field="+field+"&data="+data+"&parent_db="+parentDb+"&parentid="+parentId+"&id_field="+idField+"&secure_path="+encodeURIComponent(securePath)+"&paper_code="+paperCode+"&encrypt="+encrypt;

xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
}

function ajaxFunction12(myDiv,selectId,answerParentDb,answerParentId,choiceId,n) //
{
document.getElementById("timer").innerHTML='<img src="../images/timer.gif">';
document.getElementById("timer").style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById("timer").style.visibility = 'hidden';

	  // testing
//	  document.getElementById("timer").innerHTML=xmlHttp.responseText;
      }
    }

xmlHttp.open("GET","../subscribe/select_item_update.php?selectid="+selectId+"&answer_parent_db="+answerParentDb+"&answer_parentid="+answerParentId+"&choiceid="+choiceId+"&n="+n,true); 
xmlHttp.send(null);     
}

function ajaxFunction13(myDiv,inputId,answerParentDb,answerParentId,answer,n) //
{
document.getElementById("timer").innerHTML='<img src="../images/timer.gif">';
document.getElementById("timer").style.visibility = 'visible';

// test:ok
//alert("answer js1969: " + answer);

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById("timer").style.visibility = 'hidden';
      }
    }

xmlHttp.open("GET","../subscribe/input_item_update.php?inputid="+inputId+"&answer_parent_db="+answerParentDb+"&answer_parentid="+answerParentId+"&answer="+answer+"&n="+n,true); 
xmlHttp.send(null);     
}

function ajaxFunction14(myDiv,optionId,assignId,n,add,qty,name,questionsDiv) //
{
document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';
document.getElementById(myDiv).style.visibility = 'visible';

// reset to null 
if(typeof questionsDiv == 'undefined' || !questionsDiv || questionsDiv == 'undefined' || questionsDiv == 'null')
var questionsDiv = '';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  var response = xmlHttp.responseText;

//	  alert(response);

	  // parse new subscription ID from response
	  if(response.indexOf("subscriptionid=") != -1 && questionsDiv)
	  {
	  var start = response.indexOf("subscriptionid=") + 15;
	  var end = response.indexOf(">");
	  var length = end - start;
	  var subscriptionId = response.substr(start,length);
	  
	  // test:subscriptionid js2041: 4346, ok
	  //alert("subscriptionid js2041: " + subscriptionid);
	  
	  // show questions
	  var parentDb = 'product_options';
	  ajaxFunctionShowSelect(questionsDiv,parentDb,optionId,subscriptionId,qty,name) //
	  }

	  document.getElementById(myDiv).innerHTML=response;
//	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }

xmlHttp.open("GET","../subscribe/option_item_update.php?optionid="+optionId+"&assignid="+assignId+"&add="+add+"&qty="+qty+"&n="+n+"&name="+name,true); 
xmlHttp.send(null);     
}

function ajaxFunction15(myDiv, select_name, color, form_name, table, zero_value, zero_message, extra_value, extra_label, font_size, mode, onchange, recordDb, recordId, idField, css, from, updateMethod, parentDb, parentId, format, letter)
//function ajaxFunction15(myDiv, select_name, color, form_name, table, zero_value, zero_message, extra_value, extra_label, font_size, mode, onchange)
{

// tests
//alert("parentDb js2219: " + parentDb);   // ok, stories
//alert("parentId: " + parentId);  // ok, 2493

// reset to null 
if(typeof recordDb == 'undefined' || !recordDb || recordDb == 'undefined' || recordDb == 'null')
var recordDb = '';
// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';
// reset to null 
if(typeof idField == 'undefined' || !idField || idField == 'undefined' || idField == 'null')
var idField = '';
// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';
// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';
// reset to null 
if(typeof updateMethod == 'undefined' || !updateMethod || updateMethod == 'undefined' || updateMethod == 'null')
var updateMethod = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';
// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';
// reset to null 
if(typeof format == 'undefined' || !format || format == 'undefined' || format == 'null')
var format = '';
// reset to null 
if(typeof letter == 'undefined' || !letter || letter == 'undefined' || letter == 'null')
var letter = '';

document.getElementById(myDiv).innerHTML='<img src="../images/timer.gif">';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      }
    }

xmlHttp.open("GET","../admin/color_list.php?select_name="+select_name+"&color="+encodeURIComponent(color)+"&form_name="+form_name+"&table="+table+"&zero_value="+zero_value+"&zero_message="+zero_message+"&extra_value="+extra_value+"&extra_label="+extra_label+"&font_size="+font_size+"&mode="+mode+"&onchange="+onchange+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&css="+css+"&from="+from+"&update_method="+updateMethod+"&parent_db="+parentDb+"&parentid="+parentId+"&format="+format+"&letter="+letter,true);   // css, from, updateMethod
xmlHttp.send(null);     
}

/********************************
COLOR INSERT OR ASSIGN
********************************/
function ajaxFunctionCIA(hex, useFor) //
{

//alert("ok js2291");
//alert(hex);
//alert(useFor);

// reset to null 
if(typeof hex == 'undefined' || !hex || hex == 'undefined' || hex == 'null')
var hex = null;
// reset to null 
if(typeof useFor == 'undefined' || !useFor || useFor == 'undefined' || useFor == 'null')
var useFor = null;

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// refresh recent color list if any change; no response if not
var response = xmlHttp.responseText;
if(response)
var recentE = document.getElementById("recent_colors");
if(recentE && response)
recentE.innerHTML = response;

}
}

// switching to POST for large data strings
var url = "../utilities/color_update.php";
var params = "hex="+hex+"&use_for="+useFor+"&update_method=ajax";
xmlHttp.open("POST", url, true);
// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);

}

function ajaxFunction16(sourceFile,description,emailid,key) //
{
document.getElementById("atimer").innerHTML='<img src="../images/timer.gif">';
document.getElementById("atimer").style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

//	  document.getElementById("atimer").style.visibility = 'hidden';
	  // testing
  document.getElementById("atimer").innerHTML=xmlHttp.responseText;
      }
    }

// test:ok
//alert("ok to js1856");

//xmlHttp.open("GET","../utilities/copy_to_document.php",true); 
//xmlHttp.open("GET","../utilities/copy_to_document.php?source_file="+sourceFile,true); 
xmlHttp.open("GET","../utilities/copy_to_document.php?source_file="+encodeURIComponent(sourceFile)+"&description="+encodeURIComponent(description)+"&emailid="+emailid+"&key="+key,true); 
//xmlHttp.open("GET","../utilities/copy_to_document.php?source_file="+sourceFile+"&description="+description+"&archive="+archive,true); 

// test:OK
//alert("OK to js1868");

xmlHttp.send(null);     
}

function ajaxFunction17(myDiv, field, data, contactId, view, return_url, showLetter, thisPage, updateOnly, search, newOnly, fromNewOnly, createdOn, parentDb, parentId, startDate, endDate, activityId, size, categoryId, flagId) //
{

// test:ok, then fail
//alert("categoryId js2399: " + categoryId);

// reset to null 
if(typeof fromNewOnly == 'undefined' || !fromNewOnly || fromNewOnly == 'undefined')
var fromNewOnly = null;

// reset updateOnly to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = null;

// reset categoryId to null 
if(typeof categoryId == 'undefined' || !categoryId || categoryId == 'undefined')
var categoryId = '';
// reset flagId to null 
if(typeof flagId == 'undefined' || !flagId || flagId == 'undefined')
var flagId = '';

var timer = "timerc" + view;

// simplify
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  if(updateOnly)
      document.getElementById(timer).style.visibility = 'hidden';
	  else
	  {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      document.getElementById(timer).style.visibility = 'hidden';

// scroll
if(field != 'email' && field != 'fax' && field != 'call' && field != 'call_appt' && field != 'mailing' && field != 'appointment' && field != 'sale')
{

/* moving down
function scrollToAdmin(myDiv, view, size, newOnly)
{
// reset to null 
if(typeof view == 'undefined' || !view || view == 'undefined' || view == 'null')
var view = '';
// reset to null 
if(typeof size == 'undefined' || !size || size == 'undefined' || size == 'null')
var size = '';
// reset to null 
if(typeof newOnly == 'undefined' || !newOnly || newOnly == 'undefined' || newOnly == 'null')
var newOnly = '';

if(newOnly == 'Yes')
window.ccc++;
else
window.ccc = 1;
// try scroll
var offsetTop = 0;
var divId = document.getElementById(myDiv);

if(newOnly != 'Yes')
offsetTop += divId.offsetTop;
else
{
// recursive for new within new, etc.
for(var c=0;c<window.ccc;c++)
{
offsetTop += divId.offsetTop + divId.offsetParent.offsetTop;
divId = divId.offsetParent.offsetParent;
}
}
// scroll
if(size == 'small')
window.scrollTo(0,offsetTop);
else
if(view == 'full_page')
document.getElementById("big_scroll").scrollTop=offsetTop;
else if(view == '')
document.getElementById("side_scroll").scrollTop=offsetTop;
}
*/

scrollToAdmin(myDiv, view, size, newOnly);

}

}

}
}

if(field)
{
// switching to POST for large data strings
var url = "../notes/contact_update.php";
var params = "field="+field+"&data="+data+"&contactid="+contactId+"&view="+view+"&return="+return_url+"&show_letter="+showLetter+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&created_on="+createdOn+"&parent_db="+parentDb+"&parentid="+parentId+"&start_date="+startDate+"&end_date="+endDate+"&activityid="+activityId+"&categoryid="+categoryId+"&flagid="+flagId;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
else if(!contactId && !search)
xmlHttp.open("GET","../notes/contact_update.php?view="+view+"&return="+return_url+"&show_letter="+showLetter+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId+"&categoryid="+categoryId+"&flagid="+flagId,true); 
//xmlHttp.open("GET","../notes/contact_update.php?view="+view+"&return="+return_url+"&show_letter="+showLetter+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!contactId)
xmlHttp.open("GET","../notes/contact_update.php?view="+view+"&return="+return_url+"&show_letter="+showLetter+"&this_page="+thisPage+"&search="+search+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId+"&categoryid="+categoryId+"&flagid="+flagId,true); 
else
xmlHttp.open("GET","../notes/contact_update.php?contactid="+contactId+"&view="+view+"&return="+return_url+"&show_letter="+showLetter+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId+"&search="+search+"&categoryid="+categoryId+"&flagid="+flagId,true); 

// don't send get methos unless using one of last three above
if(!field)
xmlHttp.send(null);     
}

function ajaxFunction18(myDiv, field, data, calendarId, assignId, view, return_url, showDone, thisPage, updateOnly, search, newOnly, fromNewOnly, createdOn, parentDb, parentId, startDate, endDate) //
{
// reset to null 
if(typeof fromNewOnly == 'undefined' || !fromNewOnly || fromNewOnly == 'undefined')
var fromNewOnly = null;

if(calendarId)
var timer = "timere" + assignId + view;
else
var timer = "timere" + view;

// simplify
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  if(updateOnly)
      document.getElementById(timer).style.visibility = 'hidden';
	  else
	  {
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
      document.getElementById(timer).style.visibility = 'hidden';
	  }

	  if(field == 'status' && data == true)
	  document.getElementById(myDiv).style.display = 'none';
	  }
    }

if(field)
{
// switching to POST for large data strings
var url = "../notes/calendar_update.php";
var params = "field="+field+"&data="+data+"&calendarid="+calendarId+"&assignid="+assignId+"&view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&created_on="+createdOn+"&parent_db="+parentDb+"&parentid="+parentId+"&start_date="+startDate+"&end_date="+endDate;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
else if(!calendarId && !search)
xmlHttp.open("GET","../notes/calendar_update.php?view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!calendarId)
xmlHttp.open("GET","../notes/calendar_update.php?view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&search="+search+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else
xmlHttp.open("GET","../notes/calendar_update.php?calendarid="+calendarId+"&assignid="+assignId+"&view="+view+"&return="+return_url+"&show_done="+showDone+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 

// don't send get methos unless using one of last three above
if(!field)
xmlHttp.send(null);     
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;

	} while (obj = obj.offsetParent);
return [curleft,curtop];
}
}

function findChild(obj) {
	var curHeight = curleft = curtop = 0;
obj = obj.firstChild;
//while (obj = obj.firstChild)
	{
	if (obj) {

//alert("left: " + obj.offsetLeft);
//alert("top: " + obj.offsetTop);
//alert("height: " + obj.offsetHeight);

		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		curHeight += obj.offsetHeight;  
	}
	} 
return [curleft,curtop,curHeight];
}

function ajaxFunctionTest(message)
{
alert(message);
}

/*************************************************************************
BEGIN NEW GENERIC RECORD FUNCTIONS -- from notes
*************************************************************************/
function ajaxFunctionRE(myDiv, rte, field, recordDb, recordId, idField, returnEncode, css, displayType, imageWidth, imageHeight, x, y, sidebarWidth, sidebarHeight, from, obj, parentDb, parentId, assignId, linkDisplayType) //
{

// test: end only
//alert(css);

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = '';

// get pos. on page
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
}

// for table in rte
window.includesPath = '../admin/';

// block other edits
textEditing = 'on';

// reset to null 
if(typeof returnEncode == 'undefined' || !returnEncode || returnEncode == 'undefined' || returnEncode == 'null')
var returnEncode = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof displayType == 'undefined' || !displayType || displayType == 'undefined' || displayType == 'null')
var displayType = '';

// reset to null 
if(typeof imageWidth == 'undefined' || !imageWidth || imageWidth == 'undefined' || imageWidth == 'null')
var imageWidth = '';

// reset to null 
if(typeof imageHeight == 'undefined' || !imageHeight || imageHeight == 'undefined' || imageHeight == 'null')
var imageHeight = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined' || x == 'null')
var x = 0;

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined' || y == 'null')
var y = 0;

// reset to null 
if(typeof sidebarWidth == 'undefined' || !sidebarWidth || sidebarWidth == 'undefined' || sidebarWidth == 'null')
var sidebarWidth = 0;

// reset to null 
if(typeof sidebarHeight == 'undefined' || !sidebarHeight || sidebarHeight == 'undefined' || sidebarHeight == 'null')
var sidebarHeight = 0;

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';
// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';
// reset to null 
if(typeof assignId == 'undefined' || !assignId || assignId == 'undefined' || assignId == 'null')
var assignId = '';
// reset to null 
if(typeof linkDisplayType == 'undefined' || !linkDisplayType || linkDisplayType == 'undefined' || linkDisplayType == 'null')
var linkDisplayType = '';

// timer
if(displayType == 'flash')
var timer = "timer" + recordId + recordDb;
else
var timer = "timerR";  // new

// test:ok. fail after, same
//alert(timer);

document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

var thisDiv = document.getElementById(myDiv);

if(displayType == 'flash' && imageWidth)
var thisWidth = imageWidth;

else if(obj)
var thisWidth = obj.offsetWidth;

else
var thisWidth = thisDiv.offsetWidth;
if(displayType == 'flash')
var thisHeight = 60;

else if(obj)
var thisHeight = obj.offsetHeight;

else
var thisHeight = thisDiv.offsetHeight;

var timerLeft = thisDiv.offsetLeft + thisWidth;
var timerTop = thisDiv.offsetTop;

// test: curs undef in flash
//alert("curLeft: " + curLeft);
//alert("curTop: " + curTop);
//alert("timerLeft: " + timerLeft);
//alert("timerTop: " + timerTop);

if(displayType == 'flash')
{
document.getElementById(timer).style.left = timerLeft + 'px'; //
document.getElementById(timer).style.top = timerTop + 'px'; // 83
}
else
{
document.getElementById(timer).style.left = curLeft + 'px'; //
document.getElementById(timer).style.top = curTop + 'px'; // 83
}
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

      var response = xmlHttp.responseText;
     
      // try
	  document.getElementById(timer).innerHTML=response;

	  if(displayType == 'flash')
	  {
	  document.getElementById(timer).style.left = (-2) + 'px'; //
	  if(imageHeight > 300)
	  document.getElementById(timer).style.top = (imageHeight-145) + 'px'; // - 47
	  else if(imageHeight > 100)
	  document.getElementById(timer).style.top = (imageHeight-50) + 'px'; // - 47
	  else
	  document.getElementById(timer).style.top = (imageHeight) + 'px'; // - 47
	  }
	  else if (field == 'price')	// new for inline text editing
	  {	
	  document.getElementById(timer).style.left = curLeft-2 + 'px'; //
	  document.getElementById(timer).style.top = curTop-2 + 'px'; // 83
	  return true;	
 	  }
	  else	// new for inline text editing
	  {	
	  document.getElementById(timer).style.left = curLeft-2 + 'px'; //
	  document.getElementById(timer).style.top = curTop-74 + 'px'; // 83
 	  }

	  // new
	  ajaxFunctionRF(rte, field, recordDb, recordId, idField, css);

      }
    }

//if(!recordId)  // not done
//xmlHttp.open("GET","../admin/record_edit.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
//else
xmlHttp.open("GET","../admin/record_edit.php?my_div="+myDiv+"&rte="+rte+"&field="+field+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&return_encode="+returnEncode+"&width="+thisWidth+"&height="+thisHeight+"&css="+css+"&display_type="+displayType+"&x="+x+"&y="+y+"&sidebar_width="+sidebarWidth+"&sidebar_height="+sidebarHeight+"&from="+from+"&parent_db="+parentDb+"&parentid="+parentId+"&assignid="+assignId+"&link_display_type="+linkDisplayType,true);  //editFile, updateFile, getId

xmlHttp.send(null);     
}

/*************************************************************************
RECORD FRAME
*************************************************************************/
function ajaxFunctionRF(rte, field, recordDb, recordId, idField, css) //
{

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  var frameHtml=xmlHttp.responseText;
	  enableDesignMode(rte, frameHtml, '', '', '', rte);  // 2nd rte needed for allRTEs var, pseudo array, always just one here
      }
    }

//xmlHttp.open("GET","../admin/record.php?field="+field+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&css="+css+"&db_field="+dbField,true); 
xmlHttp.open("GET","../admin/record.php?field="+field+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&css="+css,true); 

xmlHttp.send(null);     
}


function ajaxFunctionRU(myDiv, field, data, recordDb, recordId, idField, format, displayType, css, updateOnly, obj, field1, data1) //
{

// test
//alert(field);
//alert(data);
//alert(recordDb);  // blank
//alert(recordId);  // blank
//alert(idField);

// when updated
textEditing = 'off';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';

// reset to null 
if(typeof format == 'undefined' || !format || format == 'undefined' || format == 'null')
var format = null;

// reset to null 
if(typeof displayType == 'undefined' || !displayType || displayType == 'undefined' || displayType == 'null')
var displayType = null;

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined' || updateOnly == 'null')
var updateOnly = null;

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = null;

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined' || field1 == 'null')
var field1 = '';
// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined' || data1 == 'null')
var data1 = '';

if(displayType == 'flash')
var timer = "timer" + recordId + recordDb;
else
var timer = "timerR";

var timerChild = "timerRC";

if(updateOnly == 'Yes')
{
// get pos. on page
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
var curWidth = obj.offsetWidth;
}

var timerChildE = document.getElementById(timerChild);
timerChildE.innerHTML='<img src="../images/timer.gif">';
timerChildE.style.left = (curLeft + curWidth)  + 'px';
timerChildE.style.top = curTop + 'px';
timerChildE.style.visibility = 'visible';
}
else
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

	  // for new caption return; textEditing off above
	  imageEditing = 'off';

	// test:ok
	//alert(format);

	  // new
	  if(format == 'spell')
	  {
	  document.getElementById(timer).innerHTML=xmlHttp.responseText;
	  document.getElementById(timer).style.top = (Math.round(document.getElementById(timer).offsetTop)+75) + 'px';
	  }
	  else
	  if(updateOnly != 'Yes')   // disble to test
	  document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	  // hide litte or big timer
	  if(updateOnly == 'Yes')
      timerChildE.style.visibility = 'hidden';
	  else if(format != 'spell')
      document.getElementById(timer).style.visibility = 'hidden';
      }
    }

// test:ok
//alert(recordDb);
//alert(recordId);
//alert(field);
//alert(data);
//alert(idField);

if(field)
{
data = unescape(data);
// switching to POST for large data strings
var url = "../admin/record_update.php";
var params = "field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&ajax_holder="+myDiv+"&format="+format+"&display_type="+displayType+"&css="+css+"&field1="+field1+"&data1="+data1;
//var params = "field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&ajax_holder="+myDiv+"&format="+format+"&display_type="+displayType+"&css="+css;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=ISO-8859-1");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
else if(!recordId && !search)
xmlHttp.open("GET","../admin/record_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!recordId)
xmlHttp.open("GET","../admin/record_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&search="+search+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else
xmlHttp.open("GET","../admin/record_update.php?recordid="+recordId+"&view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 

// don't send get methos unless using one of last three above
if(!field)
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW RECORD EDIT DETAIL FUNCTIONS -- from RE
*************************************************************************/
function ajaxFunctionRED(myDiv, recordDb, recordId, idField, css, from, obj, parentDb, parentId, paperCode, imageDisplayType, scriptObj, listId, parentName, assignId, fromButton, currentPageId, link, format, letter, imgWidth, imgHeight, x, y, timerQuickImage, openedFrom)  //
{

// test:nr
//alert(recordDb);
//alert(recordId);
//alert(idField);
//alert(css);

// test:ok, flash
//alert("imageDisplayType js2990: " + imageDisplayType);

// reset to null 
if(typeof myDiv == 'undefined' || !myDiv || myDiv == 'undefined' || myDiv == 'null')
var myDiv = '';

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = '';

// reset to null 
if(typeof format == 'undefined' || !format || format == 'undefined' || format == 'null')
var format = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined' || x == 'null')
var x = 0;
// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined' || y == 'null')
var y = 0;
// reset to null 
if(typeof imageDisplayType == 'undefined' || !imageDisplayType || imageDisplayType == 'undefined' || imageDisplayType == 'null')
var imageDisplayType = '';
// reset to null 
if(typeof openedFrom == 'undefined' || !openedFrom || openedFrom == 'undefined' || openedFrom == 'null')
var openedFrom = '';

// try
if(openedFrom == 'cutline')
obj = document.getElementById(myDiv);

// get pos. on page; not used?
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
var curHeight = obj.offsetHeight;
if(recordDb == 'banners')
curTop += curHeight;

// adjust image detail panel to match image position; more needed for flash, x-y pos.
if(format == 'image' && openedFrom != 'cutline')
{
curLeft -= 98;
if(imageDisplayType == 'flash')
curTop -= 23;
else
curTop -= (Math.round(imgHeight) -49);  // -65
}

}

// block other edits
textEditing = 'on';

// for table in rte
window.includesPath = '../admin/';

// for tracking if changes made
window.changesMade = 'No';

// reset to null 
if(typeof recordDb == 'undefined' || !recordDb || recordDb == 'undefined' || recordDb == 'null')
var recordDb = '';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';

// reset to null 
if(typeof idField == 'undefined' || !idField || idField == 'undefined' || idField == 'null')
var idField = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof displayType == 'undefined' || !displayType || displayType == 'undefined' || displayType == 'null')
var displayType = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// test:fail
//alert("paperCode js2901: "  + paperCode);

// reset to null 
if(typeof scriptObj == 'undefined' || !scriptObj || scriptObj == 'undefined' || scriptObj == 'null')
var scriptObj = '';

// reset to null 
if(typeof listId == 'undefined' || !listId || listId == 'undefined' || listId == 'null')
var listId = '';

// reset to null 
if(typeof parentName == 'undefined' || !parentName || parentName == 'undefined' || parentName == 'null')
var parentName = '';

// reset to null 
if(typeof assignId == 'undefined' || !assignId || assignId == 'undefined' || assignId == 'null')
var assignId = '';

// reset to null 
if(typeof fromButton == 'undefined' || !fromButton || fromButton == 'undefined' || fromButton == 'null')
var fromButton = '';

// reset to null 
if(typeof currentPageId == 'undefined' || !currentPageId || currentPageId == 'undefined' || currentPageId == 'null')
var currentPageId = '';

// reset to null 
if(typeof link == 'undefined' || !link || link == 'undefined' || link == 'null')
var link = '';

// reset to null 
if(typeof letter == 'undefined' || !letter || letter == 'undefined' || letter == 'null')
var letter = '';

// reset to null 
if(typeof imgWidth == 'undefined' || !imgWidth || imgWidth == 'undefined' || imgWidth == 'null')
var imgWidth = 0;

// reset to null 
if(typeof imgHeight == 'undefined' || !imgHeight || imgHeight == 'undefined' || imgHeight == 'null')
var imgHeight = 0;

// reset to null 
if(typeof timerQuickImage == 'undefined' || !timerQuickImage || timerQuickImage == 'undefined' || timerQuickImage == 'null')
var timerQuickImage = 0;

// edit or follow
if(link)
{
var answer = confirm("Click OK to edit this event, or Cancel for the public detail view.")
if(!answer)
{
window.location = link;
return false;
}
}

// extract vars if returning from uploadify
if(scriptObj)
{
myDiv = scriptObj.myDiv;
recordDb = scriptObj.parent_db;  // from image's perspective
recordId = scriptObj.parentid;   // "
idField = scriptObj.id_field;
parentDb = scriptObj.parentDb;   // parent of record
parentId = scriptObj.parentId;   // "
css = scriptObj.css;
from = scriptObj.from;
paperCode = scriptObj.paperCode;
imageDisplayType = scriptObj.imageDisplayType;
}

// timer
if(listId)
var timer = "timerRC";  // new
else
var timer = "timerR";  // new

document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

if(listId || fromButton || format == 'image')
{
document.getElementById(timer).style.left = curLeft + 'px';
document.getElementById(timer).style.top = curTop + 'px';
}
//var thisDiv = document.getElementById(myDiv);

document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

      var response = xmlHttp.responseText;
     
      // try
	  if(listId)
	  {
	  document.getElementById(listId).innerHTML=response;
	  document.getElementById(timer).style.visibility = 'hidden';
	  }
	  else	  
	  document.getElementById(timer).innerHTML=response;

      // hide timer if not holding reponse


	  if(recordDb == 'select_questions' || recordDb == 'input_questions')
	  {
	  window.open_panel = "select_";
	  window.show_hide = "yes";
	  }

// start rich text fields
if(format == 'image')
launchRTEs(response, parentDb, parentId, idField, css);
else
launchRTEs(response, recordDb, recordId, idField, css);

// if image, start js
if(format == 'image')
{
// use inner image size to calc cropping if fixed size image; transparency adjust on update side
/*
if($fixed_size == 'Yes' && $click_mode != 'transparency')
{
echo 'var imgWidth = '.$tn_width.';';
echo 'var imgHeight = '.$tn_height.';';
echo 'var xAdj = '.$x_adj.';';
echo 'var yAdj = '.$y_adj.';';
}
else
{
*/
//var imgWidth = '.$img_width.';';
//var imgHeight = '.$img_height.';';
var xAdj = 0;
var yAdj = 0;
//}

var newPtLtr = '';
window.newPtLtr = '';

// hide quick edit panel for images
//if(imageDisplayType == 'flash')
//var timerC = "timer" + parentId + parentDb;
//else
//var timerC = "timerI";
document.getElementById(timerQuickImage).innerHTML='';
setVisibility(timerQuickImage, 'hidden');

// tests: all ok: 334, 500, 0, 0, blank
//alert(imgWidth);
//alert(imgHeight);
//alert(xAdj);
//alert(yAdj);
//alert(newPtLtr);

}

	  
// upload prep
if(recordDb == 'subscription_products')
var recordDbImageFolder = 'subscription-products';
else
var recordDbImageFolder = recordDb;
var folder = '../images/' + recordDbImageFolder + '/' + paperCode;

if(recordDb == 'banners')
var UseScript = '../admin/record_detail_update.php';
else
var UseScript = '../uploadify/uploadify.php';

// uploadify - new images
scriptObj1=new Object();
scriptObj1.parent_db=recordDb;  // for use by image update
scriptObj1.parentid=recordId;   // "

// in case going to record detail update
scriptObj1.record_db=recordDb;  // for use by image update
scriptObj1.recordid=recordId;   // "

scriptObj1.parentDb=parentDb;   // any parent of the record itself (select or input/product)
scriptObj1.parentId=parentId;   // "
scriptObj1.id_field=idField;
scriptObj1.new_or_replace='new';
scriptObj1.timer=timer;
scriptObj1.myDiv=myDiv;
scriptObj1.css=css;
scriptObj1.from=from;
scriptObj1.inside_ajax='Yes';
scriptObj1.recordEditDetail='Yes';
scriptObj1.imageDisplayType=imageDisplayType;
scriptObj1.paper_code=paperCode;

$(document).ready(function() {
$('#multiple_images').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': UseScript,
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImg.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj1,
'folder'    : folder,
'auto': true,
'multi': true
});
});
	  
}
}

// open
xmlHttp.open("GET", "../admin/record_detail_edit.php?my_div="+myDiv+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&css="+css+"&from="+from+"&update_method=ajax"+"&parent_db="+parentDb+"&parentid="+parentId+"&listid="+listId+"&parent_name="+parentName+"&assignid="+assignId+"&current_pageid="+currentPageId+"&format="+format+"&letter="+letter+"&image_display_type="+imageDisplayType,true);

// send
xmlHttp.send(null);     
}

/********************************************
RECORD UPDATE DETAIL
********************************************/
function ajaxFunctionRUD(field, data, recordDb, recordId, idField, obj, css, from, fieldType, updateOnly, valueIfChecked, parentDb, parentId, listId, parentName, paperCode, field1, data1, field2, data2, field3, data3, showForm, returnToList, format, letter, imageDisplayType) //
{
// when updating
textEditing = 'off';

// for tracking if changes made
window.changesMade = 'Yes';

// reset to null, in case new
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof fieldType == 'undefined' || !fieldType || fieldType == 'undefined' || fieldType == 'null')
var fieldType = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined' || updateOnly == 'null')
var updateOnly = '';

// reset to null 
if(typeof valueIfChecked == 'undefined' || !valueIfChecked || valueIfChecked == 'undefined' || valueIfChecked == 'null')
var valueIfChecked = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';
// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';
// reset to null - listID for list being replaced with edited or new detail edit
if(typeof listId == 'undefined' || !listId || listId == 'undefined' || listId == 'null')
var listId = '';
// reset to null - 
if(typeof parentName == 'undefined' || !parentName || parentName == 'undefined' || parentName == 'null')
var parentName = '';
// reset to null - 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';
// reset to null 
if(typeof imageDisplayType == 'undefined' || !imageDisplayType || imageDisplayType == 'undefined' || imageDisplayType == 'null')
var imageDisplayType = '';

// reset to null - 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined' || field1 == 'null')
var field1 = '';
// reset to null - 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined' || data1 == 'null')
var data1 = '';
if(typeof field2 == 'undefined' || !field2 || field2 == 'undefined' || field2 == 'null')
var field2 = '';
// reset to null - 
if(typeof data2 == 'undefined' || !data2 || data2 == 'undefined' || data2 == 'null')
var data2 = '';
if(typeof field3 == 'undefined' || !field3 || field3 == 'undefined' || field3 == 'null')
var field3 = '';
// reset to null - 
if(typeof data3 == 'undefined' || !data3 || data3 == 'undefined' || data3 == 'null')
var data3 = '';
// reset to null - 
if(typeof showForm == 'undefined' || !showForm || showForm == 'undefined' || showForm == 'null')
var showForm = '';
// reset to null - 
if(typeof returnToList == 'undefined' || !returnToList || returnToList == 'undefined' || returnToList == 'null')
var returnToList = '';
// reset to null - 
if(typeof format == 'undefined' || !format || format == 'undefined' || format == 'null')
var format = '';
// reset to null - 
if(typeof letter == 'undefined' || !letter || letter == 'undefined' || letter == 'null')
var letter = '';

// delete confirmation
if(field == 'record_delete')
{
var answer = confirm ("Please confirm record delete for "+recordDb+" ID # "+recordId)
if(!answer)
{
obj.checked=false;
return false;
}
}

var timer = "timerR";
var timerE = document.getElementById(timer);
var timerChild = "timerRC";
var timerChildE = document.getElementById(timerChild);

var listIdE = document.getElementById(listId);

// get pos. on page
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
var curWidth = obj.offsetWidth;
timerChildE.innerHTML='<img src="../images/timer.gif">';
timerChildE.style.left = (curLeft + curWidth)  + 'px';
timerChildE.style.top = curTop + 'px';
timerChildE.style.visibility = 'visible';

// position main timer also if going to be usded for form
if(showForm == 'Yes' && timerE)
{
timerE.style.left = curLeft  + 'px';
timerE.style.top = curTop + 'px';
}

}

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
	  var response = xmlHttp.responseText;

	  // testing
	//  alert("js3504 response: " + response);
	  
	  // tests
//	  alert(format);  //ok, image
//	  alert("imageDisplayType js3492: " + imageDisplayType);  // blank;blank; now flash, ok
//	  alert(updateOnly);  // ok
	  
	  // hide little timer
      timerChildE.style.visibility = 'hidden';
	  
	  // end options

	  // flash return to page
	  if(format == 'image' && imageDisplayType == 'flash' && updateOnly != 'Yes')
	  {
	  
	  // test
//	  alert("OK to js3503");  // ok
//	 alert("timer js3504: " + timer); //ok
	  timerE.innerHTML = '';
	  timerE.style.visibility = 'hidden';
	  document.getElementById(["image_" + parentId + parentDb]).innerHTML=response;
	  imageEditing = 'off';
	  }
	  else 

	  // whole record delete or assignment removal returns
	  if(field.indexOf('delete') != -1 || field.indexOf('remove') != -1 || returnToList == 'Yes')
//	  if(field.indexOf('delete') != -1 || field.indexOf('remove') != -1)
	  {
	  if(listIdE)  // if from list, go back to it
	  listIdE.innerHTML=response;
	  else if(parentId > 0)  // if on page of parent, refresh page
	  window.location = unescape(from);
	  else  // go to location determined by record_detail_update.php (category, etc.)
	  window.location = response;
//	  return true;
	  }

	  else if(listIdE && (!recordId || updateOnly != 'Yes'))
	  {
	  listIdE.innerHTML=response;
	  	if(recordDb == 'select_questions' || recordDb == 'input_questions')
		{
	  	window.open_panel = "select_";
	  	window.show_hide = "yes";
	  	}
	  }	

	  // if new, reload page
	  else if(!recordId && showForm != 'Yes' && (format != 'image' || field.indexOf('new') != -1))
//	  else if(!recordId && showForm != 'Yes')
	  {
	
	  // test: blank, fail
	  //alert(from);
	  
	  window.location = unescape(from);
	  return true;
	  }

	  else if(updateOnly != 'Yes')  // disable to test
	  {
	  timerE.innerHTML=response;
	  timerE.style.visibility = 'visible';
      }
      timerChildE.style.visibility = 'hidden';

// image has no recordid, but not necessarily new, stop here; no,want to start rtes
//	  if(format == 'image' && updateOnly == 'Yes')
//	  return true;

// skip for now
if(format != 'image')
{
// get new id if none (new) - note blank recordId somehow becoming undefined, even though reset at top
if(recordId)
var recordId1 = recordId;
else
{
var find = 'recordid=';
var responseT = response;
var pos = responseT.indexOf(find) + find.length;
responseT = responseT.substr(pos);
var posEnd = responseT.indexOf('>');
var recordId1 = responseT.substr(0, posEnd);
}

// uploadify, if just created
if(!recordId)
{
if(recordDb == 'subscription_products')
var recordDbImageFolder = 'subscription-products';
else
var recordDbImageFolder = recordDb;
var folder = '../images/' + recordDbImageFolder + '/' + paperCode;
// uploadify - new images
scriptObj1=new Object();
scriptObj1.parent_db=recordDb;  // for use by image update
scriptObj1.parentid=recordId1;   // "
scriptObj1.parentDb=parentDb;   // any parent of the record itself (select or input/product)
scriptObj1.parentId=parentId;   // "
scriptObj1.id_field=idField;
scriptObj1.new_or_replace='new';
scriptObj1.timer=timer;
//scriptObj1.myDiv=myDiv;
scriptObj1.css=css;
scriptObj1.from=from;
scriptObj1.inside_ajax='Yes';
scriptObj1.recordEditDetail='Yes';
scriptObj1.imageDisplayType=imageDisplayType;
scriptObj1.paper_code=paperCode;

$(document).ready(function() {
$('#multiple_images').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../uploadify/uploadify.php',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImg.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj1,
'folder'    : folder,
'auto': true,
'multi': true
});
});
}
}

// launch RTEs
if(updateOnly != 'Yes')
{
if(format == 'image')
launchRTEs(response, parentDb, parentId, idField, css);
else
launchRTEs(response, recordDb, recordId1, idField, css);
}

// reset draw box for crop
if(format == 'image' && updateOnly != 'Yes')
window.newPtLtr = '';

}
}

// test:ok
//alert("format js3539: " + format);

//alert(field);  //ok
//alert(data);  //ok


// setup and send
if(field)
{
var url = "../admin/record_detail_update.php";
var params = "field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&field_type="+fieldType+"&value_if_checked="+valueIfChecked+"&from="+from+"&css="+css+"&update_only="+updateOnly+"&parent_db="+parentDb+"&parentid="+parentId+"&listid="+listId+"&parent_name="+parentName+"&field1="+field1+"&data1="+data1+"&field2="+field2+"&data2="+data2+"&field3="+field3+"&data3="+data3+"&return_to_list="+returnToList+"&format="+format+"&letter="+letter+"&image_display_type="+imageDisplayType;
//var params = "field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&ajax_holder="+myDiv+"&format="+format+"&display_type="+displayType+"&css="+css+"&field1="+field1+"&data1="+data1;
xmlHttp.open("POST", url, true);

// Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=ISO-8859-1");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);

// too long for ff
//xmlHttp.open("GET","../admin/record_detail_update.php?field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&field_type="+fieldType+"&value_if_checked="+valueIfChecked+"&from="+from+"&css="+css+"&update_only="+updateOnly+"&parent_db="+parentDb+"&parentid="+parentId+"&listid="+listId+"&parent_name="+parentName+"&field1="+field1+"&data1="+data1+"&field2="+field2+"&data2="+data2+"&field3="+field3+"&data3="+data3+"&return_to_list="+returnToList+"&format="+format+"&letter="+letter,true);
}
//xmlHttp.open("GET","../admin/record_detail_update.php?field="+field+"&data="+data+"&record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&field_type="+fieldType+"&value_if_checked="+valueIfChecked+"&from="+from+"&css="+css+"&update_only="+updateOnly+"&parent_db="+parentDb+"&parentid="+parentId+"&listid="+listId+"&parent_name="+parentName,true);
// not used
else if(!recordId && !search)
xmlHttp.open("GET","../admin/record_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else if(!recordId)
xmlHttp.open("GET","../admin/record_update.php?view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&search="+search+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
else
xmlHttp.open("GET","../admin/record_update.php?recordid="+recordId+"&view="+view+"&return="+return_url+"&show_date="+showDate+"&this_page="+thisPage+"&update_only="+updateOnly+"&ajax_holder="+myDiv+"&new_only="+newOnly+"&start_date="+startDate+"&end_date="+endDate+"&parent_db="+parentDb+"&parentid="+parentId,true); 
if(!field)
xmlHttp.send(null);     
}

/***********************************
LAUNCH RTEs
***********************************/
function launchRTEs(response, recordDb, recordId, idField, css)
{

// test:blank,fail;
//alert(response);
//alert(recordDb);
//alert(recordId);
//alert(idField);
//alert(css);

	  // determine if any rte fields in response, from hidden span, in case refreshing form w rtes in it
	  if(response.indexOf('num_rte_fields=') != -1)
	  {
	  // get number
	  var pos = response.indexOf('num_rte_fields=') + 15;
	  var num_rte_fields = Number(response.substr(pos,1));

	  for(var r=0;r<num_rte_fields;r++)
	  {
	  var fieldLabel = "rte_field" + String(r) + "=";
	  var pos = response.indexOf(fieldLabel) + fieldLabel.length;
	  response = response.substr(pos);
	  var posEnd = response.indexOf('>');
	  var field1 = response.substr(0,posEnd);
	  var rte = field1;

	  // translate
	  if((field1 == 'message') && (recordDb == 'banners'))
	  {
	  recordDb = 'text_image_banners';
	//  field1 = field1.substr(4);
	 // rte = field1;
	  }	
	  // new
	  ajaxFunctionRF(rte, field1, recordDb, recordId, idField, css);
	  }
	  }
}

/*************************************************************************
BEGIN NEW RECORD EDIT LIST FUNCTIONS -- from RED
*************************************************************************/
function ajaxFunctionREL(listId, buttonId, recordDb, parentDb, parentId, parentName, css, from, obj, currentPageId)  //
{

// test:nr
//alert(recordDb);

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = '';

// get pos. on page; not used?
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
}

// block other edits
textEditing = 'on';

// for table in rte
window.includesPath = '../admin/';

// reset to null 
if(typeof listId == 'undefined' || !listId || listId == 'undefined' || listId == 'null')
var listId = '';

// reset to null 
if(typeof buttonId == 'undefined' || !buttonId || buttonId == 'undefined' || buttonId == 'null')
var buttonId = '';

// reset to null 
if(typeof recordDb == 'undefined' || !recordDb || recordDb == 'undefined' || recordDb == 'null')
var recordDb = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';

// reset to null 
if(typeof parentName == 'undefined' || !parentName || parentName == 'undefined' || parentName == 'null')
var parentName = '';

// reset to null 
if(typeof currentPageId == 'undefined' || !currentPageId || currentPageId == 'undefined' || currentPageId == 'null')
var currentPageId = '';

/*
// reset to null 
if(typeof categoryId == 'undefined' || !categoryId || categoryId == 'undefined' || categoryId == 'null')
var categoryId = '';

// reset to null 
if(typeof subcategoryId == 'undefined' || !subcategoryId || subcategoryId == 'undefined' || subcategoryId == 'null')
var subcategoryId = '';

// reset to null 
if(typeof altcategoryId == 'undefined' || !altcategoryId || altcategoryId == 'undefined' || altcategoryId == 'null')
var altcategoryId = '';
*/

// timer
var timer = "timerRC";  // new
var timerE = document.getElementById(timer);
timerE.innerHTML='<img src="../images/timer.gif">';
timerE.style.top = curTop + 'px';
timerE.style.left = curLeft + 'px';
timerE.style.visibility = 'visible';

var listIdE = document.getElementById(listId);

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

      var response = xmlHttp.responseText;
     
      // try
	  listIdE.innerHTML=response;
	  setDisplay(buttonId, 'none');
	  timerE.style.visibility = 'hidden';
	  
}
}

// open
xmlHttp.open("GET", "../admin/record_list_edit.php?listid="+listId+"&buttonid="+buttonId+"&record_db="+recordDb+"&css="+css+"&from="+from+"&parent_db="+parentDb+"&parentid="+parentId+"&parent_name="+parentName+"&current_pageid="+currentPageId,true);
//xmlHttp.open("GET", "../admin/record_list_edit.php?listid="+listId+"&buttonid="+buttonId+"&record_db="+recordDb+"&css="+css+"&from="+from+"&parent_db="+parentDb+"&parentid="+parentId+"&parent_name="+parentName+"&categoryid="+categoryId+"&subcategoryid="+subcategoryId+"&altcategoryid="+altcategoryId,true);

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW RECORD CLONE -- from REL
*************************************************************************/
function ajaxFunctionRC(listId, recordDb, cloneIdSrc, idField, parentDb, parentId, parentName, css, from, obj, currentPageId, paperCode)  //
{
// reset to null
if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
var obj = '';

// get pos. on page; not used?
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
}

// block other edits
textEditing = 'on';

// for table in rte
window.includesPath = '../admin/';

// reset to null 
if(typeof listId == 'undefined' || !listId || listId == 'undefined' || listId == 'null')
var listId = '';

// reset to null 
if(typeof buttonId == 'undefined' || !buttonId || buttonId == 'undefined' || buttonId == 'null')
var buttonId = '';

// reset to null 
if(typeof recordDb == 'undefined' || !recordDb || recordDb == 'undefined' || recordDb == 'null')
var recordDb = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';

// reset to null 
if(typeof parentName == 'undefined' || !parentName || parentName == 'undefined' || parentName == 'null')
var parentName = '';

// reset to null 
if(typeof currentPageId == 'undefined' || !currentPageId || currentPageId == 'undefined' || currentPageId == 'null')
var currentPageId = '';

// reset to null 
if(typeof cloneIdSrc == 'undefined' || !cloneIdSrc || cloneIdSrc == 'undefined' || cloneIdSrc == 'null')
var cloneIdSrc = '';

// reset to null 
if(typeof idField == 'undefined' || !idField || idField == 'undefined' || idField == 'null')
var idField = '';

// reset to null - always blank here
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';

// reset to null - always blank here
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// timer
var timer = "timerRC";  // new
var timerE = document.getElementById(timer);
timerE.innerHTML='<img src="../images/timer.gif">';
timerE.style.top = curTop + 'px';
timerE.style.left = curLeft + 'px';
timerE.style.visibility = 'visible';

var listIdE = document.getElementById(listId);

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      

   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

      var response = xmlHttp.responseText;
       
      // try
	  if(listIdE)	
	  listIdE.innerHTML=response;
	  else
	  document.getElementById("timerR").innerHTML=response;	  	  
	  timerE.style.visibility = 'hidden';

// get new id
var find = 'recordid=';
var responseT = response;
var pos = responseT.indexOf(find) + find.length;
responseT = responseT.substr(pos);
var posEnd = responseT.indexOf('>');
var recordId = responseT.substr(0, posEnd);

// upload prep
if(recordDb == 'subscription_products')
var recordDbImageFolder = 'subscription-products';
else
var recordDbImageFolder = recordDb;
var folder = '../images/' + recordDbImageFolder + '/' + paperCode;
// uploadify - new images
scriptObj1=new Object();
scriptObj1.parent_db=recordDb;  // for use by image update
scriptObj1.parentid=recordId;   // "
scriptObj1.parentDb=parentDb;   // any parent of the record itself (select or input/product)
scriptObj1.parentId=parentId;   // "
scriptObj1.id_field=idField;
scriptObj1.new_or_replace='new';
scriptObj1.timer=timer;
//scriptObj1.myDiv=myDiv;
scriptObj1.css=css;
scriptObj1.from=from;
scriptObj1.inside_ajax='Yes';
scriptObj1.recordEditDetail='Yes';
//scriptObj1.imageDisplayType=imageDisplayType;
scriptObj1.paper_code=paperCode;

$(document).ready(function() {
$('#multiple_images').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../uploadify/uploadify.php',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImg.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj1,
'folder'    : folder,
'auto': true,
'multi': true
});
});




// start any rich text editing fields
launchRTEs(response, recordDb, recordId, idField, css);
	  
}
}

// open
xmlHttp.open("GET", "../admin/record_clone.php?listid="+listId+"&buttonid="+buttonId+"&record_db="+recordDb+"&cloneid_src="+cloneIdSrc+"&css="+css+"&from="+from+"&parent_db="+parentDb+"&parentid="+parentId+"&parent_name="+parentName+"&current_pageid="+currentPageId+"&id_field="+idField,true);

// send
xmlHttp.send(null);     
}



/*************************************************************************
BEGIN NEW IMAGE EDIT fn -- from RECORD EDIT
*************************************************************************/
function ajaxFunctionIE(myDiv, timer, imageDiv, parentDb, parentId, letter, idField, x, y, paperCode, newOrReplace, css, adId, imageWidth, imageHeight, imageDisplayType, imageDisplay, from) //
{

// test:ok, flash
//alert("imageDisplayType js4010: " + imageDisplayType);

// reset to null 
if(typeof letter == 'undefined' || !letter || letter == 'undefined' || letter == 'null')
var letter = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = 0;

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = 0;

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// reset to null 
if(typeof imageWidth == 'undefined' || !imageWidth || imageWidth == 'undefined')
var imageWidth = '';

// reset to null 
if(typeof imageHeight == 'undefined' || !imageHeight || imageHeight == 'undefined')
var imageHeight = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof adid == 'undefined' || !adid || adid == 'undefined')
var adid = '';

// reset to null 
if(typeof imageDisplayType == 'undefined' || !imageDisplayType || imageDisplayType == 'undefined')
var imageDisplayType = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

if(imageEditing == 'on')
return false;

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
var thisDiv = document.getElementById(myDiv);
var thisWidth = thisDiv.offsetWidth;
var thisHeight = thisDiv.offsetHeight;
var timerLeft = imageWidth - 20;

// update x and y to current position if already set (not inline)
if(x || y)
{
var imageDivE = document.getElementById(imageDiv);
var imageLeft = imageDivE.offsetLeft;
var imageTop = imageDivE.offsetTop;
x = imageLeft;
y = imageTop;
}

// timer pos. and show
if(imageDisplayType != 'expand_up')
document.getElementById(timer).style.left = (timerLeft) + 'px'; // - 47


document.getElementById(timer).style.visibility = 'visible';


var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

	  // display response in timer
	  document.getElementById(timer).innerHTML=response;

	  // top position
	  if(imageDisplay == 'auto_run')
	  document.getElementById(timer).style.top = (13) + 'px'; // 
	  else if(imageDisplayType == 'flash')
	  document.getElementById(timer).style.top = (0) + 'px'; // 
	  else if(imageDisplayType == 'six')
	  document.getElementById(timer).style.top = (0) + 'px'; //
	  else if(imageDisplayType == 'expand_up')
	  document.getElementById(timer).style.top = (20) + 'px'; //
	  else 
//	  document.getElementById(timer).style.top = (imageHeight) + 'px'; // 52
	  document.getElementById(timer).style.top = (imageHeight-74) + 'px'; // 52
	  
	  // left position
	  if(imageDisplay == 'auto_run')
	  document.getElementById(timer).style.left = (-imageWidth-5) + 'px'; // 
	  else if(imageDisplayType == 'flash')
	  document.getElementById(timer).style.left = (0) + 'px'; // 
	  else if(imageDisplayType == 'six')
	  document.getElementById(timer).style.left = (-140) + 'px'; //
	  else
	  document.getElementById(timer).style.left = (0) + 'px'; //
	  
if(imageDisplayType != 'flash')
imageEditing = 'on';

// new   //image_abs_pos=Yes
if(x || y || response.indexOf('checked="checked"') > -1)
//if(x || y)
{
document.getElementById("tl_" + parentDb + parentId + letter).style.visibility = 'visible';
document.getElementById("tr_" + parentDb + parentId + letter).style.visibility = 'visible';
document.getElementById("br_" + parentDb + parentId + letter).style.visibility = 'visible';
document.getElementById("bl_" + parentDb + parentId + letter).style.visibility = 'visible';
document.getElementById("dr_" + parentDb + parentId + letter).style.visibility = 'visible';

dragDrop.initElement("tl_" + parentDb + parentId + letter);
dragDrop.initElement("tr_" + parentDb + parentId + letter);
dragDrop.initElement("br_" + parentDb + parentId + letter);
dragDrop.initElement("bl_" + parentDb + parentId + letter);

dragDrop.initElement("dr_" + parentDb + parentId + letter);
//dragDrop.initElement("ic_" + parentDb + parentId + letter);
}

// test:c,ok
//alert("letter js2810: " + letter);
//alert("newOrReplace js2811: " + newOrReplace);  // replace, ok
//alert("parentDb js2812: " + parentDb);
//alert("paperCode js2812: " + paperCode);  // missing, may affect ff

// uploadify - note php format vars for uploadify php
scriptObj=new Object();
scriptObj.parent_db=parentDb;
scriptObj.parentid=parentId;
scriptObj.letter=letter;
scriptObj.id_field=idField;
scriptObj.new_or_replace=newOrReplace;
scriptObj.timer=timer;
scriptObj.myDiv=myDiv;
scriptObj.x=x;
scriptObj.y=y;
scriptObj.css=css;
scriptObj.adId=adId;
scriptObj.inside_ajax='Yes';
scriptObj.imageDisplayType=imageDisplayType;
scriptObj.paper_code=paperCode;

if(parentDb == 'subscription_products')
var parentDbImageFolder = 'subscription-products';
else
var parentDbImageFolder = parentDb;

var folder = '/images/' + parentDbImageFolder + '/' + paperCode;  // working from both home and inside pages
//var folder = '../images/' + parentDbImageFolder + '/' + paperCode;  // failing home page

$(document).ready(function() {
$('#single_image').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../uploadify/uploadify.php',
//'folder': '../uploadify/uploads-folder',   // comment out no change in ff, but ie7 still ok
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImgReplace.png',
'rollover': true,
//'buttonText': 'REPLACE',
'width': 80,
'height': 20,
'scriptData'    : scriptObj,
'folder'    : folder,
//'folder'    : '../images/' + parentDb + '/' + paperCode + '',
'auto': true
//,'multi': true
});
});

// uploadify - new images
scriptObj1=new Object();
scriptObj1.parent_db=parentDb;
scriptObj1.parentid=parentId;
//scriptObj.letter=letter;
scriptObj1.id_field=idField;
scriptObj1.new_or_replace='new';
scriptObj1.timer=timer;
scriptObj1.myDiv=myDiv;
scriptObj1.x=x;
scriptObj1.y=y;
scriptObj1.css=css;
scriptObj1.adId=adId;
scriptObj1.inside_ajax='Yes';
scriptObj1.imageDisplayType=imageDisplayType;
scriptObj1.paper_code=paperCode;

$(document).ready(function() {
$('#multiple_images').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../uploadify/uploadify.php',
//'folder': '../uploadify/uploads-folder',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImgAddNew.png',
'rollover': true,

//'buttonText': 'ADD NEW',
'width': 80,
'height': 20,

'scriptData'    : scriptObj1,
'folder'    : folder,
//'folder'    : '../images/' + parentDb + '/' + paperCode + '',
'auto': true,
'multi': true
});
});

}
}

// set up
xmlHttp.open("GET","../admin/image_edit.php?my_div="+myDiv+"&timer="+timer+"&parent_db="+parentDb+"&parentid="+parentId+"&letter="+letter+"&id_field="+idField+"&x="+x+"&y="+y+"&css="+css+"&from="+from+"&adid="+adId+"&image_display_type="+imageDisplayType,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW IMAGE UPDATE - starting out for uploadify 
*************************************************************************/
function ajaxFunctionIU(scriptObj, myDiv, timer, parentDb, parentId, letter, idField, x, y, field, data, field1, data1, field2, data2, css, adId, imageDisplayType) //
{

// test 
//return true;

// test:nr
//dumpProps(scriptObj);

var new_or_replace;

// reset to null 
if(typeof imageDisplayType == 'undefined' || !imageDisplayType || imageDisplayType == 'undefined' || imageDisplayType == 'null')
var imageDisplayType = '';

// test:ok, then no error
//alert("ok js3011");
//return true;

// unpack vars from object - careful some php format vars used also in uploadify
if(scriptObj)
{
// in case
var x;
var y;
var adId;
var letter;
var idField;

// test:ok, then no error
//alert("ok js3025");
//return true;

myDiv = scriptObj.myDiv;
timer = scriptObj.timer;
parentDb = scriptObj.parent_db;
parentId = scriptObj.parentid;
letter = scriptObj.letter;
idField = scriptObj.id_field;

// test:ok, no error after
//alert("ok js3036, after idField");
//return true;

x = scriptObj.x;
y = scriptObj.y;
css = scriptObj.css;
adId = scriptObj.adId;
new_or_replace = scriptObj.new_or_replace;
imageDisplayType=scriptObj.imageDisplayType;

// test:ok, no error after
//alert("ok js3047, after imageDisplayType");
//return true;

//test;ok
//alert("new_or_replace js2941: " + new_or_replace);  //ok, now
//alert("myDiv js2924: " + myDiv);  //
//alert("parentDb: " + parentDb);  //
//alert("parentId: " + parentId);  //
//alert("letter: " + letter);  // 

}

// test:undefined
//alert("letter js2918: " + letter);

// test
//alert("myDiv js2918: " + myDiv);
//alert("timer js2918: " + timer);
//alert("parentDb js2918: " + parentDb);
//alert("parentId js2918: " + parentId);
//alert("letter js2918: " + letter);  // undef.

// reset to null 
if(typeof letter == 'undefined' || !letter || letter == 'undefined')
var letter = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined')
var field1 = '';

// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined')
var data1 = '';

// reset to null 
if(typeof field2 == 'undefined' || !field2 || field2 == 'undefined')
var field2 = '';

// reset to null 
if(typeof data2 == 'undefined' || !data2 || data2 == 'undefined')
var data2 = '';

// delete confirmation
var delete_var = 'image' + letter + '_delete';
if(field == delete_var)
{
var answer = confirm ("Are you sure you wish to delete this image?")
if(!answer)
{
document.getElementById(field).checked=false;
//document.edit_form[field].checked=false;
return false;
}
}

// timer - this culprit
//document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
//document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response; change name no change
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {

// test:ok to 1, error before 2
//alert("xmlHttp.readyState: " + xmlHttp.readyState);
//alert("xmlHttp.statusText: " + xmlHttp.statusText);  // makes additional errors before 4

//dumpProps(xmlHttp); // error , status 200

    // test:ok, 2x, then error
//    if(xmlHttp.readyState==1)  
//	alert("OK to readyState 1");

    // test:error before
//    if(xmlHttp.readyState==2)  
//	alert("OK to readyState 2");

    if(xmlHttp.readyState==4)  
      {

// test:error before
//alert("ok js3120");

// get response
var response = xmlHttp.responseText;

// test
//alert(myDiv);
//alert(timer);
//alert("imageDisplayType js3080: " + imageDisplayType);  // udf
//alert(response);

// send to story if new images not in flash
if((new_or_replace == 'new' || field == 'new_image_order') && imageDisplayType != 'flash')
//if(new_or_replace == 'new' && imageDisplayType != 'flash')
{
myDiv = parentDb + 'Div' + parentId;
var startHeight = document.getElementById(myDiv).offsetHeight;
}

// display reponse
document.getElementById(myDiv).innerHTML=response;

// done editing, allow new
imageEditing = 'off';
//if(imageDisplayType == 'flash')
textEditing = 'off';

// adjust footer
if((new_or_replace == 'new'  || field == 'new_image_order') && imageDisplayType != 'flash')
//if(new_or_replace == 'new' && imageDisplayType != 'flash')
//if(new_or_replace == 'new')
{
var endHeight = document.getElementById(myDiv).offsetHeight;
var changeHeight = endHeight - startHeight;
adjustFooter(changeHeight);
}

// hide timer if it exists
if(timer)
var timerO = document.getElementById(timer);
if(timerO)
timerO.style.visibility = 'hidden';

// stop here if deleting, or new
var postDeleteName = 'image' + letter + '_delete';
if((field == postDeleteName) || new_or_replace == 'new')
return false;

//document.getElementById(timer).style.visibility = 'hidden';

// new
if(x || y)
{
document.getElementById("tl_" + parentDb + parentId + letter).style.visibility = 'hidden';
document.getElementById("tr_" + parentDb + parentId + letter).style.visibility = 'hidden';
document.getElementById("br_" + parentDb + parentId + letter).style.visibility = 'hidden';
document.getElementById("bl_" + parentDb + parentId + letter).style.visibility = 'hidden';
document.getElementById("dr_" + parentDb + parentId + letter).style.visibility = 'hidden';
}

// try, from uploadify forum: no change
//try { document.getElementById("single_imageUploader").SetReturnValue(__flash__toXML(jQuery("#single_image").trigger("uploadifyAllComplete",[{"filesUploaded":1,"allBytesLoaded":166272,"speed":1.15,"errors":0}])()) ); } catch (e) { document.getElementById("single_imageUploader").SetReturnValue("<undefined/>"); } 

// test: upload error before
//alert("ok js3181");

}
}

// test:ok, error after
//alert("ok js3190");

// set up; comment out, error still
xmlHttp.open("GET","../admin/image_update.php?parent_db="+parentDb+"&parentid="+parentId+"&letter="+letter+"&id_field="+idField+"&x="+x+"&y="+y+"&field="+field+"&data="+data+"&field1="+field1+"&data1="+data1+"&field2="+field2+"&data2="+data2+"&css="+css+"&adid="+adId+"&new_or_replace="+new_or_replace+"&image_display_type="+imageDisplayType,true); 

// test:ok, then error
//alert("ok js3196");

// send
xmlHttp.send(null);     

// test:ok
//alert("ok js3206");

}

/*************************************************************************
BEGIN NEW SIDEBAR EDIT -- copy images
*************************************************************************/
function ajaxFunctionSE(myDiv, timer, sidebarDiv, recordDb, recordId, paperCode, x, y, width, height, css, editMode, from) //
{
// try - new abs. pos.
timer = 'timerSB';

// stop is text editing and not called specifically for by clicking registration mark in text editor
if(textEditing == 'on') // && clickSource != 'reg-mark')
return false;

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = 0;

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = 0;

// reset to null 
if(typeof sidebarDiv == 'undefined' || !sidebarDiv || sidebarDiv == 'undefined')
var sidebarDiv = '';

// reset to null 
if(typeof moreEdit == 'undefined' || !moreEdit || moreEdit == 'undefined')
var moreEdit = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

var thisDiv = document.getElementById(myDiv);
var thisWidth = thisDiv.offsetWidth;
var thisHeight = thisDiv.offsetHeight;
var timerLeft = thisWidth - 20;

// update x and y to current position if already set (not inline), also position timer
if(sidebarDiv && (x || y))
var sidebarDivE = document.getElementById(sidebarDiv);
else
var sidebarDivE = document.getElementById("table" + recordId + recordDb);
if(sidebarDivE)
{
var curPos = findPos(sidebarDivE);
var sidebarLeft = curPos[0];
var sidebarTop = curPos[1];
var sidebarWidth = sidebarDivE.offsetWidth;
var sidebarHeight = sidebarDivE.offsetHeight;
}

document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

	  // display response in timer
	  document.getElementById(timer).innerHTML=response;
	  if(sidebarLeft || sidebarTop)
	  {
	  if(sidebarHeight)
	  var useHeight = sidebarHeight;
	  else
	  var useHeight = height;
  
	  if(x || y)
	  useHeight += 5;
	  document.getElementById(timer).style.top = (sidebarTop+useHeight) + 'px'; // 52
	  document.getElementById(timer).style.left = (sidebarLeft) + 'px'; // 52
	  }
	  else
	  // top position
	  if(x || y)
	  document.getElementById(timer).style.top = (height+3) + 'px'; // 52
	  else
	  {
	  // get height of record field, use that
	  var sidebarFieldId = 'sidebar' + recordId + recordDb;
	  var sidebarFieldHeight = document.getElementById(sidebarFieldId).offsetHeight;
	  	  
	  document.getElementById(timer).style.top = (sidebarFieldHeight + 5) + 'px'; // 52
	  document.getElementById(timer).style.left = (-15) + 'px'; // 52
	  }
	  
// new   //image_abs_pos=Yes
if(x || y)
{
document.getElementById("tl_" + recordDb + recordId).style.visibility = 'visible';
document.getElementById("tr_" + recordDb + recordId).style.visibility = 'visible';
document.getElementById("br_" + recordDb + recordId).style.visibility = 'visible';
document.getElementById("bl_" + recordDb + recordId).style.visibility = 'visible';
document.getElementById("dr_" + recordDb + recordId).style.visibility = 'visible';

dragDrop.initElement("tl_" + recordDb + recordId);
dragDrop.initElement("tr_" + recordDb + recordId);
dragDrop.initElement("br_" + recordDb + recordId);
dragDrop.initElement("bl_" + recordDb + recordId);
dragDrop.initElement("dr_" + recordDb + recordId);
}
}
}

// set up
xmlHttp.open("GET","../admin/sidebar_edit.php?my_div="+myDiv+"&timer="+timer+"&sidebar_div="+sidebarDiv+"&record_db="+recordDb+"&recordid="+recordId+"&x="+x+"&y="+y+"&width="+width+"&height="+height+"&css="+css+"&edit_mode="+editMode+"&from="+from,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW SIDEBAR UPDATE - copy of images 
*************************************************************************/
function ajaxFunctionSU(myDiv, timer, recordDb, recordId, x, y, field, data, field1, data1, field2, data2, field3, data3, css, adId, nextMode, from, parentId) //
{
// reset to default, for new 
if(typeof myDiv == 'undefined' || !myDiv || myDiv == 'undefined')
var myDiv = recordDb + '_stories' + parentId;

// tests
//alert("myDiv js3148: " + myDiv); //ok
//alert("css js3149: " + css);

// reset to default 
if(typeof timer == 'undefined' || !timer || timer == 'undefined')
var timer = 'timerSB';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined')
var recordId = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = '';

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined')
var field1 = '';

// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined')
var data1 = '';

// reset to null 
if(typeof field2 == 'undefined' || !field2 || field2 == 'undefined')
var field2 = '';

// reset to null 
if(typeof data2 == 'undefined' || !data2 || data2 == 'undefined')
var data2 = '';

// reset to null 
if(typeof field3 == 'undefined' || !field3 || field3 == 'undefined')
var field3 = '';

// reset to null 
if(typeof data3 == 'undefined' || !data3 || data3 == 'undefined')
var data3 = '';

// reset to null 
if(typeof nextMode == 'undefined' || !nextMode || nextMode == 'undefined')
var nextMode = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined')
var parentId = '';

// delete confirmation
var delete_var = "delete_" + recordDb + recordId;
//var delete_var = 'sidebar_delete';
if(field == delete_var)
{
var answer = confirm ("Are you sure you wish to delete this sidebar?")
if(!answer)
{
document.getElementById(delete_var).checked=false;
//document.edit_form[field].checked=false;
return false;
}
}

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// get response
var response = xmlHttp.responseText;

// display reponse
document.getElementById(myDiv).innerHTML=response;

// stop here if deleting, or new
//if(field == delete_var)
//return false;

// time defs
timerAbs = 'timersb' + recordId + recordDb;
timerReg = 'timersidebar' + recordId + recordDb;  // uses record editor for sidebar text, also defined in start_onclick_sidebar_edit

if(timer == timerAbs && field == 'x' && field1 == 'y' && !data && !data1)
timer = timerReg;
else if(timer == timerReg && (data || data1))
timer = timerAbs;

// hide timer
if(timer)
var timerE = document.getElementById(timer);
if(timerE)
timerE.style.visibility = 'hidden';

// stop here if deleting, or new
if(field == delete_var)
return false;

// new
if(nextMode == 'position_editing')
{
// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined')
var paperCode = '';

// reset to null 
if(typeof sidebarDiv == 'undefined' || !sidebarDiv || sidebarDiv == 'undefined')
var sidebarDiv = '';
// switch to abs. pos. timer
timer = timerAbs;
from = encodeURI(from);
ajaxFunctionSE(myDiv, timer, sidebarDiv, recordDb, recordId, paperCode, data, data1, data2, data3, css, '', from);  //
}
else if(x || y)
{
document.getElementById("tl_" + recordDb + recordId).style.visibility = 'hidden';
document.getElementById("tr_" + recordDb + recordId).style.visibility = 'hidden';
document.getElementById("br_" + recordDb + recordId).style.visibility = 'hidden';
document.getElementById("bl_" + recordDb + recordId).style.visibility = 'hidden';
document.getElementById("dr_" + recordDb + recordId).style.visibility = 'hidden';
}
}
}

// set up
xmlHttp.open("GET","../admin/sidebar_update.php?record_db="+recordDb+"&recordid="+recordId+"&x="+x+"&y="+y+"&field="+field+"&data="+data+"&field1="+field1+"&data1="+data1+"&field2="+field2+"&data2="+data2+"&field3="+field3+"&data3="+data3+"&css="+css+"&adid="+adId+"&from="+from+"&parentid="+parentId,true); 

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW LINK EDIT -- copy sidebars
*************************************************************************/
function ajaxFunctionLE(myDiv, timer, linkDiv, recordDb, recordId, assignDb, assignId, paperCode, x, y, width, height, css, editMode, from, link, position, parentDb, parentId, linkDisplayType) //
{
// test:ok
//alert("ok js4597");

if(textEditing == 'on')
return false;

if(linkSliding == 'on')
return false;

// test:ok
//alert(link);

// reset to null 
if(typeof link == 'undefined' || !link || link == 'undefined' || link == 'null')
var link = '';

// reset to null 
if(typeof linkDisplayType == 'undefined' || !linkDisplayType || linkDisplayType == 'undefined' || linkDisplayType == 'null')
var linkDisplayType = '';

// edit or follow
if(link)
{
var answer = confirm("Click OK to edit this link, or Cancel to follow it normally.")
if(!answer)
{
window.location = link;
return false;
}
}

// try - new abs. pos.
timer = 'timerL';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined' || x == 'null')
var x = 0;

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined' || y == 'null')
var y = 0;

// reset to null 
if(typeof linkDiv == 'undefined' || !linkDiv || linkDiv == 'undefined' || linkDiv == 'null')
var linkDiv = '';

// reset to null 
if(typeof moreEdit == 'undefined' || !moreEdit || moreEdit == 'undefined' || moreEdit == 'null')
var moreEdit = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof position == 'undefined' || !position || position == 'undefined' || position == 'null')
var position = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// get objects
if(myDiv)
var myDivE = document.getElementById(myDiv);
var linkTable = 'link_table' + assignId;
if(linkTable)
var linkTableE = document.getElementById(linkTable);
if(linkDiv)
var linkDivE = document.getElementById(linkDiv);

// test
//alert(linkDiv);

// try table if exists (summary)
if(linkTableE)
{
var curPos = findPos(linkTableE);
var linkLeft = curPos[0];
var linkTop = curPos[1];
var linkHeight = linkTableE.offsetHeight;
var linkWidth = linkTableE.offsetWidth;
}

else if(linkDivE)  
{
var curPos = findPos(linkDivE);
var linkLeft = curPos[0];
var linkTop = curPos[1];
var linkHeight = linkDivE.offsetHeight;
var linkWidth = linkDivE.offsetWidth;
}

else if(myDivE)  
{
var curPos = findPos(myDivE);
var linkLeft = curPos[0];
var linkTop = curPos[1];
var linkHeight = myDivE.offsetHeight;
var linkWidth = myDivE.offsetWidth;
}

// position timer	
if(linkLeft || linkTop)
{
if(linkHeight)
var useHeight = linkHeight;
else
var useHeight = height;
if(linkDisplayType == 'flash')
useHeight = 0;
var useTop = Math.round(linkTop) + Math.round(useHeight);
document.getElementById(timer).style.top = (useTop) + 'px'; // 52
document.getElementById(timer).style.left = (linkLeft) + 'px'; // 52
}
else if(x || y)
{
document.getElementById(timer).style.top = (height) + 'px'; // 52
document.getElementById(timer).style.left = (0) + 'px'; // 52
}

// show timer
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

	  // display response in timer
	  document.getElementById(timer).innerHTML=response;

/* try move up
	  // position timer	
	  if(linkLeft || linkTop)
	  {
	  if(linkHeight)
	  var useHeight = linkHeight;
	  else
	  var useHeight = height;

	  if(linkDisplayType == 'flash')
      useHeight = 0;
	  var useTop = Math.round(linkTop) + Math.round(useHeight);
	  document.getElementById(timer).style.top = (useTop) + 'px'; // 52
	  document.getElementById(timer).style.left = (linkLeft) + 'px'; // 52
	  }
	  else if(x || y)
	  {
	  document.getElementById(timer).style.top = (height) + 'px'; // 52
	  document.getElementById(timer).style.left = (0) + 'px'; // 52
	  }
*/

// determine position
if(x == 0 && y == 0 && linkDisplayType != 'flash' && linkDisplayType != 'menu' && linkDisplayType != 'viewer')
{
if(parentDb == 'stories')
var parentDiv = parentDb + "Div" + parentId;
else
var parentDiv = "main_content";
var parentDivE = document.getElementById(parentDiv);
if(parentDivE)
{
var curPos = findPos(parentDivE);
var parentLeft = curPos[0];
var parentTop = curPos[1];

var xr = linkLeft - parentLeft;
var yr = linkTop - parentTop;

document.getElementById("tl_" + assignDb + assignId).style.top = (yr) + "px";
document.getElementById("tl_" + assignDb + assignId).style.left = (xr) + "px";

document.getElementById("tr_" + assignDb + assignId).style.top = (yr) + "px";
document.getElementById("tr_" + assignDb + assignId).style.left = (xr+linkWidth) + "px";

document.getElementById("br_" + assignDb + assignId).style.top = (yr+linkHeight) + "px";
document.getElementById("br_" + assignDb + assignId).style.left = (xr+linkWidth) + "px";

document.getElementById("bl_" + assignDb + assignId).style.top = (yr+linkHeight) + "px";
document.getElementById("bl_" + assignDb + assignId).style.left = (xr) + "px";
}
}
	  
// size and/or position
if(linkDisplayType != 'flash' && linkDisplayType != 'menu' && linkDisplayType != 'viewer')
{
document.getElementById("tl_" + assignDb + assignId).style.visibility = 'visible';
document.getElementById("tr_" + assignDb + assignId).style.visibility = 'visible';
document.getElementById("br_" + assignDb + assignId).style.visibility = 'visible';
document.getElementById("bl_" + assignDb + assignId).style.visibility = 'visible';
if(x > 0 || y > 0)
document.getElementById("dr_" + assignDb + assignId).style.visibility = 'visible';

dragDrop.initElement("tl_" + assignDb + assignId);
dragDrop.initElement("tr_" + assignDb + assignId);
dragDrop.initElement("br_" + assignDb + assignId);
dragDrop.initElement("bl_" + assignDb + assignId);
if(x > 0 || y > 0)
//if(x || y)
dragDrop.initElement("dr_" + assignDb + assignId);
}

// uploadify - note php format vars for uploadify php
scriptObj=new Object();
scriptObj.record_db=recordDb;
scriptObj.recordid=recordId;
scriptObj.assign_db=assignDb;
scriptObj.assignid=assignId;
scriptObj.parent_db=parentDb;
scriptObj.parentid=parentId;
scriptObj.id_field='linkid';
scriptObj.new_or_replace='replace';
scriptObj.timer=timer;
scriptObj.from=from;
scriptObj.myDiv=myDiv;
scriptObj.x=x;
scriptObj.y=y;
scriptObj.update_method='ajax';
scriptObj.linkDisplayType=linkDisplayType;
scriptObj.paper_code=paperCode;
scriptObj.inside_uploadify='Yes';  // do not use in ajax 

$(document).ready(function() {
$('#single_image').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../admin/link_update.php',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImg.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj,
'folder'    : '../images/' + recordDb + '/' + paperCode + '',
'auto': true
});
});

// start file uploadiy
startFileUploadify(recordDb,recordId,assignDb,assignId,parentDb,parentId,timer,from,myDiv,x,y,linkDisplayType,paperCode);

}
}

// set up
xmlHttp.open("GET","../admin/link_edit.php?my_div="+myDiv+"&timer="+timer+"&link_div="+linkDiv+"&record_db="+recordDb+"&recordid="+recordId+"&assign_db="+assignDb+"&assignid="+assignId+"&x="+x+"&y="+y+"&width="+width+"&height="+height+"&css="+css+"&edit_mode="+editMode+"&from="+from+"&position="+position+"&parent_db="+parentDb+"&parentid="+parentId+"&link_display_type="+linkDisplayType,true); 
// send
xmlHttp.send(null);     
}

/***********************************
START FILE UPLOADIFY
***********************************/
function startFileUploadify(recordDb,recordId,assignDb,assignId,parentDb,parentId,timer,from,myDiv,x,y,linkDisplayType,paperCode)
{
// file uploadify - note php format vars for uploadify php
scriptObj=new Object();
scriptObj.record_db=recordDb;
scriptObj.recordid=recordId;
scriptObj.assign_db=assignDb;
scriptObj.assignid=assignId;
scriptObj.parent_db=parentDb;
scriptObj.parentid=parentId;
scriptObj.id_field='linkid';
scriptObj.new_or_replace='new';
scriptObj.timer=timer;
scriptObj.from=from;
scriptObj.myDiv=myDiv;
scriptObj.x=x;
scriptObj.y=y;
scriptObj.update_method='ajax';
scriptObj.linkDisplayType=linkDisplayType;
scriptObj.paper_code=paperCode;
scriptObj.file_upload_only='Yes';
scriptObj.inside_uploadify='Yes';  // do not use in ajax 

$(document).ready(function() {
$('#multiple_files').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../admin/link_update.php',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImgUpload.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj,
'folder'    : '../uploads/' + paperCode + '/' + recordId + '',
'auto': true,
'multi': true
});
});
}




/*************************************************************************
BEGIN NEW LINK ASSIGNMENT UPDATE - copy of sidebars 
*************************************************************************/
function ajaxFunctionLAU(myDiv, timer, linkDiv, recordDb, recordId, assignDb, assignId, x, y, field, data, field1, data1, field2, data2, field3, data3, css, adId, nextMode, from, position, parentDb, parentId, linkDisplayType, updateOnly) //
{

// test:ok
//alert(field); // fail, ok now
//alert(data);  //ok

// reset to default 
if(typeof myDiv == 'undefined' || !myDiv || myDiv == 'undefined')
var myDiv = 'links_' + parentDb + parentId;

// reset to default 
if(typeof timer == 'undefined' || !timer || timer == 'undefined')
var timer = 'timerL';

// reset to null 
if(typeof recordDb == 'undefined' || !recordDb || recordDb == 'undefined')
var recordDb = '';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined')
var recordId = '';

// reset to null 
if(typeof assignId == 'undefined' || !assignId || assignId == 'undefined')
var assignId = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = 0;

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = 0;

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined')
var field1 = '';

// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined')
var data1 = '';

// reset to null 
if(typeof field2 == 'undefined' || !field2 || field2 == 'undefined')
var field2 = '';

// reset to null 
if(typeof data2 == 'undefined' || !data2 || data2 == 'undefined')
var data2 = '';

// reset to null 
if(typeof field3 == 'undefined' || !field3 || field3 == 'undefined')
var field3 = '';

// reset to null 
if(typeof data3 == 'undefined' || !data3 || data3 == 'undefined')
var data3 = '';

// reset to null 
if(typeof nextMode == 'undefined' || !nextMode || nextMode == 'undefined')
var nextMode = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined')
var paperCode = '';

// reset to null; this fails on return 
if(typeof linkDiv == 'undefined' || !linkDiv || linkDiv == 'undefined')
var linkDiv = '';

// reset to null 
if(typeof position == 'undefined' || !position || position == 'undefined')
var position = '';

// reset to null 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined')
var parentDb = '';

// reset to null 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined')
var parentId = '';

// reset to null 
if(typeof linkDisplayType == 'undefined' || !linkDisplayType || linkDisplayType == 'undefined')
var linkDisplayType = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined' || updateOnly == 'null')
var updateOnly = '';

// set up editing if switching to abs.
if(position == 'absolute' && x == 0 && y == 0)
nextMode = 'position_editing';

// for testing if deleting/removing
var delete_var = "delete_" + assignDb + assignId;

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// hide timer
if(timer)
var timerE = document.getElementById(timer);
if(timerE)
timerE.style.visibility = 'hidden';

// disable to test
if(updateOnly == 'Yes')
return true;

// if section menu link, just reload page
if(parentDb == 'sections' && field3 == 'position' && data3 == 'menu')
{
window.location = unescape(from);
return true;
}

// get response
var response = xmlHttp.responseText;

// test: js false blank in php; blank
//alert(response);

// display reponse
document.getElementById(myDiv).innerHTML=response;

// hide timer
//if(timer)
//var timerE = document.getElementById(timer);
//if(timerE)
//timerE.style.visibility = 'hidden';

// adjust story timer position on top of control panel, in case story length changes
adjustTimer(parentDb, parentId, "timerSt");

// stop here if deleting, or new
if(field == delete_var)
return true;

// new
if(nextMode == 'position_editing')
{
from = encodeURI(from);
ajaxFunctionLE(myDiv, timer, linkDiv, recordDb, recordId, assignDb, assignId, paperCode, data, data1, data2, data3, css, '', from, '', position, parentDb, parentId);  //
}
else if(x > 0 || y > 0)
{
document.getElementById("tl_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("tr_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("br_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("bl_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("dr_" + assignDb + assignId).style.visibility = 'hidden';
}
}
}

// set up
xmlHttp.open("GET","../admin/link_assign_update.php?assign_db="+assignDb+"&assignid="+assignId+"&x="+x+"&y="+y+"&field="+field+"&data="+data+"&field1="+field1+"&data1="+data1+"&field2="+field2+"&data2="+data2+"&field3="+field3+"&data3="+data3+"&css="+css+"&adid="+adId+"&from="+from+"&position="+position+"&parent_db="+parentDb+"&parentid="+parentId+"&link_display_type="+linkDisplayType+"&update_only="+updateOnly,true); 

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW LINK UPDATE - copy of links assign update
*************************************************************************/
function ajaxFunctionLU(scriptObj, myDiv, timer, linkDiv, recordDb, recordId, assignDb, assignId, x, y, field, data, field1, data1, css, from, updateOnly, parentDb, parentId, linkStatus, linkDisplayType, obj, fileListingId) //
{

// test:ok
//alert(from);

// unpack vars from object - careful some php format vars used also in uploadify
if(scriptObj)
{
myDiv = scriptObj.myDiv;
timer = scriptObj.timer;
recordDb = scriptObj.record_db;
recordId = scriptObj.recordid;
assignDb = scriptObj.assign_db;
assignId = scriptObj.assignid;
parentDb = scriptObj.parent_db;
parentId = scriptObj.parentid;
x = scriptObj.x;
y = scriptObj.y;
css = scriptObj.css;
from = scriptObj.from;
linkDisplayType = scriptObj.linkDisplayType;
}

// reset to null 
if(typeof myDiv == 'undefined' || !myDiv || myDiv == 'undefined' || myDiv == 'null')
var myDiv = '';

// reset to null 
if(typeof timer == 'undefined' || !timer || timer == 'undefined' || timer == 'null')
var timer = 'timerL';

// reset to null; this fails on return 
if(typeof linkDiv == 'undefined' || !linkDiv || linkDiv == 'undefined' || linkDiv == 'null')
var linkDiv = '';

// reset to null 
if(typeof x == 'undefined' || !x || x == 'undefined')
var x = '';

// reset to null 
if(typeof y == 'undefined' || !y || y == 'undefined')
var y = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined')
var field1 = '';

// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined')
var data1 = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined')
var paperCode = '';

// reset to null; this fails on return 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null; this fails on return 
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined')
var parentDb = '';

// reset to null; this fails on return 
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined')
var parentId = '';

// reset to null; this fails on return 
if(typeof linkStatus == 'undefined' || !linkStatus || linkStatus == 'undefined')
var linkStatus = '';

// reset to null; this fails on return 
if(typeof linkDisplayType == 'undefined' || !linkDisplayType || linkDisplayType == 'undefined')
var linkDisplayType = '';

// reset to null; this fails on return 
if(typeof obj == 'undefined' || !obj || obj == 'undefined')
var obj = '';

// reset to null; this fails on return 
if(typeof fileListingId == 'undefined' || !fileListingId || fileListingId == 'undefined')
var fileListingId = '';


// delete upload confirmation
if(field.indexOf('delete_upload') != -1)
{
var answer = confirm ("Are you sure you wish to delete this uploaded file?")
if(!answer)
{
obj.checked=false;
//document.edit_form[field].checked=false;
return false;
}
}

// special case blank
if(field == 'link_type' && data == 'blank')
{
field1 = 'link';
data1 = '';
updateOnly = '';
alert("Link set to blank");  // this also prevents js error with timer or updateOnly otherwise won't go away
}

// timer - js error somehow, but not if paused
//if(updateOnly != 'Yes' && field.indexOf('delete_upload') == -1)
//document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';
document.getElementById(timer).style.visibility = 'visible';

// get pos. on page;
if(obj)
{
var curPos = findPos(obj);
var curLeft = curPos[0];
var curTop = curPos[1];
var curWidth = obj.offsetWidth;
var timerLeft = Math.round(curLeft) + Math.round(curWidth);

document.getElementById(timer).style.top = curTop + 'px';
document.getElementById(timer).style.left = timerLeft + 'px';
}


// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

if(field.indexOf('delete_upload') != -1)
{
document.getElementById(fileListingId).style.display='none';
return true;
}

// if section menu link, and done creating
if(parentDb == 'sections' && recordId && field == 'link')
{
window.location = unescape(from);
return true;
}

// get response
var response = xmlHttp.responseText;

// test:ok
//alert(response);

// new
document.getElementById(timer).style.visibility = 'hidden';

// close panel if just cloned
if(field == 'clone_name')
{
document.getElementById('timerL').innerHTML = '';
document.getElementById('timerL').style.visibility = 'hidden';
}

// test:blank, ok
//alert(updateOnly);

if(updateOnly == 'Yes')
return true;

if(parentDb == 'sections')  // hack for bad under-ad refresh; fix someday
return true;


// test:ok;ok
//alert(myDiv);  // links_stories5295; links_stories5295
//alert(timer);
//alert(response);  // includes new linkid, new assignid; had new linkid

// test: this is a test in panel
//document.getElementById(myDiv).innerHTML='this is a test';
//return true;

// display response
document.getElementById(myDiv).innerHTML=response;

// test
//alert(response);

// test
//document.getElementById(timer).style.visibility = 'visible';
//document.getElementById(timer).innerHTML=response;  // Test Clone 8 show correctly in timer
//return true;

// hide timer
document.getElementById(timer).style.visibility = 'hidden';

// if just created, hide form
var newLinkAjaxHolder = 'new_link' + parentId + parentDb;
if(linkStatus == 'just_created' && updateOnly != 'Yes')
{
document.getElementById(newLinkAjaxHolder).innerHTML = 'Link # ' + recordId + ' created and assigned successfully; click link itself (above) for further changes, or close and reopen this editing panel to create another new link.';
adjustTimer(parentDb, parentId, "timerSt");
}

// hide registration markers
if(x > 0 || y > 0)
{
document.getElementById("tl_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("tr_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("br_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("bl_" + assignDb + assignId).style.visibility = 'hidden';
document.getElementById("dr_" + assignDb + assignId).style.visibility = 'hidden';
}
}
}

// test:ok
//alert(from);

// set up
xmlHttp.open("GET","../admin/link_update.php?record_db="+recordDb+"&recordid="+recordId+"&assign_db="+assignDb+"&assignid="+assignId+"&x="+x+"&y="+y+"&field="+field+"&data="+data+"&field1="+field1+"&data1="+data1+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&parent_db="+parentDb+"&parentid="+parentId+"&link_status="+linkStatus+"&link_display_type="+linkDisplayType+"&paper_code="+paperCode,true); 

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW SUMMARY EDIT -- copy links
*************************************************************************/
function ajaxFunctionSuE(myDiv, summaryDiv, recordDb, recordId, css, editMode, from, summaryLink, holderDb, holderId, summaryDisplayType, sourceDb, fromRecordEdit) //
{

// reset to null 
if(typeof fromRecordEdit == 'undefined' || !fromRecordEdit || fromRecordEdit == 'undefined' || fromRecordEdit == 'null')
var fromRecordEdit = '';

// set timer
//if(fromRecordEdit == 'Yes')
//var timer = 'timerR';
//else
var timer = 'timerSu';

if(textEditing == 'on')
return false;

// reset to null 
if(typeof summaryLink == 'undefined' || !summaryLink || summaryLink == 'undefined' || summaryLink == 'null')
var summaryLink = '';

// reset to null 
if(typeof summaryDisplayType == 'undefined' || !summaryDisplayType || summaryDisplayType == 'undefined' || summaryDisplayType == 'null')
var summaryDisplayType = '';

// reset to null 
if(typeof sourceDb == 'undefined' || !sourceDb || sourceDb == 'undefined' || sourceDb == 'null')
var sourceDb = '';

// edit or follow
if(summaryLink)
{
var answer = confirm("OK to edit summary, Cancel to go to source")
if(!answer)
{
window.location = summaryLink;
return false;
}
}

// reset to null 
if(typeof summaryDiv == 'undefined' || !summaryDiv || summaryDiv == 'undefined' || summaryDiv == 'null')
var summaryDiv = '';

// reset to null 
if(typeof editMode == 'undefined' || !editMode || editMode == 'undefined' || editMode == 'null')
var editMode = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined' || from == 'null')
var from = '';

// reset to null 
if(typeof holderDb == 'undefined' || !holderDb || holderDb == 'undefined' || holderDb == 'null')
var holderDb = '';

// reset to null 
if(typeof holderId == 'undefined' || !holderId || holderId == 'undefined' || holderId == 'null')
var holderId = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

//alert("myDiv js 4127: " + myDiv);

// get objects
if(myDiv)
var myDivE = document.getElementById(myDiv);
var summaryTable = 'summary_table' + recordId;
if(summaryTable)
var summaryTableE = document.getElementById(summaryTable);
if(summaryDiv)
var summaryDivE = document.getElementById(summaryDiv);


if(summaryTableE && fromRecordEdit != 'Yes')
{
var curPos = findPos(summaryTableE);
var summaryLeft = curPos[0];
var summaryTop = curPos[1];
var summaryHeight = summaryTableE.offsetHeight;
var summaryWidth = summaryTableE.offsetWidth;
}

else

if(myDivE)
{
var curPos = findPos(myDivE);
var summaryLeft = curPos[0];
var summaryTop = curPos[1];
var summaryHeight = myDivE.offsetHeight;
var summaryWidth = myDivE.offsetWidth;
}

else if(summaryDivE)
{
var curPos = findPos(summaryDivE);
var summaryLeft = curPos[0];
var summaryTop = curPos[1];
var summaryHeight = summaryDivE.offsetHeight;
var summaryWidth = summaryDivE.offsetWidth;
}

// show timer
document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

	  // display response in timer
	  document.getElementById(timer).innerHTML=response;

	  // place timer, with editing panel within it
//	  if((summaryLeft || summaryTop) && fromRecordEdit != 'Yes')
	  if(summaryLeft || summaryTop)
	  {
	  if(summaryHeight)
	  var useHeight = summaryHeight;
	  else
	  var useHeight = height;
	  if(summaryDisplayType == 'flash')
      useHeight = 0;
//	  else if(fromRecordEdit != 'Yes')
//	  useHeight = .5*useHeight;
	  document.getElementById(timer).style.top = (summaryTop + useHeight) + 'px'; // 52
	  document.getElementById(timer).style.left = (summaryLeft) + 'px'; // 52
	  }

}
}

// set up
xmlHttp.open("GET","../admin/summary_edit.php?my_div="+myDiv+"&timer="+timer+"&summary_div="+summaryDiv+"&record_db="+recordDb+"&recordid="+recordId+"&css="+css+"&edit_mode="+editMode+"&from="+from+"&holder_db="+holderDb+"&holderid="+holderId+"&summary_display_type="+summaryDisplayType+"&source_db="+sourceDb,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW SUMMARY UPDATE - copy of links assign update
*************************************************************************/
function ajaxFunctionSuU(myDiv, summaryDiv, recordDb, recordId, idField, field, data, field1, data1, css, from, updateOnly, holderDb, holderId, summaryStatus, summaryDisplayType, sourceDb) //
{
// test:ok for just picked, blank for new
//alert("summaryStatus js4167, top: " + summaryStatus);

// test:fail;ok
//alert(field);
//alert(data);
//alert(field1);
//alert(data1);

// reset to null 
if(typeof myDiv == 'undefined' || !myDiv || myDiv == 'undefined' || myDiv == 'null')
var myDiv = '';

// set timer 
var timer = 'timerSu';

// reset to null; this fails on return 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined' || recordId == 'null')
var recordId = '';

// reset to null; this fails on return 
if(typeof summaryDiv == 'undefined' || !summaryDiv || summaryDiv == 'undefined' || summaryDiv == 'null')
var summaryDiv = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined' || field == 'null')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined' || data == 'null')
var data = '';

// reset to null 
if(typeof field1 == 'undefined' || !field1 || field1 == 'undefined' || field1 == 'null')
var field1 = '';

// reset to null 
if(typeof data1 == 'undefined' || !data1 || data1 == 'undefined' || data1 == 'null')
var data1 = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined' || css == 'null')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null; this fails on return 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null; this fails on return 
if(typeof holderDb == 'undefined' || !holderDb || holderDb == 'undefined')
var holderDb = '';

// reset to null; this fails on return 
if(typeof holderId == 'undefined' || !holderId || holderId == 'undefined')
var holderId = '';

// reset to null; this fails on return 
if(typeof summaryStatus == 'undefined' || !summaryStatus || summaryStatus == 'undefined')
var summaryStatus = '';

// reset to null; this fails on return 
if(typeof summaryDisplayType == 'undefined' || !summaryDisplayType || summaryDisplayType == 'undefined')
var summaryDisplayType = '';

// reset to null; this fails on return 
if(typeof sourceDb == 'undefined' || !sourceDb || sourceDb == 'undefined')
var sourceDb = '';

// timer - js error somehow, but not if paused
if(updateOnly != 'Yes')
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// test:ok for just picked, blank for new
//alert("summaryStatus js4256, after ready: " + summaryStatus);

// go back 
if(summaryStatus == 'just_picked' || summaryStatus == 'cancel_after_nav')
{
window.location = unescape(from);
return true;
}

// get response
var response = xmlHttp.responseText;

// test:ok
//alert(response);

if(updateOnly == 'Yes')
return true;

// if deleting update list
//if(recordId && summaryStatus != 'cancel' && field.indexOf('delete') !=  -1)
//if(recordId && summaryStatus != 'cancel' && field.indexOf('delete') ==  -1)
if(myDiv.indexOf('new_summary') ==  -1 && field.indexOf('delete') ==  -1)
myDiv = sourceDb + "summaries" + holderId + holderDb;

// test:ok, now;ok
//alert("myDiv js4358: " + myDiv);
//alert(response);

// display reponse
document.getElementById(myDiv).innerHTML=response;

// test; error before
//alert(timer);

// hide timer
document.getElementById(timer).style.visibility = 'hidden';

// blank and hide record timer (that may have launched summary detail editing)
document.getElementById("timerR").innerHTML = '';
document.getElementById("timerR").style.visibility = 'hidden';

// if just created, hide form; prob. dep. from links, delete carefully
var newLinkAjaxHolder = 'new_summary' + holderId + holderDb;
if(summaryStatus == 'just_created' && updateOnly != 'Yes')
{
document.getElementById(newLinkAjaxHolder).innerHTML = 'Link # ' + recordId + ' created and assigned successfully; click summary itself (above) for further changes, or close and reopen this editing panel to create another new summary.';
adjustTimer(holderDb, holderId, "timerSt");
}


}
}

// test
//alert(field);
//alert(data);
//alert(field1);
//alert(data1);

// set up
xmlHttp.open("GET","../admin/summary_update.php?record_db="+recordDb+"&recordid="+recordId+"&id_field="+idField+"&field="+field+"&data="+data+"&field1="+field1+"&data1="+data1+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&holder_db="+holderDb+"&holderid="+holderId+"&summary_status="+summaryStatus+"&summary_display_type="+summaryDisplayType+"&source_db="+sourceDb,true); 

// test:ok
//alert(4280);

// send
xmlHttp.send(null);     
}


/*****************************
ADJUST TIMER -- editing panel position
*****************************/
function adjustTimer(parentDb, parentId, timer)
{
// give story time to load images
pause(1000);
if(parentDb && parentId && timer)
{
var controlPanel = "control_panel" + parentId + parentDb;
var controlPanelE = document.getElementById(controlPanel);
if(controlPanelE)
{
var controlPanelPos = findPos(controlPanelE);
var controlPanelTop = controlPanelPos[1];
document.getElementById(timer).style.top = controlPanelTop + "px";
}
}
}

/*************************************************************************
BEGIN NEW STORY EDIT -- copy of sidebars
*************************************************************************/
function ajaxFunctionStE(myDiv, obj, storyDiv, recordDb, recordId, css, from, pageTableWidth, paperCode, imageDisplayType, recordDiv) //
//function ajaxFunctionStE(myDiv, obj, storyDiv, recordDb, recordId, css, from, pageTableWidth, paperCode, imageDisplayType) //
{
// try - new abs. pos.
var timer = 'timerSt';

// constant here
var idField = 'id';

// stop is text editing and not called specifically for by clicking registration mark in text editor
if(textEditing == 'on') // && clickSource != 'reg-mark')
return false;

// reset to null 
if(typeof storyDiv == 'undefined' || !storyDiv || storyDiv == 'undefined')
var storyDiv = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof pageTableWidth == 'undefined' || !pageTableWidth || pageTableWidth == 'undefined')
var pageTableWidth = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// reset to null 
if(typeof imageDisplayType == 'undefined' || !imageDisplayType || imageDisplayType == 'undefined' || imageDisplayType == 'null')
var imageDisplayType = '';

// reset to null 
if(typeof recordDiv == 'undefined' || !recordDiv || recordDiv == 'undefined' || recordDiv == 'null')
var recordDiv = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// update x and y to current position if already set (not inline), also position timer
//if(controlPanel)
//var controlPanelE = document.getElementById(controlPanel);

if(recordDiv)
obj = document.getElementById(recordDiv);

if(obj)
//if(controlPanelE)
{
var curPos = findPos(obj);
//var curPos = findPos(controlPanelE);
var controlPanelLeft = curPos[0];
var controlPanelTop = curPos[1];
var controlPanelHeight = obj.offsetHeight;
}

// position above mini control panel
if(controlPanelLeft || controlPanelTop)
{
controlPanelTop += controlPanelHeight;

document.getElementById(timer).style.top = (controlPanelTop) + 'px'; // 52
document.getElementById(timer).style.left = (controlPanelLeft) + 'px'; // 52
}

document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

// display response in timer
document.getElementById(timer).innerHTML=response;

// draggable in case youtube or other iframe below obscures; but drags out of control some cases
//dragDrop.initElement(timer);

// upload prep
var folder = '../images/' + recordDb + '/' + paperCode;

// uploadify - new images
scriptObj=new Object();
scriptObj.parent_db=recordDb;
scriptObj.parentid=recordId;
scriptObj.id_field=idField;
scriptObj.new_or_replace='new';
scriptObj.timer=timer;
scriptObj.myDiv=myDiv;
scriptObj.css=css;
scriptObj.inside_ajax='Yes';
scriptObj.imageDisplayType=imageDisplayType;
scriptObj.paper_code=paperCode;

$(document).ready(function() {
$('#multiple_images').uploadify({
'uploader': '../uploadify/uploadify.swf',
'script': '../uploadify/uploadify.php',
'cancelImg': '../uploadify/cancel.png',
'buttonImg': '../images/buttonImg.png',
'rollover': true,
'width': 80,
'height': 20,
'scriptData'    : scriptObj,
'folder'    : folder,
'auto': true,
'multi': true
});
});

}
}

// set up
xmlHttp.open("GET","../admin/story_edit.php?my_div="+myDiv+"&timer="+timer+"&story_div="+storyDiv+"&record_db="+recordDb+"&recordid="+recordId+"&css="+css+"&from="+from+"&page_table_width="+pageTableWidth,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW STORY UPDATE - copy of sidebar
*************************************************************************/
function ajaxFunctionStU(storyDiv, recordDb, recordId, field, data, css, from, updateOnly, storyStatus, pageId, pageTableWidth, paperCode, oldPageId, obj) //
{

// test:ok
//alert("css js4472: " + css);

// try - new abs. pos.
if(updateOnly == 'Yes')
var timer = 'timerRC';
else
var timer = 'timerSt';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null 
if(typeof storyStatus == 'undefined' || !storyStatus || storyStatus == 'undefined')
var storyStatus = '';

// reset to null 
if(typeof pageId == 'undefined' || !pageId || pageId == 'undefined')
var pageId = '';

// reset to null 
if(typeof pageTableWidth == 'undefined' || !pageTableWidth || pageTableWidth == 'undefined')
var pageTableWidth = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined')
var paperCode = '';

// reset to null 
if(typeof oldPageId == 'undefined' || !oldPageId || oldPageId == 'undefined')
var oldPageId = '';

// reset to null 
if(typeof obj == 'undefined' || !obj || obj == 'undefined')
var obj = '';

// delete confirmation
var delete_var = "delete_" + recordDb + recordId;
//var delete_var = 'story_delete';
if(field == delete_var)
{
var answer = confirm ("Are you sure you wish to delete this story?")
if(!answer)
{
document.edit_form[field].checked=false;
return false;
}
}

/*
// page destination
var delete_var = "delete_" + recordDb + recordId;
//var delete_var = 'story_delete';
if(field == 'pageid')
{
var answer = confirm ("Click OK to follow story to new page, or Cancel to send story there and remain on current page")
if(answer)
{
var returnPageId = data;
var returnStoryId = recordId;
}
else
{
var returnPageId = oldPageId;
var returnStoryId = '';
}
}
*/

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// position story timer
if(obj && updateOnly == 'Yes')
var useObj = obj;
else
useObj = document.getElementById(storyDiv);
if(useObj)
{
var curPos = findPos(useObj);
var storyDivLeft = curPos[0];
var storyDivTop = curPos[1];
document.getElementById(timer).style.top = storyDivTop;
document.getElementById(timer).style.left = storyDivLeft;
}

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// test:ok
//alert("OK js5946");
//alert("storyStatus: " + storyStatus);
//alert("field: " + field);
//alert("updateOnly: " + updateOnly);

// hide timer if from new on page panel
if(storyStatus == 'just_created' || field == 'story_order' || updateOnly == 'Yes')
//if(storyStatus == 'just_created' || field == 'story_order')
document.getElementById(timer).style.visibility = 'hidden';

// stop if only updating
if(updateOnly == 'Yes')
return true;

// get response
var response = xmlHttp.responseText;

// test:ok
//alert(response);

// adjust cell height if set: outside ajax
if(field == 'story_height')
{
var cellId = "story_cell" +  recordId;
document.getElementById(cellId).style.height = data + "px";
document.getElementById(storyDiv).style.height = data + "px";
}

// test
//alert("storyStatus js4560: " + storyStatus);

// display response optional targets
var linkAllDiv = 'links_' + recordDb + recordId;
var pageSpan = 'page_span';
if(storyStatus == 'place' || field == 'showid')
{
var startHeight = document.getElementById(pageSpan).offsetHeight;
document.getElementById(pageSpan).innerHTML=response;
}
else if(field == 'link_display')
document.getElementById(linkAllDiv).innerHTML=response;

else if(field == 'name' && storyStatus != 'creating')
document.getElementById(timer).innerHTML=response;

else
document.getElementById(storyDiv).innerHTML=response;

// stop here if deleting, or new
if(field == delete_var)
return false;

// test:ok
//alert("ok to js5993");
//alert("recordId: " + recordId);

// position timer, for certain cases, or hide
var controlPanelS = 'control_panel' + recordId + recordDb;
if(field == 'name' && storyStatus == '')
{
if(controlPanelS)
var controlPanelE = document.getElementById(controlPanelS);
if(controlPanelE)
{
var curPos = findPos(controlPanelE);
var controlPanelLeft = curPos[0];
var controlPanelTop = curPos[1];
}
// position above mini control panel
if(controlPanelLeft || controlPanelTop)
{
document.getElementById(timer).style.top = (controlPanelTop) + 'px'; // 52
document.getElementById(timer).style.left = (controlPanelLeft) + 'px'; // 52
}
}
else
document.getElementById(timer).style.visibility = 'hidden';

// test:ok
//alert("ok to js6019");
//alert("field: " + field);
//alert("storyStatus: " + storyStatus);

// hide control tag if moved off page or unpublished
if(field == 'pageid' || storyStatus == 'unpublish')
setVisibility(controlPanelS,'hidden');

// if placing new story from page edit panel, hide it and scroll to top
if(storyStatus == 'place' || field == 'showid')
{
if(field != 'showid')
document.getElementById("timerP").style.visibility = 'hidden';
// scroll to new story
storyDivE = document.getElementById(storyDiv);
if(storyDivE && field != 'clone_name')
//if(storyDivE)
{
var curPos = findPos(storyDivE);
var storyDivLeft = curPos[0];
var storyDivTop = curPos[1];
}
else
{
var storyDivLeft = 0;
var storyDivTop = 0;
}
window.scrollTo(storyDivLeft,storyDivTop);  // nc

// test:ok
//alert("ok to js6048");
//alert("from: " + from);
//alert("pageTableWidth: " + pageTableWidth);

// open editing panel - comment out - no change; in case of new, don't know ID
if(field != 'showid' && field != 'clone_name')
//if(field != 'showid')
{
var ajaxid = 'story_ajax' + recordId + recordDb;
var controlPanel = 'control_panel' +  recordId + recordDb;
ajaxFunctionStE(ajaxid, controlPanel, storyDiv, recordDb, recordId, css, from, pageTableWidth, paperCode);
}

// test:error before
//alert("ok to js6046");
//alert("startHeight: " + startHeight);

// adjust footer
var endHeight = document.getElementById(pageSpan).offsetHeight;
var changeHeight = endHeight - startHeight;
adjustFooter(changeHeight);

// move page editing panel
if(field == 'showid')
{
var controlPanel = 'control_panel' + pageId + 'pages';
if(controlPanel)
var controlPanelE = document.getElementById(controlPanel);
if(controlPanelE)
{
var curPos = findPos(controlPanelE);
var controlPanelLeft = curPos[0];
var controlPanelTop = curPos[1];
}
// position above mini control panel
if(controlPanelLeft || controlPanelTop)
{
document.getElementById("timerP").style.top = (controlPanelTop) + 'px'; // 52
document.getElementById("timerP").style.left = (controlPanelLeft) + 'px'; // 52
}
}


}

}
}

//alert(4729); // ok

// set up
xmlHttp.open("GET","../admin/story_update.php?record_db="+recordDb+"&recordid="+recordId+"&field="+field+"&data="+data+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&story_status="+storyStatus+"&pageid="+pageId+"&page_table_width="+pageTableWidth,true);   // +"&return_pageid="+returnPageId+"&return_storyid="+returnStoryId

//alert(4734); //now ok

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW PAGE EDIT -- copy of sidebars
*************************************************************************/
function ajaxFunctionPE(myDiv, controlPanel, pageDiv, recordDb, recordId, css, from, pageTableWidth, paperCode, imageDisplayType) //
{
// try - new abs. pos.
var timer = 'timerP';

// constant here
var idField = 'pageid';

// stop is text editing and not called specifically for by clicking registration mark in text editor
if(textEditing == 'on') // && clickSource != 'reg-mark')
return false;

// reset to null 
if(typeof pageDiv == 'undefined' || !pageDiv || pageDiv == 'undefined')
var pageDiv = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof pageTableWidth == 'undefined' || !pageTableWidth || pageTableWidth == 'undefined')
var pageTableWidth = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// update x and y to current position if already set (not inline), also position timer
if(controlPanel)
var controlPanelE = document.getElementById(controlPanel);
if(controlPanelE)
{
var curPos = findPos(controlPanelE);
var controlPanelLeft = curPos[0];
var controlPanelTop = curPos[1];
}

// position above mini control panel
if(controlPanelLeft || controlPanelTop)
{
document.getElementById(timer).style.top = (controlPanelTop) + 'px'; // 52
document.getElementById(timer).style.left = (controlPanelLeft) + 'px'; // 52
}

document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

// display response in timer
document.getElementById(timer).innerHTML=response;

}
}

// set up
xmlHttp.open("GET","../admin/page_edit.php?my_div="+myDiv+"&timer="+timer+"&page_div="+pageDiv+"&record_db="+recordDb+"&recordid="+recordId+"&css="+css+"&from="+from+"&page_table_width="+pageTableWidth,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW PAGE UPDATE - copy of sidebar
*************************************************************************/
function ajaxFunctionPU(pageDiv, recordDb, recordId, field, data, css, from, updateOnly, numStoriesU, editMode, sectionId) //
{
// test:ok
//alert("data js6526: " + data);

// try - new abs. pos.
var timer = 'timerP';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined')
var recordId = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null 
if(typeof numStoriesU == 'undefined' || !numStoriesU || numStoriesU == 'undefined')
var numStoriesU = '';

// reset to null 
if(typeof editMode == 'undefined' || !editMode || editMode == 'undefined')
var editMode = '';

// reset to null 
if(typeof sectionId == 'undefined' || !sectionId || sectionId == 'undefined')
var sectionId = '';

// delete confirmation
var delete_var = "delete_" + recordDb + recordId;
//var delete_var = 'page_delete';
if(field == delete_var)
{
var answer = confirm ("Are you sure you wish to delete this page?")
if(!answer)
{
document.edit_form[field].checked=false;
return false;
}
}

// timer
if(updateOnly != 'Yes' && field != 'list_unpublished')
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {

// get response
var response = xmlHttp.responseText;

// testing
//alert(response);

// stop if only updating
if(updateOnly == 'Yes')
return true;

// reload page if menu changes; more consistent, in case chages in style sheet, for eg.
if(field == 'page' || field == 'page_order' || field == 'sectionid' || field == 'story_display')
{
if(!recordId && field == 'page') // new
from = response;
window.location = unescape(from);
return true;
}

// stop if only updating
//if(updateOnly == 'Yes')
//return true;

// hide timer
if(field != 'list_unpublished')
document.getElementById(timer).style.visibility = 'hidden';

// display response optional targets
if(field == 'summary_type')
{
var summaryAllDiv = 'summaries' + recordId + recordDb;
var summaryAllDivE = document.getElementById(summaryAllDiv);
var startHeight = summaryAllDivE.offsetHeight;
summaryAllDivE.innerHTML=response;
var endHeight = summaryAllDivE.offsetHeight;
}
else
if(field == 'link_display')
{
var linkAllDiv = 'links_' + recordDb + recordId;
var linkAllDivE = document.getElementById(linkAllDiv);
var startHeight = linkAllDivE.offsetHeight;
linkAllDivE.innerHTML=response;
var endHeight = linkAllDivE.offsetHeight;
}
else
{
pageDivE = document.getElementById(pageDiv);
if(pageDivE)
var startHeight = pageDivE.offsetHeight;
if(pageDivE)
pageDivE.innerHTML=response;
var endHeight = pageDivE.offsetHeight;
}

// adjust footer
if(field == 'page' || field == 'page_order' || field == 'sectionid' || field == 'showid')
repositionFooterOpEd();

// for links, poss. others better
if(field == 'link_display' && linkAllDivE)
{
var changeHeight = endHeight - startHeight;
// yes to skip moving links themselves
if(field == 'link_display' && linkAllDivE)
adjustFooter(changeHeight, '', 'Yes');
else
adjustFooter(changeHeight);
}

if(field == 'summary_type')
{
var changeHeight = endHeight - startHeight;
adjustFooter(changeHeight);
}

}
}

//alert(field); // show_reorder

// set up
xmlHttp.open("GET","../admin/page_update.php?record_db="+recordDb+"&recordid="+recordId+"&field="+field+"&data="+data+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&edit_mode="+editMode+"&sectionid="+sectionId,true); 

// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW SECTION EDIT -- copy of pages
*************************************************************************/
function ajaxFunctionSeE(myDiv, controlPanel, sectionDiv, recordDb, recordId, css, from, pageTableWidth, currentPageId) //
{
// try - new abs. pos.
var timer = 'timerP';

// constant here
var idField = 'sectionid';

// stop is text editing and not called specifically for by clicking registration mark in text editor
if(textEditing == 'on') // && clickSource != 'reg-mark')
return false;

// reset to null 
if(typeof sectionDiv == 'undefined' || !sectionDiv || sectionDiv == 'undefined')
var sectionDiv = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof pageTableWidth == 'undefined' || !pageTableWidth || pageTableWidth == 'undefined')
var pageTableWidth = '';

// reset to null 
if(typeof currentPageId == 'undefined' || !currentPageId || currentPageId == 'undefined')
var currentPageId = '';

// reset to null 
if(typeof paperCode == 'undefined' || !paperCode || paperCode == 'undefined' || paperCode == 'null')
var paperCode = '';

// timer
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// update x and y to current position if already set (not inline), also position timer
if(controlPanel)
var controlPanelE = document.getElementById(controlPanel);
if(controlPanelE)
{
var curPos = findPos(controlPanelE);
var controlPanelLeft = curPos[0];
var controlPanelTop = curPos[1];
}

// position above mini control panel
if(controlPanelLeft || controlPanelTop)
{
document.getElementById(timer).style.top = (controlPanelTop+20) + 'px'; // 52
document.getElementById(timer).style.left = (controlPanelLeft) + 'px'; // 52
}

document.getElementById(timer).style.visibility = 'visible';

var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {
      var response = xmlHttp.responseText;

// display response in timer
document.getElementById(timer).innerHTML=response;

}
}

// set up
xmlHttp.open("GET","../admin/section_edit.php?my_div="+myDiv+"&timer="+timer+"&section_div="+sectionDiv+"&record_db="+recordDb+"&recordid="+recordId+"&css="+css+"&from="+from+"&page_table_width="+pageTableWidth+"&current_pageid="+currentPageId,true); 
// send
xmlHttp.send(null);     
}

/*************************************************************************
BEGIN NEW SECTION UPDATE - copy of sidebar
*************************************************************************/
function ajaxFunctionSeU(sectionDiv, recordDb, recordId, field, data, css, from, updateOnly, numStoriesU, editMode) //
{
// try - new abs. pos.
var timer = 'timerP';

// reset to null 
if(typeof recordId == 'undefined' || !recordId || recordId == 'undefined')
var recordId = '';

// reset to null 
if(typeof field == 'undefined' || !field || field == 'undefined')
var field = '';

// reset to null 
if(typeof data == 'undefined' || !data || data == 'undefined')
var data = '';

// reset to null 
if(typeof css == 'undefined' || !css || css == 'undefined')
var css = '';

// reset to null 
if(typeof from == 'undefined' || !from || from == 'undefined')
var from = '';

// reset to null 
if(typeof updateOnly == 'undefined' || !updateOnly || updateOnly == 'undefined')
var updateOnly = '';

// reset to null 
if(typeof numStoriesU == 'undefined' || !numStoriesU || numStoriesU == 'undefined')
var numStoriesU = '';

// reset to null 
if(typeof editMode == 'undefined' || !editMode || editMode == 'undefined')
var editMode = '';

// delete confirmation
var delete_var = "delete_" + recordDb + recordId;
//var delete_var = 'section_delete';
if(field == delete_var)
{
var answer = confirm ("Are you sure you wish to delete this section?")
if(!answer)
{
document.edit_form[field].checked=false;
return false;
}
}

// timer
if(updateOnly != 'Yes' && field != 'list_unpublished')
document.getElementById(timer).innerHTML='<img src="../images/timer.gif">';

// show timer
document.getElementById(timer).style.visibility = 'visible';

// prepare to receive response
var xmlHttp;
try
  {
    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
   // Internet Explorer
    try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  } 
      
   xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)  
      {


// go home
if(field == 'hide_section' && data == true)
{
window.location = '../welcome.php';  // disable to see errors, test results
return true;
}

// test
//alert(field);

// reload page if menu changes; more consistent, in case chages in style sheet, for eg; disable to test update
if(field == 'section' || field == 'section_order' || field == 'order_pages' || field == 'show_reorder' || field == 'sectionid')
{
window.location = unescape(from);  // disable to see errors, test results
return true;
}

// get response
var response = xmlHttp.responseText;

// stop if only updating
if(updateOnly == 'Yes')
return true;

// hide timer
if(field != 'list_unpublished')
document.getElementById(timer).style.visibility = 'hidden';

// display response optional targets
if(field == 'summary_type')
{
var summaryAllDiv = 'summaries' + recordId + recordDb;
var summaryAllDivE = document.getElementById(summaryAllDiv);
var startHeight = summaryAllDivE.offsetHeight;
summaryAllDivE.innerHTML=response;
var endHeight = summaryAllDivE.offsetHeight;
}
else
if(field == 'link_display')
{
var linkAllDiv = 'links_' + recordDb + recordId;
var linkAllDivE = document.getElementById(linkAllDiv);
var startHeight = linkAllDivE.offsetHeight;
linkAllDivE.innerHTML=response;
var endHeight = linkAllDivE.offsetHeight;
}
else
{
sectionDivE = document.getElementById(sectionDiv);
if(sectionDivE)
var startHeight = sectionDivE.offsetHeight;
if(sectionDivE)
sectionDivE.innerHTML=response;
var endHeight = sectionDivE.offsetHeight;
}

// adjust footer
if(field == 'section' || field == 'section_order' || field == 'sectionid' || field == 'showid')
repositionFooterOpEd();

// for links, poss. others better
if(field == 'link_display' && linkAllDivE)
{
var changeHeight = endHeight - startHeight;
// yes to skip moving links themselves
if(field == 'link_display' && linkAllDivE)
adjustFooter(changeHeight, '', 'Yes');
else
adjustFooter(changeHeight);
}

if(field == 'summary_type')
{
var changeHeight = endHeight - startHeight;
adjustFooter(changeHeight);
}

}
}

// test:all ok
//alert(recordDb);
//alert(recordId);
//alert(field);
//alert(data);

// set up
xmlHttp.open("GET","../admin/section_update.php?record_db="+recordDb+"&recordid="+recordId+"&field="+field+"&data="+data+"&css="+css+"&from="+from+"&update_only="+updateOnly+"&num_storiesu="+numStoriesU+"&edit_mode="+editMode,true); 

// send
xmlHttp.send(null);     
}




/**********************************************************
UPLOADIFY COMPLETE -- where to go
**********************************************************/
function scriptObjComplete(scriptObj)
{

// test:ok
//alert(6444);

//alert(scriptObj.from);  // still encoded when failing

// test
//alert("scriptObj.recordEditDetail js5986: " + scriptObj.recordEditDetail);

// test: nr
//dumpProps(scriptObj);

//if(scriptObj.updateOnly == 'Yes')
//return true;

// test:ok
//alert("ok to js5525");
//alert("scriptObj.record_db js5526" + scriptObj.record_db); // undefined

var record_db = scriptObj.record_db;
var recordEditDetail = scriptObj.recordEditDetail;

// reset to null 
if(typeof record_db == 'undefined' || !record_db || record_db == 'undefined' || record_db == 'null')
var record_db = '';

// reset to null 
if(typeof recordEditDetail == 'undefined' || !recordEditDetail || recordEditDetail == 'undefined' || recordEditDetail == 'null')
var recordEditDetail = '';

if(record_db && record_db == 'links')
//if(scriptObj.record_db && scriptObj.record_db == 'links')
ajaxFunctionLU(scriptObj);

else if(recordEditDetail && recordEditDetail == 'Yes')
// try
window.location = unescape(scriptObj.from);
//window.location = scriptObj.from;
//ajaxFunctionRED('','','','','','','','','','','',scriptObj);

else  // if comment out, no error
ajaxFunctionIU(scriptObj);

// test:ok,ok either way
//alert("record_db js5540: " + record_db);

}

function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {            case '\\':
                return '\\';
            case '0':
                return '\0';
            case '':                return '';
            default:
                return n1;
        }
});}

function concatObject(obj) {
  str='';
  for(prop in obj)
  {
    str+=prop + " value :"+ obj[prop]+"\n";
  }
  return(str);
}

function addfav(url,label)
   {
   if (document.all)
      {
      window.external.AddFavorite
      (url,label)
      }
   }

function disableEnterKey(e,nextField)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
{
//document.getElementById(nextField).focus(); // doesn't work in FF or Safari
         return false;
}
     else
          return true;
}

function toggleShowHideJS(element) {
	//function to show or hide elements
	//element variable can be string or object
	if (document.getElementById(element)) {
		element = document.getElementById(element);
	}

		if (element.style.visibility == "hidden") {
			showHideElement(element, 'show');
		} else {
			showHideElement(element, 'hide');
		}
}

dragDrop = {
	keyHTML: '<a href="#" class="keyLink" ></a>',
	keySpeed: 10, // pixels per keypress event
	initialMouseX: undefined,
	initialMouseY: undefined,
	previousMouseX: undefined,
	previousMouseY: undefined,
	startX: undefined,
	startY: undefined,
	dXKeys: undefined,
	dYKeys: undefined,
	draggedObject: undefined,
	initElement: function (element) {

	var element_string = element;
		if (typeof element == 'string')
			element = document.getElementById(element);
		element.onmousedown = dragDrop.startDragMouse;
		element.innerHTML += dragDrop.keyHTML;
		var links = element.getElementsByTagName('a');
		var lastLink = links[links.length-1];
		lastLink.relatedElement = element;
		lastLink.onclick = dragDrop.startDragKeys;
	},
//	startDragMouse: function (e, skipSize, skipForm) {
	startDragMouse: function (e) {

// test:undefined, fail;
//alert("skipSize at js1879: " + skipSize);

		dragDrop.startDrag(this);
		var evt = e || window.event;
		dragDrop.initialMouseX = evt.clientX;
		dragDrop.initialMouseY = evt.clientY;

		dragDrop.previousMouseX = 0;
		dragDrop.previousMouseY = 0;

		addEventSimple(document,'mousemove',dragDrop.dragMouse);
		addEventSimple(document,'mouseup',dragDrop.releaseElement);
		return false;
	},
	startDragKeys: function () {
		dragDrop.startDrag(this.relatedElement);
		dragDrop.dXKeys = dragDrop.dYKeys = 0;
		addEventSimple(document,'keydown',dragDrop.dragKeys);
		addEventSimple(document,'keypress',dragDrop.switchKeyEvents);
		this.blur();
		return false;
	},
	startDrag: function (obj) {
		if (dragDrop.draggedObject)
//			dragDrop.releaseElement(element_string);
			dragDrop.releaseElement();
		dragDrop.startX = obj.offsetLeft;
		dragDrop.startY = obj.offsetTop;
		dragDrop.draggedObject = obj;
		obj.className += ' dragged';
	},
//	dragMouse: function (e, skipSize, skipForm) {
	dragMouse: function (e) {
		var evt = e || window.event;
		var dX = evt.clientX - dragDrop.initialMouseX;
		var dY = evt.clientY - dragDrop.initialMouseY;
		
		dragDrop.setPosition(dX,dY);

		var fX = dX - dragDrop.previousMouseX;
		var fY = dY - dragDrop.previousMouseY;

		// record	
		dragDrop.previousMouseX = dX;
		dragDrop.previousMouseY = dY;
		
			// id
			var divId = dragDrop.draggedObject.id;

			// corresponing main div id
			if(divId.indexOf('panel') == -1 && divId.indexOf('timer') == -1)
			{
			var mainDivId = divId.substr(3);
			var mainDivO = document.getElementById(mainDivId);

			// form elements
			
			var widthO = document.getElementById("width_" + mainDivId);
			var heightO = document.getElementById("height_" + mainDivId);
			var xO = document.getElementById("x_" + mainDivId);
			var yO = document.getElementById("y_" + mainDivId);
			// current settings
			var mainWidth = Number(widthO.value);
			var mainHeight = Number(heightO.value);
			// corners and center drag elements
			var tlO =  document.getElementById("tl_" + mainDivId);
			var trO =  document.getElementById("tr_" + mainDivId);
			var brO =  document.getElementById("br_" + mainDivId);
			var blO =  document.getElementById("bl_" + mainDivId);
			var drO =  document.getElementById("dr_" + mainDivId);
			}
			
			// this works
			if(divId.indexOf('tl_') > -1)
			{
		    mainWidth -= fX;
			mainHeight -= fY;
			widthO.value = mainWidth; // - fX;
			heightO.value = mainHeight; // - fX;

			trO.style.top=dragDrop.draggedObject.offsetTop + "px";
			blO.style.left=dragDrop.draggedObject.offsetLeft + "px";

			drO.style.top = (dragDrop.draggedObject.offsetTop + (.5*mainHeight) - 16) + "px";
			drO.style.left = (dragDrop.draggedObject.offsetLeft + (.5*mainWidth) - 16) + "px";
	
			mainDivO.style.left=(dragDrop.draggedObject.offsetLeft+4) + "px";
			mainDivO.style.top=(dragDrop.draggedObject.offsetTop+4) + "px";
			mainDivO.style.width = mainWidth + "px";
			mainDivO.style.height= mainHeight + "px";

			xO.value=dragDrop.draggedObject.offsetLeft+4;
			yO.value=dragDrop.draggedObject.offsetTop+4;
			}
			else if(divId.indexOf('tr_') > -1)
			{
		    mainWidth += fX;
			mainHeight -= fY;
			widthO.value = mainWidth; // - fX;
			heightO.value = mainHeight; // - fX;

			tlO.style.top=dragDrop.draggedObject.offsetTop + "px";
			brO.style.left=dragDrop.draggedObject.offsetLeft + "px";

			drO.style.top = (dragDrop.draggedObject.offsetTop + (.5*mainHeight) - 16) + "px";
			drO.style.left = (dragDrop.draggedObject.offsetLeft - (.5*mainWidth) - 16) + "px";

			mainDivO.style.width = mainWidth + "px";
			mainDivO.style.height= mainHeight + "px";
			mainDivO.style.top=(dragDrop.draggedObject.offsetTop+4) + "px";

			yO.value=dragDrop.draggedObject.offsetTop+4;
			}
			else if(divId.indexOf('br_') > -1)
			{
		    mainWidth += fX;
			mainHeight += fY;
			widthO.value = mainWidth; // - fX;
			heightO.value = mainHeight; // - fX;

			trO.style.left=dragDrop.draggedObject.offsetLeft + "px";
			blO.style.top=dragDrop.draggedObject.offsetTop + "px";

			drO.style.top = (dragDrop.draggedObject.offsetTop - (.5*mainHeight) - 16) + "px";
			drO.style.left = (dragDrop.draggedObject.offsetLeft - (.5*mainWidth) - 16) + "px";

			mainDivO.style.width = mainWidth + "px";
			mainDivO.style.height= mainHeight + "px";
			}
			else if(divId.indexOf('bl_') > -1)
			{
		    mainWidth -= fX;
			mainHeight += fY;

			widthO.value = mainWidth; // - fX;
			heightO.value = mainHeight; // - fX;

			tlO.style.left=dragDrop.draggedObject.offsetLeft+"px";
			brO.style.top=dragDrop.draggedObject.offsetTop+"px";

			// try
			drO.style.top = (dragDrop.draggedObject.offsetTop - (.5*mainHeight) - 16) + "px";
			drO.style.left = (dragDrop.draggedObject.offsetLeft + (.5*mainWidth) - 16) + "px";

			mainDivO.style.left=(dragDrop.draggedObject.offsetLeft+4)+"px";
			mainDivO.style.width = mainWidth + "px";
			mainDivO.style.height= mainHeight + "px";
			xO.value = dragDrop.draggedObject.offsetLeft+4;
			}

			else if(divId.indexOf('dr_') > -1)
			{
			var newLeft = Number(dragDrop.draggedObject.offsetLeft - Math.round(.5*mainWidth) + 20);
			var newTop = Number(dragDrop.draggedObject.offsetTop - Math.round(.5*mainHeight) + 20);
			
			mainDivO.style.left=newLeft+"px";
			mainDivO.style.top=newTop+"px";

			// if sidebar, take editing panel (timer) along
			if(divId.indexOf('sidebar') > -1)
			{	
			// get main div page pos.
			var mainPagePos = findPos(mainDivO);
			var mainPageLeft = mainPagePos[0];	
			var mainPageTop = mainPagePos[1];	
			var adjustLeft = mainPageLeft - newLeft;
			var adjustTop = mainPageTop - newTop;
			
			var sbO = document.getElementById("timerSB");
			sbO.style.top=(newTop+mainHeight+adjustTop+5)+"px";
			sbO.style.left=(newLeft+adjustLeft)+"px";
			}
			// if link, take editing panel (timer) along
			else if(divId.indexOf('link') > -1)
			{	
			// get main div page pos.
			var mainPagePos = findPos(mainDivO);
			var mainPageLeft = mainPagePos[0];	
			var mainPageTop = mainPagePos[1];	
			var adjustLeft = mainPageLeft - newLeft;
			var adjustTop = mainPageTop - newTop;
			
			var lO = document.getElementById("timerL");
			lO.style.top=(newTop+mainHeight+adjustTop)+"px";
			lO.style.left=(newLeft+adjustLeft)+"px";
			}

			// if not panel or timer
			if(divId.indexOf('panel') == -1 && divId.indexOf('timer') == -1)
//			if(divId.indexOf('panel') == -1)
			{	
			tlO.style.top=(newTop-4)+"px";
			tlO.style.left=(newLeft-4)+"px";

			trO.style.top=(newTop-4)+"px";
			trO.style.left=(newLeft+mainWidth-4)+"px";

			brO.style.top=(newTop+mainHeight-4)+"px";
			brO.style.left=(newLeft+mainWidth-4)+"px";

			blO.style.top=(newTop+mainHeight-4)+"px";
			blO.style.left=(newLeft-4)+"px";

			xO.value = newLeft;
			yO.value = newTop;
			}
	
			}

		return false;
	},
	dragKeys: function(e) {
		var evt = e || window.event;
		var key = evt.keyCode;
		switch (key) {
			case 37:	// left
			case 63234:
				dragDrop.dXKeys -= dragDrop.keySpeed;
				break;
			case 38:	// up
			case 63232:
				dragDrop.dYKeys -= dragDrop.keySpeed;
				break;
			case 39:	// right
			case 63235:
				dragDrop.dXKeys += dragDrop.keySpeed;
				break;
			case 40:	// down
			case 63233:
				dragDrop.dYKeys += dragDrop.keySpeed;
				break;
			case 13: 	// enter
			case 27: 	// escape
				dragDrop.releaseElement();
//				dragDrop.releaseElement();
				return false;
			default:
				return true;
		}
		dragDrop.setPosition(dragDrop.dXKeys,dragDrop.dYKeys);
		if (evt.preventDefault)
			evt.preventDefault();
		return false;
	},
	setPosition: function (dx,dy) {
		dragDrop.draggedObject.style.left = dragDrop.startX + dx + 'px';
		dragDrop.draggedObject.style.top = dragDrop.startY + dy + 'px';
	},
	switchKeyEvents: function () {
		// for Opera and Safari 1.3
		removeEventSimple(document,'keydown',dragDrop.dragKeys);
		removeEventSimple(document,'keypress',dragDrop.switchKeyEvents);
		addEventSimple(document,'keypress',dragDrop.dragKeys);
	},
	releaseElement: function(element) {
		removeEventSimple(document,'mousemove',dragDrop.dragMouse);
		removeEventSimple(document,'mouseup',dragDrop.releaseElement);
		removeEventSimple(document,'keypress',dragDrop.dragKeys);
		removeEventSimple(document,'keypress',dragDrop.switchKeyEvents);
		removeEventSimple(document,'keydown',dragDrop.dragKeys);
		dragDrop.draggedObject.className = dragDrop.draggedObject.className.replace(/dragged/,'');

		// original end
		dragDrop.draggedObject = null;

	}
}

function addEventSimple(obj,evt,fn) {
	if (obj.addEventListener)
		obj.addEventListener(evt,fn,false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt,fn);
}

function removeEventSimple(obj,evt,fn) {
	if (obj.removeEventListener)
		obj.removeEventListener(evt,fn,false);
	else if (obj.detachEvent)
		obj.detachEvent('on'+evt,fn);
}


function pressedKey(e){
var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
var actualkey=String.fromCharCode(unicode)
return actualkey;
}

function setStartTimeNow(e,field,divName,note,noteId,view,returnURL,showDate,thisPage,updateOnly,search,newOnly,fromNewOnly, createdOn, parentDb, parentId, startDate, endDate)
{
// reset to null 
if(typeof createdOn == 'undefined' || !createdOn || createdOn == 'undefined' || createdOn == 'null')
var createdOn = '';
if(typeof parentDb == 'undefined' || !parentDb || parentDb == 'undefined' || parentDb == 'null')
var parentDb = '';
if(typeof parentId == 'undefined' || !parentId || parentId == 'undefined' || parentId == 'null')
var parentId = '';
if(typeof startDate == 'undefined' || !startDate || startDate == 'undefined' || startDate == 'null')
var startDate = '';
if(typeof endDate == 'undefined' || !endDate || endDate == 'undefined' || endDate == 'null')
var endDate = '';

var key;
if(window.event)
key = window.event.keyCode;     //IE
else
key = e.which;     //firefox

// F2
if(key == 113)
{
var d = new Date();
var currYear = d.getFullYear();
var currMonth = d.getMonth() + 1;
var currDate = d.getDate();
var currHour = d.getHours();
var currMin = d.getMinutes();
var currSec = d.getSeconds();
time = currYear + "-" +
(currMonth < 10 ? "0" : "") + currMonth + "-" +
(currDate < 10 ? "0" : "") + currDate + " " +
(currHour < 10 ? "0" : "") + currHour + ":" +
(currMin < 10 ? "0" : "") + currMin + ":" +
(currSec < 10 ? "0" : "") + currSec;

// add to field
theInput = document.getElementById(field);
if(theInput.value.substr((theInput.innerHTML.length-1),1) != " ")
theInput.value += " ";

theInput.value += time;

// needs this or crashes Safari
var browserVer = navigator.appVersion;
var isSafari = browserVer.indexOf('Safari');
if(isSafari > 0)
alert("Saving note now with timestamp");

// update field - necessary because browser does not consider insertion of timestamp a change - won't save until something else changed, but also convenient as a force-save(F2)
ajaxFunction9(divName,note,encodeURIComponent(theInput.value),noteId,view,returnURL,showDate,thisPage,updateOnly,search,newOnly,fromNewOnly, createdOn, parentDb, parentId, startDate, endDate);
}
}

function numbersOnly(e, field)
{
// reset to null - eg
if(typeof field == 'undefined' || !field || field == 'undefined' || field == 'null')
var field = '';
var key;
if(window.event)
key = window.event.keyCode;     //IE
else
key = e.which;     //firefox

// allowed: numbers, keypad numbers, some punctuation: space, - and ., and basic nav: backspace, del, arrow left and right
if(key != 48 && key != 49 && key != 50 && key != 51 && key != 52 && key != 53 && key != 54 && key != 55 && key != 56 && key != 57 && key != 96 && key != 97 && key != 98 && key != 99 && key != 100 && key != 101 && key != 102 && key != 103 && key != 104 && key != 105 && key != 32 && key != 189 && key != 8 && key != 46 && key != 190 && key != 37 && key != 39)
{
alert("Please enter only numbers for the " + field + " field");
}
}


// work around for IE7 warning
function CloseWindow()
{
window.open('','_self','');
window.close();
}

function adjustSmallMask(smallAdMask, vMenuWidth, stripeBgid, adHeight, bannerHeight, menuHeight, stripeWidth)
{
// reset to null 
if(typeof stripeWidth == 'undefined' || !stripeWidth || stripeWidth == 'undefined' || stripeWidth == 'null')
var stripeWidth = '';

// test:fail before, ok w window var window off
//alert("ok to js 1839; value of smallAdMask: "+smallAdMask);

var object = document.getElementById(smallAdMask);

// test:130,fail
//if(object)
//alert("object.offsetWidth js7106: " + object.offsetWidth);

if(stripeWidth && stripeBgid) // small ad mask bg for links, from banner down
var smallAdMaskHeight =  bannerHeight;
else

if(vMenuWidth && stripeBgid) // small ad mask bg for menu
var smallAdMaskHeight =  adHeight + bannerHeight + 0;
else
var smallAdMaskHeight =  adHeight + bannerHeight + menuHeight + 0;

if(object)
object.style.top = smallAdMaskHeight+"px";
window.lastMask = smallAdMask;

// test:130,fail
//object = document.getElementById(window.lastMask);
//if(object)
//alert("object.offsetWidth js860: " + object.offsetWidth);


}


// declare vars
var imgWidth = 0;
var imgHeight = 0;
var xAdj = 0;
var yAdj = 0;
window.newPtLtr = "";


function setPoint(img,imgWidth,imgHeight,xAdj,yAdj,xName,yName,wName,hName)
{

//alert(imgWidth);  // going here,then fail

var imgLeft = document.getElementById(img).offsetParent.offsetParent.offsetLeft;
var xScroll = document.getElementById("big_scroll").scrollLeft;
//var imgTop = document.getElementById(img).offsetTop;  // worse
var imgTop = document.getElementById(img).offsetParent.offsetTop;
//var yScroll = document.getElementById("big_scroll").offsetParent.scrollTop;  // no change
var yScroll = document.getElementById("big_scroll").scrollTop;
//var yOffset = document.getElementById("big_scroll").offsetParent.offsetTop;
var yOffset = document.getElementById("big_scroll").offsetTop;  // worse

if(window.newPtLtr == "")
{
document.link_assign_edit[xName].value= ((window.event.clientX + xScroll-2-xAdj-imgLeft)/imgWidth)*100;
document.link_assign_edit[yName].value= ((window.event.clientY + yScroll - 2 - yAdj - imgTop - yOffset)/imgHeight)*100;
window.newPtLtr = "a";
}
else if(window.newPtLtr == "a")
{
document.link_assign_edit[wName].value= ((window.event.clientX + xScroll-2-xAdj-imgLeft)/imgWidth)*100 - document.link_assign_edit[xName].value;
document.link_assign_edit[hName].value= ((window.event.clientY + yScroll - 2 - yAdj - imgTop - yOffset)/imgHeight)*100 - document.link_assign_edit[yName].value;
window.newPtLtr = "b";
}
else if(window.newPtLtr == "b")
window.newPtLtr = "";
}


function drawBox(img,imgWidth,imgHeight,box)
{
var imgLeft = document.getElementById(img).offsetParent.offsetParent.offsetLeft;
var imgTop = document.getElementById(img).offsetParent.offsetTop;
var xScroll = document.getElementById("big_scroll").scrollLeft;

var imgTop = document.getElementById(img).offsetParent.offsetTop;
var yScroll = document.getElementById("big_scroll").scrollTop;
var yOffset = document.getElementById("big_scroll").offsetTop;

if(window.newPtLtr == "")
{
document.getElementById(box).style.left= ((window.event.clientX + xScroll-2-imgLeft));
document.getElementById(box).style.top= ((window.event.clientY + yScroll-2-imgTop-yOffset));
document.getElementById(box).style.width= (imgWidth - (window.event.clientX + xScroll-4-imgLeft));
document.getElementById(box).style.height= (imgHeight - (window.event.clientY + yScroll-4-imgTop-yOffset));
}
else if(window.newPtLtr == "a")
{
document.getElementById(box).style.width= ( (window.event.clientX + xScroll-2-imgLeft-document.getElementById(box).offsetLeft));
document.getElementById(box).style.height= ( (window.event.clientY + yScroll-2-imgTop-yOffset-document.getElementById(box).offsetTop));
}
}

function drawBoxOld(imgWidth,imgHeight,newPtLtr)
{
if(newPtLtr == "")
{
document.getElementById("box").style.left= ((window.event.clientX + document.body.scrollLeft-2));
document.getElementById("box").style.top= ((window.event.clientY + document.body.scrollTop-2));
document.getElementById("box").style.width= (imgWidth - (window.event.clientX + document.body.scrollLeft-4));
document.getElementById("box").style.height= (imgHeight - (window.event.clientY + document.body.scrollTop-4));
}
else if(newPtLtr == "a")
{
document.getElementById("box").style.width= ( (window.event.clientX + document.body.scrollLeft-2-document.getElementById("box").offsetLeft));
document.getElementById("box").style.height= ( (window.event.clientY + document.body.scrollTop-2-document.getElementById("box").offsetTop));
}
}

function drawBoxAjax(img, imgWidth, imgHeight, newPtLtr, box, e)
{
// get pos. on page
var imgE = document.getElementById(img);
var curPos = findPos(imgE);
var curLeft = curPos[0];
var curTop = curPos[1];

// tests:curTop js7550: 1392,ok, ff
//alert("curLeft js7581: " + curLeft); // 0, ok
//alert("curTop js7582: " + curTop);  //0, ok

/*
function getScrollLeft()
{
var scrollLeftW = document.documentElement.scrollLeft;
if(typeof scrollLeftW == 'undefined' || scrollLeftW == 0)
var scrollLeftW = document.body.scrollLeft;
if(typeof scrollLeftW == 'undefined' || scrollLeftW == 0)
var scrollLeftW = window.pageXOffset;
if(typeof scrollLeftW == 'undefined')
var scrollLeftW = 0;
return scrollLeftW;
}

function getScrollTop()
{
var scrollTopW = document.documentElement.scrollTop;
if(typeof scrollTopW == 'undefined' || scrollTopW == 0)
var scrollTopW = document.body.scrollTop;
if(typeof scrollTopW == 'undefined' || scrollTopW == 0)
var scrollTopW = window.pageYOffset;
if(typeof scrollTopW == 'undefined')
var scrollTopW = 0;
return scrollTopW;
}
*/

var scrollLeftW = getScrollLeft();
var scrollTopW = getScrollTop();

// tests:ok;
//alert("scrollLeftW js7614 ff: " + scrollLeftW);  // scrollLeftW js7566 ff: 0, ok; saf:0;ok
//alert("scrollTopW js7615 ff: " + scrollTopW);  // scrollTopW js7567 ff: 1184, ok; saf:0;ok

var boxE = document.getElementById(box);

var evt = e || window.event;
var mouseLeft = evt.clientX;
var mouseTop = evt.clientY;

// test
//alert("mouseLeft js7624: " + mouseLeft);  // 220, ok

if(newPtLtr == "")
{
var leftNew = mouseLeft - curLeft + scrollLeftW;
var topNew = mouseTop - curTop + scrollTopW;
var widthNew = imgWidth - leftNew;
var heightNew = imgHeight - topNew;

// test
//alert("leftNew js7632: " + leftNew);  //ok
//alert("widthNew js7635: " + widthNew);  //

boxE.style.left = leftNew + 'px';
boxE.style.top = topNew + 'px';
if(widthNew > 0)
boxE.style.width = widthNew + 'px';
if(heightNew > 0)
boxE.style.height = heightNew + 'px';
//boxE.style.width = (imgWidth - leftNew) + 'px';
//boxE.style.height = (imgHeight - topNew) + 'px';

// test
//alert("widthNew js7644: " + widthNew);

}
else if(newPtLtr == "a")
{
var curPosB = findPos(boxE);
var curLeftB = curPosB[0];
var curTopB = curPosB[1];
var widthNew = mouseLeft + scrollLeftW - curLeftB;
if(widthNew > 0)
boxE.style.width = widthNew + 'px';
var heightNew = mouseTop + scrollTopW - curTopB;
if(heightNew > 0)
boxE.style.height = heightNew + 'px';
}
}

function getScrollLeft()
{
var scrollLeftW = document.documentElement.scrollLeft;
if(typeof scrollLeftW == 'undefined' || scrollLeftW == 0)
var scrollLeftW = document.body.scrollLeft;
if(typeof scrollLeftW == 'undefined' || scrollLeftW == 0)
var scrollLeftW = window.pageXOffset;
if(typeof scrollLeftW == 'undefined')
var scrollLeftW = 0;
return scrollLeftW;
}

function getScrollTop()
{
var scrollTopW = document.documentElement.scrollTop;
if(typeof scrollTopW == 'undefined' || scrollTopW == 0)
var scrollTopW = document.body.scrollTop;
if(typeof scrollTopW == 'undefined' || scrollTopW == 0)
var scrollTopW = window.pageYOffset;
if(typeof scrollTopW == 'undefined')
var scrollTopW = 0;
return scrollTopW;
}


/*******************************************
SET POINT BOTH - for manual admin and ajax, called from image_edit both cases
*******************************************/
function setPointBoth(img, imgWidth, imgHeight, newPtLtr, recordDb, recordId, idField, obj,  css, from, fieldType, updateOnly, parentDb, parentId, listId, parentName, paperCode, returnToList, format, letter, e, updateMethod, imageDisplayType)
//function setPointBoth(img, imgWidth, imgHeight, newPtLtr, xAdj, yAdj, recordDb, recordId, idField, obj,  css, from, fieldType, updateOnly, parentDb, parentId, listId, parentName, paperCode, returnToList, format, letter, e, updateMethod, imageDisplayType)
{
var evt = e || window.event;
var clickLeft = evt.clientX;
var clickTop = evt.clientY;

// get pos. on page
var imgE = document.getElementById(img);
var curPos = findPos(imgE);
var curLeft = curPos[0];
var curTop = curPos[1];

// test
//alert("xAdj js7705: " + xAdj)
//alert("yAdj: " + yAdj)

/*
var scrollLeft = document.documentElement.scrollLeft;
if(typeof scrollLeft == 'undefined')
var scrollLeft = document.body.scrollLeft;
if(typeof scrollLeft == 'undefined')
var scrollLeft = window.pageXOffset;

var scrollTop = document.documentElement.scrollTop;
if(typeof scrollTop == 'undefined')
var scrollTop = document.body.scrollTop;
if(typeof scrollTop == 'undefined')
var scrollTop = window.pageYOffset;
*/

// get window scroll
var scrollLeft = getScrollLeft();
var scrollTop = getScrollTop();

// top left or bottom right corner
if(newPtLtr == "")
{
// define and calculate
var field = "left_percent" + parentId + letter;
var data = ((clickLeft + scrollLeft - curLeft)/imgWidth)*100;
//var data = ((clickLeft + scrollLeft - curLeft - xAdj)/imgWidth)*100;

// test: 24.86... ok here
//alert("data (left_percent) js7688: " + data);

var field1 = "top_percent" + parentId + letter;
var data1 = ((clickTop + scrollTop - curTop)/imgHeight)*100;
//var data1 = ((clickTop + scrollTop - curTop - yAdj)/imgHeight)*100;

//alert("data1 (left_percent) js7693: " + data1);

if(updateMethod == 'ajax')
ajaxFunctionRUD(field, data, recordDb, recordId, idField, obj, css, from, fieldType, updateOnly, '', parentDb, parentId, listId, parentName, paperCode, field1, data1, '', '', '', '', '', returnToList, format, letter, imageDisplayType);
else
{
document.image_edit[field].value = data;
document.image_edit[field1].value = data1;
}
// next
window.newPtLtr = "a";
}
else if(newPtLtr == "a")
{
updateOnly = '';
var field = "right_percent" + parentId + letter;
var data = ((imgWidth - (clickLeft + scrollLeft - curLeft))/imgWidth)*100;
//var data = ((imgWidth - (clickLeft + scrollLeft - curLeft - xAdj))/imgWidth)*100;
var field1 = "bottom_percent" + parentId + letter;
var data1 = ((imgHeight - (clickTop + scrollTop - curTop))/imgHeight)*100;
//var data1 = ((imgHeight - (clickTop + scrollTop - curTop - yAdj))/imgHeight)*100;  // was xAdj typo
if(updateMethod == 'ajax')
ajaxFunctionRUD(field, data, recordDb, recordId, idField, obj, css, from, fieldType, updateOnly, '', parentDb, parentId, listId, parentName, paperCode, field1, data1, '', '', '', '', '', returnToList, format, letter, imageDisplayType);
else
{
document.image_edit[field].value = data;
document.image_edit[field1].value = data1;
document.image_edit.submit();
}
}
}

function pageScroll(scrollY,pageHeight) {
    	window.scrollBy(0,scrollY); // horizontal and vertical scroll increments
    	scrolldelay = setTimeout('pageScroll('+scrollY+', '+pageHeight+')',100); // scrolls every 100 milliseconds

var windowHeight = document.documentElement.clientHeight;
//var pageHeight = getDocHeight();

// test
//alert("pageHeight at jsf2617: " + pageHeight);
//alert("windowHeight at jsf2617: " + windowHeight);

var scrollPos = document.documentElement.scrollTop;
if(typeof scrollPos == 'undefined' || scrollPos == 0)
var scrollPos = document.body.scrollTop;
if(typeof scrollPos == 'undefined' || scrollPos == 0)
var scrollPos = window.pageYOffset;

// test
//alert("scrollPos: " +scrollPos);

if(scrollPos >= pageHeight - windowHeight)  // 0
stopScroll();

}

function stopScroll() {
    	clearTimeout(scrolldelay);
}

function dumpProps(obj, parent) {

if(typeof obj == 'undefined' || !obj || obj == 'undefined' || obj == 'null')
alert("obj is undefined, null, empty");


   // Go through all the properties of the passed-in object 
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to 
      // build the message. Message includes i (the object's property name) 
      // then the object's property value on a new line 
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they 
      // click "CANCEL" then quit this level of recursion 
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object 
      if (typeof obj[i] == "object") { 
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}

function scrollToElement(storyDiv)
{
storyDivE = document.getElementById(storyDiv);
if(storyDivE)
{
var curPos = findPos(storyDivE);
var storyDivLeft = curPos[0];
var storyDivTop = curPos[1];
}
else
{
var storyDivLeft = 0;
var storyDivTop = 0;
}
window.scrollTo(storyDivLeft,storyDivTop);  // nc
}

function reloadIfChanges(from)
{
if(window.changesMade == 'Yes')
window.location = unescape(from);
}

function checkEmail()
{
if(document.new_message.to.value == '')
{
alert("\"To:\" field blank; please enter an e-mail address before sending");
document.new_message.to.style.background='yellow';
}
else if(document.new_message.to.value != '' && document.new_message.to.value.indexOf('@') == -1)
{
alert("Please check the 'To:' field email address before sending; it has no '@'");
document.new_message.to.style.background='yellow';
}
if(document.new_message.cc.value != '' && document.new_message.cc.value.indexOf('@') == -1)
{
alert("Please check the 'Cc:' field email address before sending; it has no '@'");
document.new_message.cc.style.background='yellow';
}
if(document.new_message.subject.value == '' && window.subjectOK != 'Yes')
{
alert("'Subject:' field blank; enter if desired before sending");
document.new_message.subject.style.background='yellow';
window.subjectOK = 'Yes';
}
}

function scrollToAdmin(myDiv, view, size, newOnly)
{
// reset to null 
if(typeof view == 'undefined' || !view || view == 'undefined' || view == 'null')
var view = '';
// reset to null 
if(typeof size == 'undefined' || !size || size == 'undefined' || size == 'null')
var size = '';
// reset to null 
if(typeof newOnly == 'undefined' || !newOnly || newOnly == 'undefined' || newOnly == 'null')
var newOnly = '';

if(newOnly == 'Yes')
window.ccc++;
else
window.ccc = 1;
// try scroll
var offsetTop = 0;
var divId = document.getElementById(myDiv);

if(newOnly != 'Yes')
offsetTop += divId.offsetTop;
else
{
// recursive for new within new, etc.
for(var c=0;c<window.ccc;c++)
{
offsetTop += divId.offsetTop + divId.offsetParent.offsetTop;
divId = divId.offsetParent.offsetParent;
}
}
// scroll
if(size == 'small')
window.scrollTo(0,offsetTop);
else
if(view == 'full_page')
document.getElementById("big_scroll").scrollTop=offsetTop;
else if(view == '')
document.getElementById("side_scroll").scrollTop=offsetTop;
}

