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 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');
	
}

function relatedLinks(theLink) {
	if (theLink != "") {
		window.open(theLink);
	}
}

function checkSignup(theForm) {
	if (theForm.signup_name.value == "") {
		alert("Please enter a value for the \"Name\" field.");
		theForm.signup_name.focus();
		return false;
	}
	
	var email_regex = /^(([^<>;()[\]\\.,;:@"]+(\.[^<>()[\]\\.,;:@"]+)*)|(".+"))@((([a-z]([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))\.)*(([a-z]([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))$/
	if (theForm.signup_email.value == "" || email_regex.test(theForm.signup_email.value) == false) {
		alert("You must provide a valid e-mail address, please try again");
		theForm.signup_email.focus();
		return false;
	}
}
