
top.searchSubmitted = 0;

function dosearch(tp){
	if(checkSearchForm(tp))
		document.searchForm.submit();
}

function setAdvanced(val){
	val = val==null?0:val;
	document.searchForm.searchShowAdvanced.value = val;
	document.searchForm.searchWasSet.value = 1;
	document.searchForm.submit();
}

function checkSearchForm(tp){
	f = document.searchForm;
	
	var crit = f.criteriaView.value;
	if(crit == ""){
		alert("Please enter at least one search keyword.");
		return false;	
	}
	
	
	if(top.searchSubmitted==1){
		return false;
	}
	
/*	if (typeof(document.getElementById("thdirsel")) !=undefined){
		document.getElementById("thdirhidden").value= get_radio_value('thdirsel','0');
	}*/
	
	setSearch();
	
	if ( (f.criteria.value=='') && (f.imgnr.value=='') && (f.criteriaAll.value=='') && (f.cdtitle.value=='')){
		return false;
	}
	top.searchSubmitted = 1;
	return true;
}

function setSearch(){//sets the hidden fields for advanced properties
	f = document.searchForm;

	if(f.criteriaView.value == 'Keywords or image #')
		f.criteriaView.value = '';
		
	if(f.criteriaView.value != ''){
		f.criteriaAll.value = f.criteriaView.value;
	}
	
	getType();
	extraConditions();

	if (document.getElementById("advanced_search_tracker").value==1){
		//get new script for getting orientation, colortype etc
		getnewFilters();
		
		if(f.imagecolor_C.value==0 && f.imagecolor_BW.value==0){
			f.imagecolor_C.value=1;
			f.imagecolor_BW.value=1;
		}
		if(f.imageOrient_P.value==0 && f.imageOrient_L.value==0 && f.imageOrient_S.value==0){
			f.imageOrient_P.value=1;
			f.imageOrient_L.value=1;
			f.imageOrient_S.value=1;
		}
	}
	
	getBrandFilter();
	
	f.startpos.value = 1;
}

