function gup(name){
	var regexS="[\\?&]"+name+"=([^&#]*)";
	var regex=new RegExp(regexS);
	var tmpURL=window.location.href;
	var results=regex.exec(tmpURL);
	if(results===null){
		return""
	}
	else{
		return results[1]
	}
}

/*
	Script Name: "Get latest news"
	Required Params:
		1. "OUTPUTSTYLE" = "headlines" (only headlines), "paragraph" (headline, first paragraph), "fullstory" (full story)
		2. "PARAM" = search parameters
		3. "WRITEBLOCK" = Block element where results are inserted via .html()
*/
function getNews(OUTPUTSTYLE, PARAM, WRITEBLOCK) {
	$.ajax({
	    type: "GET",
	    url: "/governorherbert/rss.xml", //production: http://www.utah.gov/whatsnew/rss.xml
	    contentType: "text/xml; charset=utf-8",
	    data: PARAM,
	    dataType: "application/xml",
	    error: function(req, status, errorThrown){
	        //console.log("Error: " + status + ", " + errorThrown);
	    },
	    success: function (xml, status){
	        var xmlDoc;
	        try{
	            var domParser = new DOMParser();
	            xmlDoc = domParser.parseFromString(xml,'application/xml');
	        }
	        catch(err) {
	            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	            xmlDoc.async="false";
	            xmlDoc.loadXML(xml);
	        }
	       	$(xmlDoc).find('item').each(function(index){
				// loop through and output non-featured news stories
				$("#" + WRITEBLOCK).html("");
				if (!$(this).find('image').text()) {
					var title = $(this).find('title').text();
					var url = $(this).find('link').text();
					var description = $(this).find('description').text();
					var guid = $(this).find('guid').text();
					var date = dateFormat($(this).find('pubDate').text(), "fullDate");
					var category = $(this).find('category').text();
					if (category.match("governor")){
						url = "news_media/article.html?article="+guid;
					}
					switch(OUTPUTSTYLE){
						case "headlines":
							$("#"+WRITEBLOCK).append('<li><a href="'+url+'">'+title+'</a> ('+date+')</li>');
						break;
						case "paragraph":
							$("#"+WRITEBLOCK).append('<h4><a href="'+url+'">'+title+'</a></h4>'+description);
						break;
						case "fullstory":
							$("#"+WRITEBLOCK).append('<h4><a href="'+url+'">'+title+'</a></h4>'+description);
						break;
					}
//					$("#"+WRITEBLOCK).append('<h4><a href="'+url+'">'+title+'</a></h4>'+description);
					if (index>=4) {
						return false;
					};
				}
			});
	    }
	});
}