//Saker som laddas i sidhuvudet:

arr_event = new Array();
arr_people = new Array();
arr_people_event = new Array();
arr_event_types = new Array();
arr_event_type_roles = new Array();
arr_sources = new Array();
arr_files = new Array(100);
var persondata = '';
arr_connectedsources = new Array();
arr_connectedfiles = new Array();
//sourcetxt;
//temp;
objecteventrightcol = '';
type = '0';
arr_stop_block = '';
i = '0';
allvars = new Array();
img_arr = new Array();
allvars['connectedsources'] = '';
allvars['connectedfiles'] = '';
allvars['connectedfiles_place'] = '';
allvars['all_events'] = '';
allvars['connectedevents'] = '';
allvars['connectedtoevents'] = '';
allvars['source_types'] = '';
arr_publicplaces = new Array();
addedevents = new Array();
mapAllPlaces = new Array();
theOtherRoles = '';
varNewEvents = 0;
dummie_allvars = new Array();
dummie_allvars['connectedfiles_place'] = '';

MapLocation = new Array();
j = 0;
listkeeper = '';
var loaded_picklist = "";
var loaded_picklist_type = "";
var picklist_choosenId = "";
var picklist_choosenTextVal = "";

TheTestVar = 'blaha';
varSelectedSource = '' ;
varShowOnMap = 'Visa på karta';
varMapPlaceTypes = new Array();
var tmpPlaces = '';
mapAllShownPlaces = new Array();
tmpPosition = new Array();
//image/map objects
loadedMapObject = '';
imgFilename = '';
mapObjectSmall = "<div id='map' style='position:relative; width:280px; height:0px; left:0px; top:0px; z-index:1; ' >dasda</div>" +
		"<div id='GeocoderTextDiv' style='position:absolute; width:250px; height:20px; left:20px; top:500px; z-index:2; ' ></div>" +
		"<div id='DemoItemsDiv' style='position:absolute; width:250px; height:20px; left:20px; top:500px; z-index:2; ' ></div>";

mapObjectLarge = "<div id='map' style='position:relative; width:600px; height:500px; left:0px; top:0px; z-index:1; ' ></div>" +
		"<div id='GeocoderTextDiv' style='position:absolute; width:250px; height:20px; left:20px; top:500px; z-index:2; ' ></div>" +
		"<div id='DemoItemsDiv' style='position:absolute; width:250px; height:20px; left:20px; top:500px; z-index:2; ' ></div>";
var thePictures = new Array();
thePictures_Place = new Array();
currentImageContainerShownObject = 0;
currentImageContainerShownObject_Place = 0;
showMap = false;
lbl_showmap = '';
//end of image/map objects

//common place variables
varPlaceName = '';




//common variables for all objects
varIntroduction = '';
varObjectText = '';
varText = '';
varLinks = '';
varSources = '';

//common person variables
varPersonFirstName = '';
varPersonLastName = '';
varGender = '';
varBornDate = '';
varDeadDate = '';
varBornPlace = '';
varDeadPlace = '';
varMotherName = '';
varFatherName = '';
varPersonId = '';
varCouples = '';
varEvents = '';
arrPerson_name = new Array();

//common public place variables
varPlaceX = '';
varPlaceY = '';
varPlaceType = '';
varPlaceDate = '';
varParentPlace = '';
varinfSourceID = '';
varinfPublicPlaceId = '';
varinftypeofsource = '';
var sPlace_X_Higher = '';


//common user variables
varUserName = '';
varUserEmail = '';
varUserWebpage = '';


//Flags
flagOneImage = '';
flagImagesExists = '';


//Common place variables
varIntroduction_Place = '';
varObjectText_Place = '';
varText_Place = '';
varText_place = '';
varLinks_Place = '';
varSources_place = '';
imgFilename_Place = '';




//Images
var splittedPictures = new Array();
var splittedPictures_place = new Array();

/*
%%%%%%%%%%%%%   DUMMIE CONTENT
*/
dummie_allvars['connectedfiles'] = 'filename|jibberjabber.jpg#filetitle|jibbrish#filesize|750#filetype|img#myplaceid|1Â¤' +
		'filename|dibberdabber.jpg#filetitle|test1#filesize|1050#filetype|doc#myplaceid|1Â¤' +
		'filename|blabber.jpg#filetitle|lahhha#filesize|1000000#filetype|img#myplaceid|1Â¤';
dummie_allvars['connectedfiles_place'] = 'filename|jibberjabber.jpg#filetitle|test2#filesize|750#filetype|img#myplaceid|1Â¤' +
		'filename|dibberdabber.jpg#filetitle|muhaaa#filesize|1050#filetype|doc#myplaceid|1Â¤' +
		'filename|blabber.jpg#filetitle|test3#filesize|1000000#filetype|img#myplaceid|1Â¤';
//


//*******************************************************************************************
//*******************************************************************************************
//               Done with inital variabel loads now starting functions
//*******************************************************************************************
//*******************************************************************************************
window.onload=function()
{	var b, r, t = document.getElementsByTagName("TABLE");
	
	for(var i=0; i<t.length; i++)
	{	var current_t = t[i];
		if(current_t.className && current_t.className == "zebra")
		{	b = current_t.getElementsByTagName("TBODY");
			for(var j=0; j<b.length; j++)
			{	var current_b = b[j];
				r = current_b.getElementsByTagName("TR");
				for(var k=0; k<r.length; k+=2)
				{	r[k].className = "udda";
				}
			}
		}
	}
	
}

//////////////////////////////////////////////////////////////////
function strReplace(s, r, w){
     return s.split(r).join(w);
}

function updatePersonName()
{
	theName = document.getElementById('firstname').value + ' ' + document.getElementById('lastname').value;
	arrPersonName = document.getElementsByName('person_name');
	for(i=0;i<arrPersonName.length;i++)
	{
		//alert(arrPersonName[i].innerHTML);
		arrPersonName[i].innerHTML = theName;
	}
	
	
	return;
}
///////////////////////////////////////////////////////////////////
function choosen_PickListItem(id,thetext)
{
	picklist_choosenId = id;
	picklist_choosenTextVal = thetext;
	//alert(id+thetext);
}	 
function setValue(thetext)
{
	document.getElementById('roles_id').value = document.getElementById('roles_list').value;
	document.getElementById('roles_text').value = thetext;
	//alert(id+thetext);
}

	
    





/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////


function create_image_array(filename,title,description,myplace)
{
	//alert(myplace);
	lengthofthePictures = thePictures.length;
	thePictures[lengthofthePictures] = filename + '#' + title + '#' + description + '#' + myplace;
	
}
function create_image_array_place(filename,title,description,myplace)
{
	//alert(myplace);
	lengthofthePictures = thePictures_Place.length;
	thePictures_Place[lengthofthePictures] = filename + '#' + title + '#' + description + '#' + myplace;
	
}
function submitform(action,id)
{
	
	//alert(action);
	if(action == 'edit')
	{
		document.FOOTER.PERFORM.value = 'edit';
	}
	if(action == 'reply')
	{
		document.formModule.PERFORM.value = 'reply';
		SubmitForm();
		//document.formModule.value = id;
		//document.formModule.submit();
		return;
	}
	if(action == 'delete')
	{
		document.FOOTER.PERFORM.value = 'delete';
		varDeleted = confirm('Ta bort?');
		if(!varDeleted)
		{
			return false;
		}
	}
	else
	{
		document.FOOTER.PERFORM.value = 'view';
	}
	if(id == '')
	{
		return false;
	}
	document.FOOTER.ID.value = id;
	document.FOOTER.submit();		
}
function loadView(mode)
{
	switch(mode)
	{
		case 'publicplace':
		document.getElementById('place_name').innerHTML += '<h1>' + varPlaceName + '</h1>';
		
		if(varIntroduction != '')
		{
			document.getElementById('introduction').innerHTML = '<P>' + varIntroduction + '</p>';
		}
		//Publisher info
		tmpUserData = document.getElementById('user_data').innerHTML;
		tmpUserData = tmpUserData + '<p><h5>' + varUserName  + '</p>';
		tmpUserData = tmpUserData + '<p><h5>' + varUserEmail + '</p>';
		tmpUserData = tmpUserData + '<p><h5>' + varUserWebpage + '</p>';
		document.getElementById('user_data').innerHTML = tmpUserData;
		//End publisher info
		if(varPlaceType != '')
		{
		document.getElementById('place_type_name').innerHTML = '<P>' + varPlaceType + '</P>';
		}
		if(varPlaceDate != '')
		{
		document.getElementById('placedate').innerHTML = '<P>' + varPlaceDate + '</P>';
		}
		if(varPlaceY != '')
		{
			document.getElementById('placecoords').innerHTML = /*'<P>' + varPlaceY + '<BR>' + varPlaceX + '</P>*/'<p><a href="/largemap/'+ varPublicPlaceID + '/" class=blarrowLink>' + varShowOnMap + '</a></p>';
		}
		if(varParentPlace != '')
		{
		document.getElementById('higherplace').innerHTML = '<P>Platsen Ã¤r kopplad till <BR><A href=?com=view&action=listchildplaces&id='+varParentId+'>' + varParentPlace + '</a></P><P>Visa <A href=?com=view&action=listchildplaces&id='+varPlaceID+'>platser</a> eller <A href=?com=view&action=listchildpeopleplace&id='+varPlaceID+'>personer</a> som tillhÃ¶r ' + varPlaceName + '</a></P>';
		}
		
		
		/*if(varLinks != '')
		{
			document.getElementById('links').innerHTML = varLinks;
		}
		*/
		
		if(varSources != '')
		{
			//alert(varSources);
			document.getElementById('sources').innerHTML = '<P>' + varSources + '</p>';
		}
		break;
		case 'place':
		document.getElementById('place_name_place').innerHTML += '<h1>' + varPlaceName_place + '</h1>';
		
		if(varIntroduction != '')
		{
			document.getElementById('introduction_place').innerHTML = '<P>' + varIntroduction_place + '</p>';
		}
		
		//Publisher info
		tmpUserData_place = document.getElementById('user_data_place').innerHTML;
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserName_place  + '</p>';
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserEmail_place + '</p>';
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserWebpage_place + '</p>';
		document.getElementById('user_data_place').innerHTML = tmpUserData_place;
		//End publisher info
		
		
		/*
		if(varParentPlace != '')
		{
		document.getElementById('higherplace').innerHTML = '<P>' + varParentPlace + '</P>';
		}
		
		
		
		*/
		if(varSources_place != '')
		{
			//alert(varSources_place);
			document.getElementById('sources_place').innerHTML = '<P>' + varSources_place + '</p>';
		}
		break;
		case 'myplace':
		document.getElementById('Myplace_name').innerHTML += '<h1>' + varMyplaceName + '</h1>';
		
		if(varIntroduction != '')
		{
			document.getElementById('introduction').innerHTML = '<P>' + varIntroduction + '</p>';
		}
		
		//Publisher info
		/*tmpUserData_place = document.getElementById('user_data_place').innerHTML;
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserName_place  + '</p>';
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserEmail_place + '</p>';
		tmpUserData_place = tmpUserData_place + '<p><h5>' + varUserWebpage_place + '</p>';
		document.getElementById('user_data_place').innerHTML = tmpUserData_place;*/
		//End publisher info
		
		
		/*
		if(varParentPlace != '')
		{
		document.getElementById('higherplace').innerHTML = '<P>' + varParentPlace + '</P>';
		}
		
		
		 
		
		if(varSources_place != '')
		{
			//alert(varSources_place);
			document.getElementById('sources_place').innerHTML = '<P>' + varSources_place + '</p>';
		}*/
		break;
		case 'person':
		
		if(varPersonFirstName != '')
		{
			document.getElementById('firstname').innerHTML = '<H1>' + varPersonFirstName  + '</H1>';
		}
		if(varPersonLastName != '')
		{
			document.getElementById('lastname').innerHTML = '<H1>' + varPersonLastName  + '</H1>';
		}
		if(varGender != '')
		{
			document.getElementById('gender').innerHTML = '<P>' + varGender  + '</P>';
		}
		if(varBornDate != '')
		{
			document.getElementById('borndate').innerHTML = '<P>' + varBornDate  + '</P>';
		}
		if(varBornPlace != '')
		{
			document.getElementById('bornplace').innerHTML = '<P>' + varBornPlace  + '</P>';
		}
		if(varFatherID != '')
		{
			document.getElementById('father').innerHTML = '<P><a href=?com=view&action=viewperson&personid='+ varFatherID +'>' + varFatherName  + '</a></P>';
		}
		if(varMotherName != '')
		{
			document.getElementById('mother').innerHTML = '<P><a href=?com=view&action=viewperson&personid='+ varMotherID +'>' + varMotherName  + '</a></P>';
		}
		if(varCouples != '')
		{
			document.getElementById('couples').innerHTML = '<P>' + varCouples  + '</P>';
		}
		if(varLinks != '')
		{
			document.getElementById('links').innerHTML = varLinks;
		}
		if(varSources != '')
		{
			//alert(varSources);
			document.getElementById('sources').innerHTML = '<P>' + varSources + '</p>';
		}
		if(varDeadDate != '')
		{
			document.getElementById('deaddate').innerHTML = '<P>' + varDeadDate + '</P>';
		}
		if(varDeadPlace != '')
		{
			document.getElementById('deadplace').innerHTML = '<P>' + varDeadPlace + '</P>';
		}
		if(varEvents != '')
		{
			document.getElementById('events').innerHTML = varEvents;
		}
		document.getElementById('ColumnContent5').innerHTML = "<p><a href='/_swf/view.php?id=" + varPersonId + "&Count=20'><img src='/_images/column_familytree.png' alt='Visa sl&auml;kttr&auml;d' width='185' height='97' /></a></p>";
		document.getElementById('ColumnContent5').innerHTML = document.getElementById('ColumnContent5').innerHTML + "<p><a href='/_swf/view.php?id=" + varPersonId + "&Count=20'><img src='/_images_icons/i_show_family_tree.png' width='21' height='19' border='0' /> Visa slÃ¤kttrÃ¤d</a></p>";
		
		

		
		//Publisher info
		tmpUserData = document.getElementById('user_data').innerHTML;
		tmpUserData = tmpUserData + '<h5>' + varUserName  + '</p>';
		tmpUserData = tmpUserData + '<h5>' + varUserEmail + '</p>';
		tmpUserData = tmpUserData + '<h5>' + varUserWebpage + '</p>';
		document.getElementById('user_data').innerHTML = tmpUserData;
		//End publisher info
		if(varIntroduction != '')
		{
			document.getElementById('introduction').innerHTML = varIntroduction;
		}
		//document.getElementById('text').innerHTML = varText;
		//document.getElementById('place_x').innerHTML = varPlaceX;
		//document.getElementById('placedate').innerHTML = varPlaceDate;
		break;
	}
}

