/*

  eShox 4 Commerce Solution
  http://www.eshox.com/
  
  Copyright (c) 2003-07, Secure.CC Ltd. All rights reserved.

  SOFTWARE LICENSE INFORMATION

  http://www.eshox.com/license.html

  PLEASE READ THE SECURE.CC SINGLE USE SOFTWARE LICENSE AGREEMENT (HEREIN, THE "LICENSE") 
  CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING OR USING THE 
  SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE TERMS OF THE LICENSE.

*/

function submit_form(thisnode) {
	while(thisnode) {
		if (thisnode.tagName.toLowerCase() == 'form') break;
		thisnode = thisnode.parentNode;
	}
	if (thisnode.onsubmit && !thisnode.onsubmit(thisnode)) return false;
	return thisnode.submit();
}

function checkAll(checkClass) {
	var checkboxes = document.getElementsByTagName("INPUT");
	for (var x=0; x<checkboxes.length; x++)
		if (checkboxes[x] != checkClass && checkboxes[x].className == checkClass.className)
			checkboxes[x].checked = checkClass.checked;
	checkClass.blur();
	return true;
}

function get_checked(theField) {
	if (theField.length == 1) {
		return theField.form[theField.name].value;
	} else for (var i=0; i < theField.length; i++)
		if (theField[i].checked)
			return theField[i].value;
	return false;
}

function popupUpload(fieldname, image) {
	url = 'popup_upload.php?field=' + fieldname;
	if (image) url += '&action=change&pngimage=' + image;
	makeWindow(url, 240, 330, ((window.screen.width/2) - 160), ((window.screen.height/2) - 90));
}

function popupOption(fieldname, product_id) {
	url = 'popup_option.php?field=' + fieldname + '&products_id=' + product_id;
	makeWindow(url, 320, 480, 20, ((window.screen.height/2) - 240));
}

function go_url(theURL) {
	document.location.href = theURL;
}

function print_invoice() {
	if (parent['invoiceFrame'] && parent['invoiceFrame'].location) parent['invoiceFrame'].location.href = document.location.href+(document.location.href.indexOf('?') > 0 ? '&' : '?')+'print=true';
	if (parent['invoiceLayer'] && parent['invoiceLayer'].location) parent['invoiceLayer'].location.href = document.location.href+(document.location.href.indexOf('?') > 0 ? '&' : '?')+'print=true';
	return false;
}