function getType(){//upon submit, check the type radiobuttons
	f = document.searchForm.elements;
	
	tp = 'RF,RM';
	bud = 1;

	//collectiefilters worden hier uitgezet obv type. Later in brandfilter() wordt alsnog een eventuele specifieke selectie toegepast.
	f.brandsToFilter.value='';
	f.brandFilter.value='0';
	
	if(bud==2){
		f.imagetype.value = 'RF';
		f.budgetimages.value = 2;
	}
	else if(tp=='all' || tp=='RF,RM'){
		f.imagetype.value = 'RF,RM';
		f.budgetimages.value = 1;
	}
	else if(tp=='RF'){
		f.imagetype.value = 'RF';
		if(bud==0){
		f.budgetimages.value = 0;
		}
	}
	else if(tp=='RM'){
		f.imagetype.value = 'RM';
		f.budgetimages.value = 0;
	}
	else if(tp=='CD'){
		f.imagetype.value = 'CD';
		f.budgetimages.value = 0;
	}
	else if(tp=='EDITORIAL'){
		f.imagetype.value = 'editorial';
		f.budgetimages.value = 0;
		
		f.brandsToFilter.value='IMSSUPPLIER:B1624ADF-EFB7-4088-8F545FADA0ACB115,IMSSUPPLIER:82863110-AC8A-498E-A0D62458DE4A22D7,IMSSUPPLIER:F2150EBD-15C5-8747-F6E6D55FE26A4344,IMSSUPPLIER:B77F1FDF-0533-468A-839F288E73356006,IMSSUPPLIER:0DEFCB1F-F5FF-EAB4-97CB661F7D2046C9,IMSSUPPLIER:81043F15-A764-4D86-A5711704DEA853A3,IMSSUPPLIER:2B950ADA-3533-42C6-8F474911DA3B0249,IMSSUPPLIER:0392B780-CA9E-1E4B-E9545938E200E214,IMSSUPPLIER:6FE04138-9FB7-C4DD-49965287F9AB7530,IMSSUPPLIER:06A56405-5257-478C-9D0B00C37F1E8E83,IMSSUPPLIER:24AE09D7-B0FF-3E25-21401F17E31BBDFD,IMSSUPPLIER:165777D3-0EEE-A66F-95B61B4B2C71ADBC,IMSSUPPLIER:3BF6B4B2-FA11-91AA-20ECDC073012CEF8,IMSSUPPLIER:3BF87C15-B143-2E80-49907A184371837F,IMSSUPPLIER:5C24B0BB-15C5-8747-F651E7285A55916B,IMSSUPPLIER:493F02CC-94EB-EA98-4B1D73C26B13CBEC,IMSSUPPLIER:9CF5A9EF-C4A1-4C08-851BBB9208DD2B80,IMSSUPPLIER:E63AC8BB-94F7-404C-9A55F368BEF4B79C,IMSSUPPLIER:B0C5B8BF-689F-4A22-B506DC47473E7654,IMSSUPPLIER:27CA0A5C-0D9E-4BBD-A3850AC33D0FB85B,IMSSUPPLIER:706941AC-C81F-40D0-A89C0BA47BF4C1F4,IMSSUPPLIER:B5D58436-47CF-4248-A49FFF3C77C8CA82,IMSSUPPLIER:E0D6CF72-D038-4EED-AD3E974858F3A220,IMSSUPPLIER:1000B527-3C53-46B8-AFAD2DE41B503097,IMSSUPPLIER:6202C141-DA5D-49D0-83385CB7D97005CA,IMSSUPPLIER:3221DA0D-B976-40F4-85F5E34B6A6649E0,IMSSUPPLIER:4A9E06A1-7491-4330-86E297E6EDD0A762,IMSSUPPLIER:C151B061-0D2D-4812-B2B516321439B247,IMSSUPPLIER:2053DE93-66C8-4775-902D2CC26AA03D55,IMSSUPPLIER:BF75E3B3-CD12-4E89-8F5886A669A793F1,IMSSUPPLIER:F6B91AF6-88DA-43A2-8B19EB0243D13ADE,IMSSUPPLIER:E28BC1B7-15C5-8747-F670AF31D59CA7D3,IMSSUPPLIER:5E0A3DB1-BBEF-4F6B-A6CDF8A1B79E6548,IMSSUPPLIER:8156EA33-F48C-A40C-7105213F3C999C4E,IMSSUPPLIER:906DB333-15C5-8747-F6CE791E2D348FDE,IMSSUPPLIER:7C0D7D55-9B28-401B-B75838072A38F60C,IMSSUPPLIER:4369393A-15C5-8747-F6E0CC10D2673527,IMSSUPPLIER:5EE8BA21-15C5-8747-F69CF7558F738E47,IMSSUPPLIER:28162D2E-D50F-9A78-0E7348972669DE82,IMSSUPPLIER:B8D495CB-E691-446A-AAC856EB3E9774E6,IMSSUPPLIER:7AC8AE45-FC7D-BDED-296259D1F84148D3,IMSSUPPLIER:A8B8ED35-BA3B-4458-9951273F8F55422B,IMSSUPPLIER:C2F4F3D3-064C-8FE1-7A3D7D6174AD0996,IMSSUPPLIER:1EA5A058-AA91-8CBE-8581B709331AD8C7,IMSSUPPLIER:F02197C5-ABCE-8B46-96BF0C2A552208A9,IMSSUPPLIER:32DFC08D-E416-44AB-BEB0EBBAC8DE7243,IMSSUPPLIER:84AA529C-CB31-4D92-8DD4734453D64699,IMSSUPPLIER:7CA2E96B-57B7-4D06-B9A196320353FF69,IMSSUPPLIER:7688CCC9-0889-4583-BD8A197792EE109C,IMSSUPPLIER:D09EC0B0-0C9F-44DC-9677AA2DFF2F687A,IMSSUPPLIER:15026988-2935-48A9-B7C30504F198C6CF,IMSSUPPLIER:CD644B4F-96BF-4D64-9D2B1F06747335BA,IMSSUPPLIER:C254B570-A18C-4C0C-AA599840DFC51B13,IMSSUPPLIER:AA22A5EC-917B-4045-8652B66275BBBBE3,IMSSUPPLIER:11BF417A-4B4A-48FD-8AD9B02E6A4E6C30,IMSSUPPLIER:318E6182-ECB4-5693-C79F35CA29F6816C,IMSSUPPLIER:3808F068-0821-5526-1987FC8498012447';
		f.brandFilter.value='1';
		f.alamy_mr.value=0;
		f.imagetype.value ='editorial'
	}
	else if(tp=='ILLUSTRATION'){
		f.imagetype.value = 'illustration';
		f.budgetimages.value = 1;
	}
}

