/* 
GENERATE A BLANK FORM FOR A PARTICULAR TABLENAME 
*/
function setupStep4(tablename,displayname, callbackfunction ) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
		callbackfunction = "step4showForm";
	 }


	// if there is no tablename, take it from a global variable (mfc)
	 if (typeof tablename == "undefined") {
		tablename = contentLayer ;
	 }
	// if there is no displayname, take it from a global variable (mfc)
	 if (typeof displayname == "undefined") {
		displayname = contentLabel ;
	 }

	try {
		document.getElementById("datacapturetip").onmouseout = "";
		document.getElementById("datacapturetip").onmouseover = "";
	}
	catch (e) { }
	    if(document.getElementById('tooltip')) {
		document.getElementById('tooltip').style.display = 'none';
	    }
		
	 // create an http request to get the html text for the form!
	 xhReqData = createXMLHttpRequest();
	 var minisite_group = getMinisiteGroup();
         // Photopicker - Altered by KC (Send minisitename)
         minisitename = getMinisiteName();
	 var poststring = "mfcAction=processAddNewData&action=createNewParent&tablename="+tablename+"&displayname="+displayname+"&minisite_group="+minisite_group+"&minisitename="+minisitename;
	 // PhotoPicker-END
         
         //alert(poststring);
	 xhReqData.open("POST", "mfcPhpRequests.php");
	 xhReqData.onreadystatechange = window[callbackfunction];
	 
	 try {
	   xhReqData.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
	 	// this only works in internet explorer
	 }
	 xhReqData.send(poststring);
	 
}

/*
SAVE YOUR NEW RECORD TO THE SERVER
*/
function saveToServer(tablename,userID,callbackfunction) {


	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
		callbackfunction = "processed";
	 }

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof userID == "undefined") {
		userID = myUsername;
	 }



	xhReq = createXMLHttpRequest();
	poststring = formData("userDataCapture");
	poststring = stripNonValidXMLCharacters(poststring);
	poststring = poststring.substr(0,poststring.length - 1);




	// check if there is any information about a photo that has been uploaded
	// this will be held on a separate form as photos need separate handling
	if (document.getElementById('photoname')) {
		photoname = getPhotoName(document.getElementById('photoname').value);
		poststring = poststring + "&photoname="+ photoname;
	}
	// now add the tablename
	poststring = poststring + "&tablename="+tablename;
	// now add the user id
	poststring = poststring + "&userID="+userID;
	// now add the minisite information ...
	 minisitename = getMinisiteName();
	poststring = poststring + "&minisitename="+minisitename;
	//alert(selectedGeometryType);
	// if this is a geometry, then add coordinate information
	if (data_capture_pts.length > 0) { 
		poststring = poststring + "&hasgeometry=true";
		// now add the coordinate information 
		poststring = poststring + "&geometrytype="+ selectedGeometryType;  

		// now iterate through the points and add to the push statement
		var pointsstring = "&points=";
		if (isGoogleMap) {
			allpoints =getPointsStringGM(data_capture_pts);
		}
		else {
			allpoints = getPointsStringOL(data_capture_pts);
		}
		pointsstring = pointsstring + allpoints;
		poststring = poststring + "&"+pointsstring;
	} // has pts.length > 0
	else {
		poststring = poststring + "&hasgeometry=false";
	} // pts.length = 0
	 var minisite_group = getMinisiteGroup();
	 poststring = poststring +"&action=saveParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
	 //alert(poststring);
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];
	try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
	 	// this only works in internet explorer
	 }
	 //alert(poststring);
	xhReq.send(poststring);
}


/*
CANCEL THE PROCESS WHEN YOU ARE ADDING A NEW RECORD
*/
function deleteNewCapture(tablename,id,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
    		callbackfunction = "processCancelNewCapture";
  	 }


	// this is used where a record is first being created ...
	if (confirm("Cancel Data Capture?  You will lose all changes.")) {
		// delete the record from the server ...
		// in this case, the child record should be deleted from the database first
		// this is a PROPER delete as opposed to a 'delete' requested by the user / moderator which 
		// only flags the data as deleted

		// so the CANCEL button should only appear for an 'add new' operation

		xhReq = createXMLHttpRequest();
		// remove any dodgy characters
		var minisite_group = getMinisiteGroup();
		poststring = "";
		poststring = poststring + "&tablename="+tablename+"&id="+id;
		poststring = poststring + "&action=clearParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
		 xhReq.open("POST", "mfcPhpRequests.php", true);
		 xhReq.onreadystatechange = window[callbackfunction];
		 //
		 try {
		   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		   //xhReq.setRequestHeader('Content-Type','text/html')
		 }
		 catch (e) {
			// this only works in internet explorer
		 }
		//alert(poststring);
		xhReq.send(poststring);
	}

}





