function load_showcase_list () {
	var f 	= document.user_form;
	var ulf = document.user_list_form;

	create_xmlhttp_request(1);

	xmlhttp2.open("GET",'/cgi-bin/customers/products.cgi?command=list showcase management');
	xmlhttp2.onreadystatechange=function(){
		if (xmlhttp2.readyState==4) {
			if (xmlhttp2.status==200) {
				document.getElementById('showcase_list').innerHTML = xmlhttp2.responseXML.getElementsByTagName('showcase_list')[0].firstChild.data;
			}
		}
	}	
	xmlhttp2.send(null);
}


function load_showcase_management_detail (sid) {
	get_xml('/cgi-bin/customers/products.cgi?command=list showcase management items&showcase_id='+sid,'showcase_detail');

}

function load_view_showcase(scid,ref_sid) {
	document.getElementById('showcase_list').innerHTML='Please browse to create your own showcases.';
	get_xml('/cgi-bin/customers/products.cgi?command=view showcase management items&showcase_id='+scid+'&ref_sid='+ref_sid,'showcase_detail');
}

function delete_showcase (sid) {
	
	if (window.confirm('Are you sure you wish to delete this showcase?')) {
	
//		get_xml('/cgi-bin/customers/products.cgi?command=delete showcase&showcase_id='+sid,'showcase_list');
		create_xmlhttp_request(1);
	
		xmlhttp2.open("GET",'/cgi-bin/customers/products.cgi?command=delete showcase&showcase_id='+sid);
		xmlhttp2.onreadystatechange=function(){
			if (xmlhttp2.readyState==4) {
				if (xmlhttp2.status==200) {
					document.getElementById('showcase_list').innerHTML = xmlhttp2.responseXML.getElementsByTagName('showcase_list')[0].firstChild.data;
		
					document.getElementById('showcase_detail').innerHTML = '';
					// setTimeout("load_showcase_list()",2000);
				}
			}
		}	
		xmlhttp2.send(null);
	}	
	
}

function save_showcase (sid) {
	var name = document.showcase_form.name.value;
	
	var f = document.showcase_list_form;
	
	if (parseInt(f.profile_id.value) == 0) {
		alert('Please login to save these changes to your account. Without logging in your changes will be lost when you close your browser.');
	}
	
	create_xmlhttp_request(1);

	xmlhttp2.open("GET",'/cgi-bin/customers/products.cgi?command=save showcase&showcase_id='+escape(sid)+ '&name=' + escape(name)+'&ref_sid='+escape(f.ref_sid.value));
	xmlhttp2.onreadystatechange=function(){
		if (xmlhttp2.readyState==4) {
			if (xmlhttp2.status==200) {
				document.getElementById('showcase_list').innerHTML = xmlhttp2.responseXML.getElementsByTagName('showcase_list')[0].firstChild.data;
				document.getElementById('showcase_detail').innerHTML = xmlhttp2.responseXML.getElementsByTagName('content')[0].firstChild.data;
				f.ref_sid.value='';
			}
		}
	}	
	xmlhttp2.send(null);
}

function send_showcase () {
	
	var f 				= document.showcase_form;
	var n 				= f.name.value;
	var sid 			= f.showcase_id.value;
	var e				= f.showcase_email.value;
	
	if (e == '') {
		alert('Please supply an email address.');
		return false;
	}
	
	if (!validate_email(f.showcase_email.value)) {
		return false;
	}
	else {
		create_xmlhttp_request();
	
		xmlhttp.open("GET",'/cgi-bin/customers/send_showcase.cgi?command=send showcase&showcase_id='+sid+ '&name=' + n + '&showcase_email=' + e);
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4) {
				if (xmlhttp.status==200) {
	
					alert('Showcase has been sent via email. Thank you.');				
				}
			}
		}	
		xmlhttp.send(null);
	}
}