<!-- Begin
function dup_import_fields(id)
{ 
	var list_ = get_list_elements();
	var dup_count = 0;
	for(key in list_)
	{
			if((document.getElementById(list_[key]).value == document.getElementById(id).value
			   && document.getElementById(list_[key]).value != 'IGNORE')
			   )
			{
				dup_count++;
			}
	}
	if (dup_count > 1)	alert("PROFILE ERROR!\n DUPLICATE field names not allowed");

}

	
function verify_profile(form) 
{
	var list_ = get_list_elements();
	var k = 0;
	for(key in list_)
	{
		if (document.getElementById(list_[key]).value == 'IGNORE') {k++;}
		
		if (document.getElementById(list_[key]).value != 'IGNORE' && k > 0){
			alert("PROFILE ERROR!\n IGNORE not allowed before: \n" + document.getElementById(list_[key]).value);
			return false;
		}
			
	}
	
	id = false;
	for(key in list_)
	{
		if (document.getElementById(list_[key]).value == 'location_id') {id = true;}
	}
	
	if (!id){
		alert("Your location data must contain a Location ID.");
		return false;
	}
	
// check duplicate fields
	list_2 = list_;
	for(key_1 in list_)
	{
		dup_count = 0;
			for(key_2 in list_2)
		{	
				if((document.getElementById(list_[key_1]).value == document.getElementById(list_2[key_2]).value
					 && document.getElementById(list_2[key_2]).value != 'IGNORE')
					 )
				{
					dup_count++
				}
		}
		if (dup_count > 1)	
		{
			alert("PROFILE ERROR!\n DUPLICATE field names not allowed ");
			return false;
		}		
	}


	return true;
}

function get_list_elements()
{
		list_ = new Array();
		var tag = document.getElementsByTagName('select')
		for(var i=0;i<tag.length;i++)
		{
			if(tag[i].name.indexOf("list_") == 0) list_.push(tag[i].name);
		}

	return list_;
}

function getElements()
  {
  var x=document.getElementsByName("import_list");
  alert(x.length);
  }

function ignore_view()
{
	var list_length = 19;
	for(i = 0; i < list_length; i++)
	{
		if(document.getElementById('list_' + i).value == 'IGNORE')
		{
			for(j = i+1; j < list_length; j++)
			{
				document.getElementById('list_' + j).style.visibility = "hidden";
			}
			i = list_length;
		}
		else 	
		document.getElementById('list_' + i).style.visibility = "visible";
	}
	
}
function blockError(){return true;}
window.onerror = blockError;

