var submitRolls = new Object();

function submitroll(src, oversrc, name)
{
  this.src=src;
  this.oversrc=oversrc;
  this.name=name;
  this.alt="";
  this.write=submitroll_write;
}

function submitroll_write()
{
var thisform = 'document.forms[' + (document.forms.length - 1) + ']';
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;

document.write
(
'<A onMouseOver="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
' onMouseOut="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' + 
' HREF="javascript:'
);

if (this.sendfield)
{
if (! this.sendvalue)
this.sendvalue = 1;
document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
}

document.write(thisform + '.submit();void(0);"');
if (this.msg)document.write(' onClick="return confirm(\'' , this.msg, '\')"');
document.write('>');

document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt + '" BORDER=0 NAME="' + this.name + '"');
if (this.height)document.write(' HEIGHT=' + this.height);
if (this.width)document.write(' WIDTH='  + this.width);
if (this.otheratts)document.write(' ' + this.otheratts);
document.write('></A>');
if (this.sendfield)
{
document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield + '">');
document.forms[document.forms.length - 1].elements[this.sendfield].value='';
}
}
/*
function quickOrderDialog(frmNum)
{
	var x = window.confirm("Вы выбрали:\n\n" + document.forms["frm"+frmNum].code.value + " (" + document.forms["frm"+frmNum].count.value + " шт.)\n\nВы хотите совершить быстрый заказ?");
	if(x)
	{
		document.forms["frm"+frmNum].action = 'quickorder.php';
		document.forms["frm"+frmNum].target = '_self';
	}
	document.forms["frm"+frmNum].submit();
}

function orderOK(frmNum)
{
	var x = alert("В корзину добавлено:\n\n" + document.forms["frm"+frmNum].code.value + " (" + document.forms["frm"+frmNum].count.value + " шт.)");
	document.forms["frm"+frmNum].submit();
}
*/
/*
function orderPopUp(frmNum,minQ)
{
	var quantity = prompt("Вы хотите положить в корзину " + document.forms["frm"+frmNum].code.value + ".\nМинимальное количествово для заказа - " + minQ + " шт.\nУкажите количество, которое Вы хотите заказать:",minQ);
	document.forms["frm"+frmNum].count.value = quantity;
	document.forms["frm"+frmNum].submit();
}
*/
function orderPopUp(frmNum,minQ)
{
	var w = 800, h = 600;
	var popW = 350, popH = 100;

	if (document.all)
	{
		 w = document.body.clientWidth;
		 h = document.body.clientHeight;
	}
	else if (document.layers)
	{
		 w = window.innerWidth;
		 h = window.innerHeight;
	}

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

  popupWin = window.open('popup.php?name=' + document.forms["frm"+frmNum].code.value+'&minQ=' + minQ + '&frmNum=' + frmNum, 'popup', 'width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
  if (window.focus)
	{
		popupWin.focus();
	}
}
function orderPopUpSubmit(frmNum)
{
	opener.document.forms["frm"+frmNum].count.value = document.forms['quantityForm'].quantity.value;
  opener.document.forms["frm"+frmNum].submit();
	self.close();
}