function extraConditions(){
	f = document.searchForm;
	if(f.newInres_extra[0].checked){
		mustcontain = f.mustcontain.value;
		extracontain = mustcontain.replace(' ','+')
		f.criteriaAll.value = f.criteriaAll.value + ' ' + extracontain;
		//f.criteriaView.value = f.criteriaView.value + ' ' + extracontain;
		//alert(f.criteriaAll.value);
	}
	
	if(f.newInres_extra[1].checked){
		f.criteriaNot.value = f.criteriaNot.value + ' ' + f.mustcontain.value;
	}
	else {
		f.criteriaNot.value = ''
	}
	
	/* criteriaView = f.criteriaAll.value;
	
	res = processInput(criteriaView);

	f.criteria.value = res.criteria.replace(/  /g, ' ');
	f.criteriaAll.value = res.criteriaAll.replace(/  /g, ' ');
	f.criteriaNot.value = res.criteriaNot.replace(/  /g, ' ');
	
	f.criteriaView.value = criteriaView; */
	//if(f.criteriaNot.value != '' && f.criteriaNot.value != ' '){
	//	f.searchShowAdvanced.value = res.AdvOpen;
	//}
	
}

function getnewFilters(){
	document.getElementById("customfilter").value ='';
	get_radio_value('people','1');
	get_radio_value('ethnicity','1');
	get_radio_value('viewpoint','1');
	get_radio_value('copyspace','1');
	f = document.searchForm;
	
	if(get_radio_value('orientation','0')=='p'){

	f.imageOrient_P.value = 1;
	f.imageOrient_L.value = 0;
	f.imageOrient_S.value = 0;
	}
	else if(get_radio_value('orientation','0')=='l'){
	f.imageOrient_P.value = 0;
	f.imageOrient_L.value = 1;
	f.imageOrient_S.value = 0;
	}
	else if(get_radio_value('orientation' ,'0')=='s'){
	f.imageOrient_P.value = 0;
	f.imageOrient_L.value = 0;
	f.imageOrient_S.value = 1;
	}
	else{

	f.imageOrient_P.value = 1;
	f.imageOrient_L.value = 1;
	f.imageOrient_S.value = 1;
	}

	if(get_radio_value('color','0')=='color'){
	f.imagecolor_C.value = 1;
	f.imagecolor_BW.value = 0;
	}
	else if (get_radio_value('color','0')=='bw'){
	f.imagecolor_C.value = 0;
	f.imagecolor_BW.value = 1;
	}
	else{
	f.imagecolor_C.value = 1;
	f.imagecolor_BW.value = 1;
	}
	if (get_radio_value('mrfilter','0')=='1'){
	only_editorial();
	}
	else {
	document.getElementById("use_modelfilter").value='0'
	}
}

function getBrandFilter(){//upon submit, check the brandlist for selected brands.
	f = document.searchForm;
	brandsToFilter = '';
	allbrands = 1;
	hasbeen=0;
	
	//alert('brandfilter 1: advIsOpen='+advSearchIsOpen);
	
	allSupChk = document.getElementById("allcollections");
	
	//vanuit editorial filter (gettype), kunnen al merken gefilterd zijn. Als expliciet collecties zijn gekozen, filter dan deze lijst obv de editorial selectie. Anders gewoon alle geselecteerde
	if(typeof(allSupChk)!='undefined' && !allSupChk.checked  && advSearchIsOpen==1){
		//alert('brandfilter 2: check collections');
		
		for(x=0 ; x<f.brandlist.length ; x++){
			if(f.brandlist[x].checked==1){;
				bruuid = f.brandlist[x].value;
				if(f.brandsToFilter.value=='' || f.brandsToFilter.value.toLowerCase().indexOf(bruuid.toLowerCase())!=-1){
					brandsToFilter = brandsToFilter + bruuid + ',';
				}
			}
			else{
				allbrands = 0;
			}
		}
	}
	
	//alert('brandfilter 3: allbrands='+allbrands);
	
	if(allbrands==1 && f.brandsToFilter.value!=''){
		//editorial filter was al aangezet
		//alert('brandfilter 4a: was al gezet, doe verder niets');
	}
	else if(brandsToFilter==''){
		f.brandFilter.value = 0;
		f.brandsToFilter.value = '';
		//alert('brandfilter 4b: brand filter is uit');
	}
	else{
		f.brandFilter.value = allbrands==1?0:1;
		f.brandsToFilter.value = allbrands==1?'':brandsToFilter;
		
		//alert('brandfilter 4c: merken selectie actief');
	}
}

