/* Public Search JS  */

function getPublicSearchResults()
{
	var opportunityDetailsDiv = document.getElementById("opportunityDetailsDiv");
	
	opportunityDetailsDiv.style.display = "none"

   	var url = "publicSearchAction-search.action";
   	
   	neoAjax.submitNoCache(url,"searchResultsDiv",document.oppSearchForm);
   	
   	var searchResultsSortByDiv = document.getElementById("searchResultsSortByDiv"); 
	if (searchResultsSortByDiv.style.display == "none") 
	{ 
		searchResultsSortByDiv.style.display = "block"; 
	}
	
	var oppSearchClosedText = document.getElementById("oppSearchClosedText").innerHTML = "Search for Keyword(s): " + document.getElementById("keywords2").value;
	
	var oppSearchClosed = document.getElementById("oppSearchClosed").style.display = "block";
	var oppSearchOpen = document.getElementById("oppSearchOpen").style.display = "none";



	openSearchResults();
}


/* Opportunity Search JS  */
function getJobSubSector()
{
   	var industrialSectorId = document.getElementById("industrialSectorId").value;
   	
   	var url = "publicOpportunityAction-findIndustrialSubSectors.action?industrialSectorId="+escape(industrialSectorId);
   	neoAjax.updateNoCache(url,"industrialSubSelectList");
}



function getSearchResults()
{
	var opportunityDetailsDiv = document.getElementById("opportunityDetailsDiv");
	
	opportunityDetailsDiv.style.display = "none"

   	

	neo.form.submitToDiv('oppSearchForm', "searchResultsDiv");

   	var searchResultsSortByDiv = document.getElementById("searchResultsSortByDiv"); 
	if (searchResultsSortByDiv.style.display == "none") { 
		searchResultsSortByDiv.style.display = "block"; 
	}
	
//	var oppSearchClosedText = document.getElementById("oppSearchClosedText").innerHTML="Keyword: " + document.getElementById("keywords").value;
	
	var innerHtml = "<b>Keyword:</b> &ldquo;" + document.getElementById("keywords").value + "&rdquo;<br/>" ;
	
	if(document.getElementById("opportunityTypeId")!=null){
		innerHtml = innerHtml + "<b>Opportunity Type:</b> " + document.getElementById("opportunityTypeId").options[document.getElementById("opportunityTypeId").selectedIndex].text + "<br/>"; 
	}
	
	innerHtml = innerHtml + "<b>Industry:</b> " + document.getElementById("industrialSectorId").options[document.getElementById("industrialSectorId").selectedIndex].text + "<br/>" +
	"<b>Occupation:</b> " + document.getElementById("industrialSubSectorId").options[document.getElementById("industrialSubSectorId").selectedIndex].text + "<br/>" +
	"<b>Region:</b> " + document.getElementById("locationId").options[document.getElementById("locationId").selectedIndex].text + "<br/>" +
	"<b>Preferred Area:</b> " + document.getElementById("areaId").options[document.getElementById("areaId").selectedIndex].text + "<br/>" +
	"<b>Postcode:</b> &ldquo;" + document.getElementById("postcode").value + "&rdquo;";
	
	var oppSearchClosedText = document.getElementById("oppSearchClosedText").innerHTML=	innerHtml;	
//		"<b>Keyword:</b> &ldquo;" + document.getElementById("keywords").value + "&rdquo;<br/>" +
//		"<b>Opportunity Type:</b> " + if(document.getElementById("opportunityTypeId")!=null){document.getElementById("opportunityTypeId").options[document.getElementById("opportunityTypeId").selectedIndex].text} + "<br/>" +
//		"<b>Industry:</b> " + document.getElementById("industrialSectorId").options[document.getElementById("industrialSectorId").selectedIndex].text + "<br/>" +
//		"<b>Occupation:</b> " + document.getElementById("industrialSubSectorId").options[document.getElementById("industrialSubSectorId").selectedIndex].text + "<br/>" +
//		"<b>Region:</b> " + document.getElementById("locationId").options[document.getElementById("locationId").selectedIndex].text + "<br/>" +
//		"<b>Preferred Area:</b> " + document.getElementById("areaId").options[document.getElementById("areaId").selectedIndex].text + "<br/>" +
//		"<b>Postcode:</b> &ldquo;" + document.getElementById("postcode").value + "&rdquo;";
	
	var oppSearchClosed = document.getElementById("oppSearchClosed").style.display = "block";
	var oppSearchOpen = document.getElementById("oppSearchOpen").style.display = "none";



	openSearchResults();
}

