/** Fix issue with IE and fading (cleartype text) **/
jQuery.fn.fadeIn = function(speed, callback) { 
    return this.animate({opacity: 'show'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
    return this.animate({opacity: 'hide'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

var $j = jQuery.noConflict();

var count = 0;
	
var caseStudies = { 
		0: {			
			img:'durham.jpg',
			alt:'City of Durham, North Carolina',
			link:'/gate/pdf/case_studies/CS_Durham.pdf',
			header:'"Paper Chase Eliminated in the City of Durham"',
			text:'"Turning problems into solutions with the implementation of a host of OnBase modules has created a new, easy-to-use environment for the City of Durham.  See how a 22 department agenda workflow was completely steamlined and automated with OnBase."'},
		1: {			
			img:"seminole.jpg",			
			alt:'Seminole Electric Cooperative, Inc.',
			link:'/gate/pdf/case_studies/CS_SEMINOLEelectric.pdf',
			header:'"Electric COOP eases records management, mitigates risk"',
			text:'"$1.4 billion electric generation and transmission cooperative uses ECM to automate records management and compliance while improving operational efficiencies by making enterprise documents instantly available to the employees and auditors requiring access, even from remote locations."'},		
		2: {			
			img:"pediatrix.jpg",
			alt:'Pediatrix Medical Group',
			link:'',
			header:'"Content Management Solution that grows as business needs grow"',
			text:'"Pediatrix focuses on one simple belief: take great care of the patient. With physicians in 32 states and Puerto Rico, you can\'t do that unless you\'re all on the same page. OnBase links physician offices, regional locations and corporate offices so that Pediatrix can focus on quality, efficient healthcare."'},
		3: {			
			img:"mennonite.jpg",			
			alt:'Mennonite Mutual Insurance Company',
			link:'/gate/pdf/case_studies/CS_MennoniteMutual.pdf',
			header:'"Insurer with old fashioned values uses new technology to increase profits, cut costs"',
			text:'"See how a seamless integration with SharePoint helped Mennonite Mutual realize a double-digit increase in written premiums and increase work capacity without additional manpower."'}		
	}

$j(document).ready(function () {	
	$j.timer(15000, function(){
		doRotations();	
	});
});

function doRotations()
{	
	if (count <= 2) 
	{
		count += 1;		
	}
	else 
	{
		count = 0;
	}
	
	swap();
}

function swap() {
	$j("#caseStudy").fadeOut(600, function () 
	{
		if(caseStudies[count].link != "") {
			$j("#caseStudy").html("" +
					'<p class="center"><a href="' + caseStudies[count].link + '"><img src="/i/logos/' + caseStudies[count].img + '" alt="' + caseStudies[count].alt + '"/></a></p>' + 
					'<h3><a href="' + caseStudies[count].link + '">' + caseStudies[count].header + '</a></h3>' + 
					'<p>' + caseStudies[count].text + '</p>' +
					'<p><a href="' + caseStudies[count].link + '" class="more">Read Case Study >></a></p>'
				);
		}
		else {
			$j("#caseStudy").html("" +
					'<p class="center"><img src="/i/logos/' + caseStudies[count].img + '" alt="' + caseStudies[count].alt + '"/></p>' + 
					'<h3>' + caseStudies[count].header + '</h3>' + 
					'<p>' + caseStudies[count].text + '</p>'					
				);
		}
		
		$j("#caseStudy").fadeIn(600);
	});
}