/* =====================
ADDING DATA
=======================*/
function deleteExReturnToNewParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
    		callbackfunction = "showNewRecordForm";
  	 }

	
	// in this case, the child record should be deleted from the database first
	// this is a PROPER delete as opposed to a 'delete' requested by the user / moderator, whic
	// only flags the data as deleted
	// so the CANCEL button should only appear for an 'add new' operation


	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	poststring = "";
	minisitename = getMinisiteName();
	var minisite_group = getMinisiteGroup();
	poststring = poststring+ "&minisitename="+minisitename

	poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
	poststring = poststring + "&tablename="+lookuptablename+"&id="+lookupid;
	poststring = poststring + "&action=clearChild&mfcAction=processAddNewData&minisite_group="+minisite_group;
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];

	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	//alert(poststring);
	xhReq.send(poststring);
}

function backtoStep3(tablename, id,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
    		callbackfunction = "processBackToStep3";
  	 }

	doCloseFormWindow();
	try {
	  var pickerDiv = document.getElementById(datePickerDivID);
	  pickerDiv.style.visibility = "hidden";
	  pickerDiv.style.display = "none";
	} catch (e) {}
	// july 2008 - we now need to delete the record we have just created ...
	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	var minisite_group = getMinisiteGroup();
	poststring = "";
	poststring = poststring + "&tablename="+tablename+"&id="+id;
	poststring = poststring + "&action=clearParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];
	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	xhReq.send(poststring);
}

function editExistingNewParent(tablename,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
    		callbackfunction = "showChildNewForm";
  	 }

	var theLayerChoice = document.getElementsByName("childEditGroup");
	var j=theLayerChoice.length; 
	for (i=0; i<j; i++){
		if(theLayerChoice[i].checked) {
			var lookuptablename = theLayerChoice[i].value;
		}
	}

	// save the main record, without any validation, then show an existing sub record
	var postdata = formData("userDataCapture");
	var poststring = stripNonValidXMLCharacters(postdata);
	poststring = poststring.substr(0,poststring.length - 1);
	
	try {
		if (document.getElementById('photoname')) {
			photoname = getPhotoName(document.getElementById('photoname').value);
			poststring = poststring + "&photoname="+ photoname;
		}
	}
	catch(e) {
	}

	minisitename = getMinisiteName();
	minisite_group = getMinisiteGroup();
	poststring = poststring+ "&minisitename="+minisitename

	// now add the tablename
	poststring = poststring + "&tablename="+tablename;
	poststring = poststring+"&approved=0";

	// as this is an add new record, also send the name of the lookup tablename, this will be used
	// to generate a new blank lookup table record to show to the user
	poststring = poststring + "&lookuptablename="+lookuptablename;
	poststring = poststring + "&action=showFirstChildNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];  //showform;

	 //
	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
	 	// this only works in internet explorer
	 }
	xhReq.send(poststring);


}

function addlookuprecordNewParent(tablename,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
    		callbackfunction = "showChildNewForm";
  	 }

	// get the ID from the main form - this is hidden
	
	// get the table name from the selected radio button
	//lookuptablename = document.getElementById("
	
	var theLayerChoice = document.getElementsByName("childgroup");
	var j=theLayerChoice.length; 
	for (i=0; i<j; i++){
		if(theLayerChoice[i].checked) {
			var lookuptablename = theLayerChoice[i].value;
		}
	}


	// save the main record, without any validation, then show a new sub record
	var postdata = formData("userDataCapture");
	var poststring = stripNonValidXMLCharacters(postdata);
	poststring = poststring.substr(0,poststring.length - 1);


	if (document.getElementById('photoname')) {
		photoname = getPhotoName(document.getElementById('photoname').value);
		poststring = poststring + "&photoname="+ photoname;
	}


	 //var sPath = window.location;
	 //var paths = String(sPath).split("=");
	 //minisitename = paths[1];
	 
	 // remove any # characters
	 //minisitename = minisitename.replace("#","");
	 minisitename = getMinisiteName();
	 minisite_group = getMinisiteGroup();
	poststring = poststring+ "&minisitename="+minisitename
	
	// now add the tablename
	poststring = poststring + "&tablename="+tablename;
	poststring = poststring+"&approved=0";

	// as this is an add new record, also send the name of the lookup tablename, this will be used
	// to generate a new blank lookup table record to show to the user
	poststring = poststring + "&lookuptablename="+lookuptablename;
	poststring = poststring + "&action=createNewChildNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;

	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction]; //showform;

	 //
	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
	 	// this only works in internet explorer
	 }
	xhReq.send(poststring);
}



