
var ads = [
    {
        'title': 'QTC Offers Largest Selection of Metric Gears',
        'name': '<a href="ad.jsp?skin=<%= skin %>&c=qtc&l=http://www.qtcgears.com">Quality Transmission Components</a>',
        'image':'<div><a href="ad.jsp?skin=<%= skin %>&c=qtc&l=http://www.qtcgears.com/catalog.htm"><img src="images/ads/qtc.png" /></a></div>',
        'copy': 'Supplier of off-the-shelf metric gears, timing pulleys, timing belts and related power ' +
                'transmission components. Over 23,000 different configurations of stock metric gears and ' +
                'related power transmission products designed for use in industrial automation applications. ' +
                '3D CAD models, pricing and product availability are all available at <a href="ad.jsp?skin=<%= skin %>&c=qtc&l=http://www.qtcgears.com/catalog.htm">' +
                'www.qtcgears.com/catalog.htm</a>'
    },
    {
        'title': 'Quality components, CAD models, online pricing, estore, and much more',
        'name': '<a href="ad.jsp?skin=<%= skin %>&c=winco&l=http://www.jwwinco.com">J.W. Winco, Inc.</a>',
        'image': '<div><a href="ad.jsp?skin=<%= skin %>&c=winco&l=http://www.jwwinco.com"><img src="images/ads/jwwinco3dms.jpg" /></a></div>',
        'copy': 'Huge selection of inch and metric size adjustable levers, handles, handwheels, cranks, ' +
                'conveyor components, leveling mounts, knobs, spring plungers, fixture and fastening components, ' +
                'toggle clamps, tube clamping components, and much more!'
    },
    {
        'title': 'Fixtureworks 3D CAD Models Now Available on 3DModelSpace',
        'name': '<a href="ad.jsp?skin=<%= skin %>&c=fixtureworks&l=http%3A%2F%2Fwww.3dmodelspace.com%2Fsearch.jsp%3Fskin%3Ddefault%26q%3Dfixtureworks">Fixtureworks</a>',
        'image': '<div><a href="ad.jsp?skin=<%= skin %>&c=fixtureworks&l=http%3A%2F%2Fwww.3dmodelspace.com%2Fsearch.jsp%3Fskin%3Ddefault%26q%3Dfixtureworks"><img src="images/ads/fixtureworks.jpg" /></a></div>',
        'copy': 'Manufacturer & Supplier of unique industrial products that range from modular fixturing components, ' +
                'workholding devices, to standard machine elements. ' +
                '<a href="ad.jsp?skin=<%= skin %>&c=fixtureworks&l=http%3A%2F%2Fwww.3dmodelspace.com%2Fsearch.jsp%3Fskin%3Ddefault%26q%3Dfixtureworks">' +
                'Search Fixtureworks</a> on 3DModelSpace'
    },
    {
        'title': 'We provide both custom engineered and standard casters for all types of industries.',
        'name': '<a href="ad.jsp?skin=<%= skin %>&c=calicaster&l=http://www.californiacaster.com/">California Caster & Hand Truck</a>',
        'image': '<div><a href="ad.jsp?skin=<%= skin %>&c=calicaster&l= http://www.californiacaster.com/"><img src="images/ads/californiacaster.jpg" /></a></div>',
        'copy': 'Over 60 years of trusted material handling equipment solutions. Leading distributor of casters, carts, dock '  +
		' equipment, dollies, hand trucks, leveling mounts, pallet jacks, platform trucks, rolling ladders, spring '	+
		' plungers, swivel pad clamps, and more.'
    },
    
    {
	'title': 'Electromechanical Products for an Increasingly Interconnected World',
	'name': '<a href="ad.jsp?skin=<%= skin %>&c=qtc&l=http://www.cui.com">CUI Inc</a>',
	'image': '<div><a href="ad.jsp?skin=<%= skin %>&c=cui&l=http://www.cui.com"><img src="images/ads/cui.jpg" /></a></div>',
	'copy': ' '
    },
];

function initAdvertisements() {
    var i, a = [], ad1, ad2, ad3 = Math.floor(Math.random() * ads.length);

    for (i = 0; i < ads.length; i++) {
        if (i != ad3) {
            a.push(i);
        }
    }
    ad2 = a[Math.floor(Math.random() * (ads.length - 1))];

    a = [];
    for (i = 0; i < ads.length; i++) {
        if (i != ad3 && i != ad2) {
            a.push(i);
        }
    }
    ad1 = a[Math.floor(Math.random() * (ads.length - 2))];

    setAds(ad1, ad2, ad3);
}

function setAds(ad1idx, ad2idx, ad3idx) {
    var ltitle = ads[ad1idx]['title'],
        mtitle = ads[ad2idx]['title'],
        rtitle = ads[ad3idx]['title'],
        lname = ads[ad1idx]['name'],
        mname = ads[ad2idx]['name'],
        rname = ads[ad3idx]['name'],
        lcopy = '', mcopy = '', rcopy = '';

    if (ads[ad1idx]['image']) {
        lcopy = ads[ad1idx]['image'];
    }
    if (ads[ad2idx]['image']) {
        mcopy = ads[ad2idx]['image'];
    }
    if (ads[ad3idx]['image']) {
        rcopy = ads[ad3idx]['image'];
    }
    lcopy += ads[ad1idx]['copy'];
    mcopy += ads[ad2idx]['copy'];
    rcopy += ads[ad3idx]['copy'];

    document.getElementById('leftSupplierTitle').innerHTML = ltitle;
    document.getElementById('midSupplierTitle').innerHTML = mtitle;
    document.getElementById('rightSupplierTitle').innerHTML = rtitle;
    document.getElementById('leftSupplierName').innerHTML = lname;
    document.getElementById('midSupplierName').innerHTML = mname;
    document.getElementById('rightSupplierName').innerHTML = rname;
    document.getElementById('leftSupplierCopy').innerHTML = lcopy;
    document.getElementById('midSupplierCopy').innerHTML = mcopy;
    document.getElementById('rightSupplierCopy').innerHTML = rcopy;
}


