﻿
var popuptips_lasttimeout=null;
function startPopupTips(arrayselectors,arrayheaders,arraytips)
{
    $("body").append($("<div></div>")
                    .addClass("callout")
                    .attr("id","popuptip"));
    showNextTip(0,arrayselectors,arrayheaders,arraytips);
    $(document).unload(function(){clearTimeout(popuptips_lasttimeout);});
}
function showNextTip(index,arrayselectors,arrayheaders,arraytips)
{
    var $tip = $("#popuptip")
                    .fadeOut(1000,
                        function(){
                        
                            if(arrayselectors.length>index)
                            {
                                var $element = $(arrayselectors[index],getTopWin(window)).add(arrayselectors[index]);
                                var tip = "<h2>"+arrayheaders[index]+"</h2>"+"<p>"+arraytips[index]+"</p>";
                                var $popup = $(this);
                                
                                getTopWin(window).$.scrollTo($element.offset().top,500);
                                $popup
                                    .text("")
                                    .css("top",$element.offset().top+$element.height()+20)
                                    .css("left",$element.offset().left+(($element.width()-$popup.width())/2))
                                    .append(tip)
                                    .fadeIn(1000,
                                        function(){
                                            var shownext = function(){showNextTip(index+1,arrayselectors,arrayheaders,arraytips);};
                                            popuptips_lasttimeout =  setTimeout(shownext,5000);
                                        }
                                    );
                           }
                        }
                    )
                    ;
}

