function doNaceSearch(error_msg) {
	if (document.getElementById('searchText').value.length < 3) {
		alert(error_msg);
	} 
	else {
		easyAjax('/include/ajax/mycategories_nace_search_do.cfm','searchResultsDiv','POST','ContentToLoadForm','searchText');
	}
}

function doCordisSearch(error_msg) {
	if (document.getElementById('searchText').value.length < 3) {
		alert(error_msg);
	} 
	else {
		easyAjax('/include/ajax/myaccount_cordis_search_do.cfm','searchResultsDiv','POST','ContentToLoadForm','searchText');
	}
}

function doCPVSearch(error_msg) {
	if (document.getElementById('searchText').value.length < 3) {
		alert(error_msg);
	} 
	else {
		easyAjax('/include/ajax/mycategories_cpv_search_do.cfm','searchResultsDiv','POST','ContentToLoadForm','searchText');
	}
}

function viewPartnerSearches(prog_id) { 
	window.open('/easyconsole.cfm/page/vps/prog_id/'+prog_id, 'vpswindow', 'toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=570,height=400');
}

function PrintProgramme(id) { 
	window.open('/easyconsole.cfm/page/printprogramme/prog_id='+id, 'newwindow', 'toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=700,height=700');
}

function PrintTender(id) { 
	window.open('/easyconsole.cfm/page/printtender/tender_id='+id, 'newwindow', 'toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=720,height=700');
}

function OpenIMSPGateway(amount,subscr_c_id) { 
	window.open('/easyconsole.cfm/page/ccpayment/amount='+amount+'&subscr_c_id='+subscr_c_id, 'newwindow', 'toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=600,height=400');
}


function ColdfusionSubmitForm(form,url,el) {
    ColdFusion.Ajax.submitForm(form, url, function(text){setAndExecute(el, text)},errorHandler);
}

function errorHandler(code, msg)
{
    alert("Error!!! " + code + ": " + msg);
}


function checkAllGeneralCat(gRow, specialNum){
	for(i=1;i<=specialNum;i=i+1){
		document.getElementById('gs_'+gRow+'_'+i).checked = true;  
	}
		
	document.getElementById('cg_'+gRow).style.display = 'none';
	document.getElementById('ug_'+gRow).style.display = 'inline';
}

function uncheckAllGeneralCat(gRow, specialNum){
	for(i=1;i<=specialNum;i=i+1){
		document.getElementById('gs_'+gRow+'_'+i).checked = false;  
	}
	
	document.getElementById('cg_'+gRow).style.display = 'inline';
	document.getElementById('ug_'+gRow).style.display = 'none';
}

function checkAllSpecificCat(sRow, generalNum){
	for(i=1;i<=generalNum;i=i+1){
		document.getElementById('gs_'+i+'_'+sRow).checked = true;  
	}
	
	document.getElementById('cs_'+sRow).style.display = 'none';
	document.getElementById('us_'+sRow).style.display = 'inline';
}

function unCheckAllSpecificCat(sRow, generalNum){
	for(i=1;i<=generalNum;i=i+1){
		document.getElementById('gs_'+i+'_'+sRow).checked = false;  
	}
	
	document.getElementById('cs_'+sRow).style.display = 'inline';
	document.getElementById('us_'+sRow).style.display = 'none';
}


function enableBothCats(inputCell, sRow, gRow){
	var cellValue = document.getElementById(inputCell);
	
	if (!cellValue.checked){
		document.getElementById('cs_'+sRow).style.display = 'inline';
		document.getElementById('cg_'+gRow).style.display = 'inline';
		
		document.getElementById('us_'+sRow).style.display = 'none';
		document.getElementById('ug_'+gRow).style.display = 'none';
	}
}

function removeElement(id) {
  var element = document.getElementById(id);
  element.parentNode.removeChild(element);
}


function addLI(liID) {
	MyUL = document.getElementById('idOftheUL');
	
	aElement = document.createElement('a');
	aElement.href='javascript:removeElement('+liID+')';
	aElement.innerHTML = "<img src='/images/icon-delete.png'/>";
	
	//Create the <li> node
	liElement = document.createElement('li');
	liElement.id = liID;
	liElement.innerHTML = "<a href='javascript:removeElement("+liID+")'><img style='padding-right:5px' src='/images/icon-delete.png' align='absmiddle'/></a>"+document.getElementById('liText'+liID).value;
	//liElement.appendChild(aElement);
	
	inputElement = document.createElement('input');
	inputElement.name = 'cpvCatIDs';
	inputElement.type = 'hidden';
	inputElement.value = liID;
	liElement.appendChild(inputElement);
		
	//Append it to the Current list (Places it last on the list)
	MyUL.appendChild(liElement);
}


function coridsAddtoFavorites(c_id, cordis_id, ajaxDiv, message){
	var answer = confirm(message);
	
	if (answer){
		easyAjax('/include/ajax/mycordis_add_do.cfm?c_id='+c_id+'&cordis_id='+cordis_id,ajaxDiv);
	}
	else{
		return;
	}	
}


function cpvAddtoFavorites(c_id, cpv_id, ajaxDiv, message){
	var answer = confirm(message);
	
	if (answer){
		easyAjax('/include/ajax/mycategories_cpv_add_do.cfm?c_id='+c_id+'&cpv_id='+cpv_id,ajaxDiv);
	}
	else{
		return;
	}	
}


function naceAddtoFavorites(c_id, nace_id, ajaxDiv, message){
	var answer = confirm(message);
	
	if (answer){
		easyAjax('/include/ajax/mycategories_nace_add_do.cfm?c_id='+c_id+'&nace_id='+nace_id,ajaxDiv);
	}
	else{
		return;
	}	
}


function cpvRemoveFromTenderViewer(c_id, cpv_id, ajaxDiv, message){
	var answer = confirm(message);
	
	if (answer){
		easyAjax('/include/ajax/mycategories_cpv_remove_specific_do.cfm?c_id='+c_id+'&cpv_id='+cpv_id,ajaxDiv);
	}
	else{
		return;
	}	
}

function helpWindow(pageName){
		
		
		var w = 600;
		var h = 590;
		
		winname = 'Window_'+Math.random();
		
		ColdFusion.Window.create(winname,'Help','/include/ajax/tenders_statistics_help_window.cfm?winname='+winname+'&pageName='+pageName,
		{height:h,width:w,modal:true,closable:true,draggable:true,resizable:false,center:1,initshow:true});
		ColdFusion.Window.onHide(winname,cleanup);
}


