var to ='';
var new_class = ''; 
var prev_class = 'pos0';
var i;
for (i in document.images) {
    if (document.images[i].src) {
        var imgSrc = document.images[i].src;
        if (imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG') {
            document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
        }
    }
}

var in_motion = false;
$(document).ready(function() {$("#home-navigation a").mouseover(function() {BGSwap.swap(this.id);});});
var BGSwap ={
	swap:function(i){
		if(!in_motion){
			this.check(i);
		} else {
			// if fast mouseovers, make it do the animation of the last link moused over
			// continously clears one after another as each link is moused over to avoid multiple animations from trying to run
			// so ends up grabing the last one and slower animations if rapid
			// extremely rapid mouseovers do cause it to glitch out
			clearTimeout(to);
			to = setTimeout('BGSwap.force("'+i+'")',400);	
		}	
	},
	go:function(){
		in_motion = true;
		$('#characters_2').removeClass(prev_class).addClass(new_class).fadeIn();
		$('#characters_1').fadeOut(
			function(){
				$(this).removeClass(prev_class).addClass(new_class).show();
				$('#characters_2').hide();	
				prev_class = new_class;
				in_motion = false;
			});
	},
	check:function(i){
		new_class = 'pos' + i.substr(1,2);
		if(prev_class != new_class){
			this.go();
		}
	},
	force:function(i){this.check(i);},
}

$(document).ready(function() {
    $('#slogan').cycle({
		fx: 'fade',
		autostop: 5,
		speed: 800,
		timeout: 1
	});
});

$(document).ready(function(){
	$.preloadCssImages(); 
});
