function SlideHomeProjSearchDown(){
	$("#homeContent").height(855);
	$("#Home_ProjSearchLink1").fadeOut(300, function callback(){$("#HomeSearchContainer").slideDown(400, function callback(){$("#HomeSearchContainer_InnerDiv").fadeIn(300);});});
}

function SlideHomeProjSearchUp(){
	$("#homeContent").height(700);
	$("#HomeSearchContainer_InnerDiv").fadeOut(300, function callback(){$("#HomeSearchContainer").slideUp(400, function callback(){$("#Home_ProjSearchLink1").fadeIn(300);});});
}

var viewCompleteResults = function() {
	var newURL = '/index.cfm/Projects';
	newURL+='?projectTypes=3';
	newURL+='&markets=' + $('#homeMarketsProjSearch').val();
	newURL+='&automotiveMarkets=';
	newURL+='&services=' + $('#homeServiceProjSearch').val();
	newURL+='&regions=' + $('#homeRegionProjSearch').val();
	newURL+='&searchString=';
	
	setTimeout(function()
	{
		window.location = newURL;
	}, 0);
	
	//location.href=newURL;
}

function getSearchResults() {
	$.ajax({
	type: "POST",
	url: "/_commongoal/cg_content/Projects_Ajax.cfc",
	dataType: "json",
	data: {
	   method: 'searchProjects',
	   projectTypes: "",
	   markets: $('#homeMarketsProjSearch').val(),
	   automotiveMarkets: "",
	   services: $('#homeServiceProjSearch').val(),
	   regions: $('#homeRegionProjSearch').val(),
	   searchString: ''
	},
	success: displayHomePageResults
	})	
}

var displayHomePageResults = function(results) {
	var newHTML = "";
	if(results.length > 0){
		$('#HomeQuickSearchLink').css('display', 'block');
		$('#projectSearchHomeBtn').css('display', 'block');
		$.each(results, function(i, currentProject) {
			if (i == 3) { return false; }
			newHTML += "<li><a href='/index.cfm/Projects?projectId=" + currentProject.PROJECTID;
			newHTML+='&projectTypes=3';
			newHTML+='&markets=' + $('#homeMarketsProjSearch').val();
			newHTML+='&automotiveMarkets=';
			newHTML+='&services=' + $('#homeServiceProjSearch').val();
			newHTML+='&regions=' + $('#homeRegionProjSearch').val();
			newHTML+='&searchString=';
			newHTML += "'>";
			newHTML += currentProject.OWNER + " " + currentProject.NAME;
			newHTML += "</a></li>";
		});
		$('#homeSearchResults').html(newHTML);
	}
	else{
		$('#HomeQuickSearchLink').css('display', 'none');
		$('#projectSearchHomeBtn').css('display', 'none');
		newHTML += "<li>No Results Found</li>";
		$('#homeSearchResults').html(newHTML);
	}
}

$(document).ready( function getHomeInnovations(){
	//load in HomeInnovations's content
	$.ajax({
		type: "POST",
		url: "/_commongoal/cg_content/Projects_Ajax.cfc",
		dataType: "json",
		data: {
		   method: 'getHomeInnovations'
		},
	success: getHomeInnovations_Res
	})
});

var currHomeInnovations = 0;
var getHomeInnovations_Res = function(results) {
	var newHTML = "";
	//alert(results[0].CONTENT); return
	
	$.each(results, function(i, currInnovation) {
		if(i == 0){
			currHomeInnovations = i;
			var displayVal = "display:block;"
		}
		else{
			var displayVal = "display:none;"
		};
		newHTML += '<div id="ArrContent_' + i + '"';
		newHTML += ' style="' + displayVal + ' top:0px; z-index:' + (990 + i) + ';"';
		newHTML += ' class="ArrContent">';
		newHTML += '<div class="ImgOuterBorder"><div class="IMGContainer"><img src="../graphics/innovations/' + currInnovation.INNOVATIONSMODULEIMG;
		newHTML += '" border="0" /></div></div><h3 class="HomeInnovation"><a href="'+ currInnovation.READMORELINKSOURCE +'">' + currInnovation.ENTRYNAME;
		newHTML += '</a></h3>' + currInnovation.CONTENT;
		newHTML += '</div>';
	});
	$('#contentBoxBottom').html(newHTML);
	
	$.timer(8000, function (timer) {
		fillDebuggOutput(results);
	});
}

function fillDebuggOutput(results){
	var newHTML = $('#DebuggOutput_Content').html();
	
	var currHomeInnvDiv = "#ArrContent_" + currHomeInnovations;
	currHomeInnovations++;
	if(currHomeInnovations >= results.length){
		currHomeInnovations = 0;
	}
	var nextHomeInnvDiv = "#ArrContent_" + currHomeInnovations;
	
	$(currHomeInnvDiv).fadeOut(600, function(){$(nextHomeInnvDiv).fadeIn(1000);});
	/*newHTML += '<div>' + results.length + " | " + currHomeInnovations + ' | Current:' + currHomeInnvDiv + ' | Next:' + nextHomeInnvDiv + '</div>';
	$('#DebuggOutput_Content').html(newHTML);
	$("#DebuggOutput").css({opacity:'0.7', display:'block'});*/
}



