
checkedItems = 0;
changedqnts = 0;


function applyform(cmd) {

var a = document.results;
a.command.value = cmd;

var params = "toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=150";

if (cmd == 'recalc')
	{
	 if (changedqnts == 0)
		{
		 alert("Nothing to recalculate. You didn't change the quantity.");
		 return false;
		}
	 else
	 	{
	 	 document.results.submit();
	 	} 
	}
else
	{
	 if ((changedqnts == 1) && (cmd == 'apply'))
	 	{
	 	 alert("You've changed the quantity. Click Recalculate button to see new total cost.");
		 return false;
	 	}
	else
		{
		if (checkedItems != 0)
		    {
		     	
			str = "";
			
			for (i=0;i<a.elements.length;i++)
				{
				 if ((a.elements[i].type.toLowerCase() != "checkbox") && (a.elements[i].type.toLowerCase() != "hidden")) continue;
				 if ((a.elements[i].type.toLowerCase() == "checkbox") && ( ! a.elements[i].checked)) continue;
				 str += "&" + a.elements[i].name + "=" + a.elements[i].value;
				}

			str = js_path + "usercart.cgi?" + str.slice(1);
			
		     if ("del_favor delete apply".indexOf(cmd) < 0)
		    	{
			OW(str,'newwin',params);
			checkedItems = 0;
			document.results.reset();
		    	}
		    else
		    	{
		    	if (cmd == 'del_favor')
		    		{
		    		document.results.target="";
		    		}
		    	document.results.submit();
		    	}
		    }
		else
		    {
		    alert("You didn't choose an item");
		    return false;
		    }
	   }
	}
}


var ie_compat = (document.all)?true:false

var plain_str = /[^\s+]/;
var email_str = /^\S+@\S+\.\S+$/;

var s;

/*
var colCounter, rowCounter, colWidth;
var s;

colCounter=(screen.availWidth<1024)?3:4;
colWidth=(screen.availWidth<1024)?33:25;
x=(manufacturer_list.length-1)%colCounter;
rowCounter=(manufacturer_list.length-x)/colCounter;
rowCounter=(x==0)?rowCounter+1:rowCounter;
*/


var params = "toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=150";


function print_manuf_list() {

s = "";

while (typeof(manufacturer_list_loaded) == 'undefined') {}

var cnt = 1;
for (i=1; i<manufacturer_list.length; i++) {
	if ( cnt <= rowCounter ) {
		if ( cnt==1 ) { s += "<td width=" + colWidth + "%>" }
		s += "<nobr><a href=\"models.cgi/"+manufacturer_list[i][0]+"//\" class=\"big\">"+manufacturer_list[i][1]+"</a></nobr><BR>\n";
		if ( cnt==rowCounter ) { s += "</td>" }
		cnt++;
		}
	else { cnt = 1 }
}


s = "<p><table cellpadding=0 cellspacing=0 border=0 width=100%><tr valign=top>" + s + "</tr></table></p>"

if (ie_compat) {
//	alert(document.getElementById('manufacturers'))
	document.all['manufacturers'].innerHTML = s;
}
else {
//	alert(s);
	tmp = document.getElementById('manufacturers');
	tmp.text = "!!!";
//	alert(tmp);
//	tmp.open();
//	tmp.write(s);
//	tmp.close();
}

/*
var cnt = 1;
for (i=0; i<manufacturer_list.length; i++) {
	if ( cnt <= rowCounter ) {
		if ( cnt==1 ) { s += "<td>" }
		var ID = list_name+"[i][0]";
		var name = list_name+"[i][1]";
		s += "<nobr><a href=\"search.cgi/"+ID+"//\">"+name+"</a></nobr><BR>\n";
		if ( cnt==rowCounter ) { s += "</td>" }
		cnt++;
		}
	else { cnt = 1 }
}
*/


}

function check_fill() {

var i = document.common_search_form;
var s = js_path + "search.html";

if ((i.text.value == '') && (i.suppl_id.selectedIndex == 0) && (i.manuf_id.selectedIndex == 0))
	{
	return void(0);
	}
else
	{
	/*s += i.manuf_id.options[i.manuf_id.selectedIndex].value + "/" + i.suppl_id.options[i.suppl_id.selectedIndex].value + "/" + i.text.value + "//";
	window.location = s;*/
	return true;
	}
}

function check_login() {

var i = document.userreg;

if ((i.login.value == '') || (i.password1.value == ''))
	{
	alert("Enter login and password for registration!");
	return false;
	}
else
	{
	document.userreg.submit();
	return true;
	}
}


function OW(theURL,winName,features) {

features = features+",left="+(screen.availWidth/2-150)+",top="+(screen.availHeight/2-75);
var w=window.open(theURL,winName,features);
w.focus();
}


function check_ways() {

var i = document.forms['another_search_form'].url;
if ((i.selectedIndex != 0) && (i.selectedIndex != 1) && (i.selectedIndex != (i.length-1))) { window.location=i.value; } else { document.forms['another_search_form'].reset(); }

}



