var ie=(document.all && document.all.item && !window.opera)?1:0;
var isIE4=(navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("MSIE 7.0")==-1 && parseFloat(navigator.appVersion)>=4)?true:false;
var isIE8=(navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("MSIE 8.0")!=-1 && parseFloat(navigator.appVersion)>=4)?true:false;

/////////////////////

	function t(myId){
		for (i=0;i<=2;i++)
		document.all['d'+i].style.display='none';
		document.all['d'+myId].style.display='block';


		s = document.all['img'+myId].src;
		l = s.length;
		s = s.substr(0,l-5);

		v = document.all['arr'+myId].src;
		l = v.length;
		v = v.substr(0,l-5);

		document.all['td'+myId].style.backgroundImage = 'url(images/m_but.jpg)';
		document.all['arr'+myId].src = v + '.gif';
		document.all['img'+myId].src = s + 'a.gif';

		document.all['href'+myId].style.cursor = 'default';
		document.all['href'+act].style.cursor = 'hand';

		s = document.all['img'+act].src;
		l = s.length;
		s = s.substr(0,l-5);
		document.all['img'+act].src = s + '.gif';
		
		act = myId;
	}
	
	function mover(myId){
		s = document.all['img'+myId].src;
		l = s.length;
		s = s.substr(0,l-4);

		v = document.all['arr'+myId].src;
		l = v.length;
		v = v.substr(0,l-4);

		document.all['td'+myId].style.backgroundImage = 'url(images/m_but_.jpg)';
		document.all['arr'+myId].src = v + '_.gif';
		document.all['img'+myId].src = s + '_.gif';
	}

	function mout(myId){
		s = document.all['img'+myId].src;
		l = s.length;
		s = s.substr(0,l-5);

		v = document.all['arr'+myId].src;
		l = v.length;
		v = v.substr(0,l-5);
		
		document.all['td'+myId].style.backgroundImage = 'url(images/m_but.gif)';
		document.all['arr'+myId].src = v+'.gif';
		document.all['img'+myId].src = s+'.gif';
		
	}

	function mover_ban(myId){
		s = document.all['img'+myId].src;
		l = s.length;
		s = s.substr(0,l-4);
		
//background-color
		document.all['td'+myId].bgColor = '#ffffff';
		
		document.all['img'+myId].src = s + '_.gif';
	}

	function mout_ban(myId){
		s = document.all['img'+myId].src;
		l = s.length;
		s = s.substr(0,l-5);

		document.all['td'+myId].bgColor = '#EEEEEF';
		document.all['img'+myId].src = s+'.gif';
	}


///////////////////////
function checkf() {
	a=checkf.arguments;
	form=a[0];
	noerror=true;
	for (i=1;i<a.length;i++) if (form[a[i]].value.length==0) noerror=false;
		if (!noerror) alert('�� �������� �� �ॡ㥬� ����!');
	return noerror;
}

function ShowMail(user, domain1, domain2) {
	var email = user+'&#64;'+domain1+'&#46;'+domain2;
	if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
	else name = email;
	document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}

function SendLink(link_name) {
	window.open("/send/?link="+link_name, "SendLink", "scrollbars=0, resizable=1, width=370, height=230").focus();
}


function MM_findObj(n, d) {
  	var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}



function openImage(src,nname) {
window.open("/popup.php?img="+src,"popupimage"+nname, "scrollbars=0, resizable=0").focus();
 }
 
function preload()
{
b=preload.arguments; 
preload_images = new Array();
for(i=0; i<b.length; i++)
	{
		preload_image = new Image;
		preload_image.src=b[i];
		preload_images[i]=preload_image;
	}
}



function menu_sw(x,name,turn) 
{
	td2=x.parentElement;
	tr=td2.parentElement;
	td1=tr.children(0);
	img=td1.children(0);
	img.src='/images/smenu/'+name+'_ico'+turn+'.gif';
}

function SetHiddenVar(variable,val) {
	var forma = document.forms['search'];
	forma.elements[variable].value = val;
	forma.submit();
	return false;
}

var options = Array();
function show_option(id){

 for(i in options) 
  {
 	document.all[i].style.display = 'none'; 
  }

 options[id] = 1;
 document.all[id].style.display = 'block';
 return false;
}

function scrolldivs(obj, i)
{
	leftdiv=MM_findObj('leftdiv'+i);
	topdiv=MM_findObj('topdiv'+i);
	leftdiv.scrollTop=obj.scrollTop;
	topdiv.scrollLeft=obj.scrollLeft;
}