function populateform(formname,fieldname,values)
{
	//alert(fieldname + values);
	//alert(document.getElementById(fieldname).value)
	
	
	if(fieldname == 'gender')
	{
		var radioObj = document.getElementsByName(fieldname);
		//alert(fieldname);
		var radioLength = radioObj.length;
		//alert(radioObj.length);
		//alert(values);
		
		for(var i=0;i<radioLength;i++)
		{
			
			if(radioObj[i].value == values)
			{
				radioObj[i].checked = true;
			}
		}
		
		//radioObj.value = values;
		return false;
	}
	if(fieldname == 'msg_type')
	{
		var radioObj = document.getElementsByName(fieldname);
		//alert(fieldname);
		var radioLength = radioObj.length;
		//alert(radioObj.length);
		//alert(values);
		
		for(var i=0;i<radioLength;i++)
		{
			
			if(radioObj[i].value == values)
			{
				radioObj[i].checked = true;
			}
		}
		
		//radioObj.value = values;
		return false;
	}
	values = strReplace(values, "<BR>", "\n");
	document.getElementById(fieldname).value = values;
	if(fieldname == 'published')
	{
		var radioObj = document.getElementsByName('published');
		//alert(fieldname);
		var radioLength = radioObj.length;
		//alert(radioObj.length);
		if(radioLength == undefined) 
		{
			
			radioObj.checked = (radioObj.value == values);
			return;
		}
		for(var i=0;i<radioLength;i++)
		{
			radioObj[i].checked = false;
			if(radioObj[i].value == values)
			{
				radioObj[i].checked = true;
			}
			radioObj[i].value = i;
		}
		
		
	}	
	if(fieldname == 'published_id')
	{
		var radioObj = document.getElementsByName('published_id');
		//alert(fieldname);
		var radioLength = radioObj.length;
		//alert(radioObj.length);
		if(radioLength == undefined) 
		{
			
			radioObj.checked = (radioObj.value == values);
			return;
		}
		for(var i=0;i<radioLength;i++)
		{
			radioObj[i].checked = false;
			if(radioObj[i].value == values)
			{
				radioObj[i].checked = true;
			}
			radioObj[i].value = i;
		}
		
		
	}
	if(fieldname == 'stillalive')
	{
		//alert(values);
		var radioObj = document.getElementsByName('stillalive');
		//alert(fieldname);
		var radioLength = radioObj.length;
		//alert(radioObj.length);
		if(radioLength == undefined) 
		{
			
			radioObj.checked = (radioObj.value == values);
			return;
		}
		for(var i=0;i<radioLength;i++)
		{
			
			if(i == '0')
			{
			j = 'f'
			}
			if(i == '1')
			{
			j = 't'
			}
			radioObj[i].value = j;
			radioObj[i].checked = false;
			if(radioObj[i].value == values)
			{
				radioObj[i].checked = true;
			}
			
		}
		
		
	}	
}
function populateview(formname,fieldname,values)
{
  	
	switch(fieldname)
	{
		
		case 'introduction':
		
		varIntroduction = values;
		varIntroduction_place = values;
		break;
		case 'myplace_text':
		
		varText = values;
		
		break;
		case 'text':
		
		varText = values;
		
		break;
		case 'text_place':
		
		//alert(values);
		varText_place = values;
		
		break;
		case 'place_name': 
		
		varPlaceName = values.replace(' ','&nbsp;');
		varPlaceName = varPlaceName.replace(' ','&nbsp;');
		varPlaceName = varPlaceName.replace(' ','&nbsp;');
		varPlaceName = varPlaceName.replace(' ','&nbsp;');
		varPlaceName = varPlaceName.replace(' ','&nbsp;');
		varPlaceName = varPlaceName.replace(' ','&nbsp;');
		varPlaceName_place = varPlaceName;
		break;
		case 'myplace_name': 
		
		varMyplaceName = values;

		break;
		case 'firstname':
		
		varPersonFirstName = values;
		
		break;
		case 'lastname':
		
		varPersonLastName = values;
		break;
		case 'description':
		
		varText = values;
		
		break;
		case 'gender':
		varGender = values;
			
		break;
		case 'borndate':
		varBornDate = values;
		
		break;
		case 'bornplace':
		varBornPlace = values;
		
		break;
		case 'deadplace':
		varDeadPlace = values;
		
		break;
		case 'deaddate':
		varDeadDate = values;
		
		break;
		
		case 'mother':
		varMotherName = values;
		
		break;
		case 'father':
		varFatherName = values;
		
		break;
		case 'public_place_id':
		varPlaceID = values;
		varPublicPlaceID = values;
		//alert(values);
		break;
		case 'place_id':
		varPlaceID = values;
		//alert(values);
		break;
		case 'father_id':
		varFatherID = values;
		
		break;
		case 'mother_id':
		varMotherID = values;
		
		break;
		case 'birthplace_id':
		varBirthPlaceID = values;
		
		break;
		case 'deadplace_id':
		varDeadPlaceID = values;
		
		break;
		case 'user_name':
		varUserName =  values ;
		varUserName_place =  values ;
		break;
		case 'user_email':
		
		varUserEmail = values;
		varUserEmail_place = values;
		break;
		case 'user_webpage':
		
		varUserWebpage = values;
		varUserWebpage_place = values;		
		break;
		case 'myplace_ingress':
		
		varIntroduction = values;
		//varUserWebpage_place = values;	
		//alert(varIntroduction);	
		break;
		case 'couples':
		
		varCouples = values;
		
		break;
		case 'sources':
		
		varSources = values;

		//alert(varSources);
		break;
		case 'sources_place':
		
		
		varSources_place = values;
		//alert(varSources);
		break;
		case 'links':
		
		varLinks_place = values;
		
		break;
		case 'links_place':
		
		varLinks_place = values;
		
		break
		case 'place_x':
		
		varPlaceX = values;
		
		break;
		
		case 'place_y':
		
		varPlaceY = values;
		
		break;
		
		case 'place_type_name':
		
		varPlaceType = values;
		
		break;
		case 'placedate':
		
		varPlaceDate = values;
		varPlaceDate_place = values;
		
		break;
		case 'person_id':
		
		varPersonId = values;
		
		break;
		case 'livingevents':
		
		//showTable('livingevents')
		
		break;
		case 'events':
		
		varEvents = values;
		
		break;
		case 'higherplace':
		
		varParentPlace = values;
		varParentPlace_place = values;
		
		break;
		case 'higher_id':
		
		varParentId = values;
		//varParentPlace_place = values;
		
		break;
		
	}
	if(persondata != '')
	{
		document.getElementById('ColumnPersonData').innerHTML = persondata;
	}
		
}
function showAllText(layoutObject)
{
	//alert(layoutObject);
	switch(layoutObject)
	{
		case 'varText':
		
		if(document.getElementById('text').innerHTML == "")
		{
			document.getElementById('text').innerHTML = varText;
			document.getElementById('showalltext').innerHTML = "<a class='blarrowLink' href='#' OnClick=showAllText('varText') >dÃ¶lj text</a>";
		}
		else
		{
			document.getElementById('text').innerHTML = "";
			document.getElementById('showalltext').innerHTML = "<a class='blarrowLink' href='#' OnClick=showAllText('varText') >Mer information</a>";
		}
		break;
		case 'varText_place':
		
		if(document.getElementById('text_place').innerHTML == "")
		{
			//alert(varText_place);
			document.getElementById('text_place').innerHTML=varText_place;
			document.getElementById('showalltext_place').innerHTML = "<a class='blarrowLink' href='#' OnClick=showAllText('varText_place') >dÃ¶lj text</a>";
		}
		else
		{
			document.getElementById('text_place').innerHTML = "";
			document.getElementById('showalltext_place').innerHTML = "<a class='blarrowLink' href='#' OnClick=showAllText('varText_place') >se all text</a>";
		}
		break;
	}
	
}
function previousObject()
{
	nrofImages = thePictures.length - 1;
	if(currentImageContainerShownObject < nrofImages+1 && currentImageContainerShownObject != 0)
	{
		currentImageContainerShownObject = currentImageContainerShownObject - 1;
		splittedPictures = thePictures[currentImageContainerShownObject].split('#');
		imgFilename = splittedPictures[0];
		imgMyplace = splittedPictures[3];
		imgTitle = splittedPictures[1];
		imgText = splittedPictures[2];
		realcurrentImageContainerShownObject = currentImageContainerShownObject + 1;
		if(imgTitle == '')
		imgTitle = imgFilename;
		document.getElementById('displayPictop').innerHTML = "<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject + " av " + thePictures.length + "<a class='next' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle + "</p>";
		document.getElementById('theImage').innerHTML = "<img src="+varDataUrl+varDataPath+imgMyplace+"/"+ imgFilename +" width=280>";

	}
		//alert(thePickContent[currentImageContainerShownObject]);
}
function nextObject()
{
	//alert(currentImageContainerShownObject);
	nrofImages = thePictures.length -1;
	//alert(nrofImages);
	
	if(currentImageContainerShownObject<nrofImages)
	{
		currentImageContainerShownObject = currentImageContainerShownObject + 1;
		splittedPictures = thePictures[currentImageContainerShownObject].split('#');
		imgFilename = splittedPictures[0];
		imgMyplace = splittedPictures[3];
		imgTitle = splittedPictures[1];
		imgText = splittedPictures[2];
		realcurrentImageContainerShownObject = currentImageContainerShownObject + 1;
		if(imgTitle == '')
		imgTitle = imgFilename;
		document.getElementById('displayPictop').innerHTML = "<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject + " av " + thePictures.length + "<a class='next' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle + "</p>";
		document.getElementById('theImage').innerHTML = "<img src="+varDataUrl+varDataPath+imgMyplace+"/"+ imgFilename +" width=280>";
	}

}
function showImages()
{
	
		loadedMapObject = document.getElementById('theImage').innerHTML;
		splittedPictures = thePictures[currentImageContainerShownObject].split('#');
		imgFilename = splittedPictures[0];
		imgMyplace = splittedPictures[3];
		imgTitle = splittedPictures[1];
		imgText = splittedPictures[2];
		realcurrentImageContainerShownObject = currentImageContainerShownObject + 1;
		if(imgTitle == '')
		imgTitle = imgFilename;
		document.getElementById('displayPictop').innerHTML = "<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject + " av " + thePictures.length + "<a class='back' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle + "</p>";
		document.getElementById('theImage').innerHTML = "<img src=upload/uploaded/"+imgMyplace+"/"+ imgFilename +" width=280>";
		document.getElementById('displayPicbot').innerHTML = "<p><a class='showmap' href='#' onClick=showTheMap()  >Visa karta</a></p>";

}
function showTheMap() 
	{
		
		document.getElementById('displayPictop').innerHTML = "<P><a class='back' href='#' onClick='showBigMap()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Visa stor karta</p>";
		document.getElementById('theImage').innerHTML = mapObjectSmall;
		document.getElementById('displayPicbot').innerHTML = "<P><a class='showmap' href='#' onClick='showImages()'>Visa bilder</a></p>";
		if(loadedMapObject == '')
		{
			Geosition();
		}
		else
		{
			document.getElementById('theImage').innerHTML = loadedMapObject;
			
		}
    }
function showThePublicMap() 
	{
			//document.getElementById('theImage').innerHTML = mapObjectLarge;
			Geosition();
		
    }
function showImageContainer(page)
{
	
	
	if(thePictures != '')
	{
			splittedPictures = thePictures[currentImageContainerShownObject].split('#');
			imgFilename = splittedPictures[0];
			imgMyplace = splittedPictures[3];
			imgTitle = splittedPictures[1];
			imgText = splittedPictures[2];
			realcurrentImageContainerShownObject = currentImageContainerShownObject + 1;
	}
	
	
	if(page == 'publicplace')
	{
		if(imgFilename == '')
		{
			
			return ;
		}
		
		
		//if one image found set flag so you cant swap between images 
		if(thePictures.length == 1)
		{
			flagOneImage = true;
		}
		
				
		document.write("<div id='displayA1contentContainer'>");
		document.write("<div id='displayA1picLeft'>");
		document.write("<div id='displayPiccontainer'>");
		document.write("<div id='displayPictop'>");
		
		if(showMap != true)
		{
			if(flagOneImage == true)
			{
				document.write("<P>"+imgTitle+"</P>");
			}
			else
			{
			document.write("<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject + " av " + thePictures.length + "<a class='next' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle + "</p>");
			}
		}
		
		document.write("</div>");
		document.write("<div id='displayPiccontent'>");
		document.write("<div id='theImage'>");
		if(showMap != true)
		{
			document.write("<img src=" + varDataUrl + varDataPath +imgMyplace+"/"+ imgFilename +" width=280>");
		}
		document.write("</div>");
		document.write("<div id='displayPicbot'><p style='color:#000000'>&nbsp;</p></div>");
		/*if(flagOneImage)
		{
			document.write("");
			
		}
		else(!flagOneImage)
		{
				document.write("<div id='displayPicbot'><p><a class='showmap' href='#' onClick=showAllImages  >Visa alla bilder</a></p></div>");	
		}*/
		document.write("</div>");	
		document.write("</div>");		
		//document.write("</div>");
		
	}
	if(page == 'place')
	{
		splittedPictures_Place = new Array();
		if(thePictures_Place != '')
		{
			splittedPictures_Place = thePictures_Place[currentImageContainerShownObject_Place].split('#');
			imgFilename_Place = splittedPictures_Place[0];
			imgMyplace_Place = splittedPictures_Place[3];
			imgTitle_Place = splittedPictures_Place[1];
			imgText_Place = splittedPictures_Place[2];
			realcurrentImageContainerShownObject_Place = currentImageContainerShownObject_Place + 1;
		}
		
		
		if(imgFilename_Place == '')
		{
			
			return ;
		}
		
		
		//if one image found set flag so you cant swap between images 
		if(thePictures_Place.length == 1)
		{
			flagOneImage_Place = true;
		}
		
				
		document.write("<div id='displayA1contentContainer'>");
		document.write("<div id='displayA1picLeft'>");
		document.write("<div id='displayPiccontainer'>");
		document.write("<div id='displayPictop'>");
		
		
			if(flagOneImage == true)
			{
				document.write("<P>"+imgTitle_Place+"</P>");
			}
			else
			{
			document.write("<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject_Place + " av " + thePictures_Place.length + "<a class='next' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle_Place + "</p>");
			}
		
		
		document.write("</div>");
		document.write("<div id='displayPiccontent'>");
		document.write("<div id='theImage'>");
		if(showMap != true)
		{
			document.write("<img src=" + varDataUrl + varDataPath +imgMyplace_Place+"/"+ imgFilename_Place +" width=280>");
		}
		document.write("</div>");
		document.write("<div id='displayPicbot'><p>&nbsp;</p></div>");
		/*if(flagOneImage)
		{
			document.write("");
			
		}
		else(!flagOneImage)
		{
				document.write("<div id='displayPicbot'><p><a class='showmap' href='#' onClick=showAllImages  >Visa alla bilder</a></p></div>");	
		}*/
		document.write("</div>");	
		document.write("</div>");		
		//document.write("</div>");
		
	}
	if(page == 'person')
	{
		//locate images or map koordinates if not found leave
		
		if(imgFilename == '')
		{
			
			return ;
		}
		
		
		//if one image found set flag so you cant swap between images 
		//alert(thePictures.length);
		if(thePictures.length == 1)
		{
			flagOneImage = true;
		}
		
				
		document.write("<div id='displayA1contentContainer'>");
		document.write("<div id='displayA1picLeft'>");
		document.write("<div id='displayPiccontainer'>");
		document.write("<div id='displayPictop'>");
		
		if(showMap != true)
		{
			if(flagOneImage == true)
			{
				document.write("<P>"+imgTitle+"</P>");
			}
			else
			{
			document.write("<P><a class='back' href='#' onClick='previousObject()'><img src='/_images_icons/pic_back.png' alt=' ' /></a>Bild " + realcurrentImageContainerShownObject + " av " + thePictures.length + "<a class='next' href='#' onClick='nextObject()'><img src='/_images_icons/pic_next.png' alt=' ' /></a><BR>" + imgTitle + "</p>");
			}
		}
		
		document.write("</div>");
		document.write("<div id='displayPiccontent'>");
		document.write("<div id='theImage'>");
		if(showMap != true)
		{
			document.write("<img src=" + varDataUrl + varDataPath +imgMyplace+"/"+ imgFilename +" width=280>");
		}
		document.write("</div>");
		
		if(!flagOneImage)
		{
			document.write("<div id='displayPicbot'><p><a class='showmap' href='#' onClick=showAllImages  >Visa alla bilder</a></p></div>");	
		}
		else(flagOneImage)
		{
			document.write("<div id='displayPicbot'><p>&nbsp;</p></div>");	
		}
		document.write("</div>");	
		document.write("</div>");		
		//document.write("</div>");
			
	}
	if(page == 'editpublicplace')
	{
		return true;
	}
	return;
}
function loadtolist(listname,id,value)
{
	
	i = document.getElementById(listname).length;
	
	document.getElementById(listname).options[i] = new Option(value,id);
	
}


