function GetElemByID (ID){if (document.getElementById) var returnVar = document.getElementById(ID);else if (document.all) var returnVar =document.all[ID];else if (document.layers) var returnVar = document.layers[ID];return returnVar;}

function HideSpec()
{
var SpecZ=GetElemByID('good_spec');
if (SpecZ!=null)
   {    
	if (SpecZ.style.visibility!='hidden')
	   {
	    SpecZ.style.visibility='hidden';
		SpecZ.style.top=0;
		SpecZ.style.left=0;
		SpecZ.style.width=0;
		SpecZ.style.height=0;	   
	   }
   }
   
ifrs=GetElemByID('ifr_spec');
if (ifrs!=null)
   {
    ifrs.style.width=0;
	ifrs.style.height=0;
	ifrs.src='';	
   }   
}

function ShowAllImg(path)
{
GoodImg=GetElemByID('good_spec_img');

if (GoodImg!=null)
   {
	GoodImg.src=path;
	/*
	GoodImg.style.background="url("+path+")";
	GoodImg.style.backgroundRepeat="no-repeat";
	GoodImg.style.backgroundPosition="center center";
	GoodImg.style.backgroundColor="#FFFFFF";*/
   }

}

function RecountInterface(){HideSpec();}
/*function RecountTree()
{
var SpanCorrections=14;
var Hdr1,Hdr2,Tree,TreeData,SubTree,GroupTop;
Hdr1=GetElemByID('main_table_top');
Hdr2=GetElemByID('menu');
Tree=GetElemByID('tree_contnr');
TreeData=GetElemByID('tree_data');

var wh,nh,corr=0,gth=0,neededh,corr1=0;
if(navigator.appName.indexOf("Microsoft")!=-1){wh=document.body.offsetHeight-2;corr1=4;}
  else{wh=window.innerHeight;corr1=-2;}

if (Hdr1!=null && Hdr2!=null && Tree!=null && TreeData!=null)
   {
    neededh=TreeData.offsetHeight+4; //+4 spans
	GroupTop=GetElemByID('group_top');
	if (GroupTop!=null) gth=GroupTop.offsetHeight;		
	SubTree=GetElemByID('tree_datas');	
	if (SubTree!=null) neededh+=(SubTree.offsetHeight+corr1);	
	nh=wh-Hdr1.offsetHeight-Hdr2.offsetHeight-gth-SpanCorrections;
	if (neededh<=nh) nh=neededh; 
	if (nh<0) nh=0;
	Tree.style.height=nh;
  }
  
}

function RecountContenet()
{
var SpanCorrections=6;
var Hdr1,Hdr2,CnDat,LngPop,AllData,SpecZ;
var wh,ww,nh,corr1=0;
Hdr1=GetElemByID('main_table_top');
Hdr2=GetElemByID('menu');
CnDat=GetElemByID('content_all');

if(navigator.appName.indexOf("Microsoft")!=-1){wh=document.body.offsetHeight-1;corr1=3;ww=document.body.offsetWidth-2;}
  else{wh=window.innerHeight;corr1=0;ww=window.innerWidth;}
if (CnDat!=null && Hdr1!=null && Hdr2!=null)
   {
    nh=wh-Hdr1.offsetHeight-Hdr2.offsetHeight-SpanCorrections+corr1;
	if (nh<0) nh=0;
    CnDat.style.height=nh;
   }
   
LngPop=GetElemByID('other_languags');   
if (LngPop!=null)
{
if (LngPop.style.visibility=='visible') LngPop.style.visibility='hidden';
}

AllData=GetElemByID('data_cell');
if (CnDat!=null && AllData!=null){CnDat.style.width=ww-262;} 
HideSpec();
}






function findPosition(oElement){if( typeof( oElement.offsetParent ) != 'undefined' ){for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {posX += oElement.offsetLeft;posY += oElement.offsetTop;}return [ posX, posY ];}else{return [ oElement.x, oElement.y ];}}

function HideLanguagsPopup()
{
LngPop=GetElemByID('other_languags');
if (LngPop!=null)
    {
	if (LngPop.style.visibility=='visible') LngPop.style.visibility='hidden';
    }
}

function ShowLangsPopup()
{
LngPop=GetElemByID('other_languags');
MainLng=GetElemByID('selected_lang');
if (LngPop!=null && MainLng!=null)
   {    
	if (LngPop.style.visibility=='visible') LngPop.style.visibility='hidden';   
	else 
	   {
	    LngPop.style.visibility='visible';			
		CRDN=findPosition(MainLng);			
		LngPop.style.top=CRDN[1]+19;
		LngPop.style.left=CRDN[0];
	   }
   }
HideSpec();   
}
*/


