var newsModuleObject = Class.create({
	initialize: function(el){
		
	 	this.properties = eHA.elementToObjectLiteral(el);
	 	this.el = $(el);
			if($$("div.news.assetid-"+this.properties.assetid)[0]){
				this.newsDiv = $$("div.news.assetid-"+this.properties.assetid)[0];
				if(this.newsDiv.down("span.more")){
					this.moreLInk = this.newsDiv.down("span.more").clone(true);
				}
				this.newsDiv.update(eHA.news.preloader);
				this.loadData(function(){
					this.createForm();
					this.build();
					this.selectPage(1);
				}.bind(this),{articles:'true'});
			}else{
				
				eHA.log.create("no news articles for this module" +this.properties.assetid);
			}
	},
 	loadData: function(callback,packedargs,waitForAJAX){
		if(typeof this.ajaxRequest!=="undefined" && this.isLoading){
			this.ajaxRequest.abort();
			eHA.log.create("aborting previous ajax request",2);
		}
		if(typeof waitForAJAX==="undefined"){
			var waitForAJAX = false;
		}
 		var parameters = {
 			childpagename: eHA.Site+"/eHA_Module_C/"+eHA.Site+"/News/json",
 			site: eHA.Site,
 			c: "eHA_Module_C",
 			cid: this.properties.assetid,
 			pagename: eHA.Site+"_default_Wrapper"
 		};
 		var formPackedargs = {};
 		if(typeof this.form!=="undefined"){
 			formPackedargs = this.form.serialize(true);
 			eHA.log.create("packedargs from form = "+Object.toQueryString(formPackedargs),3);
 		}
 		if(typeof packedargs!=="undefined"){
 			Object.extend(formPackedargs,packedargs);
 			parameters.packedargs = Object.toQueryString(formPackedargs);
 		}
 		var localObj = this;
 		var URL = "/cs/Satellite";
 		this.isLoading = true;
		this.ajaxRequest = new Ajax.Request(URL,
			{
				method:'get',
				parameters: parameters,
				onCreate: function(){
					if(waitForAJAX){
						// show loading graphic because there will now be a delay
						localObj.newsDiv.down("div.pageContainer").update(eHA.news.preloader);
					}
					eHA.log.create(parameters.cid+": AJAX request for JSON created", 3);
				},
				onSuccess: function(transport){
					eHA.log.create(parameters.cid+": AJAX request for JSON succeeded", 3);
				},
				onComplete: function(transport){
					this.isLoading = false;
					// add transport.responseText to this.properties
					eHA.log.create(parameters.cid+": AJAX request for JSON completed", 3);
					if(transport.responseText){
						eHA.log.create(parameters.cid+": attempting to evaluate JSON and add to newsModuleObject", 3);
						try{
							var metaData = transport.responseText.evalJSON(true);
							Object.extend(localObj.properties,metaData.configuration);
							localObj.properties.complete = true;
							if(typeof metaData.articles!=="undefined"){
								if(typeof localObj.data==="undefined"){
									localObj.data = {};
								}
								Object.extend(localObj.data,metaData.articles);
							}
						}catch(err){
							eHA.log.create(parameters.cid+":"+err.name+" - "+err.message, 1);
						}
					}else{
						eHA.log.create(parameters.cid+": problem with transport.responseText onComplete", 1);
					}
					if(typeof callback!=="undefined" && callback){
						callback();
					}
				}.bind(this),
				onFailure: function(){
					eHA.log.create(parameters.cid+": AJAX request for JSON resulted in failure", 1);
				}
			});
 	},
 	/**
 	 * calculates page data, creates page container, selects first page
 	 * @function
 	 */
 	build: function(){
 		try{
 			// clear old pages & navigation
 			if(this.newsDiv.select("div.pageMeta")[0]){
 				this.newsDiv.select("div.pageMeta").invoke("remove");
 			}
 			if(this.newsDiv.select("div.pageContainer")[0]){
 				this.newsDiv.select("div.pageContainer").invoke("remove");
 			}
 			if(this.newsDiv.down("div.pagination")){
 				this.newsDiv.down("div.pagination").remove();
 			}
 			if(this.newsDiv.down("img.preloader")){
 				this.newsDiv.down("img.preloader").remove();
 			}
 			if(this.newsDiv.down("span.more")){
 				this.newsDiv.down("span.more").remove();
 			}
 			var itemLimit = this.properties.totalItems;
 			var pageLimit = 1;
 			
 			if(typeof this.properties.itemsPerPage!=="undefined"){
 				itemLimit = this.properties.itemsPerPage;
 				pageLimit = Math.ceil(this.properties.totalItems/this.properties.itemsPerPage);
 			}
 			
 			if(this.properties.showTotal && this.properties.showTotal!=="false"){
 				this.newsDiv.insert({bottom:new Element("div",{className:"pageMeta"}).update("<p><strong>"+this.properties.totalItems+"</strong> Articles found</p>")});
 			}
 			this.newsDiv.insert({bottom:new Element("div",{className:"pageContainer"})}).insert({bottom:this.moreLInk});
 			
 			this.properties.numberOfPages = pageLimit;
 			//this.selectPage(1);
 			eHA.log.create(this.properties.assetid+": built");
 			document.fire("newsModule:built",{ assetid:this.properties.assetid });
 		}catch(err){
 			eHA.log.create("problem building pages for news module ("+this.properties.assetid+"), "+err.message,1);
 		}
 	},
 	getData: function(startItem,endItem,pageNumber){
 		var dataOK = true;
 		var immediatePageOK = true;
 		var checkStartItem = startItem;
 		var checkEndItem = endItem;
		if(this.properties.itemsPerPage>0){
		  // expand returned results to 3 pages if possible (previous page, current page, next page)
			if((checkStartItem+2*this.properties.itemsPerPage)<this.properties.totalItems){
			  // set checkEndItem to 2 pages ahead (current page plus one)
				checkEndItem = (checkStartItem+2*this.properties.itemsPerPage);
			}else{
			  // set checkEndItem as far ahead as possible
			  checkEndItem = parseInt(this.properties.totalItems,10)+parseInt(1,10);
			}
			if(checkStartItem>this.properties.itemsPerPage){
			  // set checkStartItem to 1 page back
			  checkStartItem = checkStartItem - this.properties.itemsPerPage;
			}
		}
		eHA.log.create("checking items "+checkStartItem+" to "+checkEndItem,3);
 		for(var i=checkStartItem;i<checkEndItem;i++){
 			if(typeof this.data["item"+i]!=="undefined"){
 				// data is ok, don't affect boolean
 			}else{
 				if(i>=startItem && i<=endItem){
 					immediatePageOK = false;
 				}
 				dataOK=false;
 			}
 		}
 		
 		if(!immediatePageOK){
			eHA.log.create("need to delay page creation",2);
			this.loadData(function(){
				this.createPage(pageNumber,false);
			}.bind(this),{
				startItem:startItem,
				articles:'true'
			},true);
 		}else{
 			eHA.log.create("no need to delay page creation",3);
 			if(!dataOK){
 				eHA.log.create("prefetching data for neighboring pages",3);
 				this.loadData(false,{
 					startItem:startItem,
 					articles:'true'
 				});
 			}
 		}
 		

 		return immediatePageOK;
 	},
 	createPage: function(pageNumber,checkData){

 		if(typeof checkData==="undefined"){
 			var checkData = true;
 		}
		if(this.newsDiv.down("img.preloader")){
			this.newsDiv.down("img.preloader").remove();
			eHA.log.create("removed loading graphic",3);
		}

		eHA.log.create("attempting to create page "+pageNumber+".  "+(checkData?"Will":"Will not")+" check data",3);
		var startItem=(pageNumber-1)*this.properties.itemsPerPage+1; //add one because index starts at 1
		var endItem = parseInt(this.properties.itemsPerPage,10)+parseInt(startItem,10)-1; 
		if(endItem>this.properties.totalItems){
			endItem = this.properties.totalItems;
		}
		if(this.properties.totalItems>=startItem){
			// create new pagination with selected page properly selected
			if(this.properties.showPagination && this.properties.showPagination!=="false"){
				this.createPagination(pageNumber);
			}
			// check to see if requesting more data from server is necessary
			var immediatePageOK = false;
			if(checkData){
				immediatePageOK = this.getData(startItem,endItem,pageNumber);
			}
			if(immediatePageOK || !checkData){
				eHA.log.create("proceeding with page creation",3);
				try{
					//create replaceAll function
					String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
					var temp = this;
					var index = temp.indexOf(stringToFind);
						while(index != -1){
							temp = temp.replace(stringToFind,stringToReplace);
							index = temp.indexOf(stringToFind);
						}
						return temp;
					}
					var thisUL = new Element("ul",{className:"page page"+pageNumber,style:"display:none;"});
					for(var i=startItem;i<(endItem+1) && typeof this.data["item"+i]!=="undefined";i++){
						var thumbnailLI = "";
						if((this.properties.showThumbnails && this.properties.showThumbnails==="true") && typeof this.data["item"+i].thumbnailURL!=="undefined"){
							thumbnailLI = "<li class='thumbnail'><img src='"+this.data["item"+i].thumbnailURL+"' alt='"+escape(this.data["item"+i].title)+"' /></li>";
						}
						var abstractLI = "";
						if((this.properties.showAbstracts && this.properties.showAbstracts==="true") && typeof this.data["item"+i].abstract!=="undefined"){
							abstractLI = "<li class='abstract'>"+this.data["item"+i].abstract.ReplaceAll("&apos;","'")+"</li>";
						}
						if(eHA.news.HomePageCheck()){
							var thisLI = new Element("li",{className:"article assetid-"+this.data["item"+i].assetid})
							.update("<ul>"
							+thumbnailLI
							+"<li class='title'><a href='"+eHA.news.formatURL(this.data["item"+i])+"'>"+this.data["item"+i].title.truncate(55).ReplaceAll("&apos;","'")+"</a></li>"
							+abstractLI
							+"<li class='release_date'>"+Date.parse(this.data["item"+i].releaseDate).toString("MMMM d, yyyy")+"</li>"
							+"</ul>");							
						}else{
						var thisLI = new Element("li",{className:"article assetid-"+this.data["item"+i].assetid})
							.update("<ul>"
							+thumbnailLI
							+"<li class='title'><a href='"+eHA.news.formatURL(this.data["item"+i])+"'>"+this.data["item"+i].title.ReplaceAll("&apos;","'")+"</a></li>"
							+abstractLI
							+"<li class='release_date'>"+Date.parse(this.data["item"+i].releaseDate).toString("MMMM d, yyyy")+"</li>"
							+"</ul>");
						}
						thisUL.insert({bottom:thisLI});
					}
					this.newsDiv.down("div.pageContainer").insert({bottom:thisUL});
					thisUL.appear({duration:eHA.news.duration,afterSetup:function(){
						this.adjustPageContainer();
					}.bind(this)});
				}catch(err){
					eHA.log.create("problem with page creation! "+err.toString(),1);
				}
			}
		}else{
			eHA.log.create("requested page, "+pageNumber+", is out of range!  Proceeding to page 1 instead",2);
			this.selectPage(1);
		}
		
 	},
 	adjustPageContainer: function(){
 		eHA.log.create("adjusting page container",3);
 		try{
 			if(this.newsDiv.down("div.pageContainer ul.page")){
 				var pageDimensions = this.newsDiv.down("div.pageContainer ul.page").getDimensions();
 				new Effect.Morph(this.newsDiv.down("div.pageContainer"),{
 					"style":{
 					"height":pageDimensions.height+"px"
 				},
 				"duration": 0.1
 				});
 			}
 		}catch(err){
 			eHA.log.create(err.toString(),1);
 		}
 	},
 	/**
 	 * creates pagination for the Article pages.  visible page numbers roam for simplicity, always showing 3 pages max, prev & next, first & last
 	 * @function
 	 * @parameter {int} selectedPage
 	 * @example
 	 * output:
 	 * "|< < 1 2 3 > >|"
 	 * "|< < 2 3 4 > >|"
 	 * "|< < 9 10 12 > >|"
 	 */
 	createPagination: function(selectedPage){
 		try{
 			if(typeof selectedPage==="undefined"){
 				selectedPage = 1;
 			}
 			var startPage = Math.round(selectedPage - ((eHA.news.maxPagesToShow-1)/2));
 			if(startPage<1){
 				startPage = 1;
 			}
 			// clear old pagination
 			if(this.newsDiv.down("div.pagination")){
 				this.newsDiv.down("div.pagination").remove();
 			}
 			
 			var paginationDiv = new Element("div",{className:"pagination"});
 			var paginationUL = new Element("ul");
 			
 			var firstLink = new Element("a",{href:""}).update("First").observe("click",function(event){
 				event.stop();
 				this.selectPage(1);
 			}.bind(this));
 			var firstLI = new Element("li",{className:"first"}).update(firstLink);
 			paginationUL.insert({bottom:firstLI});
 			
 			var prevLink = new Element("a",{href:""}).update("Previous").observe("click",function(event){
 				event.stop();
 				if(this.newsDiv.down("div.pagination li.sel a")){
 					var selectedPage = this.newsDiv.down("div.pagination li.sel a").innerHTML;
 					if(selectedPage>1){
 						this.selectPage(selectedPage - 1);
 					}
 				}
 			}.bind(this));
 			var prevLI = new Element("li",{className:"previous"}).update(prevLink);
 			paginationUL.insert({bottom:prevLI});
 			
 			for(var i=startPage;i<=this.properties.numberOfPages && i<(parseInt(startPage,10)+parseInt(eHA.news.maxPagesToShow,10));i++){
 				var pageLink = new Element("a",{href:""}).update(i).observe("click",function(event){
 					event.stop();
 					this.selectPage(event.element().innerHTML);
 				}.bind(this));
 				var pageLIclass = "pageButton"+i;
 				if(typeof selectedPage!=="undefined" && i===parseInt(selectedPage,10)){
 					pageLIclass += " sel";
 				}
 				var pageLI = new Element("li",{className:pageLIclass}).update(pageLink);
 				paginationUL.insert({bottom:pageLI});
 			}
 			
 			var nextLink = new Element("a",{href:""}).update("Next").observe("click",function(event){
 				event.stop();
 				if(this.newsDiv.down("div.pagination li.sel a")){
 					var selectedPage = this.newsDiv.down("div.pagination li.sel a").innerHTML;
 					if(selectedPage<this.properties.numberOfPages){
 						this.selectPage(parseInt(selectedPage,10) + 1);
 					}
 				}
 			}.bind(this));
 			var nextLI = new Element("li",{className:"next"}).update(nextLink);
 			paginationUL.insert({bottom:nextLI});
 			
 			var lastLink = new Element("a",{href:""}).update("Last").observe("click",function(event){
 				event.stop();
 				this.selectPage(this.properties.numberOfPages);
 			}.bind(this));
 			var lastLI = new Element("li",{className:"last"}).update(lastLink);
 			paginationUL.insert({bottom:lastLI});
 			
 			paginationDiv.update(paginationUL);
 			this.newsDiv.insert({bottom:paginationDiv});
 		}catch(err){
 			eHA.log.create("problem creating pagination for news module ("+this.properties.assetid+"), "+err.message,1);
 		}
 	},
 	readQueryString:function(queryObject){
 		var oldFormOptions={};
 		if(typeof this.oldFormOptions!=="undefined"){
 			oldFormOptions = this.oldFormOptions;
 		}
 		var pageNumber = queryObject.page;
 		delete queryObject.page;
 		this.oldFormOptions = queryObject;
 		
 		// if query string (without page number) is different, must execute search and change page
 		// later by using a callback
 		if(Object.toQueryString(oldFormOptions)!==Object.toQueryString(queryObject)){
 			this.executeForm(queryObject,function(){
 				this.changePage(pageNumber);
 				this.populateForm();
 			}.bind(this));
 		}else{
 			// otherwise, just change page number
 			this.changePage(pageNumber);
 		}
 		
 		// if there is no form and no pagination, remove hash
 		if(this.noHash && this.noHash===true){
 			SWFAddress.setValue("");
 			eHA.log.create("clearing hash",3);
 		}
 	},
 	selectPage: function(pageNumber){
 		try{
 	 		// get queryString from forms, add/change page number
 	 		if((!this.properties.showPagination || this.properties.showPagination==="false") && (typeof this.form!=="undefined")){
 	 			this.noHash = true;
 	 		}else{
 	 			this.noHash = false;
 	 		}
 	 		
 	 		var formOptions = this.form.serialize(true);
 	 		Object.extend(formOptions,{page:pageNumber,articles:'true'});
 	 		if(this.executions===1){ // selectPage is called once onload, so checking for 1 instead of 
 	 			// this is the first time the form is being executed, setValue of hash to the default
 	 			// form options.
 	 			SWFAddress.setValue("/"+this.properties.assetid+"/?"+Object.toQueryString(this.defaultFormOptions));
 	 		}
 	 		this.executions++;
 	 		SWFAddress.setValue("/"+this.properties.assetid+"/?"+Object.toQueryString(formOptions));
 	 		eHA.log.create(this.properties.assetid+": page number "+pageNumber+" selected");
 		}catch(err){
 			eHA.log.create(this.properties.assetid+":"+err.toString(),1);
 		}
 	},
 	changePage: function(pageNumber){
 		try{
 			if(this.newsDiv.down("ul.page"+pageNumber)){
 				eHA.log.create("requested page, "+pageNumber+", is already showing",3);
 			}else{
 				if(this.newsDiv.select("ul.page")[0]){
 					this.newsDiv.select("ul.page").invoke("remove");
 				}
 				this.createPage(pageNumber);
 			}
 		}catch(err){
 			eHA.log.create("problem selecting page for news module ("+this.properties.assetid+"), "+err.message,1);
 		}
 	},
 	executeForm: function(queryObject,callback){
 		eHA.log.create("executing news module search form",3);
		if(typeof this.data!=="undefined"){
			delete this.data;
			eHA.log.create("clearing old news module data",3);
		}
		
		this.loadData(function(){
			this.build();
			if(typeof callback!=="undefined"){
				callback();
			}
		}.bind(this), queryObject,true);
 	},
 	populateForm: function(){
 		for(option in this.oldFormOptions){
 			if(typeof this.form[option]!=="undefined"){
 				this.form[option].setValue(this.oldFormOptions[option]);
 			}
 		}
 	},
 	createForm: function(){
 		try{
 			this.form = new Element("form",{method:"",action:"",name:"assetid-"+this.properties.assetid,id:"assetid-"+this.properties.assetid});
 			
 			var formContents = "";
 			
 			if(this.properties.showCategoryDropdown && this.properties.showCategoryDropdown!=="false"){
 				formContents += "<div class='categoryDropdown'>";
 				formContents += "<label for='categoryDropdown-"+this.properties.assetid+"'>Category:</label>";
 				formContents += "<select id='categoryDropdown-"+this.properties.assetid+"' name='category'>";
 				formContents += "<option value='null'>All</option>";
 				for(var i=0;i<this.properties.category.length;i++){
 					formContents += "<option value='"+this.properties.category[i].id+"'>"+this.properties.category[i].name+"</option>";
 				}
 				formContents += "</select>";
 				formContents += "</div>";
 			}
 			if(this.properties.showTitleSearch && this.properties.showTitleSearch!=="false"){
 				formContents += "<div class='titleSearch'>";
 				formContents += "<label for='titleSearch-"+this.properties.assetid+"'>Title:</label><input type='text' id='titleSearch-"+this.properties.assetid+"' name='title' />";
 				formContents += "</div>";
 			}
 			if(this.properties.showKeywordSearch && this.properties.showKeywordSearch!=="false"){
 				formContents += "<div class='keywordSearch'>";
 				formContents += "<label for='keywordSearch-"+this.properties.assetid+"'>Keywords:</label><input type='text' id='keywordSearch-"+this.properties.assetid+"' name='keyword' />";
 				formContents += "</div>";
 			}
 			if(this.properties.showDateRangeFilter && this.properties.showDateRangeFilter!=="false"){
 				var dtstartValue = "";
 				var dtendValue = "";
 				
 				if(typeof this.properties.dtstart!=="undefined"){
 					dtstartValue = this.properties.dtstart;
 				}
 				if(typeof this.properties.dtend!=="undefined"){
 					dtendValue = this.properties.dtend;
 				}
 				
 				var startInput = new Element("input",{type:"text",value:dtstartValue,id:"startDate"+this.properties.assetid,name:"dtstart"});
 				var endInput = new Element("input",{type:"text",value:dtendValue,id:"endDate"+this.properties.assetid,name:"dtend"});
 				
 				var startDateDiv = new Element("div",{className:"startDate"}).update("<label for='startDate"+this.properties.assetid+"'>Start Date</label>").insert({bottom:startInput});
 				var endDateDiv = new Element("div",{className:"endDate"}).update("<label for='endDate"+this.properties.assetid+"'>End Date</label>").insert({bottom:endInput});
 				
 				var dateRangeFilterHeader = new Element("h4").update("Filter results by date range");
 				var dateRangeFilterDiv = new Element("div",{className:"dateRangeFilter"}).insert({bottom:dateRangeFilterHeader}).insert({bottom:startDateDiv}).insert({bottom:endDateDiv});
 			}
 			if(this.properties.showSortOrder && this.properties.showSortOrder!=="false"){
 				formContents += "<div class='sortOrder'>";
 				formContents += "<label for='sortOrder-"+this.properties.assetid+"'>Sort Order:</label>";
 				formContents += "<select id='sortOrder-"+this.properties.assetid+"' name='sortOrder'>";
 				formContents += "<option value='release_date.descending'>Newest First</option>";
 				formContents += "<option value='release_date.ascending'>Oldest First</option>";
 				formContents += "<option value='title.ascending'>Alphabetical</option>";
 				formContents += "<option value='title.descending'>Reverse Alphabetical</option>";
 				formContents += "</select>";
 				formContents += "</div>";
 			}
 			
 			if(formContents.length>0 || (this.properties.showDateRangeFilter && this.properties.showDateRangeFilter!=="false")){
 				formContents += "<div class='submit'>";
 				formContents += "<input type='submit' class='submit' name='submit' id='submit-"+this.properties.assetid+"' value='Submit' />";
 				formContents += "<input type='reset' class='reset' name='reset' id='reset-"+this.properties.assetid+"' value='Reset' />";
 				formContents += "</div>";
 				
 				this.form.update(formContents);
 				
 				$$("div.newsModule.assetid-"+this.properties.assetid+" h3")[0].insert({after:this.form});
 				
 				if(this.properties.showDateRangeFilter && this.properties.showDateRangeFilter!=="false"){
 	 				this.form.down("div.submit").insert({before:dateRangeFilterDiv});
 	 				
 	 				if(eHA.news.dateRangePicker==="slider"){
 	 					var dateSliderOptions = {
 	 							dragHandles:       true,
 	 							dayWidth:          1,
 	 							dateFormat:        eHA.news.dateFormat,
 	 							zoom:              true,
 	 							handleFinder:      true,
 	 							appearOnFocus:     true,
 	 							lowerLimitYear:    Date.parse(this.properties.dtstart).getFullYear(),
 	 							upperLimitYear:    Date.parse(this.properties.dtend).getFullYear(),
 	 							startDate:         this.properties.dtstart,
 	 							endDate:           this.properties.dtend,
 	 							inputStartField:   startInput,
 	 							inputEndField:     endInput,
 	 							insertLocation:    'after',
 	 							insertElement:     endInput
 	 					};
 	 					try{
 	 						var dateRangeSlider = new DateSlider(dateSliderOptions);
 	 					}catch(err){
 	 						eHA.log.create(err.name+" - "+err.message,1);
 	 					}
 	 				}else{
 	 					// assume "picker"
 	 					var datePickerOptionsStart = {
							relative:		"startDate"+this.properties.assetid,
							keepFieldEmpty:	true,
							cellCallback: function(){
 	 							$("startDate"+this.properties.assetid).value = Date.parse($F("startDate"+this.properties.assetid)).toString(eHA.news.dateFormat);
 	 						}.bind(this)
 	 					};
 	 					var dpck_fieldnameStart = new DatePicker(datePickerOptionsStart);
 	 					
 	 					var datePickerOptionsEnd = {
 							relative:		"endDate"+this.properties.assetid,
 							keepFieldEmpty:	true,
							cellCallback: function(){
	 							$("endDate"+this.properties.assetid).value = Date.parse($F("endDate"+this.properties.assetid)).toString(eHA.news.dateFormat);
	 						}.bind(this)
 	 					};
 	 					var dpck_fieldnameEnd = new DatePicker(datePickerOptionsEnd);
 	 				}
 				}
 				
 		 		this.defaultFormOptions = this.form.serialize(true);
 				this.defaultFormOptions.page = 1;
 				this.defaultFormOptions.articles = 'true';
 				this.executions = 0;
 				
 				this.form.observe("submit",function(event){
 					event.stop();
 					this.selectPage(1);
 				}.bind(this));
 				
 				eHA.log.create(this.properties.assetid+": form created");
 			}else{
 				eHA.log.create(this.properties.assetid+": form not necessary, no form created");
 			}
 			
 		}catch(err){
 			eHA.log.create("problem creating news module form, "+this.properties.assetid+".  "+err.message,1);
 		}
 	}
});


