



<!--

//################# temp js/ebsl_pricing_control_se.js ################





//general functions for control of price recalculation
//copyright e-Business Systems Limited - www.e-businesssystems.co.uk

//Special Version adapted for MR Systems 01/03/05



function ebsl_Control_setup2()
{
	ebsl_setup_complete = true;
}






function Count_non_space_letters(text)
{
	var i;
	var len = 0;
	var test;
	var result;
	if (text.length <= 0)
	{
		return len;
		
	}
	
	for (i = 0; i < text.length; i++) 
	{
		
		len += 1;
		test = /[\s\.\,\-'`"]/;
		result = test.exec(text.substring(i,i + 1));
		if ((result != null))
		{
			len -= 1;
		}
		
		
		
	} 
	return len;
}



function Round2(num){
	return Math.round((num+0.0001)*100)/100;
}



function Convert_ntc2(num){
	var curr = num.toString();
	var len = curr.length;
	var x = curr.indexOf(".");
	if (x < 0) curr = curr + ".00";
	else curr += (((len-x) == 2) ? "0" : "");
	x = curr.length
	if (x>7) curr = curr.substring(0,(x-6)) + "," + curr.substring((x-6),x);
	if (x>10) curr = curr.substring(0,(x-9)) + "," + curr.substring((x-9),(x+1));
	return curr;
}



function Comma_insert_in_int(num)
{	
	var curr = num.toString();
	var x = curr.length;
	if (x>3) curr = curr.substring(0,(x-3)) + "," + curr.substring((x-3),x);
	if (x>6) curr = curr.substring(0,(x-6)) + "," + curr.substring((x-6),(x+1));
	return curr;
}


function Recalculate_price2()
{
	
	var i,j,k;
	var price;
	
}









function Validate_form2()
{
	
	var test;
	var result;
		
	return true;			
}




function Dropdowns_control()
{
	
	this.band_message = "";
	this.Recalculate = Recalculate_dropdowns;
	this.drop_down_ranges = new Array();
	this.drop_down_range_controls = new Array();
	this.Drop_downs_need_refreshing = Check_drop_downs_need_refreshing;
	this.Add_drop_down_range_entry = Add_new_drop_down_range_entry;
	this.Add_drop_down_range_control = Add_new_drop_down_range_control;
}


function Add_new_band(band_no,param_code_type,param_code,price,price_type,size_from,size_to,description)
{
	this.bands[band_no] = new Band(band_no,param_code_type,param_code,price,price_type,size_from,size_to,description);
	
}



function Add_new_drop_down_range_control(id_no,param_code_type,old_value,new_value)
{
	this.drop_down_range_controls[id_no] = new Drop_down_range_control(id_no,param_code_type,old_value,new_value);
	
}




function Add_new_drop_down_range_entry(id_no,param_code_type,param_code,value_1,value_2,value_3)
{
	this.drop_down_ranges[id_no] = new Drop_down_range(id_no,param_code_type,param_code,value_1,value_2,value_3);
	
}




function Band(band_no_x,param_code_type_x,param_code_x,price_x,price_type_x,size_from_x,size_to_x,description_x)
{
	this.band_no = band_no_x;
	this.param_code_type = param_code_type_x;
	this.param_code = param_code_x;
	this.price = price_x;
	this.price_type = price_type_x;
	this.size_from = size_from_x;
	this.size_to = size_to_x;
	this.description = description_x;
	
	
}


function Drop_down_range_control(id_no_x,param_code_type_x,old_value_x,new_value_x)
{
	this.id_no = id_no_x;
	this.param_code_type = param_code_type_x;
	this.old_value = old_value_x;
	this.new_value = new_value_x;
}



function Drop_down_range(id_no_x,param_code_type_x,param_code_x,value_1_x,value_2_x,value_3_x)
{
	this.id_no = id_no_x;
	this.param_code_type = param_code_type_x;
	this.param_code = param_code_x;
	this.value_1 = value_1_x;
	this.value_2 = value_2_x;
	this.value_3 = value_3_x;
	
}




function Check_drop_downs_need_refreshing(param_code_type)
{
	var i;
	var control_index = -1;
	var needs_refreshing = true;
	var old_from = "";
	var old_to = "";
	var new_from = "zzzz";
	var new_to = "zzzz";
	
	/*
	
	for (i = 0; i < this.drop_down_range_controls.length; i++)
	{
		
		if ((param_code_type == this.drop_down_range_controls[i].param_code_type) ) 
		{
			control_index = i;
			this.drop_down_range_controls[i].old_value = this.drop_down_range_controls[i].new_value;
			this.drop_down_range_controls[i].new_value = new_value;
		}
	
	}
	
	
	if (control_index >=0)
	{
		for (i = 0; i < this.drop_down_ranges.length; i++)
		{
			
			if ((param_code_type == this.drop_down_ranges[i].param_code_type) ) 
			{
				if (this.drop_down_range_controls[control_index].old_value == this.drop_down_ranges[i].param_code)
				{
					old_from = this.drop_down_ranges[i].value_1;
					old_to = this.drop_down_ranges[i].value_2;
				}
				
				if (this.drop_down_range_controls[control_index].new_value == this.drop_down_ranges[i].param_code)
				{
					new_from = this.drop_down_ranges[i].value_1;
					new_to = this.drop_down_ranges[i].value_2;
				}
			}
		
		}
		
		
		if ((old_from == new_from) && (old_to == new_to))
		{
			needs_refreshing = false;
		}
	}
	*/
	return needs_refreshing;
	
}





function Recalculate_dropdowns(metal,ring_size,stone)
{
	
	var i;
	var price = 0;
	var found_metal_price = false;
	var found_stone_price = false;
	
	for (i = 0; i < this.price_band_count; i++)
	{
		
		if (("metals" == this.bands[i].param_code_type) && (metal == this.bands[i].param_code) && (ring_size >= this.bands[i].size_from) && (ring_size <= this.bands[i].size_to)) 
		{
			price = this.bands[i].price;
			found_metal_price = true;
		
		}
		
		if ((stone != "") && ("stone_type" == this.bands[i].param_code_type) && (stone == this.bands[i].description) && (!found_stone_price) ) 
		{
			price += this.bands[i].price;
			found_stone_price = true;
		
		}
		
		
	}
	
	
	if (!found_metal_price)
	{
		price = this.list_price;
	}
	
	if ((!found_stone_price) && (stone != ""))
	{
		price = this.list_price;
	}
	
	return price;

}





//-->

