

var pathPrefix = '';

function AddQueryStringParameter(url, paramname, paramvalue)
{
    var rval = url;
    var pos1;
    var pos2;
    
    if (paramname == '')
        return rval;
        
    pos1 = url.indexOf("?");
    if (pos1 < 0)
    {
        rval += "?" + paramname + "=" + escape(paramvalue);
    }
    else
    {
        pos1 = url.indexOf(paramname+"=",pos1);
        if (pos1 >= 0)
        {
            pos1 += paramname.length() + 1;
            pos2 = url.indexOf("&",pos1);
            if (pos2 >= 0)
            {
                rval = url.substring(0,pos1) + escape(paramvalue) + url.substring(pos2);
            }
            else
            {
                rval = url.substring(0,pos1) + escape(paramvalue);
            }
        }
        else
        {
            rval += "&" + paramname + "=" + escape(paramvalue);
        }
    }
        
    return rval;
}

function modifyUrl(url,randParam,randVal)
{
    var rval = url;
    if (randParam != '')
    {
        rval = AddQueryStringParameter(rval,randParam,randVal);
    }
    return rval;
}

function writeSponsorFrameSet2(mainPage,toolbar,urlTop,topHeight,urlRight,rightWidth,rightScrolling,randParam)
{
    var randVal = Math.random();
    randVal = Math.floor(randVal * 32768);


    document.write('<frameset rows="' + topHeight + ', *" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpTop" src="' + modifyUrl(urlTop,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset cols="*, ' + rightWidth + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    if (toolbar.indexOf('m_all_my_sites') >= 0 )
    {
        document.write('<frameset rows="*, 60" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    else
    {
        document.write('<frameset rows="*, 52" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    document.write('<frame src="' + mainPage + '" name="fBody" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frame src="' + toolbar + '" name="fBottom" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    
    document.write('<frame name="fSpRight" src="' + modifyUrl(urlRight,randParam,randVal) + '" frameborder="0" scrolling="' + rightScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('</frameset>\r\n');

    
}

function writeSponsorFrameSet3(mainPage,toolbar,urlTop,topHeight,urlLeft,leftWidth,urlRight,rightWidth,rightScrolling,urlBottom,bottomHeight,bottomScrolling,randParam)
{
    var randVal = Math.random();
    randVal = Math.floor(randVal * 32768);


    document.write('<frameset rows="' + topHeight + ', *" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpTop" src="' + modifyUrl(urlTop,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset cols="' + leftWidth + ', *, ' + rightWidth + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpLeft" src="' + modifyUrl(urlLeft,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset rows="*, ' + bottomHeight + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    
    if (toolbar.indexOf('m_all_my_sites') >= 0)
    {
        document.write('<frameset rows="*, 60" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    else
    {
        document.write('<frameset rows="*, 52" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    document.write('<frame src="' + mainPage + '" name="fBody" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frame src="' + toolbar + '" name="fBottom" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    
    document.write('<frame name="fSpBottom" src="' + modifyUrl(urlBottom,randParam,randVal) + '" frameborder="0" scrolling="' + bottomScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('<frame name="fSpRight" src="' + modifyUrl(urlRight,randParam,randVal) + '" frameborder="0" scrolling="' + rightScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('</frameset>\r\n');

    
}

function WriteFrameSet(top, middle, bottom, renderPage, mode, isGem, topHeight)
{
	if (renderPage == true) {
		middle =  'SiteBuilderServlet?Command=RenderPage&PageNum=' + Get_Cookie('page_num') + '&Mode=' + mode + '&RenderError=f_error.html';
	}
	
    if (topHeight == null || topHeight <= 0)
    {
        topHeight = '51';
    }
	

		document.write('<FRAMESET ROWS="'+topHeight+', *, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	    document.write('<FRAME NAME="fTop" SRC="' + pathPrefix + top + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME SRC="' + middle + '" NAME="fBody" FRAMEBORDER="0" SCROLLING="Auto" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');	

}

function writeDialogFrameSet(middle, bottom)
{
	document.write('<FRAMESET ROWS="*, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	document.write('<FRAME SRC="' + middle + '" NAME="fBody" FRAMEBORDER="0" SCROLLING="Auto" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
	document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
	document.write('</FRAMESET>');
}

function WriteAdFrameSet(adReqPage, middle, bottom, renderPage, mode, isGem)
{
    WritePageFrameSet(adReqPage, middle, bottom, '', renderPage, mode, isGem)
}
function WritePageFrameSet(adReqPage, middle, bottom, pageid, renderPage, mode, isGem)
{

    WriteFrameSet('top_small.jsp?pageid='+pageid, middle, bottom, renderPage, mode, isGem);

}

function WritePreviewFrameSet(middle, bottom, renderPage, mode)
{
	if (renderPage == true) {
		middle =  'SiteBuilderServlet?Command=RenderPage&PageNum=' + Get_Cookie('page_num') + '&Mode=' + mode + '&RenderError=f_error.html';
	}
	
		document.write('<FRAMESET ROWS="*, 60" FRAMESPACING="0" FRAMEBORDER="0" NORESIZE="YES" MARGINWIDTH="0" MARGINHEIGHT="0" BORDER="0">');
	    document.write('<FRAME SRC="' + middle + '" NAME="fBody" FRAMEBORDER="0" SCROLLING="Auto" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');	
}

function logPageView(action,layout,refresh)
{
    // load blank.gif logging image
    var randVal;
    randVal = Math.random();
    randVal = Math.floor(randVal * 32768);
    var logimg = new Image();
    var pg = top.location.href;
    var pos = pg.lastIndexOf('/');
    if (pos >= 0) pg = pg.substring(pos+1);
    pos = pg.indexOf('?');
    if (pos >= 0) pg = pg.substring(0,pos);
    logimg.src = 'images/blank.gif?log=1&page='+pg+'&action='+action+'&layout='+layout+'&refresh='+refresh+'&r='+randVal;
}

function replaceBottomFrame(filename)
{
	//alert(filename);
	top.fBottom.location.replace( filename);
}



