$().ready(function() {

	/* Initial CSS Commands - for accessibility reasons */
	$('.pics').css({height: "500px"});
	$('body#product .product_box .product_image').css({height: "500px"});
	$('.slide-box-wrapper').css({width: "225px"});
	$('.associated_images').css({height: "auto", marginBottom: "20px"});
	//$('.associated-image-menu').css({opacity: "0", height: "100%", position: "absolute"});

	if ($('.slides img').length == 1) {
		$('.slides img').each(function() {
			_width = $(this).width() <= 100 ? 400 : $(this).width();
			width = _width >= 500 ? 500 : $(this).width();
			$('.slides').css({width: width});
			$(this).css({marginLeft: 0});
			$(this).css({marginTop: 0});
		});
		$('.prev').hide();
		$('.next').hide();
	} else {
		$('.slides img:first').each(function() {
			$(this).css({marginLeft: 0});
			$(this).css({marginTop: 0});
		});

		/* Product Page - Slideshow Function - Jquery Cycle Plugin */
		$('.slides').cycle({
			fx: 'fade',
			prev: '.prev',
			next: '.next',
			before: function() {
				if($(this).width() > 50){
					$(this).css({marginLeft: $(this).parent().width()/2 - $(this).width()/2});
					$(this).css({marginTop: $(this).parent().height()/2 - $(this).height()/2});
				}
				//$(this).css({top: '50%', marginTop: -$(this).height()/2});
			},
			speed: '10',
			timeout: 0
		});	
		

		/* Product Page - Next/Previous Hover Navigation */
		$('.slideshow').hover(
			function() { $('.controls').fadeIn(); },
			function() { $('.controls').fadeOut(); }
		);
	}


	/* #2 Step - Upload_Organizer - Slide Function */
	$("a.slide_button").toggle(
		
		function () {
		$('div.slide-box_' + $(this).css('id')).animate( { left:"-225px" }, { queue:false, duration:500 } )
      },
      function () {
		$('div.slide-box_' + $(this).css('id')).animate( { left:"0" }, { queue:false, duration:500 } );
      }
    );

	/* Seller Account - #2 Upload - Organizer */
	$(".notice .delete_notice").click(function(){
	  $(this).parents(".notice").animate({ opacity: "hide" }, "slow");
	});   

	/* Seller Account - Transactions > Rating */
	$('.rating_area').css({display: "none"});

	$("a.rating_button").click(function() {
		$(this).parent().parent().next('.rating_area').toggle();
		$(this).toggleClass("active");
	});	

	/* Seller Account Page - Archive Photo */
	$("a.edit-picture").css({opacity:"0", position: "absolute", zIndex: "5000", height: "70px"});
	$("div.archive-box").hover(
		function () {
			$("a.edit-picture", this).animate( { opacity:"0.8" }, { queue:false, duration:200 } )
		},
		function () {
			$("a.edit-picture", this).animate( {opacity:"0" }, { queue:false, duration:200 } );
		}
	);

	/* Seller Account Page - Messages */
    
    $('.messages ul li .column_four').css({display: "none"});
    
    $(".message_title a").click(function() {
		$(this).parent().next().next().next('ul li .column_four').toggle();
		$(this).toggleClass("active");
	});
	
/* Seller Account - Information */

	$('.cover a.button').click(function(){ 
        $(this).parents(".cover").animate({ opacity: "hide" }, "slow"); 

        if($(this).parents(".cover").is(':hidden')){ 
                $(this).parents(".cover").animate({ opacity: "show" }, "slow");
        } 
        else{ 
                $(this).parents(".cover").animate({ opacity: "hide" }, "slow");
        }
        return false;
	});
	
	
	$('.slide-newest').cycle({
		fx: 'fade',
		prev: '.newest-prev',
		next: '.newest-next',
		speed: '10',
		timeout: 0,
		pager: '.newest-pagination',
		after: function() {
			$('.slide-newest').removeClass('loader')
		}
	});
		
	$('.slide-popular').cycle({
		fx: 'fade',
		prev: '.popular-prev',
		next: '.popular-next',
		speed: '10',
		timeout: 0,
		pager: '.popular-pagination',
		after: function() {
			$('.slide-popular').removeClass('loader')
		}
	});
/*		

$('.slide-picks').cycle({
	fx: 'fade',
	prev: '.picks-prev',
	next: '.picks-next',
	speed: '10',
	timeout: 0,
	pager: '.picks-pagination',
	after: function() {
		$('.slide-picks').removeClass('loader')
	}
});	
	
	$('body#seller_account .submit').click(function(){ 
        $(".cover").animate({ opacity: "show" }, "slow");
        return false;
	});
*/	
	/*
$("body#seller_account .submit").click(function(){ 
        $(".cover").toggle(); 

        if($(".cover").is(':hidden')){ 
                $(this).html('show'); 
        } 
        else{ 
                $(this).html('hide'); 
        } 
	}); 
*/


	/*
$(".cover a.button").click(function(){
	
	if( $(element).is(":visible") == "true" ){
   	$(this).parents(".cover").hide();
	}
	else{
 	$(this).parents(".cover").show();
	}
	return false;
	});
*/
	
	
	
	
	/*
$(".cover a.button").click(function(){
	  $(this).parents(".cover").animate({ opacity: "hide" }, "slow");
	  return false;
	});
	
	$("body#seller_account .submit").click(function(){
	  $(this).parents(".cover").animate({ opacity: "hide" }, "slow");
	  return false;
	}); 
*/
	
});