//===================================== misc functions, not used upon submit of search ===========================
function get_radio_value(fieldname,addkeyword){
	f = document.searchForm;
	usefield = f.elements[fieldname];
	for (var i=0; i < usefield.length; i++){
		if (usefield[i].checked){
			var rad_val = usefield[i].value;
			if (rad_val.length > 2 && fieldname !='color' && addkeyword ==1){
				addtocustom(rad_val)
			}
			return rad_val;		 
		}
   }
}

function addtocustom(fieldvalue){
	var targetfield = document.getElementById("criteriaAll").value;
	if (targetfield.indexOf(fieldvalue,0)==-1){
		document.getElementById("criteriaAll").value = targetfield + ' ' + fieldvalue
		// targetfield = targetfield + ' ' + fieldvalue;
	}
}



function uncheckCD(){//called upon clicking the RM type checkbox
	
		if(document.searchForm.chkbx_type_RM.checked == 1){
			document.searchForm.chkbx_cdonly.checked = 0;
		}
	
}

function checkCreteriaLength(val){
	return true;
}

function showBrandlist(){
	opts = 'width=500, height=550, resizable=yes';
	theurl = 'Reflexstock/scripts/supplierchooser/index.cfm';
	brandwin = window.open(theurl, 'brandwin', opts);
	brandwin.focus();
}

