uniqueLink = new Date();
var cObj;

function saveFormOldWay( strAction, strFormName ) {
	//For each element in the form
	var strLink
	var frm=document.getElementById(strFormName);
	
	strLink = strAction + "?"
	for(i=0; i<frm.elements.length; i++)
	{
		if(i>0){strLink+="&"}
		strLink+=frm.elements[i].name + "="
		if(frm.elements[i].type=="checkbox" && frm.elements[i].checked==false){
			//Don't add a value
		}else{
			strLink+=frm.elements[i].value;
		}
	}
	SendQuery(strLink,'phone'+intFamilyID);
}

function getReturnPhone() {
	//alert( "Status Code: " + statusCode + "\n\nServer Data: " + data );
	document.getElementById('number').value=pPhoneNumber(document.getElementById('number').value);
	SendQuery('f-phone.asp?fid='+intFamilyID,'phone'+intFamilyID);}

function returnInfo(url,divid){
	var infoReturned =
	{
		success: function(o) {
			document.getElementById(o.argument).innerHTML = o.responseText;
		},
		failure: function(o) {
			document.getElementById(o.argument).innerHTML = o.responseText;
		},
		argument: divid
	}
	document.getElementById(divid).innerHTML = 'Opening . . .';
	cObj = YAHOO.util.Connect.asyncRequest('GET',serverName+'/'+url+'&'+uniqueLink.getTime(),infoReturned);
}

function openForm(url,divid,fld,func){
	args = [url, divid, fld, func];
	var formOpened = 
	{
		success: function(o) {
				//updated all the stuff that happens when the call succeeds
				document.getElementById(o.argument[1]).innerHTML = o.responseText;
				document.getElementById(o.argument[2]).focus();
				eval(o.argument[3]);
				},
		failure: function(o) {
				document.getElementById(o.argument[1]).innerHTML = o.responseText;
				},
		argument : args
	}
	//alert('http://'+serverName+'/'+url+'&'+uniqueLink.getTime());
	
	cObj = YAHOO.util.Connect.asyncRequest('GET', serverName+'/'+url+'&'+uniqueLink.getTime(), formOpened);
}

function miniAction(url,dest,func){
	args = [url, dest, func];
	var actionDone = 
	{
		success: function(o) {
				//updated all the stuff that happens when the call succeeds
				arrAttend[o.argument[1]][1] = o.responseText;
				eval(o.argument[2]);
				},
		failure: function(o) {
				alert(o.responseText);
				},
		argument : args
	}
	cObj = YAHOO.util.Connect.asyncRequest('GET', serverName+'/'+url+'&t='+uniqueLink.getTime(), actionDone);
}

function saveForm(formId, url,divid,postFunc){
	postFunc = postFunc || "";
	YAHOO.util.Connect.setForm(formId);
	var formSaved =
	{
	  success: function(o) {document.getElementById(o.argument[0]).innerHTML = o.responseText;eval(o.argument[1]);},
	  failure: function(o) {document.getElementById(o.argument[0]).innerHTML = o.responseText},
	  argument: [divid, postFunc]
	}
	cObj = YAHOO.util.Connect.asyncRequest('POST', serverName+'/'+url, formSaved);

}

function mapAddress(addr, city, state, zip, id){
	//Show map box
	document.getElementById(id).style.display='block';
	// Create a map object
	var map = new YMap(document.getElementById(id),YAHOO_MAP_REG); 
	// Display the map centered on given address 
	
	if(addr.length*city.length*state.length>0||addr.length*zip.length>0){zoom=4}else{zoom=5}
	map.drawZoomAndCenter(addr+" "+city+" "+state+" "+zip, zoom); 
	map.addMarker(addr+" "+city+" "+state+" "+zip); 
}

// An XHR DataSource
var myServer = "/directory/isearch.asp";
var mySchema = ["|", "#"];

var dsSearch = new YAHOO.widget.DS_XHR(myServer, mySchema);
dsSearch.scriptQueryParam = "q";
dsSearch.responseType = dsSearch.TYPE_FLAT;

var myServer = "/ac/addresslists.asp";

var dsCity = new YAHOO.widget.DS_XHR(myServer, mySchema);
dsCity.scriptQueryParam = "k";
dsCity.scriptQueryAppend = "f=city";
dsCity.responseType = dsCity.TYPE_FLAT;

var dsState = new YAHOO.widget.DS_XHR(myServer, mySchema);
dsState.scriptQueryParam = "k";
dsState.scriptQueryAppend = "f=stateorprovince";
dsState.responseType = dsState.TYPE_FLAT;

var dsZip = new YAHOO.widget.DS_XHR(myServer, mySchema);
dsZip.scriptQueryParam = "k";
dsZip.scriptQueryAppend = "f=postalcode";
dsZip.responseType = dsZip.TYPE_FLAT;

var myServer = "/directory/grouplists.asp";

var dsPositions = new YAHOO.widget.DS_XHR(myServer, mySchema);
dsPositions.scriptQueryParam = "p";
dsPositions.responseType = dsPositions.TYPE_FLAT;

var ac = new Array();
var i=0

//Create lookups
function initAC(fld, id, minLen, qDelay, tAhead, dSource){
	ac[i] = new YAHOO.widget.AutoComplete(fld+id,fld+'AC'+id, dSource)
	ac[i].minQueryLength = minLen; 
	ac[i].queryDelay = qDelay; 
	ac[i].typeAhead = tAhead;
	i++;
	 }					

function setHeight(objTA){
	//Set the height of a textarea in a directorycard div
	objTA.style.height = objTA.value.length+50+'px';
}