function cancelExistingAndReturnToNewParent(lookuptablename, lookupid, parenttablename, parentid, callbackfunction) {
		
			 // if no callback function is provided, then use the standard mfc callback function
			 if (typeof callbackfunction == "undefined") {
				callbackfunction = "showNewRecordForm";
			 }



			xhReq = createXMLHttpRequest();
			poststring = "parenttablename="+parenttablename+"&parentid="+parentid;
			poststring = poststring + "&lookuptablename="+lookuptablename+"&id="+lookupid;
			poststring = poststring + "&action=cancelExistingChildShowNewParent";
			
			minisitename = getMinisiteName();
			minisite_group = getMinisiteGroup();
			poststring = poststring+ "&minisitename="+minisitename+"&mfcAction=processAddNewData&minisite_group="+minisite_group;

			 xhReq.open("POST", "mfcPhpRequests.php", true);
			 xhReq.onreadystatechange = window[callbackfunction];
			 try {
			   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			   //xhReq.setRequestHeader('Content-Type','text/html')
			 }
			 catch (e) {
				// this only works in internet explorer
			 }
			//alert(poststring);
			xhReq.send(poststring);
	
}
function saveExistingAndReturnToNewParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {
			 // if no callback function is provided, then use the standard mfc callback function
			 if (typeof callbackfunction == "undefined") {
				callbackfunction = "showNewRecordForm";
			 }
		if (checkData()) {
			// submit the form, save the changes and then re-create the main form
			// get the ID from the main form - this is hidden
	
			// save the main record, without any validation, then show a new sub record
			var postdata = formData("userDataCapture");
			var poststring = stripNonValidXMLCharacters(postdata);
			poststring = poststring.substr(0,poststring.length - 1);
			poststring = poststring+"&approved=0";
	
			xhReq = createXMLHttpRequest();
			// remove any dodgy characters
			
			minisitename = getMinisiteName();
			minisite_group = getMinisiteGroup();
			poststring = poststring+ "&minisitename="+minisitename

	
			poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
			poststring = poststring + "&lookuptablename="+lookuptablename+"&id="+lookupid;
			poststring = poststring + "&action=saveExistingChildShowNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
			//alert(poststring);
			 xhReq.open("POST", "mfcPhpRequests.php", true);
			 xhReq.onreadystatechange = window[callbackfunction];
		 //
			 try {
			   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			   //xhReq.setRequestHeader('Content-Type','text/html')
			 }
			 catch (e) {
				// this only works in internet explorer
			 }
			//alert(poststring);
			xhReq.send(poststring);
		}

	
}
function saveNewAndReturnToNewParent(lookuptablename, lookupid, parenttablename, parentid, callbackfunction) {
	
				 // if no callback function is provided, then use the standard mfc callback function
				 if (typeof callbackfunction == "undefined") {
					callbackfunction = "showNewRecordForm";
				 }

	
	// new child, new parent

	// this method is called if the PARENT hasn't yet been saved
	//alert("saveNewAndReturnToNewParent");
	if (checkData()) {
		// submit the form, save the changes and then re-create the main form
		// get the ID from the main form - this is hidden

		// save the main record, without any validation, then show a new sub record
		var postdata = formData("userDataCapture");
		var poststring = stripNonValidXMLCharacters(postdata);
		poststring = poststring.substr(0,poststring.length - 1);
		poststring = poststring+"&approved=0";
		
		minisitename = getMinisiteName();
		poststring = poststring+ "&minisitename="+minisitename


	if (document.getElementById('photoname')) {
		photoname = getPhotoName(document.getElementById('photoname').value);
		poststring = poststring + "&photoname="+ photoname;
	}


		xhReq = createXMLHttpRequest();
		// remove any dodgy characters
		var minisite_group = getMinisiteGroup();
		poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
		poststring = poststring + "&lookuptablename="+lookuptablename+"&id="+lookupid;
		poststring = poststring + "&action=saveNewChildShowNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
		//alert(poststring);
		 xhReq.open("POST", "mfcPhpRequests.php", true);
		 xhReq.onreadystatechange = window[callbackfunction];
	 //
		 try {
		   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		   //xhReq.setRequestHeader('Content-Type','text/html')
		 }
		 catch (e) {
			// this only works in internet explorer
		 }
		xhReq.send(poststring);
	}
	
}


function saveNewAndReturnToParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {
				 // if no callback function is provided, then use the standard mfc callback function
				 if (typeof callbackfunction == "undefined") {
					callbackfunction = "showNewRecordForm";
				 }

	// this method is called if the PARENT hasn't yet been saved

	if (checkData()) {
		// submit the form, save the changes and then re-create the main form
		// get the ID from the main form - this is hidden

		// save the main record, without any validation, then show a new sub record
		var postdata = formData("userDataCapture");
		var poststring = stripNonValidXMLCharacters(postdata);
		poststring = poststring.substr(0,poststring.length - 1);
		poststring = poststring+"&approved=0";
		
			minisitename = getMinisiteName();
			poststring = poststring+ "&minisitename="+minisitename


		xhReq = createXMLHttpRequest();
		// remove any dodgy characters

	if (document.getElementById('photoname')) {
		photoname = getPhotoName(document.getElementById('photoname').value);
		poststring = poststring + "&photoname="+ photoname;
	}

		var minisite_group = getMinisiteGroup();
		poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
		poststring = poststring + "&lookuptablename="+lookuptablename+"&id="+lookupid;
		poststring = poststring + "&action=saveNewChildShowNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
		
		 xhReq.open("POST", "mfcPhpRequests.php", true);
		 xhReq.onreadystatechange = window[callbackfunction];
	 //
		 try {
		   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		   //xhReq.setRequestHeader('Content-Type','text/html')
		 }
		 catch (e) {
			// this only works in internet explorer
		 }
		//alert(poststring);
		xhReq.send(poststring);
	}

		
}
function deleteNewAndReturnToNewParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {

			 // if no callback function is provided, then use the standard mfc callback function
			 if (typeof callbackfunction == "undefined") {
				callbackfunction = "showNewRecordForm";
			 }

	//alert("delete new and return to new parent");
	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	poststring = "";
		//var sPath = window.location;
		//var paths = String(sPath).split("=");
		//minisitename = paths[1];
		//minisitename = minisitename.replace("#","");
		minisitename = getMinisiteName();
		minisite_group = getMinisiteGroup();
		poststring = poststring+ "&minisitename="+minisitename

	poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
	poststring = poststring + "&tablename="+lookuptablename+"&id="+lookupid;
	poststring = poststring + "&action=clearChild&mfcAction=processAddNewData&minisite_group="+minisite_group;
	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];

	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
	 	// this only works in internet explorer
	 }
	//alert(poststring);
	xhReq.send(poststring);

}



function showNextLookupNewParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {

	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
		callbackfunction = "getNextLookup";
	 }

	// in this case, the child record should be deleted from the database first
	// this is a PROPER delete as opposed to a 'delete' requested by the user / moderator, whic
	// only flags the data as deleted

	// so the CANCEL button should only appear for an 'add new' operation


	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	var postdata = formData("userDataCapture");
	var poststring = stripNonValidXMLCharacters(postdata);
	poststring = poststring.substr(0,poststring.length - 1);
	
	poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
	poststring = poststring + "&lookuptablename="+lookuptablename+"&lookupid="+lookupid;
	poststring = poststring + "&action=showNextChildNewParent";
	
	minisitename = getMinisiteName();
	minisite_group = getMinisiteGroup();
	poststring = poststring+ "&minisitename="+minisitename+"&mfcAction=processAddNewData&minisite_group="+minisite_group;

	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];

	 //
	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	//alert(poststring);
	xhReq.send(poststring);
}