function setType(type, budget){//called from Tab titles to change searchtype
	
	if(type != document.searchForm.imagetype.value || budget != document.searchForm.budgetimages.value){
		f = document.searchForm.elements;

		old = f.criteriaView
		nieuwes =  f.criteriaView.value
		f.criteriaAll.value = nieuwes.replace("illustration","");
	
		f.alamy_mr.value=1;
		f.imagetype.value = type;
		f.budgetimages.value = budget;
		
		if(f.imagetype.value!='CD' && f.cdtitle.value!=''){
			f.criteriaAll.value = f.cdtitle.value;
			f.cdtitle.value = '';
		}
		if (type=='editorial'){
			f.brandsToFilter.value='IMSSUPPLIER:B1624ADF-EFB7-4088-8F545FADA0ACB115,IMSSUPPLIER:82863110-AC8A-498E-A0D62458DE4A22D7,IMSSUPPLIER:F2150EBD-15C5-8747-F6E6D55FE26A4344,IMSSUPPLIER:B77F1FDF-0533-468A-839F288E73356006,IMSSUPPLIER:0DEFCB1F-F5FF-EAB4-97CB661F7D2046C9,IMSSUPPLIER:81043F15-A764-4D86-A5711704DEA853A3,IMSSUPPLIER:2B950ADA-3533-42C6-8F474911DA3B0249,IMSSUPPLIER:0392B780-CA9E-1E4B-E9545938E200E214,IMSSUPPLIER:6FE04138-9FB7-C4DD-49965287F9AB7530,IMSSUPPLIER:06A56405-5257-478C-9D0B00C37F1E8E83,IMSSUPPLIER:24AE09D7-B0FF-3E25-21401F17E31BBDFD,IMSSUPPLIER:165777D3-0EEE-A66F-95B61B4B2C71ADBC,IMSSUPPLIER:3BF6B4B2-FA11-91AA-20ECDC073012CEF8,IMSSUPPLIER:3BF87C15-B143-2E80-49907A184371837F,IMSSUPPLIER:5C24B0BB-15C5-8747-F651E7285A55916B,IMSSUPPLIER:493F02CC-94EB-EA98-4B1D73C26B13CBEC,IMSSUPPLIER:9CF5A9EF-C4A1-4C08-851BBB9208DD2B80,IMSSUPPLIER:E63AC8BB-94F7-404C-9A55F368BEF4B79C,IMSSUPPLIER:B0C5B8BF-689F-4A22-B506DC47473E7654,IMSSUPPLIER:27CA0A5C-0D9E-4BBD-A3850AC33D0FB85B,IMSSUPPLIER:706941AC-C81F-40D0-A89C0BA47BF4C1F4,IMSSUPPLIER:B5D58436-47CF-4248-A49FFF3C77C8CA82,IMSSUPPLIER:E0D6CF72-D038-4EED-AD3E974858F3A220,IMSSUPPLIER:1000B527-3C53-46B8-AFAD2DE41B503097,IMSSUPPLIER:6202C141-DA5D-49D0-83385CB7D97005CA,IMSSUPPLIER:3221DA0D-B976-40F4-85F5E34B6A6649E0,IMSSUPPLIER:4A9E06A1-7491-4330-86E297E6EDD0A762,IMSSUPPLIER:C151B061-0D2D-4812-B2B516321439B247,IMSSUPPLIER:2053DE93-66C8-4775-902D2CC26AA03D55,IMSSUPPLIER:BF75E3B3-CD12-4E89-8F5886A669A793F1,IMSSUPPLIER:F6B91AF6-88DA-43A2-8B19EB0243D13ADE,IMSSUPPLIER:E28BC1B7-15C5-8747-F670AF31D59CA7D3,IMSSUPPLIER:5E0A3DB1-BBEF-4F6B-A6CDF8A1B79E6548,IMSSUPPLIER:8156EA33-F48C-A40C-7105213F3C999C4E,IMSSUPPLIER:906DB333-15C5-8747-F6CE791E2D348FDE,IMSSUPPLIER:7C0D7D55-9B28-401B-B75838072A38F60C,IMSSUPPLIER:4369393A-15C5-8747-F6E0CC10D2673527,IMSSUPPLIER:5EE8BA21-15C5-8747-F69CF7558F738E47,IMSSUPPLIER:28162D2E-D50F-9A78-0E7348972669DE82,IMSSUPPLIER:B8D495CB-E691-446A-AAC856EB3E9774E6,IMSSUPPLIER:7AC8AE45-FC7D-BDED-296259D1F84148D3,IMSSUPPLIER:A8B8ED35-BA3B-4458-9951273F8F55422B,IMSSUPPLIER:C2F4F3D3-064C-8FE1-7A3D7D6174AD0996,IMSSUPPLIER:1EA5A058-AA91-8CBE-8581B709331AD8C7,IMSSUPPLIER:F02197C5-ABCE-8B46-96BF0C2A552208A9,IMSSUPPLIER:32DFC08D-E416-44AB-BEB0EBBAC8DE7243,IMSSUPPLIER:84AA529C-CB31-4D92-8DD4734453D64699,IMSSUPPLIER:7CA2E96B-57B7-4D06-B9A196320353FF69,IMSSUPPLIER:7688CCC9-0889-4583-BD8A197792EE109C,IMSSUPPLIER:D09EC0B0-0C9F-44DC-9677AA2DFF2F687A,IMSSUPPLIER:15026988-2935-48A9-B7C30504F198C6CF,IMSSUPPLIER:CD644B4F-96BF-4D64-9D2B1F06747335BA,IMSSUPPLIER:C254B570-A18C-4C0C-AA599840DFC51B13,IMSSUPPLIER:AA22A5EC-917B-4045-8652B66275BBBBE3,IMSSUPPLIER:11BF417A-4B4A-48FD-8AD9B02E6A4E6C30,IMSSUPPLIER:318E6182-ECB4-5693-C79F35CA29F6816C,IMSSUPPLIER:3808F068-0821-5526-1987FC8498012447';
			f.brandFilter.value='1';
			f.alamy_mr.value=0;
			f.imagetype.value ='editorial'
			document.getElementById("tabtype").value='editorial';
		}
		else if(type=='illustration'){
			f.imagetype.value = 'illustration';
		}
		else{
			f.brandsToFilter.value='';
			f.brandFilter.value='0';
		}
		extraConditions();
		
		document.searchForm.startpos.value = 1;
		document.searchForm.submit();
	}		
}

function goSearchInRes(kw){//search within results
	document.searchForm.criteriaAll.value = document.searchForm.criteriaAll.value + ' ' + kw;
	document.searchForm.startpos.value = 1;
	document.searchForm.submit();
}

function gotoPage(strt){
	if(checkSearchForm(1)){
		document.searchForm.startpos.value = strt;
		document.searchForm.submit();
	}
}

