var DSINIT = new Array ();
var SCFG = new Array ();
var SLIDORDER = ['cut', 'price', 'carat', 'color', 'clarity'];

// check for DS cookie
var strDSINIT = GetCookie ("DSINIT");
if (strDSINIT != null)
{
	var VALS = strDSINIT.split ("|");

	//alert (strDSINIT);
	// slider params [ top_x, bottom_x, offsetWidth]
	var aux = VALS[0].split ("/");

	SCFG[SLIDORDER[0]] = aux[0] ? aux[0].split (",") : 0;
	SCFG[SLIDORDER[1]] = aux[1] ? aux[1].split (",") : 0
	SCFG[SLIDORDER[2]] = aux[2] ? aux[2].split (",") : 0
	SCFG[SLIDORDER[3]] = aux[3] ? aux[3].split (",") : 0
	SCFG[SLIDORDER[4]] = aux[4] ? aux[4].split (",") : 0

	// init params
	DSINIT['shape'] = VALS[1];
	DSINIT['cut_low'] = VALS[2] * 1;
	DSINIT['cut_high'] = VALS[3] * 1;
	DSINIT['price_low'] = VALS[4] * 1;
	DSINIT['price_high'] = VALS[5] * 1;
	DSINIT['carat_low'] = VALS[6] * 1;
	DSINIT['carat_high'] = VALS[7] * 1;
	DSINIT['color_low'] = VALS[8] * 1;
	DSINIT['color_high'] = VALS[9] * 1;
	DSINIT['clarity_low'] = VALS[10] * 1;
	DSINIT['clarity_high'] = VALS[11] * 1;
	//DSINIT['scroll_pos'] = VALS[12] * 1;
	//DSINIT['new_scroll_pos'] = VALS[13] * 1;
	DSINIT['current_sort'] = VALS[14] * 1;
	DSINIT['sort_direction'] = VALS[15] * 1;
}

function save_dsinit ()
{
	var sliders = new Array ();
	sliders[0] = cut.cfgvals;
	sliders[1] = price.cfgvals;
	sliders[2] = carat.cfgvals;
	sliders[3] = color.cfgvals;
	sliders[4] = clarity.cfgvals;
	
	var slidersStr = sliders.join ("/");
	var VALS = [ slidersStr, shape, cut_low, cut_high, price_low, price_high, carat_low, carat_high, color_low, color_high, clarity_low, clarity_high, scroll_pos, new_scroll_pos, current_sort, sort_direction ];
	var strVALS = VALS.join ("|");

	SetCookie ("DSINIT", strVALS); 
}

function init_sliders ()
{
	if (SCFG['cut'] && (SCFG['cut'][0] * 1 > 0 || SCFG['cut'][1] * 1 > 0 || SCFG['cut'][2] * 1 > 0)) update_slider (cut, SCFG['cut'][0], SCFG['cut'][1], SCFG['cut'][2], DSINIT['cut_low'], DSINIT['cut_high']);
	if (SCFG['price'] && (SCFG['price'][0] * 1 > 0 || SCFG['price'][1] * 1 > 0 || SCFG['price'][2] * 1 > 0)) update_slider (price, SCFG['price'][0], SCFG['price'][1], SCFG['price'][2], DSINIT['price_low'], DSINIT['price_high']);
	if (SCFG['carat'] && (SCFG['carat'][0] * 1 > 0 || SCFG['carat'][1] * 1 > 0 || SCFG['carat'][2] * 1 > 0)) update_slider (carat, SCFG['carat'][0], SCFG['carat'][1], SCFG['carat'][2], DSINIT['carat_low'], DSINIT['carat_high']);
	if (SCFG['color'] && (SCFG['color'][0] * 1 > 0 || SCFG['color'][1] * 1 > 0 || SCFG['color'][2] * 1 > 0)) update_slider (color, SCFG['color'][0], SCFG['color'][1], SCFG['color'][2], DSINIT['color_low'], DSINIT['color_high']);
	if (SCFG['clarity'] && (SCFG['clarity'][0] * 1 > 0 || SCFG['clarity'][1] * 1 > 0 || SCFG['clarity'][2] * 1 > 0)) update_slider (clarity, SCFG['clarity'][0], SCFG['clarity'][1], SCFG['clarity'][2], DSINIT['clarity_low'], DSINIT['clarity_high']);
}

function update_slider (slid, top_x, bottom_x, offsetWidth, top, bottom)
{
	slid.callback (top, bottom);
	slid.cfgvals = [top_x, bottom_x, offsetWidth];
	slid.update (slid, top_x, bottom_x, offsetWidth);
}


