function glossary(url){
	if (window.name != 'glossary') {window.name = 'GEM'};
	glossaryWindow = window.open(url,'glossary','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,copyhistory=0,left=100,top=100,screenX=100,screenY=100');
	if (glossaryWindow != null) glossaryWindow.focus();
}

function wr(str){document.write(str)}

function large(url){
	largeWindow = window.open('large.aspx?img=' + escape(url),'enlargment','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=600,height=600,copyhistory=0,left=0,top=0,screenX=0,screenY=0');
	if (largeWindow != null) largeWindow.focus();
}

function attachment(url){
	attachmentWindow = window.open('attachments/' + escape(url),'attachment','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=640,height=515,copyhistory=0,left=100,top=100,screenX=100,screenY=100');
	if (attachmentWindow != null) attachmentWindow.focus();
}

function slideshow(id){
	w = screen.availWidth - 10;
	h = screen.availHeight - 30;
	slideshowWindow = window.open('slideshow.aspx?id=' + id,'slideshow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + w + ',height=' + h + ',copyhistory=0,left=0,top=0,screenX=0,screenY=0');
	if (slideshowWindow != null) slideshowWindow.focus();
}

function kids(lan){
	kidsWindow = window.open('legacy/kids.asp?lan=' + lan ,'kids','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=600,copyhistory=0,left=0,top=0,screenX=0,screenY=0');
	if (kidsWindow != null) kidsWindow.focus();
}


function changeimg(str){
	if (str=='') {str='allobjects'}
	str = str.replace("/","_");str = str.replace("/","_");str = str.replace("/","_");
	document.getElementById("objects_image").src = "gif/" + str + ".png" 
}

function fill_select(thesel,thethes) {
	theselect = document.getElementById(thesel);
	theselect.options.length = 0;
	theselect.options[0] = new Option('','');
	for(var i=1; i < thethes.length+1; i++) {
			theval=thethes[i-1]; pos=theval.indexOf('|');
			if (pos>1){theselect.options[i] = new Option(theval.substring(pos+1),theval.substring(0,pos));}
			else {theselect.options[i] = new Option(theval,theval);}
			}
	}

function loadthes(theid, theval){
	theval = theval.substring(0,7);
	theval = theval.replace("/","_");
	
	if (theid.indexOf(':2')) {level3 = theid.replace(":2",":3");
		if (document.getElementById(level3)) {
		document.getElementById(level3).options.length = 0;
		document.getElementById(level3).style.display = 'none';}}

	if (theid.indexOf(':3')) {level4 = theid.replace(":3",":4");
		if (document.getElementById(level4)) {
		document.getElementById(level4).options.length = 0;
		document.getElementById(level4).style.display = 'none';}}
		
	if (eval('self.thes_' + theval)) {
		document.getElementById(theid).disabled = false;
		document.getElementById(theid).style.display = 'inline';
		eval('fill_select(theid,thes_' + theval + ')');}
	else { if (document.getElementById(theid)) {
		document.getElementById(theid).options.length = 0;
		document.getElementById(theid).style.display = 'none';}
	}
}

function setval(theid, val){
	if (document.getElementById(theid)){document.getElementById(theid).value=val;}
}

function showpart(prt){
	if (prt=='') {showhideall('block')} else {
	showhideall('none')
	document.getElementById(prt).style.display='block';
	}
}
function showhideall(what){
	document.getElementById("basicinfo").style.display=what;
	document.getElementById("characteristics").style.display=what;
	document.getElementById("dating").style.display=what;
	document.getElementById("actors").style.display=what;
	document.getElementById("textual").style.display=what;
	document.getElementById("reference").style.display=what;
	document.getElementById("imgtable2").style.display=what;
	}
	
function show(str){
	if(document.getElementById(str)) {document.getElementById(str).style.display='block';}
}

function hide(str){
	if(document.getElementById(str)) {document.getElementById(str).style.display='none';}
}

function showhidelandiv(val){
	if (val == ''){
		show('div_D');show('div_E');show('div_F');show('div_G');
		show('div_I');show('div_P');show('div_S');show('div_A');
	} else {
		hide('div_D');hide('div_E');hide('div_F');hide('div_G');
		hide('div_I');hide('div_P');hide('div_S');hide('div_A');
		show('div_' + val)}
}

function showhidelanitem(it, val){
	hide(it +'D');hide(it +'E');hide(it +'F');hide(it +'G');
	hide(it +'I');hide(it +'P');hide(it +'S');hide(it +'A');
	if (val != ''){show(it +'' + val)}
}
	
function loadScript(scrsrc){
	var script = document.createElement('script'); 
	script.type = 'text/javascript'; 
	script.src = scrsrc; 
	document.getElementsByTagName('head')[0].appendChild(script);
} 

function changeLan(L){
	 var loc = document.location.toString();
	 if (loc.indexOf('?') > 0){
	 		 if (loc.indexOf('lan=') > 0){
			 	pos = loc.indexOf('lan=')
			 	location.href = loc.substring(0,pos+4) + L +  loc.substring(pos+5,999)
			 } else {location.href = loc + '&lan=' + L} 
	 } else
	 {location.href = loc + '?lan=' + L}
	 
}

function objectselect(tf){
	 var loc = document.location.toString();
	 pos = loc.indexOf('sel=');
	 if (pos > 0){
			 location.href = loc.substring(0,pos+4) + tf
	 } else{
	 location.href = loc + '&sel=' + tf}
}

function copydiv(parentdiv, basediv, newnumber){
	htmlstr = document.getElementById(basediv).innerHTML;
	htmlstr = htmlstr.replace(/\_1/g, "_" + newnumber);
	document.getElementById(parentdiv).innerHTML = document.getElementById(parentdiv).innerHTML + htmlstr;
}

function loadInventories() {
	loadScript('inventory.js.aspx?location=' + document.getElementById('location').value);
}

function addPerson(val){
	if (val != ''){
	tinyMCE.setContent(tinyMCE.getContent() + '<p><span style="font-family:Transliteration">' + val + '</span></p>')}
	else {alert('no selection')}
	}
	
function persons_tinyMCE(){
	tinyMCE.init({
		mode : "exact",
		elements : "person",
		theme : "advanced",
		theme_advanced_buttons1 : "fontselect",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
		paste_auto_cleanup_on_paste : true,
		paste_convert_headers_to_strong : true,
		encoding : "",
		plugins : "contextmenu,paste",
		content_css : "tinymce/jscripts/tiny_mce/themes/advanced/css/names.css",
		convert_fonts_to_spans : true,
		theme_advanced_fonts : "Latin=Arial;Greek=Symbol;Transliteration=Transliteration;Coptic=Coptic"
	});
}