function writeFooterContent() {
	var d, s = "COPYRIGHT &copy; ";
	d = new Date();
	s += d.getFullYear();
	s += " KIA MOTORS CORPORATION";
	document.write("<p class='copyright'>" + s + "</p>");
}
function showPopup(url, name, width, height, scroll, resizable, statusbar, screenpos) {
	var Xwin = width;
	var Ywin = height;
	var Xsize = screen.availWidth;
	var Ysize = screen.availHeight;
	var Xpos = 0;
	var Ypos = 0;
	switch(screenpos) {
		case "topleft":
			Xpos = 0;
			Ypos = 0;
			break;
		case "topright":
			Xpos = Xsize - width;
			Ypos = 0;
			break;
		case "bottomleft":
			Xpos = 0;
			Ypos = Ysize - height;
			break;
		case "bottomright":
			Xpos = Xsize - width;
			Ypos = Ysize - height;g
			break;
		default:
			Xpos = (Xsize - width) / 2;
			Ypos = (Ysize - height) / 2;
			break;
	}
	var popwin;
	var opts = "status=" + statusbar + ",resizable=" + resizable + ",scrollbars=" + scroll + ",height=" + Ywin + ",width=" + Xwin + ",left=" + Xpos + ",top=" + Ypos;

	popwin = window.open(url, name, opts);
	if (popwin != null) {
		popwin.focus();
	} else {
		alert("To continue, you must disable any popup blockers that are currently active, or at least allow popups for this site.");
		//if (confirm("We cannot open a popup window automatically, click on OK to open the webpage in a normal window, otherwise click CANCEL to stay on this page.\n\nNote: user experience may change as a result of viewing popup webpages in normal windows.")) {
		//	location.href = url;
		//}
	}
}
function showPopupSmall(url, name) {
	showPopup(url, name, 300, 240, 1, 1, 1, 'default');
}

function showPopupLarge(url, name) {
	showPopup(url, name, 640, 480, 1, 1, 1, 'default');
}

function changeStyle(element, strClass) {
	element.className = strClass;
}
function doRowMouseOver(rowIdentifier) {
	changeStyle(rowIdentifier, "rowMouseOver");
}
function doRowMouseOut(rowIdentifier) {
	changeStyle(rowIdentifier, "rowMouseOut");
}
function pickDate(formControlName, theValue) {

/*
	alert(formControlName);
	alert(theValue);
*/
	prefix = "";
	if ((formControlName != "insertionDate") && (formControlName != "copyDeadline")) {
		prefix = "_ctl1_"
	}
	theFormInputBox = window.opener.document.getElementById(prefix + formControlName);
	theFormInputBox.value = theValue;
	window.close();
}
function preloadNavImages() {
	MM_preloadImages('/images/common/navbuttons/home-down_btn.gif','/images/common/navbuttons/services-down_btn.gif','/images/common/navbuttons/mymarketing-down_btn.gif','/images/common/navbuttons/marketres-down_btn.gif','/images/common/navbuttons/latestnews-down_btn.gif');
}
function navMouseOver(theImage) {
	theImage.src = newReplace(theImage.src, "_btn.gif", "-down_btn.gif");
}
function navMouseOut(theImage) {
	theImage.src = newReplace(theImage.src, "-down_btn.gif", "_btn.gif");
}
function newReplace(t_str, t_x, t_y) {
	var t_ret = "",
	t_str = String(t_str), 
	t_xI;
	while((t_xI = t_str.indexOf(t_x)) != -1) {
		t_ret += t_str.substring(0, t_xI) + t_y;
		t_str = t_str.substring(t_xI + t_x.length);
	}
	return t_ret+t_str;
}

var timerID = null;
var delay = 1000;

function changeUrl(theUrl) {
	timerID = self.setTimeout("changeUrl2(" + theUrl + ")", delay);
}
function changeUrl2(theUrl) {
	location.href = theUrl;
}
function submitForm(url, name) {
	showPopup(url, name, 300, 150, 0, 0, 1, 'default');
}
function openRichTextEditor(theFormSource) {
	showPopup("/fckeditor/edit.asp?source=" + theFormSource + "", "rte", 640, 480, 0, 0, 0, 'default');
}
function showConfirm() {
	if (confirm("Are you sure?")) return true;
	else return false;
}
function getCookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}
function setCookie(name, value, expires, path, domain, secure) {
	path = "/";
	document.cookie = name + "=" +escape(value) +
	((expires) ? ";expires=" + expires.toGMTString() : "") +
	((path) ? ";path=" + path : "") + 
	((domain) ? ";domain=" + domain : "") +
	((secure) ? ";secure" : "");
}

