function ChangeFilter2()
{
	var o=document.getElementById('exfilter');
	var s=document.getElementById('exfilter2');
				
	for(var i=s.options.length;i>-1;i--)
	{
		s.options[i]=null;
	}
				
	var temp=o.options[o.options.selectedIndex].value;
				
	if(temp=='ltype')
	{
		var tmp=ltype;
		var idsa_len=ltype.length;
	}
					
	if(temp=='volt')
	{
		var tmp=volt;
		var idsa_len=volt.length;
	}

	if(temp=='watt')
	{
		var tmp=watt;
		var idsa_len=watt.length;
	}
				
	if(temp=='ip')
	{
		var tmp=ip;
		var idsa_len=ip.length;
	}
					
	for(var i=0;i<idsa_len;i++)
	{
		var oOption=document.createElement("OPTION");
		s.options.add(oOption);
		oOption.innerText=tmp[i][1];
		oOption.text=tmp[i][1];
		oOption.value=tmp[i][0];
	}
}
				
function CheckQuantity(obj, key)
{
	var s=obj.value * 1;
	var o=document.getElementById('p'+key).value * 1;

	if(s > o)
	{
		obj.value=0;
	}
	
	if(s <=0 )
	{
		obj.value=0;
	}

	if(!parseInt(s))
	{
		obj.value=0;
	}
}
// ---------------- functions ----------------
function Init()
{
	if (window.addEventListener) 
	{
		window.addEventListener('resize', ReplacePhoto, false);
	} 
	else if (window.attachEvent) 
	{
		window.attachEvent('onresize', ReplacePhoto);
	}
}
// ---------------- functions ----------------
function CheckSubscribe(str, n)
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var arrayPageSize=getPageSize();

	document.getElementById('shadow').style.display='block';
	document.getElementById('shadow').style.height=arrayPageSize[1];
	document.getElementById('shadow').style.width=arrayPageSize[0];

	document.getElementById('alert').style.top=arrayPageSize[3] / 2;
	document.getElementById('alert').style.left=x / 2 - 200 / 2 - 30;
	if(n==1) document.getElementById('alert').style.backgroundColor="#2FC702";
	if(n==0) document.getElementById('alert').style.backgroundColor="#FF0000";
	document.getElementById('alert').style.display='block';
	document.getElementById('alert').innerHTML=str;
	setTimeout('DisabledAlert()', 2000);
}
// ---------------- functions ----------------
function CheckBasket(str, n, url)
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var arrayPageSize=getPageSize();

	document.getElementById('shadow').style.display='block';
	document.getElementById('shadow').style.height=arrayPageSize[1];
	document.getElementById('shadow').style.width=arrayPageSize[0];

	document.getElementById('alert').style.top=arrayPageSize[3] / 2;
	document.getElementById('alert').style.left=x / 2 - 200 / 2 - 30;
	if(n==1) document.getElementById('alert').style.backgroundColor="#2FC702";
	if(n==0) document.getElementById('alert').style.backgroundColor="#FF0000";
	document.getElementById('alert').style.display='block';
	document.getElementById('alert').innerHTML=str;
	document.getElementById('url').value=url;
	setTimeout('DisabledAlert()', 2000);
}
// ---------------- functions ----------------
function DisabledAlert()
{
	var url=document.getElementById('url').value;

	document.getElementById('shadow').style.display='none';
	document.getElementById('alert').style.display='none';
	document.getElementById('alert').innerHTML='';
	
	if(url!='') document.location.href=url;
}
// ---------------- functions ----------------
function ReplacePhoto()
{
	if(document.getElementById('photo-is-active').value==1)
	{
		PositionPhoto();
	}
}
// ---------------- functions ----------------
function pngdisplay(image, width, height, iclass) 
{
	if(navigator.appName=='Microsoft Internet Explorer') 
	{ 
		document.write('<img src="images/empty.gif" style="width: ' + width + '; height: ' + height + '; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + image + ', sizingMethod=scale)" class="' + iclass + '" border=0 />');
	} 
	else 
	{
		document.write('<img src="' + image + '" style="width: ' + width + '; height: ' + height + ';" class="' + iclass + '" />');
	}
}
// ---------------- functions ----------------
function BorderOn(obj) 
{
	obj.style.borderColor="#2fc702";
	obj.style.borderWidth="1px";
	obj.style.borderStyle="solid";
}
// ---------------- functions ----------------
function BorderOff(obj) 
{
	obj.style.borderColor="#717171";
	obj.style.borderWidth="1px";
	obj.style.borderStyle="solid";
}  
// ---------------- functions ----------------
function BackgroundOn(obj) 
{
	obj.style.backgroundColor="#2fc702";
}
// ---------------- functions ----------------
function BackgroundOff(obj) 
{
	obj.style.backgroundColor="#717171";
}  
// ---------------- functions ----------------
function ConfirmReload(pid, fltr, param)
{
	var filter='';
	if(fltr!='') filter='&filter='+fltr;

	if(param==1)
	{
		document.location.href='index.php?pid='+pid+filter;
		return true;
	}
	
	if(confirm('Внимание!\nОтображение полного списка товаров может привести к медленной работе сайта.'))
	{
		if(param==0) document.location.href='index.php?pid='+pid+filter+'&showall=yes';
	}
}
// ---------------- functions ----------------
function CheckProductFilter(obj)
{
	if(obj.options[obj.options.selectedIndex].value=='')
	{
		var i=obj.options.selectedIndex;
		obj.options[i-1].selected=true;
	}
}
// ---------------- functions ----------------
function ShowPhoto(w,h,nn)
{
	document.getElementById('photo-is-active').value=nn;
	document.getElementById('photo-width').value=w;
	document.getElementById('photo-height').value=h;

	PositionPhoto();

	document.getElementById('photo-td').style.width=0;
	document.getElementById('photo-td').style.height=100;

	WidthObj();
}
// ---------------- functions ----------------
function ClosePhoto(nn)
{
	document.getElementById('shadow').style.display='none';
	document.getElementById('photo-is-active').value=0;		
	document.getElementById('photo-width').value=0;
	document.getElementById('photo-height').value=0;
	
	document.getElementById('photo').style.top=0;
	document.getElementById('photo').style.left=0;
	document.getElementById('photo').style.display='none';

	document.getElementById('photo-td').style.width='0px';
	document.getElementById('photo-td').style.height='0px';

	document.getElementById('img'+nn).innerHTML=document.getElementById('photo-td').innerHTML;
	document.getElementById('photo-td').innerHTML='';
	
}
// ---------------- functions ----------------
function PositionPhoto()
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	var arrayPageSize=getPageSize();

	document.getElementById('shadow').style.display='block';
	document.getElementById('shadow').style.height=arrayPageSize[1];
	document.getElementById('shadow').style.width=arrayPageSize[0];

	document.getElementById('photo').style.top=document.body.scrollTop + ((y / 2) - h / 2 - 10);
	document.getElementById('photo').style.left=x / 2 - w / 2 - 30;
	document.getElementById('photo').style.display='block';
}
// ---------------- functions ----------------
function WidthObj()
{
	var width=parseFloat(document.getElementById('photo-td').style.width.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	if(width < w - 100)
	{
		document.getElementById('photo-td').style.width=width + 100;
	}
	else
	{
		if(width >= w - 100 && width <= w - 10)
		{
			document.getElementById('photo-td').style.width=width + 10;
		}
		else
		{
			if(width >= w - 10 && width <= w)
			{
				document.getElementById('photo-td').style.width=width + 1;
			}
		}
	}

	if(width!=w) setTimeout('WidthObj()', 0.5);

	if(width==w) HeightObj();
}
// ---------------- functions ----------------
function HeightObj()
{
	var height=parseFloat(document.getElementById('photo-td').style.height.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;
	var nn=document.getElementById('photo-is-active').value;

	if(height < h - 100)
	{
		document.getElementById('photo-td').style.height=height + 100;
	}
	else
	{
		if(height >= h - 100 && height < h - 10)
		{
			document.getElementById('photo-td').style.height=height + 10;
		}
		else
		{
			if(height >= h - 10 && height <= h)
			{
				document.getElementById('photo-td').style.height=height + 1;
			}
		}
	}

	if(height!=h) setTimeout('HeightObj()', 0.5);
	
	if(height==h)
	{
		document.getElementById('photo-td').innerHTML=document.getElementById('img'+nn).innerHTML;
		document.getElementById('img'+nn).innerHTML='';
	}
}
// ---------------- functions ----------------
function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else 
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) 
	{	
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		} 
		else 
		{
			windowWidth = self.innerWidth;
		}
		
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) 
	{ 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	} 
	else 
	{ 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	} 
	else 
	{
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;
}
