var today = new Date()
var month = today.getMonth()
var year = today.getYear()
var browser = navigator.userAgent.toLowerCase()
var IE = (browser.indexOf('msie') != -1) ? true : false ;
var IE6 = (browser.indexOf('msie 6') != -1) ? true : false ;

var width = (IE6) ? "225px" : "220px" ;
var height = "247px"
var zIndex = "1000000000"


/**
* Used to reload the captcha image
* The random number is used as a way to prevent image caching
*/
var win_captcha_open = false
function reload_captcha(load_img) {
	document.getElementById("captcha_image").src = load_img
	rand_gen = 1 + Math.floor((Math.random()*10000))
	setTimeout("document.getElementById('captcha_image').src='captcha.php?new=1&rand=" + rand_gen + "'", 2500)
}

/**
* A useful function that returns an array (t -l - w - h) of the dimensions/position of an object
*/
function my_dimensions(the_obj) {
	if (the_obj) {
		my_values = new Array
		my_values[0] = (the_obj.offsetTop)? the_obj.offsetTop : the_obj.style.pixelTop ;
		my_values[1] = (the_obj.offsetLeft)? the_obj.offsetLeft : the_obj.style.pixelLeft ;
		my_values[2] = (the_obj.offsetWidth)? the_obj.offsetWidth : the_obj.style.pixelWidth ;
		my_values[3] = (the_obj.offsetHeight)? the_obj.offsetHeight : the_obj.style.pixelHeight ;
		return my_values
	}
}

/**
* Used to display the calendar
*/
function calendar_show(field) {
	editfield = field
	my_loc = my_dimensions(document.getElementById(editfield + '_year'))
	my_day = document.getElementById(editfield + '_day').value
	month = document.getElementById(editfield + '_month').value - 1
	year = document.getElementById(editfield + '_year').value
	populate_titlebar()
	
	document.getElementById('calendar').style.top = my_loc[0].toString() + 'px'
	browser = navigator.userAgent.toLowerCase()
	if (browser.indexOf('msie') != -1 && browser.indexOf('opera') == -1) {
		my_loc_2 = my_dimensions(document.getElementById('container'))
		if (browser.indexOf('msie 6') == -1) {
			document.getElementById('calendar').style.left = (my_loc[1] + my_loc[2] + my_loc_2[1]).toString() + 'px'
		} else {
			document.getElementById('calendar').style.top = (my_loc[0] + 89).toString() + 'px'
			document.getElementById('calendar').style.left = (my_loc[1] + my_loc[2] + my_loc_2[1] + 288).toString() + 'px'
		}
	} else {
		document.getElementById('calendar').style.left = (my_loc[1] + my_loc[2]).toString() + 'px'
	}
	document.getElementById('calendar').style.visibility = 'visible'
}

/** 
* Add the Google Analytics onclick event to certain links
*/
function ga_links()
{
	IE = (navigator.appName == "Microsoft Internet Explorer") ? true : false ;
	anchors = document.getElementsByTagName('a')
	for (x = 0; x < anchors.length; x++) {
		if (!IE) {
			anchors[x].addEventListener('click', ga_click, true)
		} else {
			anchors[x].attachEvent('onclick', ga_click)
		}
	}
}
/**
* Track clicks on anchors using Google Analytics
* If you're only interested in certain document types then fill in the 'interest' array with file extensions and it will track just clicks directed to those file types
* Otherwise, leave the 'interest' array empty and fill in the 'no_interest' array with file extensions and it will track all clicks directed to file types that are not in that list
*/
function ga_click(e)
{
	interest = new Array()
	no_interest = new Array('php', 'html', 'htm', 'asp', 'shtml', 'ikml') // ignore these file types
	
	no_ga = false
	if (e.target) { targ = e.target }
	else if (window.event.srcElement) { targ = window.event.srcElement }
	if (targ.nodeType == 3) { targ = targ.parentNode }
	regExp = new RegExp(/\/\/([^\/]*)/)
	my_host = location.href.match(regExp)
	my_host = my_host[1].replace('www.', '')
	if (targ.href) {
		targ_host = targ.href.match(regExp)
		targ_host = targ_host[1].replace('www.', '')
		
		external_site = (targ_host != my_host) ? true : false ;
		if (external_site) {
			regExp2 = new RegExp(/\/\/(.*)/)
			my_link = targ.href.match(regExp2)
			ga_link = '/externalsite/' + my_link[1]
		} else {
			sections = targ.href.split('.')
			extension = sections[sections.length - 1]
			filter = (interest.length > 0) ? eval(interest) : eval(no_interest) ;
			no_ga = (interest.length > 0) ? true : false ;
			for (x = 0; x < filter.length; x++) {
				if (filter[x] == extension && interest.length == 0) { no_ga = true; break; }
				if (filter[x] == extension && interest.length > 0) { no_ga = false; break; }
			}
			if (!no_ga) {
				sections = targ.href.split('/')
				filename = sections[sections.length - 1]
				ga_link = '/clicks/' + extension + '/' + filename
			}
		}
		if (!no_ga) { pageTracker._trackPageview(ga_link); }
	}
}

