var feedHeight;
var divHeight = 115;
var divWidth = 160;
var divContainerPaddingTop = 6;
var divContainerPaddingBottom = 0;
var divContainerPaddingRight = 8;
var divContainerPaddingLeft = 8;
var feedPause = 10000;
var feedSpeed = 10; //lower = faster, 0 is the fastest

function createTitle(title,link)
{return "<div><a style='font-weight:bold;' href='"+link + "'>" + title + "</a></div>";}

function createNewsItem(itemContentHtml)
{return "<div class='rssA' style=\"position:relative;width:" + (divWidth - (divContainerPaddingLeft * 2)) + "px; height:" + divHeight + "px; padding:" + divContainerPaddingTop + "px " + divContainerPaddingRight + "px " + divContainerPaddingBottom + "px " + divContainerPaddingLeft + "px; overflow:hidden;\"><div class='cyclefix'>"+itemContentHtml+"</div></div>";}

function createDescription(desc)
{return "<span class='DescRss'>"+desc+"</span>";}


function loadDoc(method)
{

	switch(method)
	{
		case "json":
			$.get("xml/pressJSON.php",{"cache":"NO"+(new Date).getTime()}, function(data){
   					 json = eval(data);
					 feedHeight = 0;
					 for(var i in json)
					 {
        				 var item = json[i];
						 var title = item.Title;
                         var link = item.PressLink;
						 var description = item.Description;
					     var pubDate = item.PressDate;
						 var itemHtml = createTitle(title,link)+createDescription(description);
                         $('#div_rssItems').append(createNewsItem(itemHtml));
						 feedHeight++;
					 }
					
					 scroller2();
                 });
			 break;
			 case "xml":
				 $.ajax({
                 type: "GET",
                 url: "xml/pressTrimmed.php",
                 dataType: "xml",
                 success: function(xml) {
                     $(xml).find('item').each(function(){
                         var title = $(this).find('title').text();
                         var link = $(this).find('link').text();
						 var description = $(this).find('description').text();
					     var pubDate = $(this).find('pubDate').text();
						 var itemHtml = createTitle(title,link)+createDescription(description);
                         $('#div_rssItems').append(createNewsItem(itemHtml));
                     });
					 scroller2();
                 }
             });
			 break;
	}

}


$(document).ready(function() {

				

				var references = {"R1":"T1","R2":"T2","R3":"T3","R4":"T4"};

				$("#tabs").tabs("#content > div");

				$("a.TabLink").each(function(){

					$(this).click(function(){
						$("#tabs div[id^='R']").removeClass("on");
						$(this).parent().addClass("on");
						

						$(".tcontent").hide();
						if($.browser.msie)
							$("#"+references[$(this).parent().attr("id")]).show();
						else
							$("#"+references[$(this).parent().attr("id")]).fadeIn("fast");
					});
				});
		});


function hideAllJobs(){
	document.getElementById("imgHR").style.visibility = "hidden";
	document.getElementById("imgCompliance").style.visibility = "hidden";
	document.getElementById("imgStaff").style.visibility = "hidden";
	document.getElementById("imgResearch").style.visibility = "hidden";
	document.getElementById("imgNurse").style.visibility = "hidden";
}


var whoWeServe = new Array();
whoWeServe[0] = '<div style="margin-top:70px; text-align:center; font-weight:bold; text-transform:uppercase; font-style:italic; color:#555">Select your area of expertise<br /><img src="img/whoWeServeArrow.gif" style="margin-right:40px" /></div>';
whoWeServe[1] = '<img alt="" src="img/hr.jpg" style="border:1px solid #999;" /><h3 style="margin:6px 0px 6px 0px; font-style:italic;">Human Resources</h3>One central Learning Management System to develop, deliver and track all online and classroom training, assess competencies and review performance.';
whoWeServe[2] = '<img alt="" src="img/compliance.jpg" style="border:1px solid #999;" /><h3 style="margin:6px 0px 6px 0px; font-style:italic;">Compliance</h3>HCCS compliance courses enable healthcare organizations to meet Joint Commission, Medicare, Medicaid, HIPAA and quality regulations.';
whoWeServe[3] = '<img alt="" src="img/staff.jpg" style="border:1px solid #999;" /><h3 style="margin:6px 0px 6px 0px; font-style:italic;">Staff Development</h3>The HCCS Healthcare Learning Platform (HLP) is a Learning Management System designed to assign, track and report on all online and offline learning and competency activities.';
whoWeServe[4] = '<img alt="" src="img/research.jpg" style="border:1px solid #999;" /><h3 style="margin:6px 0px 6px 0px; font-style:italic;">Research</h3>HCCS research courseware enables research staff to comply with the latest National Institute of Health and Responsible Conduct of Research guidelines.';
whoWeServe[5] = '<img alt="" src="img/nurse.jpg" style="border:1px solid #999;" /><h3 style="margin:6px 0px 6px 0px; font-style:italic;">Nurses</h3>HCCS courses help nursing staff meet yearly training requirements. Improved training also enables nursing staff to provide patients with superior care.';