function loadtoarray(listname,data)
{
 	
 	allvars[listname] = data;
 	
 	//document.write(allvars[listname]);
	
}


function createlist(id,fieldname,value,list_name)
{
	//alert(list_name);
	
	
	i = id;
	
	switch(list_name)
	{
	case "arr_event":
	if(i != 'undefined'){
	arr_event[i] = arr_event[i]+'#'+fieldname+'|'+value;
	}
	
	break
	case "arr_people":
	if(i != 'undefined'){
	arr_people[i] = arr_people[i]+'#'+fieldname+'|'+value;
	}
	break
	case "arr_people_event":
	if(i != 'undefined'){
	arr_people_event[i] = arr_people_event[i]+'#'+fieldname+'|'+value;
	}
	break
	case "arr_event_types":
	if(i != 'undefined'){
	arr_event_types[i] = arr_event_types[i]+'#'+fieldname+'|'+value;
	}
	break
	case "arr_event_type_roles":
	arr_event_type_roles[fieldname] = value;
	break
	case "arr_sources":
		arr_sources[i] = arr_sources[i]+'#'+fieldname+'|'+value;
		if(fieldname == 'title')
		{
			document.getElementById('all_sources').options[i] = new Option(value,id);
		}
	break
	case "arr_files":
		arr_files[i] = arr_files[i]+'#'+fieldname+'|'+value;
		
		if(fieldname == 'title')
		{
			document.getElementById('all_files').options[i] = new Option(value,id);
		}
	break
	
	case "arr_connectedsources":
			
		arr_connectedsources[i] = arr_connectedsources[i]+'#'+fieldname+'|'+value;
		if(fieldname == 'sourcetitle')
		{
			document.getElementById('connectedsources').options[i] = new Option(value,id);
		}
		break
			
	
	}
	
			
	
	//alert(arr_event_types);
	
}
function initiate_list(num_of_arrays,list_name)
{
	
	switch(list_name)
	{
	case "arr_event":
	arr_event[num_of_arrays] = '';
	break
	case "arr_people":
	arr_people[num_of_arrays] = '';
	break
	case "arr_publicplaces":
	
	allvars['list_name'] = '';
	break
	case "arr_files":
	
	allvars['list_name'] = '';
	break	
	}
	//alert(arr_event[num_of_arrays]);
}
function showProp(index,ElementName,list_name)
{
	toadd = '';
	//alert(list_name[0]);
	switch(ElementName)
	{
		case "connectedevents":
			CleanTheFormItem('eventotherpeople'); //
			CleanTheFormItem('eventdate'); //
			CleanTheFormItem('event_id'); //
			CleanTheFormItem('othereventtyperole_text'); //
			CleanTheFormItem('eventplacename'); //
			CleanTheFormItem('eventtext'); //
			CleanTheFormItem('connectedtoeventroletype_id'); //
			CleanTheFormItem('connectedtoeventperson_id'); //
			CleanTheFormItem('connectedtoeventassertion_id');
			CleanTheFormItem('eventtype_id'); //
			CleanTheFormItem('eventtyperole_id'); //
			CleanTheFormItem('eventtyperole_text'); //
			CleanTheFormItem('eventplace_id'); //
			CleanTheFormItem('eventassertion_id'); //
			eachevent = '';
			eachevent = allvars[list_name].split('Â¤');
			theOtherRoles = '';
			eachPerson = '';
			theOtherPersons = '';
			document.getElementById('eventdate').readOnly = false;
			document.getElementById('eventtext').readOnly = false;
			
			//alert(allvars['connectedevents']);
			//alert(index + ' - ' + ElementName + ' - ' + list_name);
			//alert(eachevent[index]);
			
			if(eachevent != '')
			{
				fields = eachevent[index].split('#');
				for(i=0;i<fields.length;i++)
				{
					if(fields[i] != '')
					{
						//alert(fields[i]);
						items = fields[i].split('|');
						//alert(items);
					
						document.getElementById(items[0]).value = items[1];
						
					}
				
				}
			
				//alert(allvars['connectedtoevents']);
				theOtherPersons = allvars['connectedtoevents'].split('Â¤');
				theOtherRoles = '';
				for(i=0;i<theOtherPersons.length;i++)
				{
					flagOtherToEvent = findString(theOtherPersons[i],'otherevent_id|'+ document.getElementById('event_id').value);
					//alert('otherevent_id|'+ document.getElementById('event_id').value);
					if(flagOtherToEvent)
					{
						if(theOtherRoles != '')
						{
							theOtherRoles += 'Â¤';
						}
						theOtherRoles += theOtherPersons[i];
					}
				}
			
				//alert(theOtherRoles);
				eachPerson = theOtherRoles.split('Â¤');
				for(i=0;i<eachPerson.length;i++)
				{
					//find name to put in list and the index as row
					field = eachPerson[i].split('#');
					for(j=0;j<field.length;j++)
					{
						nameandvalue = field[j].split('|');
						if(nameandvalue[0] == 'otherfirstname')
						{
							toadd = nameandvalue[1];
						}
						if(nameandvalue[0] == 'otherlastname')
						{
							toadd += ' ' + nameandvalue[1];
						}
					
					}
					document.getElementById('eventotherpeople').options[i] = new Option(toadd,i);
				}
			}
			/*
			if(arr_event[index] != undefined)
			{
			SplitArray(arr_event[index],'event');
			SplitArray(arr_people_event,'event_people');
			}
			else
			{
			SplitArray(addedevents[index-arr_event.length],'event');
			}
			var eventstr, personstr, eventsearchstr;
			var foundevent, foundperson;
			var theconnectedeventid = document.getElementById('event_id').value;
			var fieldsandvalues, fieldname, value, fieldandvalues, name, personid;
			var event_type_role_id, assertion_id;
			var m = 0;
			for(k=0;k<arr_event_type_roles.length;k++)
			{
				flag_eventtyperoles = findString(arr_event_type_roles[k],'eventtypeid|'+document.getElementById('eventtype_id').value)
				//alert(flag_eventtyperoles);
		
				if(flag_eventtyperoles)
				{
			
					rolefieldnamesandvalues = arr_event_type_roles[k].split('#');
					for(l=0;l<rolefieldnamesandvalues.length;l++)
					{
						rolefieldsandvalues = rolefieldnamesandvalues[l].split('|');
						if(rolefieldsandvalues[0] == 'event_type_role_id')
						{
							list_event_type_role_id = rolefieldsandvalues[1];
						}
						if(rolefieldsandvalues[0] == 'event_type_role_text')
						{
							list_event_type_role_text = rolefieldsandvalues[1];
						}
				}
				document.getElementById('eventotherpersonrole').options[m] = new Option(list_event_type_role_text,list_event_type_role_id);
				m++;
			}
			if(m == 0)
			{
				document.getElementById('eventotherpersonrole').length = 0;
			}*/
			
		
		break;
		case "items":
			document.getElementById('name').value = personer[index][1]+' '+personer[index][2];
			document.getElementById('born').value = personer[index][3];
			document.getElementById('dead').value = personer[index][4];
			break;
		case "connectedsources":
			
			
			var splitted, flag, fieldname, value, fieldnameandvalue, fields;
			clearfields('connectedsource');
			document.getElementById('sourcecomments').readOnly = false;
			
			splitted = allvars['connectedsources'].split('Â¤');
			//alert(allvars['connectedsources']);
			for(i=0;i<splitted.length;i++)
			{
				if(splitted.length != '')
				{
						//alert(index);
						fieldnameandvalue = splitted[index].split('#');
						
						for(j=0;j<fieldnameandvalue.length;j++)
						{
						 
							fields = fieldnameandvalue[j].split('|');
						 	if(fields[0]!= '')
						 	{
						 
						 		//alert(fields[0]+' - '+fields[1]);
						 		document.getElementById(fields[0]).value = fields[1];
							}
						
						}
						
						
					
				}
				
				
			}
			break;
		case "livingevents":
			
			
			var splitted, flag, fieldname, value, fieldnameandvalue, fields, i;
			clearfields('livingevents');
			document.getElementById('livingevent_date').readOnly = false;
			document.getElementById('livingevent_date2').readOnly = false;
			document.getElementById('livingplacedescription').readOnly = false;
			splittedlist = allvars[list_name].split('Â¤');
			
			splitted = splittedlist[index];
			//alert(index + ' - ' + splitted);
			
			
				
				if(splitted.length != '')
				{
					
						fieldnameandvalue = splitted.split('#');
						for(j=0;j<fieldnameandvalue.length;j++)
						{
						 	//alert(fieldnameandvalue[j]);
							fields = fieldnameandvalue[j].split('|');
						 	if(fields[0]!= '')
						 	{
						 		//alert(fields[0]+fields[1]);
						 		if(fields[0] == 'place_id')
						 		{
						 			document.getElementById('livingevent_placeid').value = fields[1];
						 		}
						 		if(fields[0] == 'event_id')
						 		{
						 			document.getElementById('livingevent_eventid').value = fields[1];
						 		}
						 		if(fields[0] == 'livingplacename')
						 		{
						 			document.getElementById('livingevent_livingplacename').value = fields[1];
						 		}
						 		if(fields[0] == 'living_date')
						 		{
						 			fields[0] = 'livingevent_date2';
						 		}
						 		//alert(fields[0]);
						 		document.getElementById(fields[0]).value = fields[1];
							}
						
						}
						
						
					}
				//alert(document.getElementById('livingevent_placeid').value);
			
				
			break;
			case "connectedfiles":
			
			
			var splitted, flag, fieldname, value, fieldnameandvalue, fields;
			//clearfields('connectedfile');
			splitted = allvars[list_name].split('Â¤');
			document.getElementById('imgContainer').innerHTML = '';
			for(i=0;i<splitted.length;i++)
			{
			
				
				if(splitted.length != '')
				{
					
					flag = findString(splitted[i],'data_id|'+index);
					if(flag)
					{
						AJAX_get_file_info(index);
						//alert(splitted[i]);
						/*fieldnameandvalue = splitted[i].split('#');
						for(j=0;j<fieldnameandvalue.length;j++)
						{
						 
							fields = fieldnameandvalue[j].split('|');
						 	if(fields[0]== '')
						 	{
						 
						 		//alert(fields[0]+' - '+fields[1]);
						 		document.getElementById(fields[0]).value = fields[1];
							}
						
						}*/
						
						
					}
				}
				
				
			}
			
				
			break;
			case "eventotherpeople":
			eachPerson = theOtherRoles.split('Â¤');
			//alert(eachPerson[index]);
			eachPersonField = eachPerson[index].split('#');
			for(i=0;i<eachPersonField.length;i++)
			{
				if(eachPersonField[i] != '')
				{
					nameandvalue = eachPersonField[i].split('|');
					document.getElementById(nameandvalue[0]).value = nameandvalue[1];
				}
								
			}
			
			
			break;
		
	}
	
	
	
	
}
function rename_list(listan)
{
	listan = new Array
	listan[0] = list[0];
	listan[1] = list[1];
	return listan;
}
function SplitArray(thestuff,arrtype)
{
 var listtext;
 var value;
 if(arrtype == 'event')
 {
 	var fieldname;
 	var thefieldsandvalues;
 	var fieldtype;
 	//split into sections and store in array
 	thefieldsandvalues = thestuff.split("#");
 
  	for(i=0;i<thefieldsandvalues.length;i++) 
 	{
    	mtrl = thefieldsandvalues[i].split("|");
 		fieldname = mtrl[0];
 		
 		fieldtype = typeof(document.getElementById(fieldname));
 		//alert(fieldname);
 		//alert(fieldname+' '+fieldtype);
 		
 		if(mtrl[0] != '' &&  fieldname != 'eventtypetext')
 		{
 			
 			document.getElementById(mtrl[0]).value = mtrl[1];
 			//alert(mtrl[0]+' '+mtrl[1]);
 		}
 	
 	
 	
 	}
 }
 if(arrtype == 'event_people')
 {
 	var stringToLocate;
 	
 	k = 0;	
 	for(j=0;j<thestuff.length;j++)
 	{
 		
 		if(thestuff[j] != '')
 		{
 			stringToLocate = 'event_id|'+document.getElementById('event_id').value;
 			//alert(stringToLocate);
 			//alert(thestuff[j]);
 			flag = findString(thestuff[j],stringToLocate);
 		
 			if(flag == true)
 			{
 				flag = findString(thestuff[j],'DELETE');
 				//alert(thestuff[j]);
 				if(flag != true)
 				{
 					thefieldsandvalues = thestuff[j].split("#");
 					//alert(k);
 					for(i=1;i<thefieldsandvalues.length;i++)
 					{
 						mtrl = thefieldsandvalues[i].split("|");
 					
 						switch(mtrl[0])
 						{
 							case "person_id":
 							value = mtrl[1];
 							break;
 							case "firstname":
 							listtext = mtrl[1];
 							break;
 							case "lastname":
 							listtext = listtext+" "+mtrl[1];
 							break;
 							case "eventtyperole_text":
 							listtext = listtext+", "+mtrl[1];
 							break;
 						}
 					}
 				
 					//alert(k);
 					document.getElementById('eventotherpeople').options[k] = new Option(listtext,value);
 				
 					k = k + 1;
 				}
 			}
 			//alert(flag);
 			//alert(stringToLocate);
 		}
	}
 	
 }
 if(arrtype == 'source')
 {
 	var fieldname, flag;
 	var thefieldsandvalues;
 	var fieldtype;
 	//split into sections and store in array
 	thefieldsandvalues = thestuff.split("#");
 	
  	for(i=0;i<thefieldsandvalues.length;i++) 
 	{
    	
    	
    	   	mtrl = thefieldsandvalues[i].split("|");
 		 	fieldname = mtrl[0];
 		
 		 	fieldtype = typeof(document.getElementById(fieldname));
 			//alert(fieldname);
 			//alert(fieldname+' '+fieldtype);
 		
 			if(fieldname != '' || fieldname != 'undefined' || fieldname != null )
 			{
 			
 				document.getElementById(fieldname).value = mtrl[1];
 				//alert(mtrl[0]+' '+mtrl[1]);
 			}	
 		
 		
 	}
 }
 

}
function findString(tstring,text) {
    // Replaces text with by in string
    var strLength = tstring.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)){
        return false;
    }
    var i = tstring.indexOf(text);
    if (i == -1) {
        return false;
    }
    else{
        return true;
    } 
}
function SplitTheString(thestuff)
{
 //alert(thestuff);
 var data = new Array();
 var thefieldsandvalues;
 //split into sections and store in array
 thefieldsandvalues = thestuff.split("|");
 //alert(thefieldsandvalues[4]);
  for(i=0;i<thefieldsandvalues.length;i++) 
  {
    data[i] = thefieldsandvalues[i].split("#");
  	//alert(i);
  	//alert(data);
 	
  }

return data;
}
function LoadPlaces(param)
{
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList(param);
	loaded_picklist_type = 'place';
	CleanTheFormItem('place_list');
	
	
	
}
function LoadMap(param)
{
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList(param);
	loaded_picklist_type = 'map';
	CleanTheFormItem('map');
	Geosition();
	
	
}
function AJAX_query_db() {
  
  
  if(document.getElementById('SEARCH_FOR_NAME').value != "")
  {  
    var ajaxRequest;
    //alert(document.getElementById('SEARCH_FOR_NAME').value);
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }
	
    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	}
	if(ajaxRequest.readyState == 1) {
	  AJAX_add_to_list("searching ... ");
	}
	if(ajaxRequest.readyState == 2) {
	}
	if(ajaxRequest.readyState == 3) {
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('place_list');
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	    AJAX_add_to_list(ajaxRequest.responseText);
	  else
	  {
	    AJAX_add_to_list(ajaxDisplay.innerHTML);
	    //alert(ajaxDisplay.innerHTML);
	  }
	}
    }
    
    var place = document.getElementById('SEARCH_FOR_NAME').value;
    var myplace = document.getElementById('myplaceid').value;
    var place_type = AJAX_getSelectedRadio();
    
    var queryString = encodeURI("?action=fetch_places&place_name=" + place + "&place_type=" + place_type+ "&myplace=" + myplace + "&dummy=" + new Date().getTime());
    ajaxRequest.open("GET", "_includes_functions/fetch_places2.php" + queryString, true);
    ajaxRequest.send(null); 
  }
}
function AJAX_query_place_db() {
	  
	  
	  if(document.getElementById('SEARCH_FOR_NAME').value != "")
	  {  
	    var ajaxRequest;
	    //alert(document.getElementById('SEARCH_FOR_NAME').value);
	    
	    try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	    } catch (e){
		try{
		    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    try{
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (e){
			// Something went wrong
			alert("Your browser broke!");
			return false;
		    }
		}
	    }
		
	    ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 0) {
		}
		if(ajaxRequest.readyState == 1) {
		  AJAX_add_to_list("searching ... ");
		}
		if(ajaxRequest.readyState == 2) {
		}
		if(ajaxRequest.readyState == 3) {
		}
		if(ajaxRequest.readyState == 4) {
		  var ajaxDisplay = document.getElementById('place_list');
		  ajaxDisplay.innerHTML = ajaxRequest.responseText;
		  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
		    AJAX_add_to_list(ajaxRequest.responseText);
		  else
		  {
		    AJAX_add_to_list(ajaxDisplay.innerHTML);
		    //alert(ajaxDisplay.innerHTML);
		  }
		}
	    }
	    
	    var place = document.getElementById('SEARCH_FOR_NAME').value;
	    var myplace = document.getElementById('myplaceid').value;
	    var place_type = AJAX_getSelectedRadio();
	    
	    var queryString = encodeURI("?action=fetch_places_to_higher&place_name=" + place + "&place_type=" + place_type+ "&myplace=" + myplace + "&dummy=" + new Date().getTime());
	    ajaxRequest.open("GET", "_includes_functions/fetch_places2.php" + queryString, true);
	    ajaxRequest.send(null); 
	  }
	}