/**
* The init function is called on page load to set variables and instantiate the calendar
* The onload method is appended to the window object by a command at the bottom of this script
*/
function init() {
	if (document.getElementById('get_towns')) {
		document.getElementById('get_towns').style.display = 'none'
		if (document.getElementById('town').value == '' && document.getElementById('town').options.length == 1) {
			document.getElementById('town').parentNode.style.display = 'none'
		}
	}
	// this is a little fix that enables IE to fix it's silly height and clearing issues without needing another stylesheet
	if	(document.getElementById('left_column')) {
		left_height = my_dimensions(document.getElementById('left_column'))[3]
		right_height = my_dimensions(document.getElementById('right_column'))[3]
		if (left_height > right_height) {
			document.getElementById('right_column').style.height = left_height.toString() + 'px'
		}
	}

	ga_links()
	
	/* 
	This can be used to provide dynamicism to buttons
	inputs = document.getElementsByTagName('input')
	for (x = 0; x < inputs.length; x++) {
		if (inputs[x].className == 'button') {
			inputs[x].setAttribute('onmouseover', 'this.style.border="1px #2960cf solid"')
			inputs[x].setAttribute('onmouseout', 'this.style.border="1px #dedede solid"')
		}
	} */
	
	labels = document.getElementsByTagName('label')
	for (x = 0; x < labels.length; x++) {
		if (labels[x].className == 'date' || labels[x].className == 'date_floated') {
			field = labels[x].parentNode.getElementsByTagName('select')[0].id.replace('_day', '')
			labels[x].parentNode.innerHTML += "<a href='#' onclick='calendar_show(\"" + field + "\"); return false'><img src='./images/calendar.png' alt='calendar' style='border:none; margin-left:5px; vertical-align:middle;'/></a>"
		}
	}
	if (document.getElementById('date_of_birth_day')) {
		year = year - 30
		month = 0
	}

	calendar = document.createElement('div');
	calendar.setAttribute ('id' , 'calendar')
	calendar.setAttribute ('class' , 'calendar')
	titlebar = document.createElement('div')
	titlebar.setAttribute ('id' , 'titlebar')
 	calendar.appendChild(titlebar);
	datesbar = document.createElement('div')
	datesbar.setAttribute ('id' , 'datesbar')
 	calendar.appendChild(datesbar);
	document.getElementsByTagName('body')[0].appendChild(calendar)

	document.getElementById('calendar').style.position = "absolute"
	document.getElementById('calendar').style.width = width
	document.getElementById('calendar').style.height = height
	document.getElementById('calendar').style.left = "20px"
	document.getElementById('calendar').style.bottom = "20px"
	document.getElementById('calendar').style.zIndex = zIndex
	document.getElementById('calendar').style.border = "1px solid #acacac"
	document.getElementById('calendar').style.visibility = "hidden"
	document.getElementById('calendar').style.backgroundColor = "#dfdfdf"
	document.getElementById('calendar').style.fontFamily = "arial, verdana"
	populate_titlebar()
}
function populate_titlebar() {
	document.getElementById('titlebar').style.width = width
	document.getElementById('titlebar').style.height = '20px'
	document.getElementById('titlebar').style.textAlign = "center"
	document.getElementById('titlebar').style.fontWeight = "bold"
	document.getElementById('titlebar').style.fontFamily = "arial, verdana"
	browser = navigator.userAgent.toLowerCase()
	year = year%1900 + 1900
	var thisDate = new Date(year, month, 01)
	year = thisDate.getYear()
	year = year%1900 + 1900
	browser = navigator.userAgent.toLowerCase()
	month = thisDate.getMonth()

	months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	if (month == 12) {
		month = 0
		year++
	}
	if (month == -1) {
		month = 11
		year--
	}
	thisMonth = months[month]
	document.getElementById('titlebar').innerHTML = "<div style='font-weight:bold; text-align:center; margin:4px 4px 2px 4px;'>"
	document.getElementById('titlebar').innerHTML += "<div style='float:left; margin-left:4px;'><a href='javascript: year--;populate_titlebar()' title='Minus year' style='background-color:transparent;'><img src='./images/icon_back.gif' style='border:none;' alt=''/></a><a href='javascript: month--;populate_titlebar()' title='Minus month' style='background-color:transparent;'><img src='./images/icon_previous.gif' style='border:none;' alt=''/></a></div>"
	document.getElementById('titlebar').innerHTML += "<div style='float:right; margin-right:4px;'><a href='javascript: month++;populate_titlebar()' title='Add month' style='background-color:transparent;'><img src='./images/icon_next.gif' style='border:none;' alt=''/></a><a href='javascript: year++;populate_titlebar()' title='Add year' style='background-color:transparent;'><img src='./images/icon_forw.gif' style='border:none;' alt=''/></a></div>"	
	document.getElementById('titlebar').innerHTML += "" + thisMonth + " " + year + "</div>"

	populate_datesbar()
}
function populate_datesbar() {
	document.getElementById('datesbar').style.width = width
	document.getElementById('datesbar').style.top = '20px'
	document.getElementById('datesbar').style.textAlign = "center"
	todayyear = today.getYear()

	browser = navigator.userAgent.toLowerCase()
	todayyear = todayyear%1900 + 1900

	// column headings
	day_titles = new Array('Su','Mo','Tu','We','Th','Fr','Sa')
	day_titles_full = new Array('Sun','Mon','Tues','Wed','Thurs','Fri','Sat')
	page = "<div style='clear:both; width:"
	page += (IE6) ? "212" : "210" ;
	page += "px; margin:4px 4px 0px 4px; cursor:default; font-weight:bold;'>"
	for (x = 0; x < day_titles.length; x++) {
		page += "<div style='float:left; width:30px; text-align:center;'>" + day_titles[x] + "</div>"
	}
	page += "<div style='clear:both; height:0px; overflow:hidden;'></div></div>"

	day = today.getDate()
	startingday = new Date(year,month,1)
	startingday = startingday.getDay()

	days = new Array('31','28','31','30','31','30','31','31','30','31','30','31');
	totaldays = days[month]
	if (month == 1 && year % 4 == 0) { totaldays++ }
	month_previous = (month == 0) ? 11 : (month-1) ;
	totaldays_previous = days[month_previous]
	if (month_previous == 1 && year % 4 == 0) { totaldays_previous++ }
	totaldays_previous = totaldays_previous - (startingday-1)
	
	rows = 6
	
	page += "<div style='width:"
	page += (IE6) ? "212" : "210" ;
	page += "px; margin-left:4px; border:1px #acacac solid; border-bottom:none; background-color:white;'>"
	for (y = 0; y < 7; y++) {
		if (y == startingday) {
			break;
		} else {
			page += "<div style='float:left; width:30px; height:30px; cursor:default; background-color:#acacac; color:#6a6a6a'><div style='padding-top:7px;'>" + (totaldays_previous++) + "</div></div>"
		}
	} 
	has_break = false
	for (x = 1; x <= totaldays; x++) {
		if ((x + startingday) != 1 && (x + startingday) % 7 == 1) {
			has_break = true
			rows--
		}
		page += "<div style='float:left; cursor:pointer; text-align:center;"
		if ((x + startingday) % 7 != 0) {
			page += " border-right:1px #acacac solid; width:"
			page += (IE6) ? "30px;" : "29px;" ;
		} else {
			page += " width:30px;"
		}
		if (has_break) {
			page += " border-top:1px #acacac solid; height:29px;"
		} else {
			page += " height:30px;"
		}
		my_title = day_titles_full[(x + startingday - 1) % 7] + " " + thisMonth + " " + x + ", " + year
		page += "' onMouseOver='this.style.backgroundColor = \"#2960cf\"; this.style.color = \"white\"; document.getElementById(\"cal_current\").innerHTML=\"" + my_title + "\"' onMouseOut='this.style.backgroundColor = \"white\";this.style.color = \"black\"; document.getElementById(\"cal_current\").innerHTML=\"\"' onClick='selectDate(" + x + "," + (month + 1) + "," + year + ")'><div style='padding-top:6px;'>" + x + "</div></div>"
	}
	z = (x + startingday) % 7
	n = 1
	if (z != 1) {
		if (z == 0) { z = 7 }
		for (z = z - 1; z < 7; z++) {
			page += "<div style='float:left; width:30px; height:30px; cursor:default; background-color:#acacac; color:#6a6a6a'><div style='padding-top:7px;'>" + (n++) + "</div></div>"
		}
		rows--
	} else {
		rows--
	}
	if (rows > 0) {
		for (z = 1; z <= (rows*7); z++) {
			page += "<div style='float:left; width:30px; height:30px; cursor:default; background-color:#acacac; color:#6a6a6a'><div style='padding-top:7px;'>" + (n++) + "</div></div>"
		}
	}
	page += "<div style='clear:both; height:1px; overflow:hidden; background-color:#acacac;'></div></div><div style='float:right; height:15px; overflow:hidden; margin:4px;'><a href='javascript: hide()' style='background-color:transparent;'><img src='./images/icon_close.gif' style='border:none;' alt=''/></a></div><div style='text-align:left; color:#6a6a6a; margin:4px; font-size:95%;' id='cal_current'>&#160;</div>"

	document.getElementById("datesbar").innerHTML = page
}
function selectDate(d,m,y) {
	d.toString().length < 2 ? d = "0" + d.toString() : d = d ;
	m.toString().length < 2 ? m = "0" + m.toString() : m = m ;
	eval ("document.getElementById('" + editfield + "_day').value = '" + d.toString() + "'")
	eval ("document.getElementById('" + editfield + "_month').value = '" + m.toString() + "'")
	eval ("document.getElementById('" + editfield + "_year').value = '" + y.toString() + "'")
	document.getElementById("calendar").style.visibility = "hidden"
}
function hide() {
	document.getElementById("calendar").style.visibility = "hidden"
}