function ShowGoodSpec(ID,NOSA)
{
var specW=640;
var specH=570;
var ww,wh,crr,corr1=0,corr2=0,corr3=0;


if(navigator.appName.indexOf("Microsoft")!=-1){wh=document.body.offsetHeight-1;ww=document.body.offsetWidth-2;crr=4;corr1=4;corr2=4;corr3=0;}
  else{wh=window.innerHeight;ww=window.innerWidth;crr=0;corr1=8;corr2=8;corr3=0;}
  
if (specW>ww) specW=ww-26;
if (specH>wh) specH=wh-26;

SpecZ=GetElemByID('good_spec');
SpecHdr=GetElemByID('SPEC_HDR');

if (SpecZ!=null && SpecHdr!=null)
   {

  
	SpecZ.style.left=ww/2-specW/2;
	SpecZ.style.top=wh/2-specH/2;
	SpecZ.style.width=specW;
	SpecZ.style.height=specH;
	SpecZ.style.visibility='visible';
	SpecHdr.style.width=specW-35-crr;
	SpecHdr.innerHTML=NOSA;
	
   }
ifrs=GetElemByID('ifr_spec');
if (ifrs!=null)
   {
    ifrs.style.width=specW-10+corr1;
	ifrs.style.height=specH-28+corr2-corr3;
	ifrs.src=ID;
	
   }


}

function SetCartValue(svl)
{
var CDV=GetElemByID('TotaGROs');
if(CDV!=null) CDV.innerHTML=svl;
}


function DeleteUnneededCart()
{
document.forms.CartForm1.HiddenVarCart.value='delete';
document.forms.CartForm1.submit();
}


function SaveCartData()
{
document.forms.CartForm1.HiddenVarCart.value='savechanges';
document.forms.CartForm1.submit();
}


function RemoveGoodFromCart(val)
{
document.forms.CartForm1.HiddenVarCart.value='removegood';
document.forms.CartForm1.HiddenVar1Cart.value=val;
document.forms.CartForm1.submit();	
}



function ProcessDelButtenVsbty()
{
var DelBTN=GetElemByID('CartDelButton');
var SavBTN=GetElemByID('SaveCartButtn');
var DivdBTN=GetElemByID('SaveOrChangeSPN');

OBJ=GetElemByID('GroupCartCbx');
var SomeCHK=false;
if (DelBTN!=null && OBJ!=null) 
   {
	var Cform;
    Cform=GetElemByID('CartForm1');		 
    if (Cform==null) return;
    
    for (var el=0;el<Cform.elements.length; el++)
       {
    	 var item = Cform.elements[el];
    	  if (item.name.substring(0,9)=='CartGoodx' && item!=OBJ)
    	    if (item.checked==true) {SomeCHK=true;break;}
	
       }
    
if (SomeCHK && DelBTN.style.visibility=="hidden")
   {
	DelBTN.style.visibility="visible";
	DelBTN.style.display="inline";
   }
else if (!SomeCHK && DelBTN.style.visibility=="visible")
{
	DelBTN.style.visibility="hidden";
	DelBTN.style.display="none";
   }
	
   }

if (SavBTN!=null && SavBTN.style.visibility=="hidden")
   {
	SavBTN.style.visibility="visible";
	SavBTN.style.display="inline";	
   }

if (DivdBTN!=null && DelBTN.style.visibility=="visible" && DivdBTN.style.visibility=="hidden")
{
	DivdBTN.style.visibility="visible";
	DivdBTN.style.display="inline";		
}
else if (DivdBTN!=null && DelBTN.style.visibility=="hidden" && DivdBTN.style.visibility=="visible")
{
	DivdBTN.style.visibility="hidden";
	DivdBTN.style.display="none";		
	
}



}


function ForceCboxesCart()
{
	
	OBJ=GetElemByID('GroupCartCbx');
	if (OBJ!=null)
	  {
		 var Cform;
		 Cform=GetElemByID('CartForm1');		 
	     if (Cform==null) return;
	     
	     for (var el=0;el<Cform.elements.length; el++){var item = Cform.elements[el];if (item.name.substring(0,9)=='CartGoodx' && item!=OBJ){
	item.checked=OBJ.checked;}}}
	
	ProcessDelButtenVsbty();
}

