var cmd = {
	'c1': {
		'title': 'Allslots Casino',
		'desc' : 'All Slots Casino is a popular casino with good reputation in the market. All Slots Casino offers a variety of good bonuses and popular games for mobile customers.',
		'link' : 'https://instant.allslotscasino.com/?utm_campaign=All+Slots+English+Instant+Play+redirect&utm_source=asaff04440_&utm_medium=Affiliate&utm_term=&utm_content=All+Slots+English+Instant+Play+redirect&'
	},
	'c2': {
		'title': 'Royal Vegas Casino',
		'desc' : 'Royal Vegas has good reputation among players and has been around for over a decade. With good payout rates, Royal Casino is the first choice among many loyal casino players.',
		'link' : 'http://www.royalvegas.eu/'
	},
	'c3': {
		'title': 'JackpotCity Casino',
		'desc' : 'JackpotCity is one of our most popular casino rooms. The casino is ranked among the best by its players with excellent customer support and offers popular casino games directly to your mobile phone.',
		'link' : 'http://www.redirectorsworld.com/re/default.aspx?SiteID=1&s=aff115425&b=sb371'
	},
	'c4': {
		'title': 'William Hill Mobile Casino',
		'desc' : 'The entertainment giant William Hill is among the first movers on mobile casino experience. Providing games and entertainment for several decades, the William Hill group now also offers popular casino games directly on your mobile.',
		'link' : 'http://serve.williamhillcasino.com/promoRedirect?member=kyoogi2&campaign=DEFAULT&channel=DEFAULT&zone=1469078565&lp=720775485'
	},
	'c5': {
		'title': '32 Red Online Casino',
		'desc' : 'UK’s favourite casino site is now offering popular games on your mobile. Listed on the London Stock Exchange, 32Red group is now also offering mobile casino to mobile users.',
		'link' : 'http://resources.32red.com/redirect.aspx?pid=18504&bid=3100'
	},
	'c6': {
		'title': 'Wild Jack',
		'desc' : 'Wild Jack Casino offers players easy access to popular casino games. With several games offered to mobile customers, Wild Jack Casino is one of the top mobile casinos available.',
		'link' : 'http://www.brightshare.com/clickscounter.php?compaign=95&groupid=0&bTag=wjaff04440&affid=10009400'
	},
	'c7': {
		'title': 'Platinum Play',
		'desc' : 'Platinum Play has quickly become a popular casino among mobile players. The casino offers good promotions and is very suitable for people new to casino games.',
		'link' : 'http://www.platinumplay.eu/btag-ad384930/'
	}
};

$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 130;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
   if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
  
	// Dialog			
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
  
	var $c1d = $('<p></p>').html(cmd['c1'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c1'].title,
		buttons: {
			"Register": function() {window.open(cmd['c1'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c2d = $('<p></p>').html(cmd['c2'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c2'].title,
		buttons: {
			"Register": function() {window.open(cmd['c2'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c3d = $('<p></p>').html(cmd['c3'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c3'].title,
		buttons: {
			"Register": function() {window.open(cmd['c3'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c4d = $('<p></p>').html(cmd['c4'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c4'].title,
		buttons: {
			"Register": function() {window.open(cmd['c4'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c5d = $('<p></p>').html(cmd['c5'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c5'].title,
		buttons: {
			"Register": function() {window.open(cmd['c5'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c6d = $('<p></p>').html(cmd['c6'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c6'].title,
		buttons: {
			"Register": function() {window.open(cmd['c6'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});
	var $c7d = $('<p></p>').html(cmd['c7'].desc).dialog({
		autoOpen: false, modal: true, width: '400px', title: cmd['c7'].title,
		buttons: {
			"Register": function() {window.open(cmd['c7'].link, '_blank')},
			"Close": function() {$(this).dialog("close")}
		}			
	});

	$('#c1').click(function() {$c1d.dialog('open');return false});
	$('#c2').click(function() {$c2d.dialog('open');return false});
	$('#c3').click(function() {$c3d.dialog('open');return false});
	$('#c4').click(function() {$c4d.dialog('open');return false});
	$('#c5').click(function() {$c5d.dialog('open');return false});
	$('#c6').click(function() {$c6d.dialog('open');return false});
	$('#c7').click(function() {$c7d.dialog('open');return false});
  
});
