/**
 * @author Allen Chow - MKCorp
 */

var msCurPage;
var temp;	
var msPage01 = 0;
var msPage02 = -264;
var msPage03 = -528;

document.write('<link rel="stylesheet" href="/whatsnew/colortrend/css/miniSlider_style.css" type="text/css" />');

$(document).ready(function(){
	
	/* ******plug in associated css stylesheet for the mini slider****** */
	$('head').append('<link rel="stylesheet" href="/whatsnew/colortrend/css/miniSlider_style.css" type="text/css" />');
	
	/* ******adding left and right buttons****** */
	$("#mini_slider")
		.append('<img id="ms_btn_left" class="png" src="/whatsnew/colortrend/images/061611/mini_slider/ms_btn_left.png" width="32" height="34">')
		.append('<img id="ms_btn_right" class="png" src="/whatsnew/colortrend/images/061611/mini_slider/ms_btn_right.png" width="32" height="34">');
	
	/* ******set miniSlider position based on which page is active****** */
	$("#ms_imagesCntr ul").css({"left":msCurPage});
	
	/* ******adding functionalty to the left and right buttons****** */
	$("#ms_btn_right")
		.mousedown(function(){
			$(this).css({"margin": "-17px 0 0 -13px"});
			ms_slideTo("right");
		})
		.mouseup(function(){
			$(this).css({"margin":"-17px 0 0 -16px"})
		});
	$("#ms_btn_left")
		.mousedown(function(){
			$(this).css({"margin": "-17px 0 0 -15px"});
			ms_slideTo("left");
		})
		.mouseup(function(){
			$(this).css({"margin":"-17px 0 0 -12px"})
		});

});

function ms_whichPage(x){
	if(x<4){
		msCurPage = msPage01;
	}else if(x<8){
		msCurPage = msPage02;
	}else if(x<12){
		msCurPage = msPage03;
	}
}

function ms_slideTo(y){
	if (y == "right") {
		if (msCurPage == msPage01) {
			$("#ms_imagesCntr ul").animate({
				"left": msPage02
			},600);
			temp = msPage02;
		}
		else if (msCurPage == msPage02) {
			$("#ms_imagesCntr ul").animate({
				"left": msPage03
			},600);
			temp = msPage03;
		}
	}else if(y == "left"){
		if (msCurPage == msPage03) {
			$("#ms_imagesCntr ul").animate({
				"left": msPage02
			},600);
			temp = msPage02;
		}
		else if (msCurPage == msPage02) {
			$("#ms_imagesCntr ul").animate({
				"left": msPage01
			},600);
			temp = msPage01;
		}
	}
	
	msCurPage = temp;
}