var ajax_compat = true
var IE = (navigator.appName == "Microsoft Internet Explorer") ? true : false ;
try {
	// Firefox, Opera 8.0+, Safari
	xmlHttp = new XMLHttpRequest();
} catch (e) {
	// Internet Explorer
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			ajax_compat = false
		}
	}
}
/**
* Use AJAX to get a list of towns for the selected county
* This uses the same function as the PHP-generated towns list so that non-js enabled browsers don't get a different list
*/
function AJAX_load(file, value, return_function) {
	var xmlHttpReq = false;
	var self = this;
	if (IE) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	self.xmlHttpReq.open('GET', file + "?" + value, true);
	self.xmlHttpReq.onreadystatechange = function() {
      	if (self.xmlHttpReq.readyState == 4 && return_function) {
            return_function(self.xmlHttpReq.responseText)
        }
	}
	self.xmlHttpReq.send(null);
}

/**
* These two functions are used to get the towns list and alter the towns select innerHTML
*/
function get_counties() {
	county = document.getElementById('county').value
	return AJAX_load('ajax_counties.php', 'county=' + county, populate_counties)

}
function populate_counties(value) {
	document.getElementById('town').options.length = 0;
	my_options = value.split('---')
	for (x = 0; x < my_options.length; x++) {
		this_options = my_options[x].split('::')
		if (this_options[0] != '') {
			document.getElementById('town').options[x] = new Option(this_options[1], this_options[0]);
		}
	}
	document.getElementById('town').parentNode.style.display = 'block'
	document.getElementById('town').focus()
}

