function CategoryChange(thisForm,id) {
	if(id!=-1)
		checkList[id]=!checkList[id];
	for(i=0,c=0,t='' ; i<checkList.length ; i++)
		if(checkList[i]) {
			if(t.length)
				t+=',';
			t+=dataIds[i];
			c++;
		}
	oldValue=thisForm.elements['id__data_categories__name'].options[thisForm.id__data_categories__name.selectedIndex].value;
	ccc=0;
	for(cc=0 ; cc<cat.length ; cc++) {
		needCat=CheckCat(cc,t);
		if(needCat) {
			if(ccc==0) {
				ccc++;
				thisForm.id__data_categories__name.length=ccc;
				thisForm.elements['id__data_categories__name'].options[ccc-1].text='Select';
				thisForm.elements['id__data_categories__name'].options[ccc-1].value='*';
			}
			ccc++;
			thisForm.id__data_categories__name.length=ccc;
			thisForm.elements['id__data_categories__name'].options[ccc-1].text=cat[cc];
			thisForm.elements['id__data_categories__name'].options[ccc-1].value=ids[cc];
		}
	}
	for(i=0 ; i<thisForm.id__data_categories__name.length ; i++)
		if(thisForm.elements['id__data_categories__name'].options[i].value==oldValue) {
			thisForm.id__data_categories__name.selectedIndex=i;
			break;
		}

	if(c==0) {
		thisForm.id__data_categories__name.length=1;
		thisForm.elements['id__data_categories__name'].options[0].text='Please select an application first';
		thisForm.elements['id__data_categories__name'].options[0].value='*';
		return;
	}
	if(ccc==0) {
		thisForm.id__data_categories__name.length=1;
		thisForm.elements['id__data_categories__name'].options[0].text='No common category';
		thisForm.elements['id__data_categories__name'].options[0].value='*';
	}
}

function CheckCat(cat,t) {
	app0=appl[cat].split(",");
	app1=t.split(",");
	
	for(a=0 ; a<app1.length ; a++) {
		found=false;
		for(b=0 ; b<app0.length ; b++)
			if(app0[b]==app1[a])
				found=true;
		if(found==false)
			return false;
	}
	return true;
}

function MenuChangeCategory(url,theForm) {
	id=theForm.category[theForm.category.selectedIndex].value;
//	if(id>0)
		document.location.href=url+'&category='+id;
//	else
//		document.location.href=url;
}

function MenuChangeLicense(url,theForm) {
	id=theForm.license[theForm.license.selectedIndex].value;
	if(id>=0)
		document.location.href=url+'&license='+id;
	else
		document.location.href=url;
}

function MenuChangePlatform(url,theForm) {
	id=theForm.platform[theForm.platform.selectedIndex].value;
	if(id>=0)
		document.location.href=url+'&platform='+id;
	else
		document.location.href=url;
}

function MenuChangeSort(url,theForm) {
	id=theForm.sortby[theForm.sortby.selectedIndex].value;
	document.location.href=url+'&sortby='+id;
}


