var http_request = false;

function selval(s) {
  return s.options[s.selectedIndex].value;
}

function seltext(s) {
  tmpElement = document.getElementById(s);
  return tmpElement.options[tmpElement.selectedIndex].text;
}

function makeRequest(url) {
 if (window.XMLHttpRequest) {
  // Mozilla, Safari,...
  http_request = new XMLHttpRequest();
 } else if (window.ActiveXObject) {
   // IE
  http_request = new ActiveXObject("Microsoft.XMLHTTP");
 }
 http_request.onreadystatechange = alertContents;
 http_request.open('GET', url, true);
 http_request.send(null);
}

function alertContents() {
 if (http_request.readyState == 4) {
  if (http_request.status == 200) {
    //alert(http_request.responseText);
    eval(http_request.responseText);
    //document.selector1.series_drop.value = http_request.responseText;
   } else {
    alert('There was a problem with the request. '+http_request.status);
   }
  }
 }
function clearOptions(selectId) {
	//alert('clearing '+selectId);
	document.getElementById(selectId).options.length=0;
//	for (i = 0; i < document.getElementById(selectId).options.length; i++){
//document.getElementById(selectId)[i].text = "";
//document.getElementById(selectId)[i].value = "";
//      document.getElementById(selectId)[i] = null;
//}
}
function addOption(selectId, val, txt) {
   //alert('adding option');
   var objOption = new Option(txt, val);
   document.getElementById(selectId).options.add(objOption);
}
function showProduct(mfgname,seriesname,modelname,id) {
	url = 'printer_products_'+id+'.html';
	//url = 'printers_'+encodeURI(mfgname)+'_'+encodeURI(seriesname)+'_'+encodeURI(modelname)+'_main_'+id+'.html';
	//alert(url);
	//document.location = 'printers_'+mfgname+'_'+seriesname+'__main_'+id+'.html';
	document.location = url;
}

// functions added by jose.
function showProductNew(mfgid,seriesname,modelname,id) {
	// TODO for Jose: code confusing, clear it out 
	if (mfgid>0 && seriesname!=null && seriesname!="-- select series --" && modelname!=null && id==0) {
		url = 'manufacturer_printers_'+mfgid+'.html#'+seriesname;
		//'printers.'+mfgname+'.html#'+seriesname;
	}
	else {
		if (id > 0) { 
			url = 'printer_products_'+id+'.html'; 
		}
		if (id == 0 && mfgid>0) { // && seriesname=="-- select series --"
			url = 'manufacturer_printers_'+mfgid+'.html';
		}
	}
	//alert(url);
	//location.href = url;
	document.location = url;
	
}
function disableSubmitButton(buttonId) {
	document.getElementById(buttonId).disabled = true;
}
function enableSubmitButton(buttonId) {
	document.getElementById(buttonId).disabled = false;
}
// end functions added by jose. 
