// Gravity Package(lifeline.js and lifeline_vb.js) must be included in html pages with this 
// file AND LL_initial() must be called, so LL_risitor_id is set before calling load functions

var LL_home_sm_timeout;
var LL_home_lg_timeout;
var LL_tert_timeout;

function LL_loadSmallHomePTarget() {
    var url = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&home_sm=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContent = '<alt/><a href="http://www.mksinst.com/product/product.aspx?ProductID=103"><img src="/images/pt-2-pt3ia.png" border="0" width="226" height="99"></a>';
    LL_home_sm_timeout = LL_loadAltPTContent('sm_iframe_div', altContent, 3000);  // make delayed call to load alternate content
    document.write(['<sc', 'ript src="', url, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
}

function LL_loadLargeHomePTarget() {
    var url = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&home_lg=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContent = '<alt/><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="323" height="311" id="ptpages/mks-prim-default.swf" align="">\n<param name="movie" value="mks-prim-default.swf?">\n<param name="quality" value="high">\n<param name="bgcolor" value="#000000">\n<embed src="mks-prim-default.swf?" quality="high" bgcolor="#000000"  width="323" height="311" name="mks-prim-default.swf" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n</embed>\n</object>';
    LL_home_lg_timeout = LL_loadAltPTContent('lg_iframe_div', altContent, 3000);  // make delayed call to load alternate content
    document.write(['<sc', 'ript src="', url, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
}

function LL_loadHomePTarget() {
    var urlSm = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&home_sm=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContentSm = '<alt/><a href="http://www.mksinst.com/product/product.aspx?ProductID=103"><img src="/images/pt-2-pt3ia.png" border="0" width="226" height="99"></a>';
    var urlLg = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&home_lg=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContentLg = '<alt/><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="323" height="311" id="ptpages/mks-prim-default.swf" align="">\n<param name="movie" value="mks-prim-default.swf?">\n<param name="quality" value="high">\n<param name="bgcolor" value="#000000">\n<embed src="mks-prim-default.swf?" quality="high" bgcolor="#000000"  width="323" height="311" name="mks-prim-default.swf" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n</embed>\n</object>';

    LL_home_sm_timeout = LL_loadAltPTContent('sm_iframe_div', altContentSm, 3000);  // make delayed call to load alternate content
    LL_home_lg_timeout = LL_loadAltPTContent('lg_iframe_div', altContentLg, 3000);  // make delayed call to load alternate content

    document.write(['<sc', 'ript id="sm_iframe_div_script" src="', urlSm, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
    document.write(['<sc', 'ript id="lg_iframe_div_script" src="', urlLg, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
    return
}

function LL_loadTertPTarget() {
    var url = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&tert_sm=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContent = '<alt/><a href="http://www.mksinst.com/product/category.aspx?categoryID=101" ><img src="http://www.mksinst.com/images/BACKUPpt-fab-tertiary.gif" border="1" width="194" height="98" /></a>';
    LL_tert_timeout = LL_loadAltPTContent('tert_iframe_div', altContent, 3000);  // make delayed call to load alternate content
    document.write(['<sc', 'ript src="', url, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
}

function LL_loadPTHomeBanner() {
    var url = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&home_ban=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContentSm = '<alt/><a href="http://www.mksinst.com/markets/SolarEnergy.aspx"><img src="images/home-solar.jpg" id="ptMain" border="0" width="300" height="469"></a>';
    LL_home_timeout = LL_loadAltPTContent('home_iframe_div', altContentSm, 3000);  // make delayed call to load alternate content
    document.write(['<sc', 'ript src="', url, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
}

function LL_loadPTInsideBanner() {
    var url = ['http://gravity.psynchronous.com/20/ptserve.py?group=1&ins_ban=1&risitor_id=', LL_risitor_id, '&rand=', Math.round(Math.random() * 10000)].join('');
    var altContentSm = '<alt/><a href="http://www.mksinst.com/markets/PharmaceuticalMedicine.aspx"><img src="http://www.mksinst.com/images/ins-pharma.jpg" border="0" width="230" height="200"></a>';
    LL_ins_timeout = LL_loadAltPTContent('ins_iframe_div', altContentSm, 3000);  // make delayed call to load alternate content
    document.write(['<sc', 'ript src="', url, '"></sc', 'ript>'].join(''));  // make call to gravity. a successful call should cancel delayed call above and load content
}

function LL_loadAltPTContent (div, content, time) {
    return setTimeout(function () {
        var divObj = document.getElementById(div);
        if (divObj) {
            divObj.innerHTML = content;
        }
    }, time);
}

