function OpenWindow(theURL,winName,features) { //v2.0
  window.open(theURL,null,features);
}


//Javascript adapted from:
//Matt Kruse <matt@mattkruse.com>
//http://www.mattkruse.com/
function sortSelect(obj)
{ 
  var o = new Array();
  for(var i=0; i<obj.options.length; i++)
    o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected);
  o = o.sort(function(a,b)
            {
              if((a.text+"")<(b.text+""))
                return -1;
              if((a.text+"")>(b.text+""))
                return 1;
              return 0;
            });
  for(var i=0; i<o.length; i++)
    obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
}

function moveSelectedOptions(from,to)
{
  for (var i=0; i<from.options.length; i++)
  {
    var o = from.options[i];
    if (o.selected)
    {
      var index=to.options.length;
      if(!o.fakevalue)
      	to.options[index] = new Option( o.text, o.value, false, false);
    }
  }

  for (var i=(from.options.length-1);i>=0;i--)
  {
    var o = from.options[i];
    if(o.selected)
      from.options[i] = null;
  }

  from.selectedIndex=-1;
  to.selectedIndex=-1;
  sortSelect(to);
}

function selectSum(obj)
{
  var sum = "";
  for (var i=0; i<obj.options.length; i++)
    sum+= obj.options[i].value + "|";
  return sum;
}

function addNewAttribute(list,item) {
	var name;
	var len;
	len = list.options.length;
	name = prompt("Enter a name for a new " + item + " attribute: ","");
	if(name != '' && name != false && name != null) {
		list.options[len] = new Option(name,name,false,false);
		list.options[len].fakevalue = true;
	}
}

function newManufacturer(list) {
	var name;
	name = prompt("Enter a name for a new manufacturer:","");
	if(name != '' && name != false && name != null) {
		var len = list.options.length;
		list.options[len] = new Option(name,name,false,false);
		list.selectedIndex = len;
	}

}

function scaleImg(img) {
	if(img.style.height == "") {
		if(img.style.temp) {
			img.style.height = img.style.temp;
		} else {
			img.style.height = '130px';
		}
	} else {
		img.style.temp = img.style.height;
		img.style.height = "";
	}
}

function enableCategory(list,button) {
	var cat;
	cat = list.options[list.selectedIndex].value;
	g("tr_"+cat).style.display = "";
	
	list.options[list.selectedIndex] = null;
	
	if(list.options.length == 1) {
		button.disabled = true;
		list.disabled = true;
	}
}




function bigImg(img) {
	var i;
	i = img.src.replace("-thumb","-full");
	g("big-image").src = i;
}


function g(id) {
	return document.getElementById(id);
}
