        var WidgetListInArray = new Array();
        var WidgetTitleInArray = new Array();
                       WidgetListInArray[0] ='10';
               WidgetTitleInArray[0] ='How Much Are My Payments?';
                       WidgetListInArray[1] ='9';
               WidgetTitleInArray[1] ='How Much Can I Borrow?';
         
document.write('<script type="text/javascript" src="http://www.mortgagefit.com/sys/common/tools/js/movable-win.js"></script>');

function showWidgetdiv(e,WidgetType)
{                       
        if(e != undefined)
          FnSetTopForInfoWin(e)                                                       
        var IframeObj = document.getElementById('WidgetInfoIFrame');
        IframeObj.src ='http://www.mortgagefit.com/widgets/widgetshtmcache/'+WidgetType+'.htm';
        setTimeout("winList['WidgetWindow'].open()", 500);
}
function FnSetTopForInfoWin(e)
{
        var x=0;
        var y=0;

        if (e.pageX || e.pageY)
        {
                x = e.pageX;
                y = e.pageY;
        }
        else if (e.clientX || e.clientY)
        {
                x = e.clientX + document.body.scrollLeft;
                y = e.clientY + document.body.scrollTop;
        }

        var WinDivObj = document.getElementById('WidgetWindow');

        WinDivObj.style.top = (y+40)+"px";
}

function FnShowInitialTableForWidgetForm(WidgetLink)
{
        var InitialTable = ''; 
        var IframeCode = '<IFRAME id="WidgetInfoIFrame" src="" scrolling="auto" frameborder="0" width="100%" height="100%"></IFRAME>';
        var WindowHTMLCode = '<div id="WidgetWindow" class="window" style="left: 219px; z-index: 6; width: 597px; visibility:hidden;" align="left">';
        WindowHTMLCode += '<div style="" class="titleBar">';
        WindowHTMLCode += '<span style="" class="titleBarText">Mortgage Widget.</span>';
        WindowHTMLCode += '<span style=""><img class="titleBarButtons" alt="" src="http://www.mortgagefit.com/styles/mortgage/img/nav-button.gif" usemap="#MiniForumMap">';
        WindowHTMLCode += '<map id="MiniForumMap" name="MiniForumMap">';
        WindowHTMLCode += '<area shape="rect" coords="0,0,15,13" href="" alt="" title="Minimize" onclick="this.parentWindow.minimize();return false;">';
        WindowHTMLCode += '<area shape="rect" coords="16,0,31,13" href="" alt="" title="Restore" onclick="this.parentWindow.restore();return false;">';
        WindowHTMLCode += '<area shape="rect" coords="34,0,49,13" href="" alt="" title="Close" onclick="this.parentWindow.close();return false;">';
        WindowHTMLCode += '</map></span></div>';
        WindowHTMLCode += '<div id="ShowTopicInfo" class="clientArea" style="top:30px; height:500px" >'+IframeCode+'</div>';
        WindowHTMLCode += '</div>';
        
        if(ShowList > 0)
        {
             InitialTable =  this.FnCreateWidgetList(WidgetLink);
        }
        
      document.getElementById('WidgetBoardBox').innerHTML = InitialTable+WindowHTMLCode;            

        
}
function FnCreateWidgetList(WidgetLink)
{
   
     var InitialTable = ''; 
     if(WidgetLink =='http://www.mortgagefit.com/')
        {
                InitialTable += '<table border="'+BorderWidth+'" cellspacing="0" cellpadding="5"  bordercolor="'+BorderColor+'" width="'+BoxWidth+'" height="'+BoxHeight+'">';
                InitialTable += '<tr><td valign="top" width="" height="" bgcolor="'+BackGroundColor+'" class="hedirmessagetext"><ul>';
                var Counter;
                for(Counter=0;Counter<WidgetListInArray.length;Counter++)
                   {
                          InitialTable +='<li><a href="javascript:showWidgetdiv(event,'+WidgetListInArray[Counter]+');">'+WidgetTitleInArray[Counter]+'</a></li>'; 
                         
                   }
                InitialTable += '</ul></td></tr></table>';

                
       }
        else
        {
               InitialTable += 'Oops, Either the code has changed or it is manipulated at your end. Please get the code again from <a href="">Mortgagefit</a>'; 
        }
       return  InitialTable;

}

function FnInitialiseCSSAndShowInitialTableForWidgetForm()
{
       var WidgetLinkInArray = FnExplodeWidgetLinkURL(document.getElementById('WidgetLink'),"/");   
       var WidgetLink=WidgetLinkInArray[0]+"//"+WidgetLinkInArray[2]+"/"; 
                                        
       FnShowInitialTableForWidgetForm(WidgetLink);
}
FnInitialiseCSSAndShowInitialTableForWidgetForm();
/* This function will explode the string in to array. */

function FnExplodeWidgetLinkURL(inputstring, separators, includeEmpties) {
                inputstring = new String(inputstring);
                separators = new String(separators);

                if(separators == "undefined") {
                separators = " :;";
                }

                fixedExplode = new Array(1);
                currentElement = "";
                count = 0;

                for(x=0; x < inputstring.length; x++) {
                Character = inputstring.charAt(x);
                if(separators.indexOf(Character) != -1) {
                if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { }
                else {
                fixedExplode[count] = currentElement;
                count++;
                currentElement = ""; } }
                else { currentElement += Character; }
                }

                if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
                fixedExplode[count] = currentElement; }
                return fixedExplode;
}