function ChangeFilterName(val,fltr1,fltr2)
{

var CDV=GetElemByID('GroupFilterName');
var CDVV=GetElemByID('GroupFilterValue');

if (val=='2' && fltr1!='' && fltr2!='' && CDV!=null && CDVV!=null)
{
	CDV.value=fltr1;
	CDVV.value=fltr2;
}


var CDV2=GetElemByID('GroupFilterName2');
var CDVV2=GetElemByID('GroupFilterValue2');


var CurrLoc=document.location;
var CL=CurrLoc+'';
strbf='';
straf='';

if (CL.indexOf("&filter=")!=-1)
{ 
 straf='';
 strbf=CL.substring(0,CL.indexOf("&filter="));
 ixbef=CL.indexOf("&filter=")+1;
 saftr=CL.substring(ixbef,CL.length);
 if (saftr.indexOf("&")!=-1)
    {
    straf=saftr.substring(saftr.indexOf("&"),saftr.length);   
    }	    
}
else strbf=CL;

if (CDV!=null)    
	{	
	 if (CDV.value=='1') filtr_s='';
	 else
	 {
	   if (CDVV!=null && CDVV.value!='1' && (val=='1' || val=='2' || val=='3'))
	   filtr_s='&filter='+CDV.value+"^"+CDVV.value;
	   else	   
	   filtr_s='&filter='+CDV.value;	  
	 }	
	}
if (CDV2!=null && filtr_s!='' && CDVV.value!='1')    
{
  if (CDV2.value=='1') filtr_s+='';
	 else
	 {
  if (CDVV2!=null && CDVV2.value!='1' && val=='3')    
    filtr_s+='_'+CDV2.value+"^"+CDVV2.value;
  else	   
    filtr_s+='_'+CDV2.value;
	 }
 	
}
link=strbf+filtr_s+straf;
document.location=link;
}
	





function ChangeFilter(fltr)
{
var CurrLoc=document.location;
var CL=CurrLoc+'';
strbf='';
straf='';

if (CL.indexOf("&filter=")!=-1)
{ 
 straf='';
 strbf=CL.substring(0,CL.indexOf("&filter="));
 ixbef=CL.indexOf("&filter=")+1;
 saftr=CL.substring(ixbef,CL.length);
 if (saftr.indexOf("&")!=-1)
    {
    straf=saftr.substring(saftr.indexOf("&"),saftr.length);   
    }	    
}
else strbf=CL;
filtr_s='&filter='+fltr;
link=strbf+filtr_s+straf;
document.location=link;
}

function CancelFilter(fltr)
{
var CurrLoc=document.location;
var CL=CurrLoc+'';
strbf='';
straf='';

if (CL.indexOf("&filter=")!=-1)
{ 
 straf='';
 strbf=CL.substring(0,CL.indexOf("&filter="));
 ixbef=CL.indexOf("&filter=")+1;
 saftr=CL.substring(ixbef,CL.length);
 if (saftr.indexOf("&")!=-1)
    {
    straf=saftr.substring(saftr.indexOf("&"),saftr.length);   
    }	    
}
else strbf=CL;

if (fltr!='') filtr_s='&filter='+fltr; else filtr_s=''; 



link=strbf+filtr_s+straf;
document.location=link;
}









function CompareSelectedITMS(locprefx)
{
var wrk_str=''; 
var node_list = document.getElementsByTagName('input');
  
 for (var i = 0; i < node_list.length; i++) {
     var node = node_list[i];  
     if (node.getAttribute('type') == 'checkbox') {
    	 
    	 var NMA=node.name+'';
    	 if (NMA.substring(0,3)=='CWx' && node.checked)
    	    {
    		 wrid=NMA.substring(3,NMA.length);
    		 wrk_str+='^'+wrid;    		 
    	    }        
     }
}

if (wrk_str.substring(0,1)=='^') wrk_str=wrk_str.substring(1,wrk_str.length);

if (wrk_str!='' && wrk_str.indexOf("^")!=-1)
{
wwn=window.open(locprefx+'&compare='+wrk_str, "ComprWND", 
 "status = 1, height = 600, width = 800, resizable = 1, scrollbars =1, menubar = 1");
wwn.focus();
}
}


function ShowAdditionlSgr(ob,hd)
{
var wrob = GetElemByID(ob);
var hdob = GetElemByID(hd);

if (wrob!=null && hdob!=null)
   {
	if (wrob.style.visibility=="hidden")
	   {		
		wrob.style.visibility="visible";
		wrob.style.display="inline";
		hdob.style.visibility="hidden";		
		}	 
	
   }	  
}