/**
 * eHA.news object namespace.  Most functions are a part of {@link newsModuleObject} because
 * multiple news on one page must be supported
 * @namespace
 */
eHA.news = {
	/**
	 * @function
	 */
	init: function(){
		if($$("div.newsModule")[0]){
			this.preloader = new Element("img",{src:eHA.resourcepath+"images/wide-preloader.gif",alt:"please wait",className:"preloader"});
			this.newsModuleObjects = {};
			$$("div.newsModule").each(function(element){
				//element.setStyle({overflow:"hidden"});
				var newsModuleID = eHA.elementToObjectLiteral(element).assetid;
				this.newsModuleObjects[newsModuleID] = new newsModuleObject(element);
			}.bind(this));
			
			// adding SWFaddress listeners
			
			 // EXTERNAL_CHANGE is used for back button
			 SWFAddress.addEventListener(SWFAddressEvent.EXTERNAL_CHANGE, function(event){
					eHA.log.create("SWFAddress event: "+Object.toJSON(event), 3);
					if(typeof event.pathNames!=="undefined"){
						if(typeof this.newsModuleObjects[event.pathNames[0]]!=="undefined" && typeof event.parameters!=="undefined"){
							this.newsModuleObjects[event.pathNames[0]].readQueryString(event.parameters);
						}
					}
				 }.bind(this));

			 SWFAddress.addEventListener(SWFAddressEvent.INTERNAL_CHANGE, function(event){
					eHA.log.create("SWFAddress event: "+Object.toJSON(event), 3);
					if(typeof event.pathNames!=="undefined"){
						if(typeof this.newsModuleObjects[event.pathNames[0]]!=="undefined" && typeof event.parameters!=="undefined"){
							this.newsModuleObjects[event.pathNames[0]].readQueryString(event.parameters);
						}
					}
				 }.bind(this));
			
		}
	},
	dateRangePicker: "picker", // slider or picker
	/**
	 * makes sure that rendermode is added to URL
	 * @function
	 * @returns theURL
	 */
	formatURL: function(obj){
		var theURL = obj.url;
		var pageQueryParams = window.location.href.toQueryParams();
		if(typeof pageQueryParams.rendermode!=="undefined"){
			if(theURL.indexOf("?")!==-1){
				var urlQueryParams = theURL.toQueryParams();
				Object.extend(urlQueryParams,{rendermode:pageQueryParams.rendermode});
				theURL = theURL.split("?")[0] +"?"+ Object.toQueryString(urlQueryParams);
			}
			theURL = theURL +"?"+ Object.toQueryString({rendermode:pageQueryParams.rendermode});
		}
		return theURL;
	},
	HomePageCheck: function(){
		if($$('body.eHA_LandingPage_C')[0]){
		return true;
		}
		else {
			return false}
	},

	dateFormat: "yyyy-MM-dd HH:mm:ss",
	maxPagesToShow: 3,
	duration: 0.5
};
