ns=(document.layers)?true:false
ns6=(navigator.userAgent.indexOf("Gecko")!=-1 && navigator.userAgent.indexOf("Netscape6")!=-1)?true:false
ns7=(navigator.userAgent.indexOf("Gecko")!=-1 && navigator.userAgent.indexOf("Netscape/7")!=-1)?true:false
opera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false
ie=(document.all)?true:false;
FF = (navigator.userAgent.indexOf('Firefox')>=0);

ns6 = (ns6 || ns7 || FF);

	if (ns)  document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	document.onmousemove=move_P;
	document.onmouseup=up_P;
	
	//-----------------------------------------------------	
		
	function Skala_init()
	{
	
		if(this.h_or_v)
		{
		//horizont
		
			
			if(this.polzunok1_poz < 0 ){this.polzunok1_poz=0;}
			if(this.polzunok2_poz >= this.width ){this.polzunok1_poz = this.width-1;}
		//	if((this.polzunok2_poz - this.polzunok1_poz) < this.shag)
			//{
				
			//	this.polzunok1_poz = 0;
			//	this.polzunok2_poz = this.width;
		//	}
			
			this.from_value = Math.round(this.start_value + this.polzunok1_poz*(this.end_value - this.start_value)/(this.width -1));
			this.to_value = Math.round(this.start_value + this.polzunok2_poz*(this.end_value - this.start_value)/(this.width -1));
			
			view_res(this.from_value,this.to_value);
			
			this.polzunok1_poz = parseInt(5+this.polzunok1_poz)-5;
			this.polzunok2_poz = parseInt(5+this.polzunok2_poz)-5;
			
			Ten(this.ten1_id,this.rasporka_name1,this.polzunok1_poz +1,-1,this.left,-1);
			Ten(this.ten2_id,this.rasporka_name2,this.width - this.polzunok2_poz,-1,this.left + this.polzunok2_poz,-1);
			
			Polzunok(this.polzunok1_id,this.left+this.polzunok1_poz - parseInt(this.shag/2),-1);
			Polzunok(this.polzunok2_id,this.left+this.polzunok2_poz - parseInt(this.shag/2),-1);
			
			
			
			
		}
		else
		{
		
			//vert
		
			if(this.polzunok1_poz < 0 ){this.polzunok1_poz=0;}
			if(this.polzunok2_poz >= this.height ){this.polzunok1_poz = this.height-1;}
			if((this.polzunok2_poz - this.polzunok1_poz) < this.shag)
			{
				
				this.polzunok1_poz = 0;
				this.polzunok2_poz = this.height;
			}
			
			Ten(this.ten1_id,this.rasporka_name1,-1,this.polzunok1_poz +1,-1,this.top);
			Ten(this.ten2_id,this.rasporka_name2,-1,this.height - this.polzunok2_poz,-1,this.top + this.polzunok2_poz);
		
		
			Polzunok(this.polzunok1_id,-1,this.top+this.polzunok1_poz - parseInt(this.shag/2));
			Polzunok(this.polzunok2_id,-1,this.top+this.polzunok2_poz - parseInt(this.shag/2));
			
			
			this.from_value = parseInt(this.start_value + this.polzunok1_poz*(this.end_value - this.start_value)/(this.height -1));
			this.to_value = parseInt(this.start_value + this.polzunok2_poz*(this.end_value - this.start_value)/(this.height -1));
			
			view_res(this.from_value,this.to_value);
			
		
		
		
		
		
		}

	}
	
	function Shkala(start_value, end_value, width, heigt, shag, left, top, h_or_v, polzunok1_id, polzunok2_id, polzunok1_poz, polzunok2_poz, ten1_id, ten2_id, rasporka_name1, rasporka_name2  )
	{
		this.start_value=start_value;
		this.end_value=end_value;
	
		this.width=width;
		this.height=heigt;
		
		this.shag=shag; //ширина или высота ползунка
		
		this.left=left;
		this.top=top;
				
		this.h_or_v=h_or_v; //(true - horizont, false - vertical)
				
		this.ten1_id=ten1_id;
		this.ten2_id=ten2_id;
		
		this.rasporka_name1=rasporka_name1;
		this.rasporka_name2=rasporka_name2;
		
		this.polzunok1_id=polzunok1_id;
		this.polzunok2_id=polzunok2_id;
		
		this.from_value;
		this.to_value;
		
		this.polzunok1_poz=polzunok1_poz;
		this.polzunok2_poz=polzunok2_poz;
		
		
		this.init=Skala_init;
				
		return this;
	}
	
	
	function Ten(id,rasp_name,width,height,left,top)
	{
		
		if(ns)
		{
			if(width >0){document.layers[id].document.images[rasp_name].width=width;} 
			if(height >0){document.layers[id].document.images[rasp_name].height=height;}
		}
		else
		{
			if(ns6)
			{
				if(width >0){document.layers[id].document.images[rasp_name].width=width;} 
				if(height >0){document.layers[id].document.images[rasp_name].height=height;}
			}
			else
			{
				if(width >0){document.all[rasp_name].style.width=width;}
				if(height >0){document.all[rasp_name].style.height=height;}
			
				if(left >=0){document.all[id].style.left=left;}
				if(top >=0){document.all[id].style.top=top;}
							
			}
		}
		
			//alert(height);
	}
	
	function Polzunok(id,left,top)
	{
		if(ns)
		{
		
			if(left >=0){document.layers[id].left=left;}
			if(top >=0){document.layers[id].top=top;}
			document.layers[id].visibility="visible";
		}
		else
		{
			if(ns6)
			{
				if(left >=0){document.getElementById(id).style.left=left;}
				if(top >=0){document.getElementById(id).style.top=top;}
				document.getElementById(id).style.visibility="visible";
			}
			else
			{
				if(left >=0){document.all[id].style.left=left;}
				if(top >=0){document.all[id].style.top=top;}
				document.all[id].style.visibility="visible";
			}
		}
	
	}
	
	var Tek_obj;
	var Tek_num;
	var Tek_down=false;
	
	function move_P(e)
	{
		
		if(!Tek_down){return;}
		
		if(ns)
		{
			
			if(objects[Tek_obj].h_or_v)
			{
			
				if(Tek_num==1)
				{
					
					t=e.pageX-objects[Tek_obj].left;
					if(t<0){t=0;}
	if((objects[Tek_obj].polzunok2_poz-t)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok2_poz - objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok1_poz=t;
					objects[Tek_obj].init();
				}
				else
				{
					t=e.pageX-objects[Tek_obj].left;
					if(t >= objects[Tek_obj].width){t=objects[Tek_obj].width-1;}
	if((t - objects[Tek_obj].polzunok1_poz)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok1_poz + objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok2_poz=t;
					objects[Tek_obj].init();
				}
	
			}
			else
			{
				if(Tek_num==1)
				{
					
					t=e.pageY-objects[Tek_obj].top;
					if(t<0){t=0;}
	if((objects[Tek_obj].polzunok2_poz-t)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok2_poz - objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok1_poz=t;
					objects[Tek_obj].init();
				}
				else
				{
					t=e.pageY-objects[Tek_obj].top;
					if(t >= objects[Tek_obj].height){t=objects[Tek_obj].height-1;}
	if((t - objects[Tek_obj].polzunok1_poz)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok1_poz + objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok2_poz=t;
					objects[Tek_obj].init();
				}
			}
		}
		else
		{
			if(objects[Tek_obj].h_or_v)
			{
			
				if(Tek_num==1)
				{
					
					t=event.clientX-objects[Tek_obj].left;
					if(t<0){t=0;}
	if((objects[Tek_obj].polzunok2_poz-t)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok2_poz - objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok1_poz=t;
					objects[Tek_obj].init();
				}
				else
				{
					t=event.clientX-objects[Tek_obj].left;
					if(t >= objects[Tek_obj].width){t=objects[Tek_obj].width-1;}
	if((t - objects[Tek_obj].polzunok1_poz)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok1_poz + objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok2_poz=t;
					objects[Tek_obj].init();
				}
	
			}
			else
			{
				if(Tek_num==1)
				{
					
					t=event.clientY-objects[Tek_obj].top;
					if(t<0){t=0;}
	if((objects[Tek_obj].polzunok2_poz-t)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok2_poz - objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok1_poz=t;
					objects[Tek_obj].init();
				}
				else
				{
					t=event.clientY-objects[Tek_obj].top;
					if(t >= objects[Tek_obj].height){t=objects[Tek_obj].height-1;}
	if((t - objects[Tek_obj].polzunok1_poz)<objects[Tek_obj].shag){t=objects[Tek_obj].polzunok1_poz + objects[Tek_obj].shag;}
					
					objects[Tek_obj].polzunok2_poz=t;
					objects[Tek_obj].init();
				}
			}
		
		
		}
		
		
		return false;
	}
	
	function down_P(i,num)
	{
		Tek_obj=i;
		Tek_num=num;
		Tek_down=true;
		return false;
	}
	
	function up_P()
	{
		Tek_down=false;
		
	}
	
	function view_res(a,b)
	{

		document.aa.min.value=a;
		document.aa.max.value=b;
		
		my_To = b;
		my_from = a;
	}
	//----------------------------------------------
	
	
	
	function Uroven(start_value, end_value, n, cnt, name_of_mass_images, name_of_grop )
	{
		this.start_value=start_value;
		this.end_value=end_value;
		this.n=n;
		
		this.cnt = cnt;
		this.mass = name_of_mass_images;
		this.group = name_of_grop;	
		
		this.view = Uroven_view;
				
		return this;
	}
	
	function Uroven_view(value)
	{
		
		var n1 = this.cnt * (value - this.start_value)/(this.end_value - this.start_value);
			
		
		var n=parseInt(n1+5)-5;
		
		if (n < 0){n = 0;}
		else
		{
			if (n == 0){n = 1;}
		}
		
		if (n > this.cnt){n = this.cnt;}
		
		if(n > this.n)
		{
			for(i=this.n+1; i<n+1; i++)
			{
				Change_pict(this.group + i, eval('' + this.mass + '['+i+'].src'));
			}
		
		}
		
		if(n < this.n)
		{
		
			for(i=n+1; i<this.n+1; i++)
			{
				Change_pict(this.group + i,eval('' + this.mass + '[0].src'));
			}
		
		
		}
				
		this.n=n; 
	}

	function Change_pict(name,src)
	{
		
		document.images[name].src=src;
	}	
	
	
	//---------------------------------------------------
	
	var my_To;
var my_from;
var hal_tek=1;

var str=false;

function start()
{
	//tel_photo[0] = document.images['phone0'].src;
	//tt_tel_photo[0] = document.images['phone0'].src;
	
	for(i=0; i<objects.length; i++)
	{
		objects[i].init();
		
	}
	
	//halyava_init
	
	var rnd = parseInt(5  + Math.random() * (tt_id.length))-5;
	
	if(rnd <= 0){rnd=1;}
	if(rnd >= tt_id.length){rnd = tt_id.length - 1;}
	str=true;
	
	Drop_change1(rnd)
	
	Drop_Change_bb(0);
}


function start1()
{
		
	for(i=0; i<objects.length; i++)
	{
		objects[i].init();
		
	}
		
}



function cc_subm()
{
	
	if(document.cc.id.value == 0)
	{
		alert('Ничего не выбрано!');

	}
	else
	{
		document.cc.submit();
		
	}

}

function Drop_change1(n)
{
	if(!str){return;}
	var i;
	if(n > 0){i=n;}
	else
	{
		i= document.cc.specOffer.selectedIndex;
	}
	document.images['phone0h'].src = tt_photo[i];
	
	document.cc.id.value=tt_id[i];
	
	if(ns)
	{
		document.layers['hal'+hal_tek].visibility="hidden";
		document.layers['hal'+i].visibility="visible";
	}
	else
	{
		if(ns6)
		{
			document.getElementById('hal'+hal_tek).style.visibility="hidden";
			document.getElementById('hal'+i).style.visibility="visible";
		}
		else
		{
			document.all['hal'+hal_tek].style.visibility="hidden";
			document.all['hal'+i].style.visibility="visible";
		}
	}
	
	hal_tek=i;
	document.cc.specOffer.selectedIndex=0;
	
}

var my_bb_price;
var my_bb_econ;

function Drop_Change_bb(i)
{
	scrolltextInit(i);
	
	my_bb_price = complect_pr[i];
	my_bb_econ = complect_econ[i];
	
	document.bb.price.value = my_bb_price;
	document.bb.econ.value = my_bb_econ;

}



