/* ========================================================
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                           hisa_cart module                                //
//                   <http://hisacart.chushokigyo.net/>                      //
//  ------------------------------------------------------------------------ //
*/

function openPreviewWindow(url,name,width,height)
{
	var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
	new_window = window.open(url, name, options);
	window.self.name = "main";
	new_window.focus();
}

function send_cart_input(f)
{
	var n = parseInt(f.gid.value);
	var m = parseInt(f.purchase.value);
	var s = parseInt(f.stock.value);
	var alart = f.alart.value;
	var alart2 = f.alart2.value;

	if (m<=0) {
		window.alert(alart);
		f.purchase.value = 1;
		location.href = "index.php?function=good&item="+n; 
		return false;
	}

	if (m <= s) {
		f.submit();
	} else {
		window.alert(alart2);
		f.purchase.value = 1;
		location.href = "index.php?function=good&item="+n; 
		return false;
	}
	return true;
}

function send_cart_edit(f)
{
	var n = parseInt(f.gid.value);
	var m = parseInt(f.stock.value);
	var v = parseInt(f.hisacart_buyuser.value);
	var s = parseInt(f.editstock.value);
	var alart = f.alart.value;
	var alart2 = f.alart2.value;


	if (m<=0) {
		window.alert(alart);
		return false;
	}

	if (s <= m+v) {
		f.fno.value = 1;
		f.submit();

//		location.href = "index.php?function=cartedit&item="+n+"&ses="+str+"&v="+v+"&s="+s;
		return true;
	} else {
		window.alert(alart2);
		f.stock.value = v;
		return false;
	}
}

function send_cart_delete(f)
{
	var str = f.alart3.value;
	if (confirm(str)) {
		f.fno.value = 2;
		f.submit();
		return true;
	} else {
		f.editstock.focus();
		return false;
	}
}
function send_confirm_del(f)
{
	var str = f.alart4.value;
	if (confirm(str)) {
		f.submit();
		return true;
	} else {
		return false;
	}
}

function sendok(f)
{
	f.submit();
}

function exMenu(tName)
{
	tMenu = document.all[tName].style;
	if (tMenu.display == 'none') tMenu.display = "block"; else tMenu.display = "none";
}