function openSearch()
{
	var oppSearchClosed = document.getElementById("oppSearchClosed");
	var oppSearchOpen = document.getElementById("oppSearchOpen");
	
	oppSearchOpen.style.display = "block";
	oppSearchClosed.style.display = "none";
}


function openSearchResults()
{
	var oppSearchResultsClosed = document.getElementById("oppSearchResultsClosed");
	var oppSearchResultsOpen = document.getElementById("oppSearchResultsOpen");
	
	oppSearchResultsOpen.style.display = "block";
	oppSearchResultsClosed.style.display = "none";
	
	var opportunityDetailsDiv = document.getElementById("opportunityDetailsDiv").innerHTML="";
	
	document.getElementById("noResultDiv").style.display = "none";
}

function closeSearchResult(){
	
	var oppSearchResultsOpen = document.getElementById("oppSearchResultsOpen");
	oppSearchResultsOpen.style.display = "none";
	document.getElementById("noResultDiv").style.display = "block";
}

function getOpportunityDetails(id)
{
   	var url = "publicOpportunityAction-viewOpportunity.action?opportunityId="+escape(id);
   	neoAjax.updateNoCache(url,"opportunityDetailsDiv");
   	
   	var opportunityDetailsDiv = document.getElementById("opportunityDetailsDiv"); 
	if (opportunityDetailsDiv.style.display == "none") { 
		opportunityDetailsDiv.style.display = "block"; 
	}
		
	var oppSearchResultsClosed = document.getElementById("oppSearchResultsClosed");
	var oppSearchResultsOpen = document.getElementById("oppSearchResultsOpen");
	
	oppSearchResultsOpen.style.display = "none";
	oppSearchResultsClosed.style.display = "block";
}

function sortSearchResults(orderBy)
{
   	var url = "publicOpportunityAction-opportunitySearch.action?orderBy="+escape(orderBy.value);
   	
   	neoAjax.submitNoCache(url,"searchResultsDiv",document.oppSearchForm);
}

function getOpportunityApplicationDetails(id)
{
   	var url = "publicOpportunityAction-viewAppliedOpportunityDetails.action?opportunityId="+escape(id);
   	//neoAjax.updateNoCache(url,"appliedOpportunityDetails");
   	window.location = url;
}

function getOpportunityInterestDetails(id)
{
   	var url = "publicOpportunityAction-viewInterestedOpportunityDetails.action?opportunityId="+escape(id);
   	//neoAjax.updateNoCache(url,"interestedOpportunityDetails");
   	
   	window.location = url;
}

function showTab(divId)
{
	document.getElementById("cvToUse").value = divId;
	
}

function storeCvClicked()
{
	var saveCV = document.getElementById("saveCV").checked;

	if (saveCV == true) 
	{
		document.getElementById("fileDescription").style.display = "block";
		
	}
	else
	{
		document.getElementById("fileDescription").style.display = "none";
	}
}

function removeDivContent(divId)
{
	var div = document.getElementById(divId);
	div.innerHTML = "";
}


function getAreasForOppSearch(){

   	var locationId = document.getElementById("locationId").value;
   	
   	var url = "publicOpportunityAction-findAreasForOppSearch.action?locationId="+escape(locationId);
   	
   	neoAjax.updateNoCache(url,"areaTownListDiv");
}

//function hideUnhideDiv(divId)
//{
//	var div = document.getElementById(divId); 
//	if (div.style.display == "none") { 
//		div.style.display = "block"; 
//	} else if (div.style.display == "block") { 
//		div.style.display = "none"; 
//	}
//}

