// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery(document).ready(function() {

  jQuery('.subpage-link').click(function() {
    var id = jQuery(this).attr('name');
    jQuery.ajax({
      url: "/admin/show.php",
      type: "GET",
      data: "id=" + id,
      success: function(data) {
        jQuery('#inner-inner-content').html(data);
      }    
    });
    return false;
  });

	/* Using custom settings */
	
/*
	jQuery("a.inline").fancybox({
    'autoDimensions': false,
    'height': '475',
    'width': '625',
		'hideOnContentClick': true
	});
*/

  jQuery(".inline").live("click",function() {
    var id = jQuery(this).attr("id");
    jQuery.ajax({
      url: "/test.php",
      data: "id=" + id.substring(4, id.length),
      type: "POST",
      success: function(data) {
        jQuery.fancybox(data);
      }
    });
  });

  jQuery(".first").show();

  jQuery(".cmp-slider").slider({			
    slide: function() {rotate(this);}
  });

  jQuery('.cancel').click(function() {
    window.location.href = "/admin";
  });

});


function rotate (obj) {
  var id = jQuery(obj).attr('value');
  var pos = jQuery("#cmp" + id + "-slider a").css('left');
  var len = pos.substring(0, pos.length - 1);
  jQuery("#cmp" + id + " div").hide();
  if (len <= 16)
    jQuery("#cmp" + id + "-ang-0").show();
  else if (len > 16 && len <= 32)
    jQuery("#cmp" + id + "-ang-30").show();
  else if (len > 32 && len <= 48)
    jQuery("#cmp" + id + "-ang-60").show();
  else if (len > 48 && len <= 64)
    jQuery("#cmp" + id + "-ang-90").show();
  else if (len > 64 && len <= 80)
    jQuery("#cmp" + id + "-ang-120").show();
  else if (len > 80 && len <= 96)
    jQuery("#cmp" + id + "-ang-150").show();
  else 
    jQuery("#cmp" + id + "-ang-0").show();
}