function setKW(kw){
	document.searchForm.criteriaAll.value = kw;
	document.searchForm.criteriaAll.imgnr = '';
	
	if(checkSearchForm()){
		document.searchForm.submit();
	}
}

function setSup(supid){
	f = document.searchForm;
	f.brandFilter.value = 1;
	f.brandsToFilter.value = supid;
	f.imagecolor_BW.value = 1;
	f.imageOrient_P.value = 1;
	f.imageOrient_L.value = 1;
	f.imageOrient_S.value = 1;
	f.imageAvail_CD.value = 1;
	f.imageAvail_S.value = 1;
	f.startpos.value = 1;
	f.searchmode.value = 2;
	
	
	f.criteriaAll.value = '';
	f.criteria.value = '';
	f.criteriaNot.value = '';
	f.imgnr.value = '';
	
	
	f.submit();
}

function doMaxrows(){
	noRows = document.searchInRes.maxrows.options[document.searchInRes.maxrows.options.selectedIndex].value;
	document.searchForm.maxros.value = noRows;
	document.searchForm.startpos.value = 1;
	if(checkSearchForm)
		document.searchForm.submit();
}


function handleAllSup(){//triggered when clicking checkbox for all suppliers
	f = document.searchForm;
	allSel = 1;
	for(x=0 ; x<f.brandlist.options.length ; x++){
		if(f.brandlist.options[x].selected==0)
			allSel = 0;
	}
	newval = allSel==1?0:1;
	for(x=0 ; x<f.brandlist.options.length ; x++){
		f.brandlist.options[x].selected=newval;
	}
	f.doAllSup.checked = newval;	
}

function checkAllSup(){//triggered when changing the supplier selection
	f = document.searchForm;
	allset = 1;
	for(x=0 ; x<f.brandlist.options.length ; x++){
		if(f.brandlist.options[x].selected==0)
			allset = 0;
	}
	f.doAllSup.checked = allset;
}

function hint(){
	window.open('index.cfm?/hint','hint','width=500,height=300,resizable,scrollbars')
}

function showLogin(){
	//alert('this is showLogin');
	opts = 'width=500,height=300,statusbar=1';
	theurl = 'http:\/\/www.reflexstock.com/Reflexstock/scripts/login/index.cfm?lang=en';
	loginwin = window.open(theurl, 'loginwin', opts);
	loginwin.focus();
}

function trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

function processInput(str){
	var words = str.toLowerCase().split(' ');
	var f = document.searchForm;
	
	var lastoperator = '';
	
	var wordsNoOp = '';
	var wordsAND = '';
	var wordsOR = '';
	var wordsNOT = '';
	
	for(x=0; x<words.length; x++){
		w = words[x];
		
		if(w=='and'){
			lastoperator = w;
			if(wordsNoOp!=''){wordsAND = wordsAND + ' ' + wordsNoOp;wordsNoOp='';}
		}
		else if(w=='or'){
			lastoperator = w;
			if(wordsNoOp!=''){wordsOR = wordsOR + ' ' + wordsNoOp;wordsNoOp='';}
		}
		else if(w=='not'){
			lastoperator = w;
			if(wordsNoOp!=''){wordsAND = wordsAND + ' ' + wordsNoOp;wordsNoOp='';}
		}
		else{//normal keyword
			if(lastoperator=='and'){
				wordsAND = wordsAND + ' ' + w;
			}
			else if(lastoperator=='or'){
				wordsOR = wordsOR + ' ' + w;
			}
			else if(lastoperator=='not'){
				wordsNOT = wordsNOT + ' ' + w;
			}
			else{
				wordsNoOp = wordsNoOp + ' ' + w;
			}
		}
		
		//alert('end of word '+w+', lastoperator='+lastoperator+'\nwordsNoOp='+wordsNoOp+'\nwordsAND='+wordsAND+'\nwordsOR='+wordsOR+'\nwordsNOT='+wordsNOT);
	}
	if(wordsNoOp!=''){wordsAND = wordsAND + ' ' + wordsNoOp;}
	
	res = new Object();
	res.criteria = wordsOR + ' ' + f.criteria.value;
	res.criteriaAll = wordsAND;
	res.criteriaNot = wordsNOT + ' ' + f.criteriaNot.value;
	
	if(wordsNOT.length == 0){
		res.AdvOpen = 1;	
	}else{
		res.AdvOpen = 1;
	}	
	
	return res;
}