function field_dropdown (my_list, my_select) {

var items = {"location_id": "location_id", 
			 "name": "name",
			 "address_1": "address_1",
             "address_2": "address_2", 
			 "city": "city",
			 "state": "state/province",
             "postal_code": "postal code", 
             "country": "country", 
			 "phone": "phone",
			 "email": "email",
             "url": "url", 
             "longitude": "longitude", 
             "latitude": "latitude", 
			 "marker": "marker",
             "active_filter": "active_filter", 
			 "extra_1": "extra_1",
			 "extra_2": "extra_2",
             "extra_3": "extra_3", 
             "extra_4": "extra_4", 
             "IGNORE": "IGNORE"
			};

listString = "<select name=" + my_list + " class=dropdown onChange=unique_list(this.form,this.value)>";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function my_dropdown (my_list, my_select) {

var items = {"location_id": "location_id", 
			 "name": "name",
			 "address_1": "address_1",
             "address_2": "address_2", 
			 "city": "city",
			 "state": "state/province",
             "postal_code": "postal code", 
             "country": "country", 
			 "phone": "phone",
			 "email": "email",
             "url": "url", 
             "longitude": "longitude", 
             "latitude": "latitude", 
			 "marker": "marker",
             "active_filter": "active_filter", 
			 "extra_1": "extra_1",
			 "extra_2": "extra_2",
             "extra_3": "extra_3", 
             "extra_4": "extra_4", 
             "IGNORE": "IGNORE"
			};

listString = "<select name=" + my_list + " class=dropdown >";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function my_select_list (my_list, my_select) {

var items = {"location_id": "location_id", 
			"name": "name",
			"address_1": "address_1",
            "address_2": "address_2", 
			"city": "city",
			"state": "state/province",
            "postal_code": "postal code", 
            "country": "country", 
			"phone": "phone",
			"email": "email",
            "url": "url", 
            "longitude": "longitude", 
            "latitude": "latitude", 
			"marker": "marker",
            "active_filter": "active_filter", 
			"extra_1": "extra_1",
			"extra_2": "extra_2",
            "extra_3": "extra_3", 
            "extra_4": "extra_4", 
            "IGNORE": "IGNORE"
		    };

listString = "<select name=" + my_list + " size=8 class=dropdown onchange=this.form.my_" + my_list + ".value=this.form." + my_list + ".options[this.selectedIndex].value>";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function my_postal_list (my_list, my_select) {

var items = {"postal_code": "postal_code", 
						 "city": "city",
						 "state": "state",
             "lng": "lng", 
						 "lat": "lat"
						 };
	
listString = "<select name=" + my_list + " size=5 class=dropdown onchange=this.form.my_" + my_list + ".value=this.form." + my_list + ".options[this.selectedIndex].value>";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function unique_list(form, field) {

var items = {"field_0": "location_id", 
			"field_1": "name",
			"field_2": "address_1",
            "field_3": "address_2", 
			"field_4": "city",
			"field_5": "state/province",
            "field_6": "postal code", 
            "field_7": "country", 
			"field_8": "phone",
			"field_9": "email",
            "field_10": "url", 
            "field_11": "longitude", 
            "field_12": "latitude", 
			"field_13": "marker",
            "field_14": "active_filter", 
			"field_15": "extra_1",
			"field_16": "extra_2",
            "field_17": "extra_3", 
            "field_18": "extra_4"
			};

	k = 0;
	for (key in items) {
		if (form.elements[key].value == field && form.elements[key].value != 'IGNORE') {k++;}
	}
	if (k >1 ) {
	alert("IMPORT PROFILE ERROR!\n DUPLICATE field names not allowed");
	return k;
	}
	else return k;

}

function check_selected(form) {

var items = {"location_id": "location_id", 
			"name": "name",
			"address_1": "address_1",
            "address_2": "address_2", 
			"city": "city",
			"state": "state/province",
            "postal_code": "postal code", 
            "country": "country", 
			"phone": "phone",
			"email": "email",
            "url": "url", 
            "longitude": "longitude", 
            "latitude": "latitude", 
			"marker": "marker",
            "active_filter": "active_filter", 
			"extra_1": "extra_1",
			"extra_2": "extra_2",
            "extra_3": "extra_3", 
            "extra_4": "extra_4"
			 };

	k = 0;
	for (key in items) {
		if (form.elements[key].value == 'IGNORE') {k++;}
			
		if (form.elements[key].value != 'IGNORE' && k > 0){
			alert("IMPORT PROFILE ERROR!\n IGNORE not allowed before: \n" + form.elements[key].value);
			return false;
		}		
	}

	id = false;
	for (key in items) {
		if (form.elements[key].value == 'location_id') { 			
			id = true;
			}
	}
	if (!id){
		alert("The data file must contain a Location ID.");
		return false;
	}
	
	return true;
}

function my_list (my_list, my_select) {

var items = {"location_id": "location_id", 
			"name": "name",
			"address_1": "address_1",
            "address_2": "address_2", 
			"city": "city",
			"state": "state/province",
            "postal_code": "postal code", 
            "country": "country", 
			"phone": "phone",
			"email": "email",
            "url": "url", 
            "longitude": "longitude", 
            "latitude": "latitude", 
			"marker": "marker",
            "active_filter": "active_filter", 
			"extra_1": "extra_1",
			"extra_2": "extra_2",
            "extra_3": "extra_3", 
            "extra_4": "extra_4", 
            "IGNORE": "IGNORE"
			 };
	
listString = "<select name=" + my_list + " size=16 class=dropdown>";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function my_postal (my_list, my_select) {

var items = {"postal_code": "postal_code", 
						 "city": "city",
						 "state": "state",
             "lng": "lng", 
						 "lat": "lat"
						 };
	
listString = "<select name=" + my_list + " size=5 class=dropdown>";

for (key in items) {
	if (my_select == key) listString += "<option value=" + key + " selected>" + items[key] + "</option>";
	else listString += "<option value=" + key + ">" + items[key] + "</option>";
}
// document.write("For the key " + key     + " element value is " + items[key]);

listString += "</select>"

document.writeln(listString);
}

function confirm_delete()
{
input_box=confirm("Click OK to DELETE this record");
if (input_box==false) return false ;
}

function openViewFinder(path) {
border_color		= "FFFFFF"	// PICTURE OUTLINE COLOR
background_colors	= "292929"	// BACKROUND COLOR OF THE GALLERY POPUP

view_width 		= 650		// GALLERY POPUP WIDTH
view_height 	= 475		// GALLERY POPUP HEIGHT

scrollbarS 		= "0"		// TURN ON POPUP SCROLLBARS "1" FOR ON "0" FOR OFF

var look='toolbar=0,scrollbars=' + scrollbarS + ',location=0,statusbar=0,menubar=0,resizable=1,width='+view_width+',height='+view_height+','
	window.open(path, 'coordinates', look);
}

function openPopup(path) {
border_color		= "FFFFFF"	// PICTURE OUTLINE COLOR
background_colors	= "292929"	// BACKROUND COLOR OF THE GALLERY POPUP

view_width 		= 650		// GALLERY POPUP WIDTH
view_height 	= 475		// GALLERY POPUP HEIGHT

scrollbarS 		= "0"		// TURN ON POPUP SCROLLBARS "1" FOR ON "0" FOR OFF

var look='toolbar=0,scrollbars=' + scrollbarS + ',location=0,statusbar=0,menubar=0,resizable=1,width='+view_width+',height='+view_height+','
	window.open(path, 'coordinates', look);
}

function set_marker(path, marker) {
	document['ui_map_marker'].src = path + marker;
	document.map_prefs.ui_map_marker.value = marker;
}

function set_manual_marker(path, marker) {
	document['default_icon'].src = path + marker;
	document.edit_record.marker.value = marker;
}

function set_origin(path, marker) {
	document['ui_user_origin'].src = path + marker;
	document.map_prefs.ui_user_origin.value = marker;
}

 	function show_hide(el) {
		if(el == 'origin_selections') 
		document.getElementById('marker_selections').style.visibility = "hidden";
		else 	
		document.getElementById('origin_selections').style.visibility = "hidden";
			
		document.getElementById(el).style.visibility = "visible";	
 	}

function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
setTimeout("", 5000 );
}
function deleteAllConfirm(url) {
	var answer = confirm("Are you sure you want to DELETE ALL TABLES?")
	if (answer){
		window.location = url;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}