Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help Following Code Causing problems with site

    Hi,

    I am using the following code as a AD Rotation system on my wordpress site, the previous theme had no problems with this code, however, I have switched themes to a Gabfire developed theme called City Desk that utilizes a Slider for Featured Articles and the code is causing problems.

    I need the following code to be changed but still function as a AD rotation system that won't cause the problems with the theme, as I have these sponsors under contract for the rotation of the ads.

    Any help will be appreciated

    rsaw3rd

    Code:
    <script type="text/javascript" src="http://www.rockinghamcountymerchants.com/JQUERY/jquery-1.4.3.min.js"></script>
    <style type="text/css" media="screen"> 
    img{border:none}
    .adlink{position:relative;height:167px;width:300px ;display:block}
    .adlink img{position:absolute}
    .active{z-index:2;}
    .next{z-index:1}
    #staticads img{width:90px;height:50px;float:left;border-right:2px;margin: 3px 4px 3px 4px;}
    </style>
    <img src="http://www.rockinghamcountymerchants.com/300x62Banners/186x19AdvertismentsBanner.png" alt="banner"><br />
    <script type="text/javascript"> 
    var ads = [
    
    
    
    
    ['http://www.rockinghamcountymerchants.com/anicolejewelry/300x167-ANicoles.jpg',
    'http://www.rockinghamcountymerchants.com/anicolejewelry/index.html'],
    
    
    ['http://www.rockinghamcountymerchants.com/avante/Avante300x167px.jpg',
    'http://www.rockinghamcountymerchants.com/avante/index.html'],
    
    
    
    ['http://www.rockinghamcountymerchants.com/carolinacafe/300x167-CarolinaCafe.jpg',
    'http://www.rockinghamcountymerchants.com/carolinacafe/index.html'],
    ['http://www.rockinghamcountymerchants.com/catsmeow/300x167-CatsMeow-032811.jpg',
    'http://www.rockinghamcountymerchants.com/catsmeow/index.html'],
    ['http://www.rockinghamcountymerchants.com/ChambersCommerce/300x167-ChambersCommerce.jpg',
    'http://www.rceno.com/RCENO/advertisers/ChambersOfCommerce/index.html'],
    
    ['http://www.rockinghamcountymerchants.com/DavidFrizzellInvestigations/300x167-DFI.jpg',
    'http://www.rockinghamcountymerchants.com/DavidFrizzellInvestigations/DFIredirect.html'], 
    ['http://www.rockinghamcountymerchants.com/DavidPriceAutoWorks/DavidPrice-Jan2013.jpg',
    'http://www.rockinghamcountymerchants.com/DavidPriceAutoWorks/index.html'],
    ['http://www.rockinghamcountymerchants.com/Diamonds-N-Dust/300x167-Diamonds-N-Dust-Aug2012.jpg',
    'http://www.rockinghamcountymerchants.com/Diamonds-N-Dust/index.html'],
    
    
    ['http://www.rockinghamcountymerchants.com/EOJ/300x167-EdensOwn.jpg',
    'http://www.rockinghamcountymerchants.com/EOJ/EOJ-REDIRECT.html'],
    ['http://www.rockinghamcountymerchants.com/elizabeths-wentworth/300x167-ElizabethsWentworthEden.jpg',
    'http://www.rockinghamcountymerchants.com/elizabeths-wentworth/index.html'],
    
    ['http://www.rockinghamcountymerchants.com/fairfuneralhome/300x167FairsFuneral1.jpg',
    'http://www.rockinghamcountymerchants.com/fairfuneralhome/FairREDIRECT.html'],
    
    
    
    ['http://www.rockinghamcountymerchants.com/HolidayInnExpress/HolidayInnExpress300x250.jpg',
    'http://www.rockinghamcountymerchants.com/HolidayInnExpress/index.html'],
    ['http://www.rockinghamcountymerchants.com/HOSPICE/HOSPICE-300x167.jpg',
    'http://www.rockinghamcountymerchants.com/HOSPICE/HospiceREDIRECT.html'],
    
    
    ['http://www.rockinghamcountymerchants.com/Kameldas/kamelda300x167-062111.jpg',
    'http://www.rockinghamcountymerchants.com/Kameldas/KameldasREDIRECT.html'],
    ['http://www.rockinghamcountymerchants.com/kingsway4/300x167Theatres-April2011.jpg',
    'http://www.rockinghamcountymerchants.com/kingsway4/'],
    
    
    ['http://www.rockinghamcountymerchants.com/MARC/MARC-300x167-JourneyStories.jpg',
    'http://www.rockinghamcountymerchants.com/MARC/MARCredirect.html'],
    ['http://www.rockinghamcountymerchants.com/SMcCollumMechanical/300x167-SMcCollumMechanical.jpg',
    'http://www.rockinghamcountymerchants.com/SMcCollumMechanical/SMM-Redirect.html'],
    ['http://www.rockinghamcountymerchants.com/monoreminimart/300x167-FebMonroeMM-GS-Collect.jpg',
    'http://www.rockinghamcountymerchants.com/monoreminimart/index.html'],
    ['http://www.rockinghamcountymerchants.com/MoreheadHospital/300x167-MMH-CASE-031313.jpg',
    'http://www.rockinghamcountymerchants.com/MoreheadHospital/MoreheadHospitalREDIRECT.html'],
    
    
    ['http://www.rockinghamcountymerchants.com/PSSSPA/300x167-pssspa-GWMLayout.jpg',
    'http://www.rockinghamcountymerchants.com/PSSSPA/PSSSPA-Redirect.html'], 
    
    
    
    ['http://www.rockinghamcountymerchants.com/redrivergrill/March2013-RedRiverMarchMadness.jpg',
    'http://www.rockinghamcountymerchants.com/redrivergrill'],
    ['http://www.rockinghamcountymerchants.com/ReggieDenneyAuto/300x167ReggieDenney.jpg',
    'http://www.rockinghamcountymerchants.com/ReggieDenneyAuto/index.html'],
    ['http://www.rockinghamcountymerchants.com/eventcenter/300x250REC-RYD.jpg',
    'http://www.theexhibitcenter.com'],
    
    ['http://www.rockinghamcountymerchants.com/RCBTC/RCBTC-March2012.jpg',
    'http://www.rockinghamcountymerchants.com/RCBTC/index.html'],
    ['http://www.rockinghamcountymerchants.com/RCC/RCC-Nov2012-300x167.jpg',
    'http://www.rockinghamcountymerchants.com/RCC'],
    
    ['http://www.rockinghamcountymerchants.com/RCPC/RCPS300x167-April2012Rev1.jpg',
    'http://www.rockinghamcountymerchants.com/RCPC/RCPC-REDIRECT.html'],
    
    
    ['http://www.rockinghamcountymerchants.com/WLOE/300x167-WLOEWMYN.jpg',
    'http://www.rockinghamcountyradio.com'],
    
    
    ['http://www.rockinghamcountymerchants.com/SKATbus/300x167-SKAT-ver1.jpg',
    'http://www.rockinghamcountymerchants.com/SKATbus/RideSKAT-REDIRECT.html']
    
    
    ];
    
    // preload the images:
    var adimages = [];
    for ( var i = 0; i < ads.length; ++i )
    {
    adimages[i] = new Image();
    adimages[i].src = ads[i][0];
    
    }
    
    var curad = 0;
    var lastad = null;
    
    var numberOfAdSpots = 4;
    var numberOfStaticAds = 28;
    
    // random re-ordering
    function scramble()
    {
    for ( var i = 0; i < ads.length; ++i )
    {
    var r = Math.floor( ads.length * Math.random() );
    var temp = ads[r];
    ads[r] = ads[i];
    ads[i] = temp;
    }
    if ( lastad == ads[0] )
    {
    ads[0] = ads[ads.length-1];
    ads[ads.length-1] = lastad;
    }
    }
    
    function getnextad( )
    {
    ad = ads[curad];
    ++ curad;
    if ( curad >= ads.length )
    {
    scramble();
    curad = 0;
    }
    lastad = ad;
    return ad;
    }
    
    function showNextSet( )
    {
    for ( var inum = 1; inum <= numberOfAdSpots; ++inum )
    {
    var link = $('#adlink' + inum);
    var ad = getnextad();
    link.attr('href',ad[1]);//set the href on the link
    link.find('.next').attr('src',ad[0]);//set new image to the src on the .next element
    link.find('.active').fadeOut(600,function(){//fade the top image out, and when the fade has completed
    $(this).siblings('.next').removeClass('next').addC lass('active');
    $(this).removeClass('active').addClass('next').sho w();//swap the active/next classes on both images
    }); 
    }
    setTimeout( showNextSet, 7000 ); // 7 seconds between changes
    }
    onload=function(){
    $('.active').hide();
    scramble();
    for (var j=1;j<=numberOfStaticAds;++j)
    {
    var staticad = getnextad();
    $('#staticads').append('<a></a>');//append a link
    $('#staticads a:last').attr('href',staticad[1]).append('<img>');//add the href and append an image to the last link (which is the one created on the line above)
    $('#staticads a:last img').attr('src',staticad[0]);//add the src to the last link image, created above
    }
    showNextSet();
    }
    </script>
    <div>
    <a id="adlink1" class="adlink" href="" target="PopupAd">
    <img class="active" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    <img class="next" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    </a>
    </div>
    <br />
    <div>
    <a id="adlink2" class="adlink" href="" target="PopupAd">
    <img class="active" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    <img class="next" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    </a>
    </div>
    <br />
    <div id="staticads"></div>
    <div class="clear"></div>
    <br />
    <div>
    <a id="adlink3" class="adlink" href="" target="PopupAd">
    <img class="active" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    <img class="next" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    </a>
    </div>
    <br />
    <div>
    <a id="adlink4" class="adlink" href="" target="PopupAd">
    <img class="active" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    <img class="next" src="loading.gif" alt="ad" style="height: 167px; width: 300px;">
    </a>
    </div>
    <div class="clear"></div>

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    well, you say it's causing problems, but you don't specify what the problem is.
    is it not working? do you get an error? when you laod the page, what errors are you getting in the console of your web browser?

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, you are correct, I see I did not go into enough detail, I apologize...

    Will try and clear up...

    The theme I wanted to use utilizes a Featured Article Slider and also a "Lightbox" style pop up on the home page and inner pages.

    The Featured Article Slider rotates automatically or when a link is clicked, this is when it is working correctly, However when I placed the above code, (Which I have been using on a previous theme with much success for the past 2 years, thus the reason for wanting to keep, as my advertisers are sold on the display and rotation of ads) - It breaks the Slider and the Lightbox pop-up, meaning which the Slider will not auto rotate nor will it switch the featured articles when clicked, nor will the Lightbox style popup appear.

    I guess the two codes are in conflict with there call to actions or for some other reason and thought if elements of the above code could be renamed or referenced that it would not break the theme's use of similar code.

    Or perhaps there is another way to accomplish the same task with the above code that doesn't require javascript, not sure, but searching for ideas. Just need the Random Rotation Element and Random display of the Thumbs of the ADs on each load.

    Thanks for any and all help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •