var CdTid=0;
var CrntPos=0;
function ProcessAllDynamics(){window.onresize=PrepareSystemVisual;document.onclick=sourceCheck;}
function sourceCheck(e){var el=(typeof event!=='undefined')? event.srcElement : e.target;if (el.tagName=='IMG') return;CloseImgPreview();}
function PrepareSystemVisual(){CloseImgPreview();}
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 CloseImgPreview(){var InDIV=GetElemByID('BFRLGIMG001');if (InDIV!=null){if (InDIV.style.visibility!='hidden'){InDIV.style.width=0;
InDIV.style.height=0;InDIV.style.top=0;InDIV.style.left=0;InDIV.style.display='none';InDIV.style.visibility='hidden';}}}
function CHK_ALL(){OBJ=GetElemByID('MAINCB');if (OBJ!=null){var Cform;Cform=GetElemByID('cart_form');if (Cform==null) Cform=GetElemByID('notes_form');
if (Cform==null) return;for (var el=0;el<Cform.elements.length; el++){var item = Cform.elements[el];if (item.name.substring(0,7)=='FRIZDS_' && item!=OBJ){
item.checked=OBJ.checked;}}}}	 
function FinishPreviewLoad(object){var InCB2=GetElemByID('BFRLGIMG005');if (InCB2!=null) {InCB2.style.visibility='visible';InCB2.style.display='block';}DropAlt(object)}
function DropAlt(object){if (object.alt!=null) object.alt="";}
function SaveWCartM(){document.forms.cart_form.CartSubaction.value='save';document.forms.cart_form.submit();}	
function TrashWCartM(){document.forms.cart_form.CartSubaction.value='trash';document.forms.cart_form.submit();}
function TrashCartItem(item){document.forms.cart_form.CartSubaction.value='trash_item_'+item;document.forms.cart_form.submit();}
function TrashWNotesM(){document.forms.notes_form.NotesSubaction.value='trash';document.forms.notes_form.submit();}
function TrashNotesItem(item){document.forms.notes_form.NotesSubaction.value='trash_nitem_'+item;document.forms.notes_form.submit();}
function SaveWNotesM(){document.forms.notes_form.NotesSubaction.value='save';document.forms.notes_form.submit();}	
function FmtVal(num){num = num.toString().replace(/\$|\,/g,'');if(isNaN(num))num = "0";sign = (num == (num = Math.abs(num)));num = Math.floor(num*100+0.50000000001);cents = num%100;num = Math.floor(num/100).toString();if(cents<10)cents = "0" + cents;for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)num = num.substring(0,num.length-(4*i+3))+' '+num.substring(num.length-(4*i+3));return (((sign)?'':'-') + num + '.' + cents);}
function RecountLiz (litex,sum,obj){INTD=GetElemByID('LIZZUM');if (INTD==null) return false;if (obj==null) return false;var selval=obj.options[obj.selectedIndex].text;
if (sum>0 && selval!=''){selval=selval.replace('%','');var f_PRC=parseFloat(selval);if (f_PRC>=0 && f_PRC<=100){f_SMA=sum*f_PRC/100;fmted=FmtVal(f_SMA);
fmted=fmted.replace(/ /g,'&nbsp;');INTD.innerHTML=litex+'&nbsp;(<fon'+'t color="#EA6D1A">~'+fmted+'&nbsp;LVL<'+'/fo'+'nt>):&nbsp;';}else INTD.innerHTML=litex+':&nbsp;';}else INTD.innerHTML=litex+':&nbsp;';}
function ShowHover(obj){var OBJECT;OBJECT=GetElemByID(obj);if (OBJECT!=null) OBJECT.className='CATL_ITM_1';}
function UnShowHover(obj){var OBJECT;OBJECT=GetElemByID(obj);if (OBJECT!=null) OBJECT.className='CATL_ITM';}
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 getBrowserInfo() {var t,v = undefined;if (window.opera) t = 'Opera';else if (document.all) {t = 'IE';var nv = navigator.appVersion;var s=nv.indexOf('MSIE')+5;v=nv.substring(s,s+1);}else if (navigator.appName)t='Netscape';return {type:t,version:v};}
function bookmark(a){var url=window.document.location;var title=window.document.title;var b=getBrowserInfo();if (b.type=='IE' && 8 > b.version&& b.version>=4)window.external.AddFavorite(url,title);else if (b.type=='Opera'){a.href = url;a.rel = "sidebar";a.title = title;return true;}else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");else alert("This browser does not support automaticaly bookmark implemitation.\nPlease press Ctr+D to complete this operation manually.");return false;}
function RecntGood(INP_ID,EX)
        {
		    var CNT,PRC,TTL;			
			CNT=GetElemByID(INP_ID);
			if (CNT!=null && CNT.name.substring(0,5)=='BZIR_')
			   {			    
				CNT_n=CNT.name;
				PRC_n='AVIA_'+CNT.name.substring(5,CNT_n.length);
				TTL_n='CXER_'+CNT.name.substring(5,CNT_n.length);
				
				PRC=GetElemByID(PRC_n);
				TTL=GetElemByID(TTL_n);
				if (PRC!=null && TTL!=null)
				   {				    
					V1=PRC.value;
					V1=V1.replace(' ','');
					V1=V1.replace(' ','');
					V1=V1.replace(' ','');
					V1=V1.replace(' ','');					
					
					V2=CNT.value;
					V2=V2.replace(' ','');
					V2=V2.replace(' ','');
					V2=V2.replace(' ','');
					V2=V2.replace(' ','');
					
					f_PRC=parseFloat(V1);
					f_CNT=parseFloat(V2);
					if (!f_CNT || f_CNT<0) 
					   {
					    if(EX=='1') CNT.value='1';
						f_CNT=1;
					   }					
					f_TTL=f_CNT*f_PRC;					
					TTL.value=FmtVal(f_TTL);
					if(EX=='1') CNT.value=f_CNT;
					if (TTL.value=='NaN') TTL.value='".BT_ReadLng(1,$CLANG,8)."';
				   }
				}
				
				CountTotal();
		}

		
		
function PrepareFltrs(objk)
{
var Cform=GetElemByID('bxFilterForm');
var Progind=GetElemByID('WrkProgFl');
var FnLab=null;
if (objk.name.indexOf('bxFilterIx')!=-1)
   {
    ChkIx=objk.name.substring(10,objk.name.length);	
	if (ChkIx.indexOf("_")!=-1)
		    {
			 flid=ChkIx.substring(ChkIx.indexOf("_")+1,ChkIx.length);			 
			 FnLab=GetElemByID('FiltrLabx'+flid);			 
			}
   }   
if (objk!=null)
{
pz=findPosition(objk);
if(navigator.appName.indexOf("Microsoft")!=-1){ty=pz[1]+6;tx=pz[0]+21;}
else if(navigator.appName.indexOf("Safari")!=-1 || navigator.appName.indexOf("Netscape")!=-1){ty=pz[1]+1;tx=pz[0]+17;}
else if(navigator.appName.indexOf("Opera")!=-1){ty=pz[1]+5;tx=pz[0]+20;}
else{ty=pz[1]+2;tx=pz[0]+16;}
if (FnLab!=null) tx+=FnLab.offsetWidth;
}
if (Cform==null) return false;
var item;
var CurrLoc=document.location;
var CL=CurrLoc+'';
strbf='';
straf='';
filtertag=false;
if (CL.indexOf("&filter=")!=-1)
   {
    filtertag=true;
	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;   
ttsk=0;
fltrs='';
for (var el=0;el<Cform.elements.length; el++)
	{
	 item = Cform.elements[el];
	 inm=item.name;
	 if (inm.substring(0,10)=='bxFilterIx' && item.checked)
	    {
		 wrkinm=inm.substring(10,inm.length);
		 if (wrkinm.indexOf("_")!=-1)
		    {
			 flid=wrkinm.substring(wrkinm.indexOf("_")+1,wrkinm.length);
			 if (fltrs!='') fltrs+='^'+flid; else fltrs=flid;			 
			 ttsk++;
			}		 
		}
	}
	
if (ttsk<=0 && filtertag)
  {
   if (Progind!=null && objk!=null && FnLab!=null)
      {	   
	   Progind.style.top=ty;
	   Progind.style.left=tx;
	   Progind.style.visibility='visible';	  
	  }
   StopCoundown();
   StartCountdown();
   document.location=strbf+straf;   
   return false;
  }
else
if (ttsk<=0 && !filtertag) return false;
else
{
 if (Progind!=null && objk!=null && FnLab!=null)
    {	
	Progind.style.top=ty;
	Progind.style.left=tx;	
	Progind.style.visibility='visible';	 
	} 
 StopCoundown(); 
 StartCountdown();
 document.location=strbf+'&filter='+fltrs+straf; 
 return false;
}
return false;
}
function DoProgrAnm(){var Progind=GetElemByID('WrkProgFl');CrntPos-=8;if (CrntPos<-40) CrntPos=0;posst='0 '+CrntPos+'px';
if (Progind!=null) Progind.style.backgroundPosition=posst;}
function Countdown(){if (CdTid){DoProgrAnm();CdTid=setTimeout("Countdown()", 70);}}
function StartCountdown(){CdTid  = setTimeout("Countdown()", 70);}
function StopCoundown(){if(CdTid){clearTimeout(CdTid);CdTid=0;}}





function ProcFiltersGr(Block,HGHT,OpA)
{
var BLK=GetElemByID(Block);
var HROB=GetElemByID(OpA);

if (BLK!=null)
   {
    if (BLK.style.visibility!='visible')
	   {
	    if (HROB!=null)
		   {
		    HROB.style.visibility='hidden';
			HROB.style.display='none';
			HROB.style.height=0;			
		   }
		BLK.style.visibility='visible';		
		BLK.style.display='block';
	    BLK.style.height=HGHT;   
	   }
	   else
	   {
	    if (HROB!=null)
		   {
		    HROB.style.visibility='visible';
			HROB.style.display='block';
			HROB.style.height=17;
		   }
		BLK.style.visibility='hidden';		
		BLK.style.display='none';
	    BLK.style.height=0;
	   }
   }


}