/* KEYWORD CHECKING */
var focus_field = null
var keywords = new Array("took", "thieved", "thief", "theft", "taken", "take", "stolen", "stole", "steal", "snatched", "snatch", "robbery", "robbed", "rob", "pinched", "pinch", "pick-pocketed", "pick-pocket", "nicked", "nick", "mugged", "mug", "grabbed", "grab")
function keyword_check(obj) {
	focus_field = obj
	field_value = obj.value
	var reg = new RegExp("[^a-z0-9]", "i");
	words = field_value.split(reg)
	outer_loop: 
	for (w in words) {
		for (k in keywords) {
			if (words[w].toLowerCase() == keywords[k]) { keyword_response(keywords[k]); break outer_loop; }
		}
		if (document.getElementById('tooltip_div')) {
			YAHOO.container.tooltip_div.hide();
		}
	}

}
function keyword_response(value) {
	if (value != '') {
		dimensions = my_dimensions(focus_field)
		dimensions_2 = my_dimensions(document.getElementById('main'))
		my_top = dimensions[0] + dimensions_2[0]
		my_left = dimensions[1] + dimensions[2] + dimensions_2[1] +10
		if (IE) { my_left += 290 }
		YAHOO.namespace("container");
		if (!document.getElementById('tooltip_div')) {
			my_tooltip = document.createElement('div');
			my_tooltip.setAttribute ('id', 'tooltip_div')
			document.getElementsByTagName('body')[0].appendChild(my_tooltip)
			document.getElementById('tooltip_div').style.visibility = 'hidden'
			
			YAHOO.container.tooltip_div = new YAHOO.widget.Panel("tooltip_div", { xy:[my_left,my_top], width:"300px", close:false, visible:false, draggable:false, constraintoviewport:true, zIndex:4 } );
		}
		
		document.getElementById('tooltip_div').style.textAlign = 'left'
		YAHOO.container.tooltip_div.setHeader("<span><img src='./images/warning.png' alt='' style='margin-right:5px; vertical-align:middle' />Please check your entry</span>");
		YAHOO.container.tooltip_div.setBody('<p>As you have entered the word <strong>' + value + '</strong> we believe that you may be filing a report for an item that has been stolen and not lost.</p><p>If this is the case, please report the theft at your local police station rather than with Report My Loss</p>');
		YAHOO.container.tooltip_div.render(document.body);
		YAHOO.container.tooltip_div.show();
		
		// styling - as the default doesn't work!
		document.getElementById('tooltip_div').style.background = '#efefef'
		document.getElementById('tooltip_div').style.border = '1px #bdbdbd solid'
		divs = document.getElementsByTagName('div')
		for(d in divs) {
			if (divs[d].className == 'hd') {
				divs[d].style.background = '#D92121 url(./images/stripe_warning.png) top left'
				divs[d].style.color = 'white'
				divs[d].style.fontWeight = 'bold'
				divs[d].style.padding = '5px'
			}
			if (divs[d].className == 'bd') { divs[d].style.padding = '5px' }
		}
	} else {
		if (document.getElementById('tooltip_div')) {
			YAHOO.container.tooltip_div.hide();
		}
	}
}