function AJAX_query_people_db() {
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	}
	if(ajaxRequest.readyState == 1) {
	  
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('people_list');
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  //alert(ajaxDisplay.innerHTML);
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	  {
	    AJAX_add_to_list(ajaxRequest.responseText);
		
	  }
	  else
	  {
	    AJAX_add_to_list(ajaxDisplay.innerHTML);
	    //alert(ajaxDisplay.innerHTML);
	  }
	}
    }
    var person_firstname = document.getElementById('FIRST_NAME').value;
    var person_lastname = document.getElementById('LAST_NAME').value;
    var myplace = document.getElementById('myplaceid').value;
    //alert(myplace);
    var queryString = encodeURI("?action=fetch_people&person_firstname=" + person_firstname + "&person_lastname=" + person_lastname + "&myplace=" + myplace + "&dummy=" + new Date().getTime());
    ajaxRequest.open("GET", "_includes_functions/fetch_person.php" + queryString, true);
    ajaxRequest.send(null); 
}
function AJAX_query_eventtypes_db() {
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	 
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('roles_list');
	  //alert(ajaxRequest.responseText);
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	  {
	    AJAX_addotherstoevent_list(ajaxRequest.responseText);
		
	  }
	  else
	  {
	    AJAX_addotherstoevent_list(ajaxDisplay.innerHTML);
	    //alert(ajaxDisplay.innerHTML);
	  }
	}
    }
    var eventtype_id = document.getElementById('eventtype_id').value;
    if(loaded_picklist == 'choose_event_type')
    {
    	eventtype_id = document.getElementById('all_eventtypes').value;
    }
    
    var myplace = document.getElementById('myplaceid').value;
    var queryString = "?action=fetch_event_type_role&eventtype_id=" + eventtype_id + "&myplace=" + myplace + "&dummy=" + new Date().getTime();
    ajaxRequest.open("GET", "_includes_functions/fetch_eventtype_role.php" + queryString, true);
    ajaxRequest.send(null); 
}
function AJAX_query_placetype_db() {
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	 
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('placetypes');
	  ajaxInsertString = ajaxRequest.responseText;
	  ajaxInsertArray = ajaxInsertString.split('|');
	  //alert(ajaxInsertArray[1]);
	  ajaxInsertText = checkCookieValue(ajaxInsertArray[0]);
	  //alert(ajaxInsertText);
	  ajaxDisplay.innerHTML += ajaxInsertText;
	  
	}
    }
        
    var queryString = "?action=fetch_place_types" + "&dummy=" + new Date().getTime();
    ajaxRequest.open("GET", "_includes_functions/fetch_places2.php" + queryString, true);
    ajaxRequest.send(null); 
}
function AJAX_getPlaces(top,bottom,left,right) {
  var ajaxRequest;
    response = new Array();
    
    //return response;
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	 
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  //var ajaxDisplay = document.getElementById('popUp');
	  tmpPlaces =  ajaxRequest.responseText;
	  //alert(ajaxRequest.responseText);
	  //	return ajaxInsertString;
	  
	}
    }
     //alert(readCookie('mapPlaceTypes'));   
    var queryString = "?action=fetchplaces&top=" + top + "&bottom=" + bottom + "&left=" + left + "&right=" + right + "&placetypes="+readCookie('mapPlaceTypes') + "&dummy=" + new Date().getTime();
    ajaxRequest.open("GET", "_includes_functions/fetch_places2.php" + queryString, true);
    ajaxRequest.send(null); 
}
function AJAX_getPlaces_com(top,bottom,left,right) {
  	//alert('anropar com function');
	var ajaxRequest;
    response = new Array();
    
    //return response;
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	 
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  //var ajaxDisplay = document.getElementById('popUp');
	  //alert(ajaxRequest.responseText);
	  tmpPlaces =  ajaxRequest.responseText;
	  //alert(tmpPlaces);
	  //	return ajaxInsertStr ing;
	  
	}
    }
     //alert(top+ ' ' +bottom+ ' ' +left+ ' ' +right);   
    var queryString = "?action=fetchplacescom&top=" + top + "&bottom=" + bottom + "&left=" + left + "&right=" + right + "&placetypes="+readCookie('mapPlaceTypes') + "&dummy=" + new Date().getTime();
    //alert(queryString);
    
    ajaxRequest.open("GET", "_includes_functions/fetch_places2.php" + queryString, true);
    ajaxRequest.send(null); 
}
function AJAX_query_files_db() {
   
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	}
	if(ajaxRequest.readyState == 1) {
	  
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('file_list');
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	  {
	    AJAX_add_to_list(ajaxRequest.responseText);
		//alert(ajaxRequest.responseText);
	  }
	  else
	  {
	    AJAX_add_to_list(ajaxDisplay.innerHTML);
	    //alert(ajaxDisplay.innerHTML);
	  }
	}
    }
    var title = document.getElementById('SEARCH_FOR_NAME').value;
    var type = AJAX_getSelectedRadio();
    var myplace = document.getElementById('myplaceid').value;
    var queryString = encodeURI("?action=fetch_files&title=" + title + "&file_type=" + type + "&myplace=" + myplace + "&dummy=" + new Date().getTime());
    ajaxRequest.open("GET", "_includes_functions/fetch_files.php" + queryString, true);
    ajaxRequest.send(null); 
    
}
function AJAX_get_file_info(index) {
   
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	}
	if(ajaxRequest.readyState == 1) {
	  
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('imgContainer');
	  myplaceid = document.getElementById('myplaceid').value;
	  theresponse = new Array();
	  
	  theresponse = ajaxRequest.responseText.split('#');
	  if(theresponse[1] == 'img')
	  {
	  	ajaxDisplay.innerHTML = "<img src=" + varDataUrl + varDataPath+ myplaceid + "/" + theresponse[0] + " height=150 >";
	    
	  }
	  else
	  {
	  	ajaxDisplay.innerHTML = "<p><a href=" + varDataUrl + varDataPath + myplaceid + "/" + theresponse[0] + " target=blank>Klicka hÃ¤r fÃ¶r att <br>fÃ¶rhandsgranska dokumentet</a></p>";
	  }
	}
    }
    var fileid = index;
    
    var queryString = "?action=fetch_file_info&fileid=" + fileid + "&dummy=" + new Date().getTime();
    //alert(queryString);
    ajaxRequest.open("GET", "_includes_functions/fetch_files.php" + queryString, true);
    ajaxRequest.send(null); 
    
}
function AJAX_query_sources_db(todo) {
   
  if(todo == 'search')
  {
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	  
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('source_list');
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	  {
	    AJAX_add_to_list(ajaxRequest.responseText);
		
	  }
	  else
	  {
	    AJAX_add_to_list(ajaxDisplay.innerHTML);
	    //alert(ajaxDisplay.innerHTML);
	  }
	}
    }
    var title = document.getElementById('SEARCH_FOR_NAME').value;
    var type = AJAX_getSelectedRadio();
    var myplace = document.getElementById('myplaceid').value;
    var queryString = encodeURI("?action=fetch_sources&title=" + title + "&source_type=" + type + "&myplace=" + myplace + "&dummy=" + new Date().getTime());
    ajaxRequest.open("GET", "_includes_functions/fetch_sources.php" + queryString, true);
    ajaxRequest.send(null); 
    //alert(queryString);
  }
  
  
  if(todo == 'get_info')
  {
 	var ajaxRequest;
    
    try
    {
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } 
    catch (e)
    {
		try
		{
	    	ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
	    	try
	    	{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    	} 
	    	catch (e)
	    	{
				// Something went wrong
				alert("Your browser broke!");
				return false;
	    	}
		}
    }

    ajaxRequest.onreadystatechange = function()
    {
		if(ajaxRequest.readyState == 0) 
		{
			
		}
		if(ajaxRequest.readyState == 1)
		{
			
		}
		if(ajaxRequest.readyState == 2) 
		{
		
		}
		if(ajaxRequest.readyState == 3) 
		{
		
		}
		if(ajaxRequest.readyState == 4) 
		{
	 		varSelectedSource = ajaxRequest.responseText;
	  		if(varSelectedSource == '' || varSelectedSource == null)
	  		{
	  			varSelectedSource = ajaxRequest.responseText;
	  		}
	  	}
    }
    var id = picklist_choosenId;
    var queryString = "?action=get_source_info&id=" + id  + "&dummy=" + new Date().getTime();;
    ajaxRequest.open("GET", "_includes_functions/fetch_sources.php" + queryString, true);
    ajaxRequest.send(null); 
   
  }
  if(todo == 'getSource')
  {
  var ajaxRequest;
    
    try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
    } catch (e){
	try{
	    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try{
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e){
		// Something went wrong
		alert("Your browser broke!");
		return false;
	    }
	}
    }

    ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 0) {
	
	}
	if(ajaxRequest.readyState == 1) {
	  
	}
	if(ajaxRequest.readyState == 2) {
	  
	}
	if(ajaxRequest.readyState == 3) {
	  
	}
	if(ajaxRequest.readyState == 4) {
	  var ajaxDisplay = document.getElementById('viewsourceinfo');
	  ajaxDisplay.innerHTML = ajaxRequest.responseText;
	  if ( ajaxDisplay.innerHTML == "" || ajaxDisplay.innerHTML == null )
	  {
	    //AJAX_add_to_list(ajaxRequest.responseText);
		//alert(ajaxRequest.responseText);
	  }
	  
	}
    }
   
    var queryString = "?action=getSource&id=" + varinfSourceID + "&object_id=" + varinfPublicPlaceId + "&type=" + varinftypeofsource + "&dummy=" + new Date().getTime();
    var realQueryString = "_includes_functions/fetch_sources.php" + queryString;
    ajaxRequest.open("GET", realQueryString , true);
    //alert(realQueryString);
    ajaxRequest.send(null); 
   
  }
}
function DeleteSource(id)
{
	
	var thestring = '';
	var splitted, value, sources;
	clearfields('connectedsource');
	sources = allvars['connectedsources'].split('Â¤');
	sources.splice(id,1);
	//thestring= thestring+sources[1];
	for(i=0;i<sources.length;i++)
	{
		if(sources[i] != '')
		{
			if(thestring != '')
			{
				thestring = thestring + 'Â¤';
			}
			thestring = thestring + sources[i];
		}
	}
	allvars['connectedsources'] = thestring;
	loadfromarray('connectedsources');
	//alert(allvars['connectedsources']);
}
function DeleteOthersFromEvent()
{
	
	//alert();
	document.getElementById('eventotherpeople').options[document.getElementById('eventotherpeople').selectedIndex] = null;
	document.getElementById('othereventtyperole_text').value = '';
	theOtherPersons = allvars['connectedtoevents'].split('Â¤');
	theNewString = '';
	for(i=0;i<theOtherPersons.length;i++)
	{
		locateEvent = findString(theOtherPersons[i],'otherevent_id|' + document.getElementById('otherevent_id').value);
		locatePerson = findString(theOtherPersons[i],'person_id|' + document.getElementById('otherperson_id').value);
		if(!locateEvent || !locatePerson)
		{
			if(theNewString != '')
			{
				theNewString += 'Â¤';
			}
			theNewString += theOtherPersons[i]
				
			
		}
	}
	
	allvars['connectedtoevents'] = theNewString;
	//document.getElementById('eventotherpeople').length = 0;
	//alert();
	//showProp(document.getElementById('connectedevents').selectedIndex,'connectedevents','connectedevents');
	loadfromarray('connectedevents');


}
function DeleteFile(id)
{
	document.getElementById('imgContainer').innerHTML = '';
	var thestring = '';
	var i,t,tmpstring;
	files = new Array();
	tmpfiles = new Array();
	//alert(id);
	
	files = allvars['connectedfiles'].split('Â¤');
	//rightColumnfiles
	tmpstring = '<P>';   
	for(t=0;t<files.length;t++)
	{
		if(t == id)
		{
			files[t] = '';
		}
		tmpfiles = files[t].split('#');
		
		tmpstring += ''+id+''+':'+t + files[t]+'<BR>';   
	}
	tmpstring += '</P>'; 
	//document.getElementById('rightColumnfiles').innerHTML = tmpstring; 
	//alert(id + files);
	//alert(id +' '+ files[id]);
	
	
	
	for(i=0;i<files.length;i++)
	{
	 if(files[i] != '')
	 {
	 	
	 	thestring = thestring+files[i]+'Â¤';
	 }
	 
	}
	allvars['connectedfiles'] = thestring;
	loadfromarray('connectedfiles');
	
}
function DeleteEvent(id)
{
	
	var thestring = '';
	var files = new Array();
	var splitted, value, sources;
	//alert(id);
	files = allvars['connectedevents'].split('Â¤');
	files.splice(id,1);
	//alert(id + '-' + files[id]);
	
	for(i=0;i<files.length;i++)
	{
		if(thestring != '')
		{
			thestring += 'Â¤';	
		}
	thestring = thestring+files[i];
	}
	allvars['connectedevents'] = thestring;
	loadfromarray('connectedevents');
	//alert()
	clearfields('event');
}
function DeletePlaceEvent(id)
{
	
	var thestring = '';
	var splitted, value, sources;
	files = allvars['livingevents'].split('Â¤');
	files.splice(id,1);
	
	for(i=0;i<files.length;i++)
	{
		if(i != 0)
		{
			thestring += 'Â¤';
		}
		thestring = thestring+files[i];
	}
	allvars['livingevents'] = thestring;
	loadPlaceEventsfromarray('livingevents');
	clearfields('livingevents');
	
}
function SaveSource(id)
{
	var sources;
	var thestring = '';
	var notaddflag;
	var theotherstring;
	
	sources = allvars['connectedsources'].split('Â¤');
	//alert(sources[id]);
		
	thestring += '#source_id|' + document.getElementById('source_id').value;
	thestring += '#sourcetitle|' + document.getElementById('sourcetitle').value;
	thestring += '#sourcetype|' + document.getElementById('sourcetype').value;
	thestring += '#sourcedescription|' + document.getElementById('sourcedescription').value;
	thestring += '#sourcecomments|' + document.getElementById('sourcecomments').value;
	thestring += '#assertion_id|' + document.getElementById('assertion_id').value;
	
	sources[id] = thestring;
	thestring = '';
	for(i=0;i<sources.length;i++)
	{
		if(thestring != '')
		{
			thestring = thestring + 'Â¤';
		}
		thestring = thestring + sources[i];
	}
	allvars['connectedsources'] = thestring;
	//alert(allvars['connectedsources']);
}
function SavePlaceEvent(id)
{
	var placeevents = new Array();
	var thestring = '';
	var notaddflag = '';
	var theotherstring = '';
	var fnv = new Array();
	fnv[0] = '';
	placeevents = allvars['livingevents'].split('Â¤');
	//alert(placeevents[id]);
		
		//alert(document.getElementById('livingevent_placeid').value)
		livingplaceid = document.getElementById('livingevent_placeid').value;
		livingeventid = document.getElementById('livingevent_eventid').value;
		livingplacedescription = document.getElementById('livingplacedescription').value;
		livingeventdate = document.getElementById('livingevent_date').value;
		livingeventdate2 = document.getElementById('livingevent_date2').value;
		livingeventplacename = document.getElementById('livingevent_livingplacename').value;
		
		theotherstring = 'place_id|' + livingplaceid + '#';
		theotherstring += 'livingplacename|' + livingeventplacename + '#';
		theotherstring += 'livingevent_date|' + livingeventdate + '#';
		theotherstring += 'living_date|' + livingeventdate2 + '#';
		theotherstring += 'event_id|' + livingeventid + '#';
		theotherstring += 'livingplacedescription|' + livingplacedescription + '#';
		
		placeevents[id] = theotherstring;	
		
	
	//alert(placeevents[id]);
	for(i=0;i<placeevents.length;i++)
	{
		
		if(placeevents[i] != '')
		{
			if(i != 0)
			{
				thestring = thestring + 'Â¤';
			}
			thestring += placeevents[i];
		}
		
	}
	i = 0;
	allvars['livingevents'] = thestring;
	thestring = '';
	//alert(allvars['livingevents'])
	clearfields('livingevents');
	document.getElementById('livingevents').options[id].selected = false;
	
}
function SaveEventConn(id)
{
	alert(arr_event[id]);
	
	
}
function SaveEvent(id)
{
	//alert(allvars['connectedevents']);
	var allEvents = allvars['connectedevents'].split('Â¤');
	var TheEvent = allEvents[id];
	var theotherstring;
	var allEventsNew = '';
	
	TheEvent = '';
	TheEvent += '#eventassertion_id|' + document.getElementById('eventassertion_id').value;
	TheEvent += '#event_id|' + document.getElementById('event_id').value;
	TheEvent += '#eventtypetext|' + document.getElementById('eventtypetext').value;
	TheEvent += '#eventtyperole_id|' + document.getElementById('eventtyperole_id').value;
	TheEvent += '#eventtyperole_text|' + document.getElementById('eventtyperole_text').value;
	TheEvent += '#eventtype_id|' + document.getElementById('eventtype_id').value;
	TheEvent += '#eventplace_id|' + document.getElementById('eventplace_id').value;
	TheEvent += '#eventplacename|' + document.getElementById('eventplacename').value;
	TheEvent += '#eventdate|' + document.getElementById('eventdate').value;
	TheEvent += '#eventtext|' + document.getElementById('eventtext').value;
	
	//alert(TheEvent);
	
	
	allEvents[id] = TheEvent;
	
	for(i=0;i<allEvents.length;i++)
	{
		if(allEventsNew != '')
		{
			allEventsNew += 'Â¤';
		}
		allEventsNew += allEvents[i];
	}
	allvars['connectedevents'] = allEventsNew;
	
	//alert(allvars['connectedevents']);
	
}
function SaveOtherRole()
{
	var theString = '';
	
	theString += '#otherperson_id|' + document.getElementById('otherperson_id').value;
	theString += '#otherfirstname|' + document.getElementById('otherfirstname').value;
	theString += '#otherlastname|' + document.getElementById('otherlastname').value;
	theString += '#otherevent_type_role_id|' + document.getElementById('otherevent_type_role_id').value;
	theString += '#othereventtyperole_text|' + document.getElementById('othereventtyperole_text').value;
	theString += '#otherevent_id|' + document.getElementById('event_id').value;
	
	
	//theOtherRoles += 'Ã¯Â¿Â½' + theString;
	allvars['connectedtoevents'] += 'Â¤' + theString;
	showProp(document.getElementById('connectedevents').selectedIndex,'connectedevents','connectedevents')
}

		
function LoadEventPlaces(param)
{
	//if()
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	CleanTheDiv('rightColumnevent');
	LoadPickList('placestoevent');
	loaded_picklist_type = 'place';
	loaded_picklist = param;
	picklist_choosenId = "";
	picklist_choosenTextVal = "";
}
function CleanTheFormItem(element)
{
	//alert(element);
	TheElement = document.getElementById(element);
	TheElement.value = '';
	if(TheElement.length != '')
	{
		TheElement.length = 0;
		
	}
}
function CleanTheDiv(ObjectName)
{
	switch(ObjectName)
	{
		case "popUp":
		document.getElementById('popUp').innerHTML = objecteventrightcol;
		loaded_picklist ="";
		picklist_choosenId = "";
		picklist_choosenTextVal = "";
		MM_showHideLayers('popUp','','hide');
		return ;
		break;
		
	}
	
	document.getElementById(ObjectName).innerHTML = '';
	
}
function LoadPeople(param)
{
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList('people');
	loaded_picklist_type = 'people';
	CleanTheFormItem('people_list');
	
}
function LoadPeopletoevent(param)
{
	// otherstoevent
	if(document.getElementById('eventtype_id').value != '')
	{
		if(loaded_picklist != "")
		{
			alert ('Error, error, chooser open on other place')
			return ;
		}
		loaded_picklist = param;
		LoadPickList('peopletoevent');
		loaded_picklist_type = 'peopletoevent';
		CleanTheFormItem('people_list');
	}
	else
	{
		alert('Du mÃƒÂ¥ste fÃ¶rst vÃ¤lja en hÃ¤ndelse');
		
	}
}
function LoadFiles(param)
{
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList('files');
	loaded_picklist_type = 'files';
	CleanTheFormItem('file_list');
	
}
function LoadEventTypes(param)
{
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList('eventtypes');
	loaded_picklist_type = 'eventtypes';
	CleanTheFormItem('all_eventtypes');
	//alert(allvars['all_eventtypes']);
	loadfromarray('all_eventtypes');
	
}
function LoadSources(param)
{
	//alert(allvars['source_types']);
	if(loaded_picklist != "")
	{
		alert ('Error, error, chooser open on other place')
		return ;
	}
	loaded_picklist = param;
	LoadPickList('sources');
	loaded_picklist_type = 'sources';
	CleanTheFormItem('source_list');
	
}
function SplitThePeople(thestuff)
{
 //alert(thestuff);
 ///////////////////////////////////////
 var data = new Array();
 var peoplevalues = new Array();
 var thefieldsandvalues;
 firstname = new Array();
 lastname = new Array();
 birthdate = new Array();
 deaddate = new Array();
 var personid = new Array();
 personer = new Array();
 ///////////////////////////////////////
 
 //split into sections and store in array
 thefieldsandvalues = thestuff.split("#");
 //alert(thefieldsandvalues.length);
 for(i=1;i<thefieldsandvalues.length;i++) 
  {
    data[i] = thefieldsandvalues[i].split("Â¤");
    
  	peoplevalues[i] = data[i][1].split("|");
  	//alert(peoplevalues[i]);
 	//alert(peoplevalues[i][1]+' '+peoplevalues[i][2]);
 	
 	personid[i] = data[i][0];
 	//alert(personid[i]);
 	//alert(peoplevalues[i][1]);
 	firstname[i] = peoplevalues[i][0];
 	//alert(firstname[i]);
 	
 	lastname[i] =  peoplevalues[i][1];
 	//alert(peoplevalues[i][1]);
 	birthdate[i] = peoplevalues[i][2];
 	deaddate[i] = peoplevalues[i][3];
 	personer[i] = new Array(); 	
 	personer[i][0] = personid[i];
 	
 	personer[i][1] = firstname[i];
 	personer[i][2] = lastname[i];
 	//alert(personer[i][0]);
 	//alert(firstname[i]+'->'+lastname[i]);
 	personer[i][3] = birthdate[i];
 	personer[i][4] = deaddate[i];
  }
//(alert(personer['1']['0']);
//alert(personer[45][1]+'->'+personer[45][2]);
return personer;
}
function GoBack()
{
 history.go(-2);
}
function ShowConnectedPeopleInfo(value)
{
 //alert(value);
 showProp(value,'items',personer)
 //alert(personer[value][0]+' '+personer[value][1]+' '+personer[value][2]+' '+personer[value][3]+' '+personer[value][4]);
 
}
function showsourceInfo(infSourceId,infPublicPlaceId,inftypeofsource)
{
	varinfSourceID = infSourceId;
	varinfPublicPlaceId = infPublicPlaceId;
	varinftypeofsource = inftypeofsource;
	LoadPickList('SourceInfo');	
	
}
function unloadPickList()
{
	CleanTheDiv('popUp');
	loaded_picklist = "";
}
function LoadPickList(object)
{
	
	var string = "";
	MM_showHideLayers('popUp','','show')
	
	if(object == "people")
	{
		
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP echo lbl_choose_from_list ?>";
		string = string + "<?PHP echo lbl_searchfirstname ?><label for='firstname'>FÃ¶rnamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='FIRST_NAME' ID='FIRST_NAME' Title=''><BR>";
		string = string + "<?PHP echo lbl_searchlastname ?><label for='lastname'>Efternamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='LAST_NAME' ID='LAST_NAME' Title=''><BR>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search' ID='submit' OnClick=AJAX_query_people_db()><BR>";
		string = string + "<SELECT NAME='people_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text); id='people_list' value= SINGLE SIZE=20 STYLE='width:250' Title=''></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
	}
	if(object == "layers")
	{
		//alert();
		//string = "<fieldset>";
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<P><H4>VÃ¤lj lager</H4></P>";
		
		//string = string + "<?PHP echo lbl_searchfirstname ?><label for='firstname'>FÃ¶rnamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='FIRST_NAME' ID='FIRST_NAME'><BR>";
		//string = string + "<?PHP echo lbl_searchlastname ?><label for='lastname'>Efternamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='LAST_NAME' ID='LAST_NAME'><BR>";
		//string = string + "<INPUT TYPE=button VALUE='search' NAME='search' ID='submit' OnClick=AJAX_query_people_db()><BR>";
		//string = string + "<SELECT NAME='people_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text);alert(this.options[selectedIndex].text); id='people_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		//string = string + "<INPUT TYPE=button VALUE='koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		//string = string + "</fieldset>"
		string += '<input type=button id=submit value=OK name=submit onClick="reloadTheMap();" >';
		document.getElementById('popUp').innerHTML = string;
		AJAX_query_placetype_db();
		return;
		
	}
	if(object == "SourceInfo")
	{
		//alert();
		//string = "<fieldset>";
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=/_images_icons/i_cancel.png></a></div>";
		string = string + "<P><H4>KÃ¤ll information</H4></P><div id=viewsourceinfo><label></label></div>";
		
		//string = string + "<?PHP echo lbl_searchfirstname ?><label for='firstname'>FÃ¶rnamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='FIRST_NAME' ID='FIRST_NAME'><BR>";
		//string = string + "<?PHP echo lbl_searchlastname ?><label for='lastname'>Efternamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='LAST_NAME' ID='LAST_NAME'><BR>";
		//string = string + "<INPUT TYPE=button VALUE='search' NAME='search' ID='submit' OnClick=AJAX_query_people_db()><BR>";
		//string = string + "<SELECT NAME='people_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text);alert(this.options[selectedIndex].text); id='people_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		//string = string + "<INPUT TYPE=button VALUE='koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		//string = string + "</fieldset>"
		string += '<input type=button id=submit value=OK name=submit onClick="unloadPickList();" >';
		
		document.getElementById('popUp').innerHTML = string;
		AJAX_query_sources_db('getSource');
		return;
		
	}
	if(object == "peopletoevent")
	{
		
		
		
			//string = "<fieldset>";
			string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
			string = string + "<?PHP echo lbl_choose_from_list ?><BR>";
			string = string + "<?PHP echo lbl_searchfirstname ?><label for='firstname'>FÃ¶rnamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='FIRST_NAME' ID='FIRST_NAME' Title=''><BR>";
			string = string + "<?PHP echo lbl_searchlastname ?><label for='lastname'>Efternamn</label><BR><INPUT TYPE=TEXT VALUE='' NAME='LAST_NAME' ID='LAST_NAME' Title=''><BR>";
			string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='submit' ID='submit' OnClick=AJAX_query_people_db()><BR>";
			string = string + "<SELECT NAME='people_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='people_list' value= SINGLE SIZE=20 STYLE='width:250' Title=''></select>";
			string = string + "<SELECT NAME='roles_list'  id='roles_list' value= SINGLE SIZE=5 STYLE='width:250' OnChange=setValue(this.options[selectedIndex].text); ></select>";
			string = string + "<INPUT TYPE=HIDDEN VALUE='' NAME='roles_id' ID='roles_id'>";
			string = string + "<INPUT TYPE=HIDDEN VALUE='' NAME='roles_text' ID='roles_text'><BR>";
			string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()><INPUT TYPE=button VALUE='Cancel' NAME='cancel' OnClick=CleanTheDiv('popUp'); ID='cancel'>";
			document.getElementById('popUp').innerHTML = string;
			AJAX_query_eventtypes_db();
			return;
	}	
		
		
	
	if(object == "places")
	{
	
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_db()><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type' ><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' selected><label for='placetype'>min fÃ¶renings platser</label><BR><BR>";
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
		
		
	}
	if(object == "files")
	{
	
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_files_db()><br><br>";
		string = string + "<P><INPUT TYPE=RADIO VALUE='img' NAME='place_type' ID='place_type' select><label for='img'>img</label><?PHP echo lbl_img; ?><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='doc' NAME='place_type' ID='place_type' select><label for='doc'>doc</label><?PHP echo lbl_document; ?></P>";
		string = string + "<SELECT NAME='file_list'  OnChange='choosen_PickListItem(this.value,this.options[selectedIndex].text);' id='file_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		// 
		document.getElementById('popUp').innerHTML = string;
		return;
		
	}
	if(object == "map")
	{
	
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + mapObjectLarge;
		
		// 
		document.getElementById('popUp').innerHTML = string;
		return;
		
	}
	if(object == "sources")
	{
		
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=/_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_sources_db('search')><br><br>";
		if(allvars['source_types'] != '')
		{
			//alert(allvars['source_types']);
			varSourceTypes = allvars['source_types'].split('Â¤');
			for(i=0;i<varSourceTypes.length;i++)
			{
				//alert(varSourceTypes[i]);
				SourceTypes = varSourceTypes[i].split('|');
				string = string + "<p><INPUT TYPE=RADIO VALUE='" + SourceTypes[0] + "' NAME='place_type' ID='place_type' ><label for='people'>" + SourceTypes[1] + "</label><BR>";
			}
		}
		string = string + "<p><INPUT TYPE=RADIO VALUE='' NAME='place_type' ID='place_type' checked><label for='people'>OkÃ¤nt</label><BR>";
		//string = string + "<p><INPUT TYPE=RADIO VALUE='people' NAME='place_type' ID='place_type' select><label for='people'>people</label><?PHP echo lbl_people; ?><BR>";
		//string = string + "<INPUT TYPE=RADIO VALUE='other' NAME='place_type' ID='place_type' select><label for='other'>other</label><?PHP echo lbl_other; ?></p>";
		string = string + "<SELECT NAME='source_list' OnChange='choosen_PickListItem(this.value,this.options[selectedIndex].text);' id='source_list' value= SINGLE SIZE=10 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		document.getElementById('popUp').innerHTML = string;
		return;
		
	}
	if(object == "bornplace")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_db()><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type'><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' checked><label for='placetype'>min fÃ¶renings platser</label><BR><BR>";
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
		
		
	}
	if(object == "deadplace")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_db()><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type'><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' checked><label for='placetype'>min fÃ¶renings platser</label><BR><BR>";
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='Koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
		
		
	}
	if(object == "choose_publicplace")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'><BR>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_db()>";
		string = string + "<INPUT TYPE=HIDDEN VALUE='public_place' NAME='place_type' ID='place_type'>";
		
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text); id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
		
		
	}
		if(object == "higherplace")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search' ID='submit' OnClick=AJAX_query_place_db()><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type'><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' checked><label for='placetype'>min fÃ¶renings platser</label><BR><BR>";
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='koppla' NAME='submit' ID='submit' OnClick=ConnectListItem()>";
		
		
		
		
	}
	if(object == "choose_living_place")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search' ID='submit' OnClick=AJAX_query_db()><BR>";
		
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type'><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' checked><label for='placetype'>min fÃ¶renings platser</label><BR><BR>";
		
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='koppla' NAME='connect' ID='submit' OnClick=ConnectListItem()>";
		
		document.getElementById('popUp').innerHTML = string;
		return;
		
	}
	if(object == "placestoevent")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<?PHP lbl_choose_from_list ?><BR>";
		string = string + "<INPUT TYPE=TEXT VALUE='' NAME='SEARCH_FOR_NAME' ID='SEARCH_FOR_NAME'>";
		string = string + "<INPUT TYPE=button VALUE='S&ouml;k' NAME='search'  ID='submit' OnClick=AJAX_query_db()><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='public_place' NAME='place_type' ID='place_type'><label for='placetype'>alla platser</label><BR>";
		string = string + "<INPUT TYPE=RADIO VALUE='private_place' NAME='place_type' ID='place_type' checked><label for='placetype'>min&nbsp;fÃ¶renings&nbsp;platser</label><BR><BR>";
		string = string + "<SELECT NAME='place_list'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text) id='place_list' value= SINGLE SIZE=20 STYLE='width:250'></select><BR>";
		string = string + "<INPUT TYPE=button VALUE='OK' NAME='submit' OnClick=ConnectListItem(); ID='submit'><INPUT TYPE=button VALUE='Cancel' NAME='cancel' OnClick=CleanTheDiv('popUp'); ID='cancel'>";
		//string = string + "</fieldset>"
		document.getElementById('popUp').innerHTML = string;
		return;
	}
	if(object == "eventtypes")
	{
		string = string + "<div align=right><a href=# OnClick=CleanTheDiv('popUp'); ><img src=_images_icons/i_cancel.png></a></div>";
		string = string + "<BR><BR>";
		string = string + "";
		string = string + "<SELECT NAME='all_eventtypes'  OnChange=choosen_PickListItem(this.value,this.options[selectedIndex].text);AJAX_query_eventtypes_db(); id='all_eventtypes' value= SINGLE SIZE=20 STYLE='width:250'></select>";
		string = string + "<SELECT NAME='roles_list'  id='roles_list' value= SINGLE SIZE=5 STYLE='width:250' OnChange=setValue(this.options[selectedIndex].text); ></select><BR>";
		string = string + "<INPUT TYPE=HIDDEN VALUE='' NAME='roles_id' ID='roles_id'>";
		string = string + "<INPUT TYPE=HIDDEN VALUE='' NAME='roles_text' ID='roles_text'>";
		string = string + "<INPUT TYPE=button VALUE='OK' NAME='submit' OnClick=ConnectListItem(); ID='submit'><INPUT TYPE=button VALUE='Cancel' NAME='cancel' OnClick=CleanTheDiv('popUp'); ID='cancel'>";
		
		//string = string + "</fieldset>"
		document.getElementById('popUp').innerHTML = string;
		return;
	}
