﻿(function($){$.fn.innerfade=function(options){return this.each(function(){$.innerfade(this,options)})};$.innerfade=function(container,options){var settings={animationtype:"fade",speed:"normal",type:"sequence",timeout:2000,containerheight:"auto",runningclass:"innerfade",children:null,onStartFade:function(){return},onMidFade:function(){return},onEndFade:function(){return}};if(options){$.extend(settings,options)}if(settings.children===null){var elements=$(container).children()}else{var elements=$(container).children(settings.children)}if(elements.length>1){$(container).css("position","relative").css("height",settings.containerheight).addClass(settings.runningclass);for(var i=0;i<elements.length;i++){$(elements[i]).css("z-index",String(elements.length-i)).css("position","absolute").hide()}if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(elements,settings,1,0)},settings.timeout);$(elements[0]).show()}else{if(settings.type=="random"){var last=Math.floor(Math.random()*(elements.length));setTimeout(function(){do{current=Math.floor(Math.random()*(elements.length))}while(last==current);$.innerfade.next(elements,settings,current,last)},settings.timeout);$(elements[last]).show()}else{if(settings.type=="random_start"){settings.type="sequence";var current=Math.floor(Math.random()*(elements.length));setTimeout(function(){$.innerfade.next(elements,settings,(current+1)%elements.length,current)},settings.timeout);$(elements[current]).show()}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'")}}}}};$.innerfade.next=function(elements,settings,current,last){if(settings.animationtype=="slide"){settings.onStartFade();$(elements[last]).slideUp(settings.speed,function(){settings.onMidFade()});$(elements[current]).slideDown(settings.speed,function(){settings.onEndFade()})}else{if(settings.animationtype=="fade"){settings.onStartFade();$(elements[last]).fadeOut(settings.speed,function(){settings.onMidFade()});$(elements[current]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);settings.onEndFade()})}else{alert("Innerfade-animationtype must either be 'slide' or 'fade'")}}if(settings.type=="sequence"){if((current+1)<elements.length){current=current+1;last=current-1}else{current=0;last=elements.length-1}}else{if(settings.type=="random"){last=current;while(current==last){current=Math.floor(Math.random()*elements.length)}}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'")}}setTimeout((function(){$.innerfade.next(elements,settings,current,last)}),settings.timeout)}})(jQuery);function removeFilter(element){if(element.style.removeAttribute){element.style.removeAttribute("filter")}};
/*Cufon.replace('.moduleBox h1',{fontFamily:'liberation',fontSize:'24px',fontWeight:'bold',letterSpacing:'0px',color:'#b13c39'});
Cufon.replace('.moduleBox h1 div',{fontFamily:'liberation',fontSize:'14px',fontWeight:'normal',letterSpacing:'0px',color:'#b13c39'});
Cufon.replace('.moduleBox h1 span',{fontFamily:'liberation',fontSize:'20px',fontWeight:'bold',letterSpacing:'0px',color:'#b13c39'});
Cufon.replace('a.division',{fontFamily:'liberation',fontSize:'16px',fontWeight:'bold',letterSpacing:'0px',color:'#ffffff'});*/
var popupStatus = 0;
function loadPopup(div){
    if(popupStatus==0){
        $("#backgroundPopup").css({
        "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("medium");
        $(div).fadeIn("medium");
        popupStatus = 1;
        }
}
function disablePopup(div){
    if(popupStatus==1){
        $("#backgroundPopup").fadeOut("medium");
        $(div).fadeOut("medium");
        popupStatus = 0;
    }
}
function centerPopup(div){
    var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = $(div).height(); var popupWidth = $(div).width();
    $(div).css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
    });
    $("#backgroundPopup").css({
    "height": windowHeight
    });
}

$(document).ready(function(){
    $("#buttonCV").click(function(){
        centerPopup("#popupCV");
        loadPopup("#popupCV");
    });
    $("#buttonReq").click(function(){
        centerPopup("#popupReq");
        loadPopup("#popupReq");
    });
    $(".popupContactClose").click(function(){ disablePopup(".popupContact"); });
    $("#backgroundPopup").click(function(){ disablePopup(".popupContact"); });
    $(document).keypress(function(e){ if(e.keyCode==27 && popupStatus==1){ disablePopup(".popupContact"); } });
    /* News Ticker */
    var newstimer = window.setInterval(changeNews, 3500);
    var i = 0;
    var c = 1;
    function changeNews()
    {
        if(i == 5)
        {  
            $("#healthcarenews_container").scrollTo('0px', 800);
            i = 0;
        }
        else
        {
            if(jQuery.browser.version == "7.0"){
                $("#healthcarenews_container").scrollTo('+=56px', 800);
            }
            else
            {
                $("#healthcarenews_container").scrollTo('+=52px', 800);
            }
        }
        i++;
    }
    $("#healthcarenews_container").mouseenter(function(){
        window.clearInterval(newstimer);
    });
    $("#healthcarenews_container").mouseleave(function(){
        newstimer = window.window.setInterval(changeNews, 2500);
    });
    
    var count = 0;
    var current = 1;
    $("ul#quote>li").each(function(i){
            count += 1;
    });
    
    $('#person ul').innerfade({
			speed: 'slow',
			timeout: 6600,
			type: 'sequence',
			containerheight: '335px',
			onStartFade: function() {
			    var $current = $("#item"+current);
			    current += 1;
			    if(current > count) { current = 1; }
			    var $next = $("#item"+current);
			    $current.fadeOut(this.speed);
			    $next.fadeIn(this.speed);
			}
	});
	
	$("img.a").hover(
    function() {
        $(this).stop().animate({"opacity": "0"}, 300);
    },
    function() {
        $(this).stop().animate({"opacity": "1"}, 300);
    });
});