/**
* Validation - this just checks for empty fields that are mandatory and highlights the mandatory asterisk and gives a bold red error message at the top
* This uses JSON to do the error messages... which is added during deployment
*/
var JSONerrors = {"host_url":"dev.reportmyloss.com","no_data_true":"No form data was entered","field_match_true":"The submitted fields do not match what was expected","confirm_lost_invalid":"Please confirm the items were lost and have not been stolen","agree_to_terms_invalid":"You need to agree to the Report My Loss terms","county_empty":"A county must be selected","town_empty":"Both a county and a town must be selected","town_length":"Your town name must be 150 characters or less, you have used: ","email_confirmation_invalid":"Your email confirmation does not match the email address entered","last_had_day_invalid":"Last in owner's possession date cannot be after today's date or the date it was noticed to be lost","no_longer_had_day_invalid":"No longer in owner's possession date cannot be after today's date","where_lost_empty":"Please provide details about where the property was lost","how_lost_empty":"Please provide details about how the property was lost","where_lost_length":"Where the item was lost must be 1000 characters or less, you have used: ","how_lost_length":"How the property was lost must be 1000 characters or less, you have used: ","how_lost_invalid":"Please check your entry for how the property was lost.","captcha_empty":"Please enter the security code","captcha_length":"The captcha code that you have entered is not correct","captcha_invalid":"The captcha code that you have entered is not correct","full_name_empty":"Please enter your full name","full_name_invalid":"You must provide both your first and last name","full_name_length":"Your name must be 100 characters or less, you have used: ","date_of_birth_day_invalid":"Invalid value given for birth day","date_of_birth_month_invalid":"Invalid value given for birth month","date_of_birth_year_invalid":"Invalid value given for birth year","is_owner_invalid":"Invalid value given for owner checkbox","address_1_empty":"Please provide the first line of your address","address_1_length":"Address line 1 must be 100 characters or less, you have used: ","address_2_length":"Address line 2 must be 100 characters or less, you have used: ","address_3_length":"Address line 3 must be 100 characters or less, you have used: ","post_code_empty":"Please supply a valid UK postcode","post_code_invalid":"Please supply a valid UK postcode","post_code_length":"Your post code must be 10 characters or less, you have used: ","email_invalid":"Please check the email address that you have entered","email_length":"Your email address must be 100 characters or less, you have used: ","mobile_length":"Your mobile number must be 20 characters or less, you have used: ","home_telephone_length":"Your home telephone number must be 20 characters or less, you have used: ","work_telephone_length":"Your work telephone number must be 20 characters or less, you have used: ","home_telephone_invalid":"Please provide a home, work or mobile telephone number","mobile_invalid":"Please check the mobile phone number you have entered","work_telephone_invalid":"Please check the mobile phone number you have entered","description_length":"Description of the item must be 1000 characters or less, you have used: ","markings_length":"Distinct markings information must be 1000 characters or less, you have used: ","make_length":"Make name must be 50 characters or less, you have used: ","model_length":"Model name must be 50 characters or less, you have used: ","model_invalid":"Please check the model name you have entered","serial_number_empty":"Please enter a serial number","photograph_invalid":"Please upload a 4MB or less JPEG image","note_empty":"Please enter some additional information","note_length":"Your additional information must be 10000 characters or less, you have used: ","found_day_invalid":"Found date cannot be before the item was noticed to be lost, or after today's date","how_found_empty":"Please provide details of how and where the item was found","how_found_length":"How and where the item was found must be 1000 characters or less, you have used: "}