function resizediv()
{
	if (ie==1)
	{
		i=1;
		br_cycle=0;
		do
   		{
   			topdivobj=MM_findObj('topdiv'+i);
			infodivobj=MM_findObj('infodiv'+i);			
			if (topdivobj&&infodivobj)
			{
				topdivobj.style.width=document.body.clientWidth-124-16-40; 
				infodivobj.style.width=document.body.clientWidth-124-40;
			}	
			else
				br_cycle=1;
			i++;
   		}
		while (br_cycle==0)	
	}
	else if (opera==1)
	{
		i=1;
		br_cycle=0;
		do
   		{
   			topdivobj=MM_findObj('topdiv'+i);
			leftdivobj=MM_findObj('leftdiv'+i);
			infodivobj=MM_findObj('infodiv'+i);			
			infodata=MM_findObj('infodata'+i);

			if (topdivobj&&infodivobj)
			{
				topdivobj.style.width=infodata.clientWidth;
				leftdivobj.style.height=infodata.clientHeight;
				infodivobj.style.width=infodata.clientWidth+16;
				infodivobj.style.height=infodata.clientHeight+16;
			}	
			else
				br_cycle=1;
			i++;
   		}
		while (br_cycle==0)
	}
}

function cartpopup(url)
{
	return window.open(url, "cart_window", "scrollbars=1, resizable=0, width=650, height=500").focus();
}

function popup(url)
{
	return window.open(url, "popup_window", "scrollbars=1, resizable=1, width=650, height=500").focus();
}

function displayDetails(type,item,e) {
	var obj = document.getElementById(type + '_' + item);
	var divHeight = 0;
	var divWidth = 0;
	if ( obj == null ) { return; }
	
	obj.style.display="block";
	obj.style.top=0;
	obj.style.left=0;
	// Get dimensions of div				
	if(obj.clip){
         divHeight=obj.clip.height;
    } else if (obj.offsetHeight){
		divHeight=obj.offsetHeight;
    } else if(obj.style.pixelHeight) {
        divHeight=obj.style.pixelHeight;
	}
    if(obj.clip){
         divWidth=obj.clip.width;
    } else if (obj.offsetWidth){
		divWidth=obj.offsetWidth;
    } else if(obj.style.pixelWidth) {
        divWidth=obj.style.pixelWidth;
	}
	
	// Get scroll offset 
	var scrollX = 0, scrollY = 0;
    if (document.body && typeof document.body.scrollTop != "undefined") {
        scrollX += document.body.scrollLeft;
        scrollY += document.body.scrollTop;
        if (!document.body.scrollTop && document.body.parentNode && 
            typeof document.body.parentNode.scrollTop != "undefined") {
                if (window.opera) {
                }
                if (isIE4 && !isIE8) {
                    scrollX += document.body.parentNode.parentNode.parentNode.scrollLeft;
                    scrollY += document.body.parentNode.parentNode.parentNode.scrollTop;
                } else {
                    scrollX += document.body.parentNode.scrollLeft;
                    scrollY += document.body.parentNode.scrollTop;
                }
        }
    } else if (typeof window.pageXOffset != "undefined") {
        scrollX += window.pageXOffset;
        scrollY += window.pageYOffset;
    }
   
	var newLeft=e.clientX - (parseInt(divWidth) + 10) + scrollX;
	var newTop=e.clientY - 30 + scrollY;

	var newBottom=0;
	var newRight = newLeft + obj.style.width;
	
	// Get window height 
	if (self.innerWidth){
		winWidth = self.innerWidth;
		winHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)	{
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	}
	else if (document.body)	{
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}	
	
	
	if ( obj != null ) {
		// Get our bottom position
        newBottom = newTop + divHeight;
        // If our bottom is out of the page, fix it
        if ( newBottom > winHeight + scrollY ) {
        	newTop = winHeight + scrollY - divHeight - 20;
        }
        // If our top is out of the page, fix it
        if ( newTop < scrollY ) {
        	newTop = scrollY;	
        }
        if ( newLeft < scrollX ) {
        	newLeft = scrollX;
        }
        // Set our position 
        obj.style.left = newLeft + "px";
		obj.style.top = newTop + "px";
	}
}

function hideDetails(type,item) {
	var obj = document.getElementById(type + '_' + item);
	if ( obj != null ) {
		obj.style.display="none";	
	}
}



function openCompare() {
	window.open("/compare/", "Compare", "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
}