/*
    Copyright (c) 2005-2009 thankyou.com.au pty ltd
	All Rights Reserved
*/
/* LightWindow */
function activateLightWindow(width,height,content,title) {
	myLightWindow.activateWindow({
		href: content, 
		title: title,
		width: width,
		height : height
});
}
/* end LightWindow */
/* FAQs */
function selectFAQItem(the_id, the_panel) {
	fe = document.getElementById(the_id + "-faq");
	pe = document.getElementById(the_panel);
	if (fe.style.display == "none") {
		// hide all items
		l=pe.getElementsByTagName('div');
		c=[];
		for(i=0;i<l.length;i++){
			h=l[i].id;
			if(h.substr(h.indexOf('-')+1,h.length)=='faq') {
				c.push(h);
				document.getElementById(h).style.display = 'none';
			}
		}
		// show this item
		fe.style.display = "block";
		// adjust height of accordion panel
		ex1(pe, fe.offsetHeight);
	}
	// scroll to bottom of page
	window.scrollTo(0,99999999999);
}
function selectEvent(the_id) {
	document.getElementById("event_id").value = the_id;
}

function changeSort(webroot, the_table, sort_code, display_type) {
	switch (the_table) {
		case "telegrams":
			location.href = webroot + 'oo/oo.cfm?page=messages&sort=' + sort_code;
			break;
		case "gifts":
			location.href = webroot + 'guest/guest.cfm?page=gift&sort=' + sort_code;
			break;
		case "manage":
			location.href = webroot + 'oo/oo.cfm?page=manage&sort=' + sort_code + '&display=' + display_type;
			break;
		case "contrib":
			location.href = webroot + 'oo/oo.cfm?page=contribution&sort=' + sort_code + '&display=' + display_type + '#sectiontop';
			break;
	}
}

function confirmDeleteItem(webroot, check_id, item_id) {
	if (confirm("Are you sure you want to delete this item from your Gift Registry?\n\nAny Guest or purchase details associated with this item will also be deleted.")) {
		location.href = webroot + 'oo/a_deleteitem.cfm?check_id=' + check_id + '&item_id=' + item_id;
	}
}

function purchaseItem(the_id) {
	window.open('p_purchaseitem.cfm?the_id=' + the_id, 'purchaseitem','width=500,height=450,top=50,left=50');
}

function switchDisplay(webroot, display_type) {
	location.href = webroot + 'oo/oo.cfm?page=manage&display=' + display_type;
}

function submitPayment(the_btn) {
	document.getElementById(the_btn.id).disabled = "disabled";
	document.getElementById("paymentForm").submit();
}

function comingSoon() {
	alert("Service Coming Soon!");
}

function disableEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		return false;
	}
}

function prepareArgs() {
	oArgs = new Object();
	for(i=0;i<arguments.length;i=i+2) {
		eval("oArgs." + arguments[i] + " = \"" +	(arguments[i+1].toString()) + "\";");
	}
	return oArgs;
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function confirmDeleteTelegram(webroot, check_id, telegram_id, the_name) {
	if (confirm("Are you sure you want to delete the telegram from " + the_name + "?")) {
		location.href = webroot + 'oo/a_deletetelegram.cfm?check_id=' + check_id + '&telegram_id=' + telegram_id;
	}
}

function overlay() {
	e1 = document.getElementById("overlay");
	e1.style.visibility = (e1.style.visibility == "visible") ? "hidden" : "visible";
}
function showDemoAlert() {
	alert('You cannot perform this function from the demo site.\nTo return to the previous screen click OK.');
}
function swapImage(o, newsrc) {
	o.src = newsrc;
}