function mod_check(pref, ProdID)
{
s=document.getElementById( pref+ProdID );
if ('[object]' != s) return true;

if ( (-1 == s.selectedIndex) || 0 == s.selectedIndex)
{
alert('Пожалуйста, выберите модификацию товара');
return false;
}
else return true;
}

function p_href(t, ProdID)
{
s=document.getElementById('s'+ProdID);
if('[object]'==s && (-1 != s.selectedIndex))
t.href += '?ModID='+s.options[s.selectedIndex].value;
} // func p_href


function box(id)
{
hdc = eval("document.cook.cm_"+id+".checked");
if ((hdc) && navigator.cookieEnabled)
{
	setCookie("cmp["+id+"]", "1", false, thisPath);
}
else if ((!hdc) && navigator.cookieEnabled)
{
	deleteCookie("cmp["+id+"]", thisPath);
}
} // box()

function setCookie(name, value, expires, path, domain, secure)
{
var newCookie = name + "="	+ escape(value) +
((expires)	? ";expires="	+ expires.toGMTString() : "") +
((path)		? ";path="		+ path					: "") +
((domain)	? ";domain="	+ domain				: "") +
((secure)	? ";secure"								: "");
document.cookie = newCookie;
}

function getCookie(name)
{
var prefix = name + "=";
var start = document.cookie.indexOf(prefix);
if (start == -1)
	return null;
var end = document.cookie.indexOf(";", start+prefix.length);
if (end == -1)
	end = document.cookie.length;
var value = document.cookie.substring(start + prefix.length, end);

return unescape(value);
}

function deleteCookie(name, path, domain)
{
if (getCookie(name))
{
document.cookie = name + "=0" +
";expires=Thu, 01-Jan-70 00:00:01 GMT" +
((path)		? ";path="		+ path		: "") +
((domain)	? ";domain="	+ domain	: "");
}
}

function qs()
{
	if (0 == document.qsf.q.value.length)
		return false;
	else
		return true;
} // qs()


//Catalog
img = [];

function flip(hid)
{
h=document.getElementById('s' + hid);
modID = h.options[h.selectedIndex].value;

if (0 == modID)
{
// default image
prodID = h.options[h.selectedIndex].id;
i = document.getElementById('i'+hid);

i.src = '/i/prod/' + prodID + '.jpg';
return true;
}

v = img[modID];
if ('1'==v[0])
{
// exists
i = document.getElementById('i'+hid);
i.src = '/i/prod/' + v[1] + '/' + modID + '.jpg';

}
else
{
// not exists
h.outerHtml = '<div class="modArt">' + v[2] + '</div>';

}
}


function op(prodID)
{
window.open('/mods.html?ProdID='+prodID);
}


function ret(ProdID,w)
{
val = '';
f=w.document.forms['mod_form']['ModID'+ProdID];

if (f.value)
val = f.value;
else
for(var i=0; i < f.length; i++)
{
	if (f[i].checked == true)
	{
	val = f[i].value;
	break;
	}
}

if (''==val) return false;
w.opener.document.getElementById('s'+ProdID).selectedIndex = val;
w.opener.flip(ProdID);
w.self.close();
}