function showPreviousLookupNewParent(lookuptablename, lookupid, parenttablename, parentid,callbackfunction) {
	//alert("showpreviouslookup");
	
	 // if no callback function is provided, then use the standard mfc callback function
	 if (typeof callbackfunction == "undefined") {
		callbackfunction = "getPreviousLookup";
	 }

	
	// in this case, the child record should be deleted from the database first
	// this is a PROPER delete as opposed to a 'delete' requested by the user / moderator, whic
	// only flags the data as deleted

	// so the CANCEL button should only appear for an 'add new' operation


	xhReq = createXMLHttpRequest();
	// remove any dodgy characters
	var minisite_group = getMinisiteGroup();
	var postdata = formData("userDataCapture");
	var poststring = stripNonValidXMLCharacters(postdata);
	poststring = poststring.substr(0,poststring.length - 1);

	poststring = poststring + "&parenttablename="+parenttablename+"&parentid="+parentid;
	poststring = poststring + "&lookuptablename="+lookuptablename+"&lookupid="+lookupid;
	poststring = poststring + "&action=showPreviousChildNewParent&mfcAction=processAddNewData&minisite_group="+minisite_group;
	
	minisitename = getMinisiteName();
	poststring = poststring+ "&minisitename="+minisitename;

	 xhReq.open("POST", "mfcPhpRequests.php", true);
	 xhReq.onreadystatechange = window[callbackfunction];

	 //
	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	//alert(poststring);
	xhReq.send(poststring);
}



function setupAddContentTab3(callbackfunction) {
	 // capture the geometry type first
	  // if no callback function is provided, then use the standard mfc callback function
	  if (typeof callbackfunction == "undefined") {
	 		callbackfunction = "completeAddContentTab3";
	 }

	 processStep3Map();

	 minisitename = getMinisiteName();

	 xhReqContent3= createXMLHttpRequest();
	 xhReqContent3.open("POST", "mfcPhpRequests.php",true);

	 xhReqContent3.onreadystatechange = window[callbackfunction];
	try {
	   xhReqContent3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	 xhReqContent3.send("minisitename="+minisitename+"&mfcAction=addContentStep3");	
	
}

function updateControlContentStep3(callbackfunction) {
	  // if no callback function is provided, then use the standard mfc callback function
	  if (typeof callbackfunction == "undefined") {
	 		callbackfunction = "showStep3Content";
	 }

	
	var themeSelected = contentLayer;
	minisitename = getMinisiteName();
	 xhReqContent3 = createXMLHttpRequest();
	 xhReqContent3.open("POST", "mfcPhpRequests.php",true);
	 xhReqContent3.onreadystatechange = window[callbackfunction];
	try {
	   xhReqContent3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	xhReqContent3.send("minisitename="+minisitename+"&theme="+themeSelected+"&displayname="+contentLabel+"mfcAction=addContentStep3");
}


function previewVideo(tablename, resultID,callbackfunction) {

	  if (typeof callbackfunction == "undefined") {
	 		callbackfunction = "showVideo";
	 }

	// call an xml http request to download the HTML for the video
	// then show a DIV with the result inside it
	xhReq = createXMLHttpRequest();
	poststring = "";
	minisitename = getMinisiteName();
	minisite_group = getMinisiteGroup();
	poststring = poststring+ "minisitename="+minisitename
	poststring= poststring +"&action=showVideo";
	poststring = poststring + "&mfcAction=processEditData&tablename="+tablename+"&resultID="+resultID+"&minisite_group="+minisite_group;
        xhReq.open("POST", "mfcPhpRequests.php", true);
	xhReq.onreadystatechange = window[callbackfunction];

	 try {
	   xhReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   //xhReq.setRequestHeader('Content-Type','text/html')
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	xhReq.send(poststring);
	

}
function setupAddContentTab2(callbackfunction) {
	  if (typeof callbackfunction == "undefined") {
	 		callbackfunction = "completeAddContentTab2";
	 }
	
	
	var themeSelected = contentLayer;
	minisitename = getMinisiteName();
	minisite_group = getMinisiteGroup();
	
	 xhReqContent2 = createXMLHttpRequest();
	 xhReqContent2.open("POST", "mfcPhpRequests.php",true);

	 xhReqContent2.onreadystatechange = window[callbackfunction];
	try {
	   xhReqContent2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 }
	 catch (e) {
		// this only works in internet explorer
	 }
	 xhReqContent2.send("mfcAction=addContentStep2&minisitename="+minisitename+"&minisite_group="+minisite_group+"&theme="+themeSelected+"&displayname="+contentLabel);

}