function HideAdditionlSgr(ob,hd)
{
var wrob = GetElemByID(ob);
var hdob = GetElemByID(hd);

if (wrob!=null && hdob!=null)
   {	
	if (wrob.style.visibility=="visible")
	   {
		wrob.style.visibility="hidden";
		wrob.style.display="none";
		hdob.style.visibility="visible";	
		}	 
	
   }	  
}

	
//var WISHES=0;


function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];

 
if (x[1]==null) x2='.00';
else
if (x[1].length==1) x2='.'+x[1]+'0';
else
if (x[1].length==2) x2='.'+x[1];

var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ' ' + '$2');
}


return x1 + x2;
}


function AddToWishes(obj)
{
var HdnV='AddTWSi'+obj;
var WViz='WSHDDx'+obj;
var hbb=GetElemByID(HdnV);
var obb=GetElemByID(WViz);
if (hbb!=null && obb!=null)	
   {
	if (hbb.value=='1')
	   {
	    obb.className='WishesHRF';
	    hbb.value='';
	   }
	   else
	   {
	    hbb.value='1';
	    obb.className='WishesHRFOk';
	   }
	   
recNtDaWSH();
}
}

function recNtDaWSH()
{
var TOTALWISH=0;
Cform=GetElemByID('MainFrm');
if (Cform==null) return;


for (var el=0;el<Cform.elements.length; el++)
    {
     var item = Cform.elements[el];    
     if (item.name.substring(0,7)=='AddTWSi')
        {         
         if (item.value=='1')
         {
         var obji=item.name.substring(7,item.name.length);
         var Prcc=GetElemByID("AddTWSc"+obji);
         var Cntt=GetElemByID("CZx"+obji);
         if (Prcc!=null && Cntt!=null)
            {             
             var PrccP=parseInt(Prcc.value);
             var CnttP=parseFloat(Cntt.value);             
             if (PrccP=='NaN') PrccP=0;
             if (CnttP=='NaN') CnttP=0;
             TOTALWISH+=PrccP*CnttP;
            }
          }
	    }
	 }


	  
var smms=GetElemByID('VelmesCipars');
var NOPRINTTHIS07=GetElemByID('NOPRINTTHIS07');


if (smms!=null && NOPRINTTHIS07!=null)
   {
	if (TOTALWISH<=0 && NOPRINTTHIS07.style.visibility!='hidden')  {NOPRINTTHIS07.style.visibility='hidden'; return;}
	else
	if (TOTALWISH>0 && NOPRINTTHIS07.style.visibility=='hidden')  NOPRINTTHIS07.style.visibility='visible';	
	smms.innerHTML=addCommas(TOTALWISH/100);	
   }
}


function AllToCartFrw()
{
document.forms.MainFrm.MainFrmAct.value='alltocart';
document.forms.MainFrm.submit();
}

function findPosition(oElement){if( typeof( oElement.offsetParent ) != 'undefined' ){for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {posX += oElement.offsetLeft;posY += oElement.offsetTop;}return [ posX, posY ];}else{return [ oElement.x, oElement.y ];}}


function ChangzDaClass(obj, tocla)
{
 if (obj!=null && navigator.appName.indexOf("Microsoft")!=-1)
    {	 
	 MM1=null;
	 MM2=null;

	 if (obj.id=="Mnu1" && obj.className=="SmedNsel") {MM1=GetElemByID('CommonMnu1');}
	 if (obj.id=="Mnu2" && obj.className=="SmedNsel") {MM1=GetElemByID('CommonMnu2');}
	 if (obj.id=="Mnu3" && obj.className=="SmedNsel") {MM1=GetElemByID('CommonMnu3');}
	 if (obj.id=="Mnu4" && obj.className=="SmedNsel") {MM1=GetElemByID('CommonMnu4');}
	 if (MM1!=null)
	    {
	  	 var PS=findPosition(obj);	    	   
	   	 MM1.style.left=PS[0]+16;
	   	 MM1.style.top=PS[1]+12;	   	 
	    }
	 
    }
	
	
 obj.className=tocla;	
}

function ChangePayPtype()
{
	document.forms.CartForm2.PPersSWITCH.value='CHK';
	document.forms.CartForm2.submit();		

}

function ShowLognLegend()
{
 var Legend=GetElemByID('LoginLegend');
 if (Legend!=null) 
	{
	 if (Legend.style.visibility!='visible')
		{
		Legend.style.visibility='visible';
		Legend.style.display='block';
		}
	   }
}


function HideLognLegend()
{
var Legend=GetElemByID('LoginLegend');
if (Legend!=null) 
   {
	if (Legend.style.visibility!='hidden')
	{
	Legend.style.visibility='hidden';
	Legend.style.display='none';
	}
   }
}