/*	if(object == "peopletoevent")
	{
		
			if(objecteventrightcol == '')
			{
			string = document.getElementById('popUp').innerHTML;
			objecteventrightcol = document.getElementById('popUp').innerHTML;
			}
			else
			{
			document.getElementById('popUp').innerHTML = objecteventrightcol;
			string = document.getElementById('popUp').innerHTML;
			}
		
			string = string + "<?PHP lbl_choose_from_list ?><BR>";
			string = string + "<select name='eventitems' id='eventitems' value='' MULTIPLE SIZE=40 OnChange='ShowConnectedPeopleInfo(this.selectedIndex+1);'><BR>";
			string = string + "<input name='name' id='name' value='' type='text' /><BR>";
			string = string + "<input name='born' id='born' value='' type='text' /><BR>";
			string = string + "<input name='dead' id='dead' value='' type='text' /><BR>";
			string = string + " <br><input type='button' name='connectbutton'  ID='submit'  value='Koppla' onClick='ConnectListItem()' />&nbsp;<BR>";
			string = string + " <input name='itemstype' id='itemstype' value='' type='hidden' /><BR>";
			document.getElementById('popUp').innerHTML = string;
			return;
		
		
	}
*/
document.getElementById('popUp').innerHTML = string;

}
function AJAX_getSelectedRadio() {
  TheElement = document.getElementsByName('place_type');
  
  //alert(TheElement.length);
  for (i=0; i<TheElement.length; i++) {
  
    if (TheElement[i].checked==true) {
      
      return TheElement[i].value;
      
    }
  }
  TheElement = document.getElementById('place_type');
  if(TheElement.value != "")
  {
  	//alert(TheElement.value);
  	return TheElement.value;
  	
  }
  
  return "";
}
function AJAX_add_to_list(name) {
    if(loaded_picklist_type == 'place')
    {
      var splitResult = name.split("|");
      splitted_place = new Array();
      
     
      for (j=0; j<splitResult.length; j++) {
	  i = document.getElementById('place_list').length;
	 
	  
	  if ( splitResult[j] != " " || splitResult[j] != null)
	     
	     splitted_place = splitResult[j].split("#");
	     if ( typeof splitted_place[0] != "")
	     {
	     	
	     	for(k=0; k<splitted_place.length; k++)
	     	{
	     	document.getElementById('place_list').options[i] = new Option(splitted_place[0],splitted_place[1]);
	     	}
	     }
	      
      }
    }
   // alert(loaded_picklist_type);
    if(loaded_picklist_type == 'people')
    {
    	//alert(name);
    	var splitResult = name.split("|");
    	splitted_person = new Array();
  		for (j=0; j<splitResult.length; j++) 
  		{
    		i = document.getElementById('people_list').length;
   		 	if ( splitResult[j] != "" || splitResult[j] != null) 
   		 	{
   		  		splitted_person = splitResult[j].split("#");
	     		
	     	
	     		for(k=0; k<splitted_person.length; k++)
	     		{
	     			//var splitted_person[0] = splitted_person[0].replace(/^\s+|\s+$/g, '');
	     			document.getElementById('people_list').options[i] = new Option(splitted_person[0],splitted_person[1]);
	     		}
	    	
   		  		
   		  		
    	  		
   		 	}
  		}
    }
    if(loaded_picklist_type == 'peopletoevent')
    {
    	//alert(name);
    	var splitResult = name.split("|");
    	splitted_person = new Array();
  		for (j=0; j<splitResult.length; j++) 
  		{
    		i = document.getElementById('people_list').length;
   		 	if ( splitResult[j] != "" || splitResult[j] != null) 
   		 	{
   		  		splitted_person = splitResult[j].split("#");
	     		
	     	
	     		for(k=0; k<splitted_person.length; k++)
	     		{
	     			//var splitted_person[0] = splitted_person[0].replace(/^\s+|\s+$/g, '');
	     			document.getElementById('people_list').options[i] = new Option(splitted_person[0],splitted_person[1]);
	     		}
	    	
   		  		
   		  		
    	  		
   		 	}
  		}
    }
    if(loaded_picklist_type == 'files')
    {
      var splitResult = name.split("|");
      splitted_place = new Array();
      
     
      for (j=0; j<splitResult.length; j++) {
	  i = document.getElementById('file_list').length;
	 
	  
	  if ( splitResult[j] != " " || splitResult[j] != null)
	     
	     splitted_place = splitResult[j].split("#");
	     if ( typeof splitted_place[0] != "")
	     {
	     	
	     	for(k=0; k<splitted_place.length; k++)
	     	{
	     	document.getElementById('file_list').options[i] = new Option(splitted_place[0],splitted_place[1]);
	     	}
	     }
	      
      }
    }
    if(loaded_picklist_type == 'sources')
    {
      var splitResult = name.split("|");
      splitted_source = new Array();
      
     
      for (j=0; j<splitResult.length; j++) {
	  i = document.getElementById('source_list').length;
	 
	  
	  if ( splitResult[j] != " " || splitResult[j] != null)
	     
	     splitted_source = splitResult[j].split("#");
	     if ( typeof splitted_source[0] != "")
	     {
	     	
	     	for(k=0; k<splitted_source.length; k++)
	     	{
	     	document.getElementById('source_list').options[i] = new Option(splitted_source[0],splitted_source[1]);
	     	}
	     }
	      
      }
    }
}
function AJAX_addotherstoevent_list(name) 
{
     //alert(name);
     var splitResult = name.split("|");
     splitted_roles = new Array();
     document.getElementById('roles_list').length = 0;
     
     for (j=0; j<splitResult.length; j++) 
     {
	 	i = document.getElementById('roles_list').length;
	 	if ( splitResult[j] != " " || splitResult[j] != null)
	 	{	     
	     	splitted_roles = splitResult[j].split("#");
	     	if ( typeof splitted_roles[0] != "")
	     	{
	     	 	for(k=0; k<splitted_roles.length; k++)
	     		{
	     			document.getElementById('roles_list').options[i] = new Option(splitted_roles[0],splitted_roles[1]);
	     		}
	     	}
	      
      	}
     }
}

