﻿/* ---------------------------------------------------------------------

OSUAA Promo Ad Image Rotator
Written by SusQtech
www.susqtech.com

* requires: 
	jQuery 1.3.2 or later
	jquery.cycle.lite.1.0.min.js  

--------------------------------------------------------------------- */
/* 
	possible configuration settings when using the cycle plugin
		
    timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance) 
    speed:         1000,  // speed of the transition (any valid fx speed value) 
    next:          null,  // id of element to use as click trigger for next slide 
    prev:          null,  // id of element to use as click trigger for previous slide 
    before:        null,  // transition callback (scope set to element to be shown) 
    after:         null,  // transition callback (scope set to element that was shown) 
    height:       'auto', // container height 
    sync:          1,     // true if in/out transitions should occur simultaneously 
    fit:           0,     // force slides to fit container 
    pause:         0,     // true to enable "pause on hover" 
    delay:         0,     // additional delay (in ms) for first transition (hint: can be negative) 
    slideExpr:     null   // expression for selecting slides (if something other than all children is required) 
*/ 

$(document).ready(function() {

	// get each item from web part
    $('.promoAdImageContainer').each(function() {
		var title = $(this).children('#promoAdImageTitle').text();
		var position = $(this).children('#promoAdImagePosition').text();
		var linkUrl = $(this).children('#promoAdLinkUrl').text().split(",",1);
		var image = $(this).children('#promoAdImageUrl').text();				
						
		var imageHTML = "<div class=\"OSUAAPromoAdImage\" ><a href=\""+linkUrl+"\"><img src=\"/"+image+"\" title=\""+title+"\" /></a></div>";
		$('#OSUAAPromoAdImages').append(imageHTML);									
    });
    
    $('#OSUAAPromoAdImages').before('<ul id="OSUAAPromoAdPager"').cycle({
			speed:			1000,
			timeout:		4000,	
			pause:			1,
	  		slideExpr:		'.OSUAAPromoAdImage',   // expression for selecting slides (if something other than all children is required)    
	    	pager:			'#OSUAAPromoAdPager',
		    // callback fn that creates a thumbnail to use as pager anchor 
		    pagerAnchorBuilder: function(idx, slide) { 
		        return '<li><a href="#"><img src="/Style%20Library/Images/spacer.gif" height="14px" width="14px" /></a></li>'; 
		    }    	
    		
    });
   
    
});