function RegeneratePassword()
{
document.forms.MainLoginFrm.reGenPass.value='REGN';
document.forms.MainLoginFrm.submit();
}


function ShowLognLegendCart()
{
 var Legend=GetElemByID('LoginLegendCart');
 var LegendHr=GetElemByID('LoginLegendCartHR');
 
 var PS=findPosition(LegendHr);
 
 if (Legend!=null) 
	{
	 if (Legend.style.visibility!='visible')
		{
		Legend.style.left=PS[0]-154;
		Legend.style.top=PS[1]+23;
		Legend.style.visibility='visible';
		Legend.style.display='block';
		}
	   }
}


function HideLognLegendCart()
{
var Legend=GetElemByID('LoginLegendCart');
if (Legend!=null) 
   {
	if (Legend.style.visibility!='hidden')
	{
	Legend.style.visibility='hidden';
	Legend.style.display='none';
	}
   }
}


function RegeneratePasswordCart()
{
document.forms.CartForm2.reGenPassCart.value='REGN';
document.forms.CartForm2.submit();
}


function BfCheckChanges()
{	
	ProcessDelButtenVsbty();
}

function LoginToSystemFromCart()
{
	document.forms.CartForm2.TryToLogin.value='LOGIN';
	document.forms.CartForm2.submit();
}


function AcceptLoginEvent(evnt)
{
 if(navigator.appName.indexOf("Microsoft")!=-1)
  {
   if(window.event)
	 {
	  keynum = evnt.keyCode;
	  SRC=GetElemByID('cart_form');
	  if(keynum==13 && SRC!=null)
		  LoginToSystemFromCart();
	 }
	}
	else{if (evnt.which==13) LoginToSystemFromCart();}
}

var CdTid=0;
var CrntPos=0;
var CrntCdwn=null;
function DoProgrAnm()
  {
	if (CrntCdwn==null)
	   {
		StopCoundown();
		return;		
	   }	
	CrntPos-=2;
	if (CrntPos<=0)
	   {
		CrntCdwn.style.width=23;
		CrntCdwn.style.height=20;
		StopCoundown();
		
		return;
	   }
	CrntCdwn.style.width=CrntPos;
	CrntCdwn.style.height=CrntPos;
	CdTid=setTimeout("Countdown()", 30);
  }
function Countdown(){if (CdTid){DoProgrAnm();}}
function StartCountdown(){CdTid  = setTimeout("Countdown()", 30);}
function StopCoundown(){if(CdTid){clearTimeout(CdTid);CdTid=0;CrntCdwn=null;}}

function AnimateAddCart(cid)
{
 var BATN=GetElemByID('PutTskR'+cid);
 CrntCdwn=BATN;
 CrntPos=26;
 StartCountdown();
}

function ChangeFltrBselect(fltrid)
{
  if (fltrid=='0') {ChangePrcFilter(fltrid);return;}
  
  F1=GetElemByID('CurrentFltrContent1');
  F2=GetElemByID('CurrentFltrContent2');
  F3=GetElemByID('CurrentFltrContent3');
  if (F1!=null) {F1.style.visibility='hidden';F1.style.display='none';}
  if (F2!=null) {F2.style.visibility='hidden';F2.style.display='none';}
  if (F3!=null) {F3.style.visibility='hidden';F3.style.display='none';}
  
  switch (fltrid)
         {
  case '1': F1.style.visibility='visible';F1.style.display='block';break;
  case '2': F2.style.visibility='visible';F2.style.display='block';break;
  case '3': F3.style.visibility='visible';F3.style.display='block';break;
  default: break; 
         }	
}


function ChangePrcFilter(fltrid)
{ 
 var ADDVAR="";
 var PrcFLTR1=GetElemByID('PrcFltrNR1');
 var PrcFLTR2=GetElemByID('PrcFltrNR2');
 var PrcFLTR3=GetElemByID('PrcFltrNR3');
 var PrcFLTR4=GetElemByID('PrcFltrNR4');
 
 if (PrcFLTR1!=null) ADDVAR+=PrcFLTR1.value+"::";
 if (PrcFLTR2!=null) ADDVAR+=PrcFLTR2.value+"::";
 if (PrcFLTR3!=null) ADDVAR+=PrcFLTR3.value+"::";
 if (PrcFLTR4!=null) ADDVAR+=PrcFLTR4.value+"::";
 
 document.forms.MainFrm.MainFrmAct.value='changeprcfltr'+fltrid; 
 document.forms.MainFrm.MainFrmActAdd.value=ADDVAR;
 
 document.forms.MainFrm.submit();
}