function ConnectSource(id)
{
	AJAX_query_sources_db('get_info');
	var addingstring = '';
	var splitted = '';
	var field = '';
	//alert(varSelectedSource);
	
	setTimeout ( function(){
		
		
		
		//alert(varSelectedSource);
		if(allvars['connectedsources'] == '')
		{
			allvars['connectedsources'] = allvars['connectedsources']+varSelectedSource;
		}
		else
		{
			allvars['connectedsources'] = allvars['connectedsources']+'Â¤'+varSelectedSource;
		}
		
		loaded_picklist = "";
		picklist_choosenId = "";
		picklist_choosenTextVal = "";
		loadfromarray('connectedsources');
		
		
	},1000);
	
}
function ConnectFile(id)
{
	var string, splitted; 
	var addingstring;
	addingstring = '';
	
	
	clearfields('connectedfile');
	addingstring = addingstring + 'data_id|' + picklist_choosenId + '#filetitle|' + picklist_choosenTextVal + 'NEWFILE';
	
	allvars['connectedfiles'] = allvars['connectedfiles']+ addingstring+'Â¤';
	loadfromarray('connectedfiles');
	//alert(allvars['connectedfiles']);
	

}
function ConnectLivingPlace(id)
{
	var string, splitted; 
	var addingstring;
	addingstring = '';
	
	
	clearfields('connectedlivingplace');
	if(allvars['livingevents'] != '')
	{
		addingstring = 'Â¤';
	}
	addingstring = addingstring + 'place_id|' + picklist_choosenId + '#livingplacename|' + picklist_choosenTextVal + '#livingevent_date|' + '' + '#living_date|' + '' + '#livingplacedescription|' + '';

	allvars['livingevents'] = allvars['livingevents']+ addingstring;
	loadPlaceEventsfromarray('livingevents');
	//alert(allvars['livingevents']);
	

}

