startList = function() {
	if (document.all&&document.getElementById) {
		topnaviRoot = document.getElementById("topnavi");
		for (i=0; i<topnaviRoot.childNodes.length; i++) {
			node = topnaviRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function centre(size,area) {
	return (area/2)-(size/2);
}

function open_window(fileName, windowName, windowWidth, windowHeight, scrollbars, resizable) {
	window.open(fileName, windowName, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=' + scrollbars + ', resizable=' + resizable + ', left=' + centre(windowWidth, screen.availWidth) + ', top=' + centre(windowHeight, screen.availHeight) + ', width=' + windowWidth + ', height=' + windowHeight);
}

function changeImage(element, car_id) {
	window.location.href = '../edit/photo_editor.asp?area=stock&amp;car_id=' + car_id + '&amp;image_old=' + element.id + '&amp;image_new=' + element.options[element.selectedIndex].value;
}

function checkDelete(element, car_id) {
	if (confirm('Are you sure you want to delete this image?\n\nYou will not be able to recover the image.') == true) {
		window.location.href = '../edit/photo_editor.asp?area=stock&amp;car_id=' + car_id + '&amp;image_old=' + element.id + '&amp;image_new=delete';
	}
}

function changeMainImage(element) {
	element = document.getElementById('picture_ref' + element);
	var elementSrc = element.src;
	var master = document.getElementById('picture_ref');
	var masterSrc = master.src;
	master.src = elementSrc;
	element.src = masterSrc;
}

function checkDate(element) {
	my_regex = /^(?:[01]?[0-9]|2[0-9](?!\/0?2)|2(?:[0-8]|9(?=\/(?:0?2\/\d{2}0[48]|[2468][048]|[13579][26])))|(?:3(?:0|1(?=\/(?:0?[13578]|1[02]))))(?!\/0?2))\/(?:0?[1-9]|1[0-2])\/(?:\d{4})$/
	if (element.value != "" && my_regex.test(element.value) == false) {
		alert("You have not entered a valid date, please try again using the \"DD/MM/YYYY\" format.")
		element.focus();
		return false;
	}
}

function toggleDisplay (element, show) {
	element.style.display = show;
	return true;
}

function theflash(movie,width,height) 
{
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">\n');
    document.write('<param name="movie" value="'+movie+'">\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="menu" value="false">\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<embed src="'+movie+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>\n');
    document.write('</object>\n');
	
}