function changeWhoWeServe(showImg, id){
	hideAllJobs();
	if(showImg != ""){ document.getElementById(showImg).style.visibility = "visible"; }
	document.getElementById("id_whoWeServe").innerHTML = whoWeServe[id];
}

var questionArray = new Array();
questionArray[0] = "";
questionArray[1] = "<b>HCCS</b> has provided over <b>2.5 million</b> hours of compliance and competency training courseware to <b>1.4 million</b> learners at over <b>700</b> hospitals, teaching facilities, medical schools, health plans and other healthcare entities.";
questionArray[2] = "<b>HCCS</b> online compliance courses <b>contain video scenarios</b> and other multimedia elements to increase retention and employee satisfaction. <b>HCCS</b> compliance courses have a <b>96% completion rate</b>, the highest in the industry.";
questionArray[3] = "The day to day management of <b>HCCS</b> is the responsibility of six individuals with over <b>150 years in healthcare</b> compliance, medical practice management, training, consulting, and new product development.";

var selectedQuestion = 0;
function changeQuestion(i){
	
	if(i > 0){ document.getElementById("div_questions").innerHTML = questionArray[i].toString(); }
	else{ document.getElementById("div_questions").innerHTML = '<img alt="" src="img/hccs_logo_small.png" style="margin:33px 0px 0px 20px" />'; }

	selectedQuestion = i;
}





var rssTimer;
var locationCounter = 1;
var locationCounter2 = divContainerPaddingTop * 2;
var newLocation = 0;
var feedMaxHeight = 0;

function scroller2()
{
	clearTimeout(rssTimer);
	rssTimer = setTimeout("scroller2()", feedSpeed);
	feedMaxHeight = ((-divHeight * (feedHeight)) + 1) - (divHeight / 2);

	//alert(parseInt(document.getElementById("div_rssItems").style.top));

	if(parseInt(document.getElementById("div_rssItems").style.top) < feedMaxHeight){ document.getElementById("div_rssItems").style.top = divHeight + "px"; }

	//for(i = 0; i > feedMaxHeight; i--)
	//{
		//newLocation = -divHeight * locationCounter;
		//if(navigator.appName != "Microsoft Internet Explorer"){ newLocation = ((-divHeight * locationCounter) - locationCounter2); }
		newLocation = ((-divHeight * locationCounter) - locationCounter2);
		//alert(newLocation);
		if((parseInt(document.getElementById("div_rssItems").style.top) == newLocation || parseInt(document.getElementById("div_rssItems").style.top) == 0) && (parseInt(document.getElementById("div_rssItems").style.top) != feedMaxHeight && parseInt(document.getElementById("div_rssItems").style.top) >= feedMaxHeight + (divHeight / 2)))
		{
			clearTimeout(rssTimer);
			rssTimer = setTimeout("scroller2()", feedPause);
			if(parseInt(document.getElementById("div_rssItems").style.top) != 0)
			{
				locationCounter++;
				locationCounter2 = (locationCounter2 + divContainerPaddingTop);
				//alert(parseInt(document.getElementById("div_rssItems").style.top) + " - " + newLocation + " " + " - " + feedMaxHeight + " - " + (feedMaxHeight + (divHeight / 2)));
			}
			else{ locationCounter = 1; locationCounter2 = divContainerPaddingTop; }
		}
	//}
	document.getElementById("div_rssItems").style.top = (parseInt(document.getElementById("div_rssItems").style.top) - 1) + "px";
}



   $(document).ready(function(){loadDoc("json");/*json or xml*/}); 


