//Light Window

$('.defaultDOMWindow').openDOMWindow({ 
eventType:'click', 
loader:1, 
loaderImagePath:'http://swip.codylindley.com/animationProcessing.gif', 
loaderHeight:16, 
loaderWidth:17,
borderSize:0,
windowBGColor:'#F4F4F4',
width: 700,
height: 600 
}); 

//HP rotator
function theRotator() {
      $('#promotions ul li').css({opacity: 0.0});
      $('#promotions ul li:first').css({opacity: 1.0}).addClass('show');
      $('#next').click(function(){
	    rotate()
	    clearInterval(play);
      	return false;
      });
      $('#previous').click(function(){
	    var current = ($('#promotions ul li.show')?  $('#promotions ul li.show') : $('#promotions ul li:first'));
	    var previous = ((current.prev().length) ? ((current.prev().hasClass('show')) ? $('#promotions ul li:last') :current.prev()) : $('#promotions ul li:last'));    
		previous.css({opacity: 0.0})
	    .addClass('show')
	    .animate({opacity: 1.0}, 1000);
	    current.animate({opacity: 0.0}, 1000)
	    .removeClass('show');
	    clearInterval(play);
      	return false;
      });
      timedRotate()
}

function timedRotate() {
	play = setInterval('rotate()',6000);
};

function rotate() {    
    var current = ($('#promotions ul li.show')?  $('#promotions ul li.show') : $('#promotions ul li:first'));
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#promotions ul li:first') :current.next()) : $('#promotions ul li:first'));    
	next.css({opacity: 0.0})
    .addClass('show')
    .animate({opacity: 1.0}, 1000);
    current.animate({opacity: 0.0}, 1000)
    .removeClass('show');
};

//

$(document).ready(function() {
    if($('#promotions ul li').length > 1){
    	$('#previous').css({cursor:'pointer'});
    	$('#next').css({cursor:'pointer'});
    	theRotator();				       
    }
    
	$('a').each(function(index) {
		var $target = $(this).attr("target");
		var blank = /blank/;
		if($target.match(blank)) {
		 $(this).addClass( 'external' ).attr( 'title' , 'External link' ); 
		}    
	});
    
    
});