function ConnectListItem()
{
	
	switch( loaded_picklist)
	{
		
		case "choose_event_type":
		if(document.getElementById('roles_id').value == '')
		{
			alert('ingen roll vald..');
			break;
		}
		TheEventString = '';
		//alert(allvars['connectedevents']);
		//alert(document.getElementById('roles_id').value);
		//alert(document.getElementById('roles_text').value);
		//alert(picklist_choosenId);
		//alert(picklist_choosenTextVal);
		varNewEvents += 1;
		if(allvars['connectedevents'] != '')
		{
			TheEventString = 'Â¤';
		}
		TheEventString += 'eventassertion_id|NEW' + varNewEvents + '#event_id|NEW' + varNewEvents +  '#eventtypetext|' + picklist_choosenTextVal + '#eventtyperole_id|' + document.getElementById('roles_id').value + '#eventtyperole_text|' + document.getElementById('roles_text').value + '#eventtype_id|' + picklist_choosenId + '#eventplace_id|#eventplacename|#eventdate|#eventtext|#';
		allvars['connectedevents'] += TheEventString;
		//alert(allvars['connectedevents']);
		loadfromarray('connectedevents');
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;		
		case "mother":
		
		document.getElementById('mother_id').value = picklist_choosenId;
		document.getElementById('mother').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "father":
		
		document.getElementById('father_id').value = picklist_choosenId;
		document.getElementById('father').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "bornplace":
		
		document.getElementById('birthplace_id').value = picklist_choosenId;
		document.getElementById('bornplace').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "deadplace":
		
		document.getElementById('deadplace_id').value = picklist_choosenId;
		document.getElementById('deadplace').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "eventplace":
		
		document.getElementById('eventplace_id').value = picklist_choosenId;
		document.getElementById('eventplacename').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		
		case "otherstoevent":
		//alert();
		//alert(document.getElementById('eventitems').value);
		if(document.getElementById('roles_id').value == '')
		{
			alert('ingen roll vald');
			break;
		}
		document.getElementById('otherperson_id').value = picklist_choosenId;
		document.getElementById('otherfirstname').value = picklist_choosenTextVal;
		document.getElementById('otherlastname').value = ' ';
		document.getElementById('otherevent_type_role_id').value = document.getElementById('roles_id').value;
		document.getElementById('othereventtyperole_text').value = document.getElementById('roles_text').value;
		//alert(document.getElementById('otherevent_type_role_id').value + document.getElementById('othereventtyperole_text').value);
		i = document.getElementById('eventotherpeople').length;
		document.getElementById('eventotherpeople').options[i] = new Option(document.getElementById('otherfirstname').value + ' ' + document.getElementById('otherlastname').value,i-1);
		SaveOtherRole();
		CleanTheDiv('popUp');
		loaded_picklist = "";
		
		break;
		
		case "higherplace":
		
		document.getElementById('higher_id').value = picklist_choosenId;
		document.getElementById('higherplace').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "publicplace":
		
		document.getElementById('public_place_id').value = document.getElementById('items').value;
		document.getElementById('public_place_name').value = document.getElementById('bornplacename').value;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "choose_publicplace":
		
		document.getElementById('public_place_id').value = picklist_choosenId;
		document.getElementById('public_place_name').value = picklist_choosenTextVal;
		CleanTheDiv('popUp');
		loaded_picklist = "";
		break;
		
		case "choose_living_place":
		
		ConnectLivingPlace(picklist_choosenId);
		CleanTheDiv('popUp');
		loaded_picklist = "";
		picklist_choosenId = "";
		picklist_choosenTextVal = "";
		break;
		
		case "choose_sources":
		
		
		ConnectSource(picklist_choosenId);
		if(varSelectedSource == 'loading')
		{
		setTimeout('ConnectSource(picklist_choosenId)',500)
		}
		
		CleanTheDiv('popUp');
		
		break;
		
		
		case "files":
		

		ConnectFile(picklist_choosenId);
		/*
		document.getElementById('deadplace_id').value = picklist_choosenId;
		document.getElementById('deadplace').value = picklist_choosenTextVal;
		CleanTheDiv('rightColumnPlaces');
		loaded_picklist = "";
		*/
		CleanTheDiv('popUp');
		loaded_picklist = "";
		picklist_choosenId = "";
		picklist_choosenTextVal = "";
		break;
	}
	
}
function DisConnectListItem()
{
	switch(document.getElementById('itemstype').value)
	{
		case "mother":
		
		document.getElementById('mother_id').value = '';
		document.getElementById('mother').value = '';
		CleanTheDiv('rightColumn');
		break;
		
		case "father":
		
		document.getElementById('father_id').value = '';
		document.getElementById('father').value = '';
		CleanTheDiv('rightColumn');
		break;
		
		case "bornplace":
		
		document.getElementById('birthplace_id').value = '';
		document.getElementById('bornplace').value = '';
		CleanTheDiv('rightColumn');
		break;
		
		case "deadplace":
		
		document.getElementById('deadplace_id').value = '';
		document.getElementById('deadplace').value = '';
		CleanTheDiv('rightColumn');
		break;
		
		case "higherplace":
		
		document.getElementById('higher_id').value = '';
		document.getElementById('higherplace').value = '';
		CleanTheDiv('rightColumn');
		break;
	}
	
}
function ShowPlaceName(placename)
{

document.getElementById('bornplacename').value = placename;
}
function ShowEventPlaceName(placename)
{

document.getElementById('eventchooseplacename').value = placename;
}
function SubmitForm()
{
	//alert(document.getElementById('FORMTYPE').value);
	if(document.getElementById('FORMTYPE').value == 'person')
	{
	document.getElementById('introduction').value = ReplaceTheLB(document.getElementById('introduction').value);
	document.getElementById('description').value = ReplaceTheLB(document.getElementById('description').value);
	document.getElementById('deadinfo').value = ReplaceTheLB(document.getElementById('deadinfo').value);
	document.getElementById('borninfo').value = ReplaceTheLB(document.getElementById('borninfo').value);
	document.getElementById('notes').value = ReplaceTheLB(document.getElementById('notes').value);
	
	document.getElementById('sourceconnections').value = allvars['connectedsources'];
	document.getElementById('livedonevents').value = ReplaceTheLB(allvars['livingevents']);
	document.getElementById('fileconnections').value = allvars['connectedfiles'];
	document.getElementById('persons_connectedtoevents').value = allvars['connectedtoevents'];
	document.getElementById('connectedonevents').value = ReplaceTheLB(allvars['connectedevents']);
	
	//varGender = document.getElementsByName('gender');
	
	
	
	//alert(document.getElementById('livingevents').value+allvars['livingevents']);
	}
	if(document.getElementById('FORMTYPE').value == 'personal')
	{
	document.getElementById('myplace_ingress').value = ReplaceTheLB(document.getElementById('myplace_ingress').value);
	document.getElementById('myplace_text').value = ReplaceTheLB(document.getElementById('myplace_text').value);
	//document.getElementById('user_webpage').value = ReplaceTheLB(document.getElementById('deadinfo').value);
	
	document.getElementById('fileconnections').value = allvars['connectedfiles'];
	
	//alert(document.getElementById('myplace_text').value);
	}
	if(document.getElementById('FORMTYPE').value == 'message')
	{
	document.getElementById('msg_body').value = ReplaceTheLB(document.getElementById('msg_body').value);
	document.getElementById('subject').value = ReplaceTheLB(document.getElementById('subject').value);
	//document.getElementById('myplace_text').value = ReplaceTheLB(document.getElementById('myplace_text').value);
	//document.getElementById('user_webpage').value = ReplaceTheLB(document.getElementById('deadinfo').value);
	
	//document.getElementById('fileconnections').value = allvars['connectedfiles'];
	
	//alert(document.getElementById('livingevents').value+allvars['livingevents']);
	}
	if(document.getElementById('FORMTYPE').value == 'public_place')
	{
	
	document.getElementById('introduction').value = ReplaceTheLB(document.getElementById('introduction').value);
	document.getElementById('text').value = ReplaceTheLB(document.getElementById('text').value);
	document.getElementById('notes').value = ReplaceTheLB(document.getElementById('notes').value);
	document.getElementById('connectedonsources').value = allvars['connectedsources'];
	document.getElementById('fileconnections').value = allvars['connectedfiles'];
	//alert(allvars['connectedfiles']);
	}
	if(document.getElementById('FORMTYPE').value == 'place')
	{
	//alert(allvars['connectedfiles']);
	document.getElementById('introduction').value = ReplaceTheLB(document.getElementById('introduction').value);
	document.getElementById('text').value = ReplaceTheLB(document.getElementById('text').value);
	document.getElementById('notes').value = ReplaceTheLB(document.getElementById('notes').value);
	
	
	document.getElementById('fileconnections').value = allvars['connectedfiles'];
	document.getElementById('connectedonsources').value = allvars['connectedsources'];
	}
	if(document.getElementById('FORMTYPE').value == 'source')
	{
	document.getElementById('description').value = ReplaceTheLB(document.getElementById('description').value);
	document.getElementById('location').value = ReplaceTheLB(document.getElementById('location').value);
	
	}
	if(document.getElementById('FORMTYPE').value == 'file')
	{
	document.getElementById('text').value = ReplaceTheLB(document.getElementById('text').value);
	if(document.getElementById('title').value == '')
	{
		alert('Du mÃƒÂ¥ste ange ett filnamn');
		return false;
	}
	document.formModule.Submit;
	}
	if(document.getElementById('FORMTYPE').value == 'files')
	{
		
		if(document.getElementById('highestId').value == 0)
		{
			alert('Du mÃƒÂ¥ste ange ett filnamn');
			return false;
	}
	document.formModule.Submit;
	}
	if(document.getElementById('FORMTYPE').value == 'uploadgedcom')
	{
		if(document.getElementById('fil').value != '')
		{
			document.getElementById('run_upload').value = 'runupload';
		}
		if(document.getElementById('clean_database').checked)
		{
			resp_confirm = confirm("Detta rensar databasen frÃƒÂ¥n alla dina existerande platser/personer/hÃ¤ndelser \n Ã¤r du sÃ¶ker? \n \n Dina bilder och dokument kommer inte raderas");
			if(!resp_confirm)
			{
				return;
			}
		}
		
	document.forms[1].submit();
	}
	if(document.getElementById('FORMTYPE').value == 'searcheditperson')
	{
	value = new Array();
	value[0] = document.getElementById('firstname').value
	value[1] = document.getElementById('lastname').value
	value[2] = document.getElementById('birth').value
	value[3] = document.getElementById('birth1').value
	value[4] = document.getElementById('death').value
	value[5] = document.getElementById('death1').value
	
	for(i=0;i<value.length;i++)
	{
		if(value[i] != '')
		{
			document.formModule.submit();
			return ;
		}
	}
	
	alert('No values entered');
	
	return false;
	
	}
}
function ReplaceTheLB(strLineBreaks)
{
	//.replace(/\r\n/g,'<br>');
	strWOLineBreaks = strLineBreaks.replace(/\n/g,"<br>").replace(/\r/g,"");
	return strWOLineBreaks;
}

function addevents(text,id)
{

	
}
function RemoveOtherRole(value,index)
{


	var eventstr, personstr, eventsearchstr;
	var foundevent, foundperson;
	var theconnectedeventid = document.getElementById('event_id').value;
	var fieldsandvalues, fieldname, value, fieldandvalues, name, personid;
	var event_type_role_id, assertion_id;
	//connectedtoeventperson_id
	//connectedtoeventassertion_id
	//connectedtoeventroletype_id
	//alert(value);
	for(i=0;i<arr_people_event.length;i++)
	{
		eventstr = arr_people_event[i];
		personstr = 'person_id|'+value;
		eventsearchstr = 'event_id|'+ theconnectedeventid;
		foundperson = findString(eventstr,personstr);
		//alert(foundperson);
		if(foundperson)
		{
			
			foundevent = findString(eventstr,eventsearchstr);
			if(foundevent)
			{
				
				eventstr = eventstr + '#DELETE';
				arr_people_event[i] = eventstr;
				//alert(eventstr);
				//alert(index);
				document.getElementById('eventotherpeople').remove(index);
				/*fieldsandvalues = eventstr.split('#');
				for(j=0;j<fieldsandvalues.length;j++)
				{
					
					fieldandvalues = fieldsandvalues[j].split('|')
					
					fieldname = fieldandvalues[0];
					value = fieldandvalues[1];
					
					if(fieldname != '')
					{
						if(fieldname == 'firstname')
						{
							name = value
						}
						if(fieldname == 'lastname')
						{
							name = name + ' ' + value
						}
						document.getElementById('eventotherpersonname').value = name;
						if(fieldname == 'person_id')
						{
							personid = value
						}
						document.getElementById('connectedtoeventperson_id').value = personid;
						if(fieldname == 'event_type_role_id')
						{
							event_type_role_id = value;
						}
						document.getElementById('connectedtoeventroletype_id').value = event_type_role_id;
						if(fieldname == 'assertion_id')
						{
							assertion_id = value;
						}
						document.getElementById('connectedtoeventassertion_id').value = assertion_id;
						
					}
				}	*/			
			}
		}
	}
	/*
		Load data to event_type_role
	
	//alert(+' '+document.getElementById('event_id').value);
	var m = 0;
	for(k=0;k<arr_event_type_roles.length;k++)
	{
		flag_eventtyperoles = findString(arr_event_type_roles[k],'eventtypeid|'+document.getElementById('eventtype_id').value)
		//alert(flag_eventtyperoles);
		
		if(flag_eventtyperoles)
		{
			
			rolefieldnamesandvalues = arr_event_type_roles[k].split('#');
			for(l=0;l<rolefieldnamesandvalues.length;l++)
			{
				rolefieldsandvalues = rolefieldnamesandvalues[l].split('|');
				if(rolefieldsandvalues[0] == 'event_type_role_id')
				{
					list_event_type_role_id = rolefieldsandvalues[1];
				}
				if(rolefieldsandvalues[0] == 'event_type_role_text')
				{
					list_event_type_role_text = rolefieldsandvalues[1];
				}
			}
			document.getElementById('eventotherpersonrole').options[m] = new Option(list_event_type_role_text,list_event_type_role_id);
			m++;
		}
	}
*/
}
function RemoveEvent(value,index)
{
	alert(value);
	alert(index);
}
function AddPersonToEvent(person_id,eventtypeid,event_type_role_text,event_type_role_id,event_id)
{
alert(person_id);
alert(event_type_role_id);
alert(event_id);
}
function Quest_AnotherPerson(id)
{
	confirmvalue = confirm('Vill du lÃ¤gga till ytterligare personer?');
	
	if(confirmvalue == false)
	{
		
		document.write('<FORM ACTION=index.php?com=myplace&action=editperson METHOD=POST NAME=formModule ID=formModule>');
		document.write('<INPUT TYPE=HIDDEN NAME=ID VALUE='+id+'>');
		document.formModule.submit();
		document.write('</FORM>');
		
	}
	else
	{
		
		location.replace('index.php?com=myplace&action=newperson');
		
	}
}
function Quest_AnotherSource(id)
{
	confirmvalue = confirm('LÃ¤gg till en ny kÃ¤lla');
	
	if(confirmvalue == false)
	{
		
		document.write('<FORM ACTION=index.php?com=myplace&action=editsource METHOD=POST NAME=formModule ID=formModule>');
		document.write('<INPUT TYPE=HIDDEN NAME=ID VALUE='+id+'>');
		document.formModule.submit();
		document.write('</FORM>');
		
	}
	else
	{
		
		location.replace('index.php?com=myplace&action=newsource');
		
	}
}
function Quest_AnotherPublicPlace(id)
{
	confirmvalue = confirm('LÃ¤gg till en ny publik plats');
	//alert(id);
	if(confirmvalue == false)
	{
		
		document.write('<FORM ACTION=index.php?com=myplace&action=editpublicplace METHOD=POST NAME=formModule ID=formModule>');
		document.write('<INPUT TYPE=HIDDEN NAME=ID VALUE='+id+'>');
		document.formModule.submit();
		document.write('</FORM>');
		
	}
	else
	{
		
		location.replace('index.php?com=myplace&action=newpublicplace');
		
	}
}
function Quest_AnotherPlace(id)
{
	confirmvalue = confirm('LÃ¤gg till en ny plats');
	//alert(id);
	if(confirmvalue == false)
	{
		
		document.write('<FORM ACTION=index.php?com=myplace&action=editplace METHOD=POST NAME=formModule ID=formModule>');
		document.write('<INPUT TYPE=HIDDEN NAME=ID VALUE='+id+'>');
		document.formModule.submit();
		document.write('</FORM>');
		
	}
	else
	{
		
		location.replace('index.php?com=myplace&action=newplace');
		
	}
}

function loadPlaceEventsfromarray(name)
{
	document.getElementById(name).length = 0;
	var splitted, fieldname, value, i, j, fieldnameandvalues, thevalues, row;
	var row = 0;
	splitted = allvars[name].split('Â¤');
	
	for(i=0;i<splitted.length;i++)
	{
		fieldnameandvalues = splitted[i].split('#')
		for(j=0;j<fieldnameandvalues.length;j++)
		{
			thevalues = fieldnameandvalues[j].split('|');
			fieldname= thevalues[0];
			value= thevalues[1];
			
			
			if(fieldname == 'livingplacename')
			{
				
				document.getElementById(name).options[row] = new Option(value,row);
				//alert(fieldname+fieldvalue);
				fieldname = '';
				value = '';
				row++;
			}
		
		}
	}
}
function loadfromarray(name)
{
	document.getElementById(name).length = 0;
	
	//alert(name);
	var splitted, fieldname, fieldvalue, i, j, fieldnameandvalues, thevalues, row;
	var row = 0;
	splitted = allvars[name].split('Â¤');
	
	for(i=0;i<splitted.length;i++)
	{
		fieldnameandvalues = splitted[i].split('#')
		fieldname = '';
		
		fieldvalue = '';
		//alert(allvars);
		
		for(j=0;j<fieldnameandvalues.length;j++)
		{
			
			if(name == 'connectedevents')
			{
				thevalues = fieldnameandvalues[j].split('|');
				if(thevalues[0] == 'eventassertion_id')
				{
					fieldname = thevalues[1];
				}
			
				if(thevalues[0] == 'eventtypetext')
				{
					fieldvalue = thevalues[1];
				}
				if(fieldname != '' && fieldvalue != '')

				{
					document.getElementById(name).options[row] = new Option(fieldvalue,row);
					//alert(fieldname+fieldvalue);
					fieldname = '';
					fieldvalue = '';
					row++;
				}
				
				
				
			}
			if(name == 'all_eventtypes')
			{
				//alert(allvars[name]);
				
				thevalues = fieldnameandvalues[j].split('|');
				if(thevalues[0] == 'event_type_id')
				{
					fieldname = thevalues[1];
				}
			
				if(thevalues[0] == 'event_type_text')
				{
					fieldvalue = thevalues[1];
				}
				if(fieldname != '' && fieldvalue != '')
				{
					document.getElementById(name).options[row] = new Option(fieldvalue,fieldname);
					//alert(fieldname+fieldvalue);
					fieldname = '';
					fieldvalue = '';
					row++;
				}
				
				
				
			}
			if(name == 'connectedsources')
			{
				//alert(document.getElementById(name).length);
				thevalues = fieldnameandvalues[j].split('|');
				if(thevalues[0] == 'source_id')
				{
					fieldname = thevalues[1];
				}
			
				if(thevalues[0] == 'sourcetitle')
				{
					fieldvalue = thevalues[1];
				}
				if(fieldname != '' && fieldvalue != '')
				{
					//alert(fieldvalue +' '+ row +' '+ name);
					document.getElementById(name).options[row] = new Option(fieldvalue,row);
				
					fieldname = '';
					fieldvalue = '';
					row++;
				}
				
			}
			thevalues = fieldnameandvalues[j].split('|');
			if(thevalues[0] == 'event_type_text')
			{
				fieldvalue = thevalues[1];
			}
			
			if(fieldname != '' && fieldvalue != '')
			{
				//alert(fieldname+fieldvalue);
				document.getElementById(name).options[row] = new Option(fieldvalue,row);
				
				fieldname = '';
				fieldvalue = '';
				row++;
			}
			//alert(thevalues[0]);
			
				if(thevalues[0] == 'data_id')
				{
					fieldname = thevalues[1];
				}
				if(thevalues[0] == 'filetitle' || thevalues[0] == 'title')
				{
					fieldvalue = thevalues[1];
				}
				if(fieldname != '' && fieldvalue != '')
				{
					//alert(name);
					document.getElementById(name).options[row] = new Option(fieldvalue,fieldname);
					//alert(fieldname+fieldvalue);
					fieldname = '';
					fieldvalue = '';
					row++;
					
				}
			
			
			if(thevalues[0] == 'event_id')
			{
				fieldname = thevalues[1];
			}
			if(thevalues[0] == 'name' )
			{
				fieldvalue = thevalues[1];
			}
			
			if(fieldname != '' && fieldvalue != '')
			{
				
				document.getElementById(name).options[row] = new Option(fieldvalue,fieldname);
				//alert(fieldname+fieldvalue);
				fieldname = '';
				fieldvalue = '';
				row++;
			}
			
			if(thevalues[0] == 'place_id')
			{
				fieldname = thevalues[1];
				//alert(fieldname);
			}
			if(thevalues[0] == 'livingplacename' )
			{
				fieldvalue = thevalues[1];
				//alert(fieldvalue);
			}
			
			if(fieldname != '' && fieldvalue != '')
			{
				
				//alert()
				document.getElementById(name).options[row] = new Option(fieldvalue,fieldname);
				//alert(fieldname+fieldvalue);
				fieldname = '';
				fieldvalue = '';
				row++;
			}
			//alert(thevalues[0]+' - '+thevalues[1])
		}
		
	}
	
	//alert(allvars[name]);
}
function isset(  ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: FremyCompany
    // +   improved by: Onno Marsman
    // *     example 1: isset( undefined, true);
    // *     returns 1: false
    // *     example 2: isset( 'Kevin van Zonneveld' );
    // *     returns 2: true
    
    var a=arguments; var l=a.length; var i=0;
    
    if (l==0) { 
        throw new Error('Empty isset'); 
    }
    
    while (i!=l) {
        if (typeof(a[i])=='undefined' || a[i]===null) { 
            return false; 
        } else { 
            i++; 
        }
    }
    return true;
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function clearfields(object)
{
	switch(object)
	{
		case 'connectedsource':
		document.getElementById('source_id').value = '';
		document.getElementById('sourcetitle').value = '';
		document.getElementById('sourcetype').value = '';
		document.getElementById('sourcedescription').value = '';
		document.getElementById('sourcecomments').value = '';
		document.getElementById('undefined').value = '';
		
	break;
	case 'event':
		document.getElementById('eventdate').value = '';
		document.getElementById('eventplacename').value = '';
		document.getElementById('eventtyperole_text').value = '';
		document.getElementById('eventtext').value = '';
		document.getElementById('eventotherpeople').value = '';
		document.getElementById('othereventtyperole_text').value = '';
		document.getElementById('eventdate').readOnly = true;
		document.getElementById('eventtext').readOnly = true;
	break;
	case 'livingevents':
		document.getElementById('livingevent_date').value = '';
		document.getElementById('livingevent_date2').value = '';
		document.getElementById('livingplacedescription').value = '';
		document.getElementById('livingevent_placeid').value = '';
		document.getElementById('livingevent_eventid').value = '';
		document.getElementById('livingevent_livingplacename').value = '';
		
		document.getElementById('livingevent_date').readOnly = true;
		document.getElementById('livingevent_date2').readOnly = true;
		document.getElementById('livingplacedescription').readOnly = true;
		
		
	break;
	}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
var id = 0;
function addImageToList(){
	//alert('dfsf');
	filnamn = document.getElementById('image'+id).value;
	arr = filnamn.split('/');
	if (arr.length == 1) {
		// windows platform
		arr = filnamn.split('\\');
	}
	filnamn = arr[arr.length-1];
	org_filnamn = filnamn;
	var no_ext_arr = filnamn.split('.');
	filnamn = no_ext_arr[0]; 

	// gÃ¶m nuvarande filvÃ¤ljare
	document.getElementById('filvaljare' + id).style.display = 'none';	

	// lÃ¤gg till ny filvÃ¤ljare
	id++;
	document.getElementById('highestId').value = id;
	
	div1 = document.createElement('div');
	div1.id = 'filvaljare' + id;

	div2 = document.createElement('div');
	div2.innerHTML = '<div id="fil' + id + '"><input type="file" name="image' + id + '" id="image' + id + 
		'" class="mmFileUpload" onChange="addImageToList('+ id + ')" /></div>';
	
	bigdiv = document.getElementById('filer');
	div1.appendChild(div2);
	bigdiv.appendChild(div1);
	
	
	oneInList = document.createElement("div");
	onInListId = id-1;
	elName = 'check_img'+ onInListId;
	oneInList.innerHTML = '' +
			'<a href="javascript:document.getElementById(elName).value = true;removeSelectedImages()" Title="Ta bort denna bild frÃƒÂ¥n uppladdningslista" style="float:right;" />' +
			'<img src="/_images_icons/i_delete.png" style="margin-top:7px;">' +
			'</a>' +
			'<input type=hidden id="check_img' + onInListId + '" />' +
			'' + 
		'<P>"' + filnamn + '"' +
		'&nbsp;<select name="filetype' + onInListId + '" id="filetype' + onInListId + '" value=""><option value=img>bild</option><option value=doc>dokument</option></select></P>'+
		'<input type="hidden" id="image_name' + onInListId + '" name="image_name' + onInListId + '" value="' + filnamn + '" />' + 
		'<input type=hidden id="image_desc' + onInListId + '" name="image_desc' + onInListId + '" value="" class="img_name_input" />' + 
		'<input type="hidden" name="connected_person' + onInListId  +'" id="connected_person' + onInListId  +'" />' + 
		'<input type="hidden" name="geotag_x' + onInListId  +'" id="geotag_x' + onInListId  +'" />' + 
		'<input type="hidden" name="geotag_y' + onInListId  +'" id="geotag_y' + onInListId  +'" />' + 
		'<input type="hidden" name="filename' + onInListId  +'" id="filename' + onInListId  +'" value="' + org_filnamn + '" />' +
		'';
	if(id%2 == 0)
	{
		oneInList.className = 'imageToUploadListRow2';
	}
	else
	{
		oneInList.className = 'imageToUploadListRow1';
	}
	
	oneInList.id = 'oneInList'+onInListId;
	
		
	bigdiv2 = document.getElementById('imageToUploadList');
	bigdiv2.appendChild(oneInList);
	document.getElementById('removeImageDiv').style.display = 'block';
}
function removeSelectedImages(){
	for(i=0;i<=id;i++){
		var theid = 'check_img'+i;
		if(document.getElementById(theid) != undefined){
			if(document.getElementById(theid).value = true){
				var oneInList = 'oneInList' + i;
				removeElement(oneInList);
				var fil = 'fil'+i;
				removeElement(fil);
				var connected_person = 'connected_person' + i;
				removeElement(connected_person);
			}
		}
	}
}
function removeElement(id)	{
	var Node = document.getElementById(id);
	Node.parentNode.removeChild(Node);
}
-->