var today = new Date();
var expires = new Date(today.getTime() + (365 * 86400000));

function pickRandomNumber(num) {
	return Math.round(num*Math.random());
}
function arrayShuffle(u_array, n) {
	var i, j, k;
	var temp;
	for (i = 0; i < n; i++)
	for (j = 0; j < u_array.length; j++) {
		k = Math.floor(Math.random() * u_array.length);
		temp = u_array[j];
		u_array[j] = u_array[k];
		u_array[k] = temp;
	}
}
function cancelEditArticle(theForm) {
	theForm.action = "cancelEdit.asp";
	theForm.submit();
}
function cancelEditCategory(theForm) {
	theForm.action = "cancelEdit.asp";
	theForm.submit();
}
function editNews(NewsID) {
	if (NewsID == "new") {
		// showPopup("add.asp", "AddNewsPage", 640, 480, 1, 1, 0, 'default');
		location.href = "add.asp";
	} else {
		// showPopup("edit.asp?NewsID="+NewsID, "EditNewsPage", 640, 480, 1, 1, 0, 'default');
		location.href = "edit.asp?NewsID="+NewsID;
	}
}
function deleteNewsEntry(theForm) {
	if (confirm("Are you sure?")) {
		document.forms["editForm"+theForm]["delete"].value = "yes";
		document.forms["editForm"+theForm].submit();
	}
}
function openSubmitWindow() {
	showPopup("about:blank", "savePage", 300, 150, 0, 0, 1, 'default');
}
function checkSupportDetails(f) {
	msg = "";
	if (f["n"].value == "") {
		msg += "You didn't specify your Name;\n";
	}
	if (f["e"].value == "") {
		msg += "You didn't specify your Email address;\n";
	}
	if (f["pr"].value == "") {
		msg += "You didn't specify your problems that require assistance;\n";
	}
	if (msg != "") {
		msg = "You cannot continue because:\n\n" + msg + "\nClick OK and go back and fill in all required fields.";
		alert(msg);
		return false;
	} else {
		var ms;
		today = new Date();
		ms = Date.parse(today)
		ms += today.getMilliseconds();
		f["id"].value = ms;
		return true;
	}
}
function validateAccountForm() {
	d = document.forms["accForm"];
	if (d["thePassword1"].value != d["thePassword2"].value) {
		alert("Passwords don't match!");
		d["thePassword1"].focus();
		return false;
	}
	return true;
}
function pick(thePath, theFile) {
	window.opener.SetUrl("" + thePath + "" + theFile + "", 11, 12, "alt text required");
	window.close();
}

function submitForm(theForm) {

	var sMsg = "";

	if (theForm.title.value  == "") {
		sMsg = sMsg + "Please enter your title.\n";
	}
	if (theForm.forename.value == "") {
		sMsg = sMsg + "Please enter your forename.\n";
	}
	if (theForm.surname.value == "") {
		sMsg = sMsg + "Please enter your surname.\n";
	}
	if (theForm.house.value == "") {
		sMsg = sMsg + "Please enter your house name/no.\n";
	}
	if (theForm.address1.value == "") {
		sMsg = sMsg + "Please enter a street name\n";
	}
	if (theForm.town.value == "") {
		sMsg = sMsg + "Please enter a town.\n";
	}
	if (theForm.county.value == "") {
		sMsg = sMsg + "Please enter a county.\n";
	}

	var sEmail = theForm.email.value;
	if (sEmail == "") {
		sMsg = sMsg + "Please enter an email address.\n";
	} else {
		if (sEmail.indexOf("@") == -1) {
			sMsg = sMsg + "Invalid email address.\n";
		}
	}

	if (!(
		theForm.picanto.checked || 
		theForm.rio.checked || 
		theForm.carens.checked ||
		theForm.magentis.checked || 
		theForm.sportage.checked || 
		theForm.sorento.checked || 
		theForm.carnival.checked || 
		theForm.ceed.checked || 
		theForm.ceedsw.checked || 
		theForm.ceed_commercial.checked || 
		theForm.sportage_commercial.checked || 
		theForm.sorento_commercial.checked
	)){
		sMsg = sMsg + "Please select a brochure!"
	}

	if (sMsg == "") {
		return true;
	} else {
		alert(sMsg);
		return false;
	}
}
