var xmlhttp;

// auto population of secondary instrument list
function pop_instr_search_box(srchtype,dropwidth) {
// takes selected option from _search_instr_cat select and populates
//    _search_instr_type using data from hidden input _search_typelist

	var tmpdata;
 	var instrLine;
 	var formtype='';
 	if (srchtype=="p") {
		formtype="print";
 	}
	var selIdx = eval('document.' + formtype + 'searchform._search_instr_cat.selectedIndex');
	var selVal = eval('document.' + formtype + 'searchform._search_instr_cat.options[' + selIdx + '].value');
	loadSearchData('apopinstrlist.php?id=' + selVal + '&t=' + srchtype + '&w=' + dropwidth,srchtype);
}  // end function pop_search_box

function loadSearchData(url,searchtype)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  switch (searchtype) {
  	case 'i' :
  	  xmlhttp.onreadystatechange=pop_instr_inst_list;
  	break;
  	case 'p' :
  	  xmlhttp.onreadystatechange=pop_print_inst_list;
  	break;
  }

  xmlhttp.open("GET",url,true);
  xmlhttp.send(searchtype);

  }

}

function pop_instr_inst_list()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    	document.getElementById('instr_inst_search_box').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}

function pop_print_inst_list()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    	document.getElementById('print_inst_search_box').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
// end auto population code

function clearsearchkwdbox() {
// clears _searchkeyword text box if text reads "keywords" to allow user to input
//    keywords.
	if (document.searchform._searchkeyword.value="keywords") {
		document.searchform._searchkeyword.value="";
	}
}

function clearsearchtext(formitem) {
// clears textinput item - resets the value to blank.
	eval('document.searchform.' + formitem + '.value=""');
}

function viewitem(itemid) {
	document.searchresultselector._itemid.value=itemid;
	document.searchresultselector.submit();
}



//   PRINTED MUSIC FUNCTIONS

// Payment functions


function paypal_buynow(itemid){
	window.location='pp_buynow_form.php?itemid=' + itemid;
}
function invoice_request(itemid){
	window.location='request_invoice.php?itemid=' + itemid;
}