google.load('search', '1.0', {"nocss":true});
var newsSearch, q;
var cseIdNews = "011667481278979575132:vbkcnjk7vac"

function OnLoad() {	
	// Initialize news search instance
	newsSearch = new google.search.WebSearch();
	newsSearch.setNoHtmlGeneration()
	newsSearch.setResultSetSize(google.search.Search.SMALL_RESULTSET);
	newsSearch.setSiteRestriction(cseIdNews);
	newsSearch.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
	newsSearch.setSearchCompleteCallback(this, OnSearch);
	if (q!="") newsSearch.execute(q);
}
	
function OnSearch(e) {
	// Test for News results
	if (newsSearch.results && newsSearch.results.length > 0) {
		
		// Create news search results display element and prep for placement.
		var parentDiv = document.getElementById('searchResults');
		var contentDiv = document.createElement('div')
		contentDiv.id = "newsSearch";
		contentDiv.setAttribute("class","f33 gray");
		contentDiv.setAttribute("className","f33 gray");

		// Create news search results display element title
		var title = document.createElement('h4');
		title.setAttribute("class","centered");
		title.setAttribute("className","centered");
		title.innerHTML = '<img src="/cgi-bin/images/PCToday148.gif" alt="PCToday News &amp Information"/>'
		contentDiv.appendChild(title);
	
		// Loop through our results, printing them to the page.
		var results = newsSearch.results;
		for (var i = 0; i < results.length; i++) {
			// Add each result to the screen
			var result = results[i];
			var title = document.createElement('h5');
			var desc = document.createElement('p');
			title.innerHTML = '<a href="' + result.url + '">' + result.title + '<\/a>';				
			desc.innerHTML = result.content + '<br \/><span class="searchURL" title="' + result.url + '">' + result.url + '<\/span>';
			contentDiv.appendChild(title);
			contentDiv.appendChild(desc);
		}
		
		// Append news search results display element to parent element
		parentDiv.appendChild(contentDiv);

		// Append "More News" link if result > 3
		$("#newsSearch").append('<p><a href="http://www.pct.edu/cgi-bin/pctoday/search.cgi?action=search&amp;categoryNum=&amp;perpage=10&amp;keyword='+q+'">More PCToday results...</a></p>');
	}
}

function parseGetVars() {
	var getVars = new Array();
	var qString = unescape(top.location.search.substring(1));
	var pairs = qString.split(/\&/);
	for (var i in pairs) {
		var nameVal = pairs[i].split(/\=/);
		getVars[nameVal[0]] = nameVal[1];
		}	
	return getVars;
}
google.setOnLoadCallback(OnLoad, true)