function validate() {
	spans = document.getElementsByTagName('span')
	valid = true
	error_string = ''
	for (x = 0; x < spans.length; x++) {
		if (spans[x].className == 'mandatory') {
			has_error = false
			if (spans[x].parentNode.getElementsByTagName('input').length > 0 && spans[x].parentNode.getElementsByTagName('input')[0].id != 'serial_number' && spans[x].parentNode.getElementsByTagName('input')[0].id != 'photograph' && spans[x].parentNode.getElementsByTagName('input')[0].className != 'button' && spans[x].parentNode.getElementsByTagName('input')[0].value == '') {
				has_error = true
				me = spans[x].parentNode.getElementsByTagName('input')[0]
			} else if (spans[x].parentNode.getElementsByTagName('textarea').length > 0 && spans[x].parentNode.getElementsByTagName('textarea')[0].value == '') {
				has_error = true
				me = spans[x].parentNode.getElementsByTagName('textarea')[0]
			} else if (spans[x].parentNode.getElementsByTagName('select').length > 0 && spans[x].parentNode.getElementsByTagName('select')[0].value == '') {
				has_error = true
				me = spans[x].parentNode.getElementsByTagName('select')[0]
			}
			if (has_error) {
				spans[x].style.color = '#ce0c0c'
				my_error = eval('JSONerrors.' + me.id + '_empty');
				error_string += "<li><a href='#' onclick='document.getElementById(\"" + me.id + "\").focus(); return false'>" + my_error + "</a></li>"
				valid = false
			} else {
				spans[x].style.color = 'black'
			}
		}
	}
	if (valid) {
		return true
	} else {
		if (!document.getElementById('error_output')) {
			var error = document.createElement('p')
			error.setAttribute('class', 'error')
			error.setAttribute('id', 'error_output')
			error_msg = document.createTextNode('There are some errors on your form. Please review and correct before continuing.')
			error.appendChild(error_msg)
			var form = document.getElementById('main_form')
			form.parentNode.insertBefore(error, form)
			document.getElementById('error_output').style.fontWeight = 'bold'
			document.getElementById('error_output').style.color = '#ce0c0c'
			var error = document.createElement('ul')
			error.setAttribute('id', 'error_list')
			form.parentNode.insertBefore(error, form)
			error_as = document.getElementById('error_list').getElementsByTagName('a')
			document.getElementById('error_list').innerHTML = '<ul class="error">' + error_string + '</ul>'
		}
		return false
	}
}

var editfield = null
window.onload = init