
var checkStoreStatus=0;
/* Показать корзину */ 
function viewStore(oper, id, val){

           if (checkStoreStatus==0) {     
            ajaxStart("includes/ajax_functions.php", "?page=viewStore&oper="+oper+"&ID="+id+"&VAL="+val, "DivViewStore");
           }
          
    }
    
    
/* Показать форму авторизации */ 
function showAuth(obj){
    
 var div0=document.getElementById("divAll");
    if (div0.style.display=='block'){
        div0.style.display="none";
        div0.innerHTML='';
    }else{

        
        obj_pos=getAbsolutePos(obj); 
        div0.style.top=(obj_pos.y+20); 
        div0.style.left=(obj_pos.x-50); 
        div0.style.width='250px';
        div0.style.height='80px';
        div0.style.display="block";
            
           div0.innerHTML='<br><FORM action="" method="post"><table cellSpacing=0 cellPadding=0 width=100%><tr><td align=left valign=middle><input type="hidden" name="log" value="on"><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD width=10></TD><TD align=left>Логин:</TD><TD><INPUT maxLength="20" style="height:18px" name="LOGIN"></TD></TR><TR><TD height=3></TD></TR><TR><TD width=10></TD><TD align=>Пароль:</TD><TD><INPUT type="password" style="height:18px" maxLength="20" name="PASSWORD"></TD></TR><TR></TBODY></TABLE></td><TD colSpan=2 align=right><input type="submit" name="but" style="height:22px; padding:0px; margin:0px; font-size:12px" value="Войти"></TD></tr></table></FORM><div align=center><a href="#null" onclick="showAuth()">Закрыть</a></div>';
        }
    }  
    
/* Показать корзину */ 
function checkStore(event){

           if (OnlyCifri(event)) {
            checkStoreStatus=0;
            return true;
           }else{
           checkStoreStatus=1; 
           alert('Введите число');     
           return false;    
           }
    }


/* В корзину */ 
function toStore(ID, TY){
    obj=document.getElementById('DivStoreAll'); 
    if (obj.style.display=='none')
        obj.style.display='block'; 
        
      if (ID){
           ajaxStart("includes/ajax_functions.php", "?page=toStore&ID="+ID+"&type="+TY, "DivStore");  
      }
      if (TY='all'){
          obj=document.getElementById('DivStoreAll_'+ID);
          obj.innerHTML='<a href="#null" onclick="delStore('+ID+', \'all\')" title="Убрать из корзины"><img src="/images/delshop.gif"></a>';
      }
  
}  

function OnlyCifri(event){
        var key = event.keyCode;
        if (key == 0){ // фикс для ФФ
          key = event.charCode;
        }
        if ((key == 44)|| // ','
            (key == 46)|| // '.' и delete
            (key == 8)||  // backspace
            ((key >= 48)&&(key <= 57))|| // '0' - '9'
            ((key >= 37)&&(key <= 40))){ // 'up','right','down','left'
            event.returnValue = true;
            return true;
          }
        event.returnValue = false;
        return false;
      }

/* Из корзины */ 
function delAllStore(ID, TY){

        if (confirm("Вы хотите очистить корзину?"))
            ajaxStart("includes/ajax_functions.php", "?page=delStore&ALL=1&ID="+ID+"&type="+TY, "", 1); 
}

/* Из корзины */ 
function delStore(ID, TY){
    
 if (ID)
           ajaxStart("includes/ajax_functions.php", "?page=delStore&ID="+ID+"&type="+TY, "DivStore");  
    obj=document.getElementById('DivStoreAll'); 
    if (obj.style.display=='none')
        obj.style.display='block'; 
    if (TY='all'){
          obj=document.getElementById('DivStoreAll_'+ID);
          obj.innerHTML='<a href="#null" onclick="toStore('+ID+', \'all\')" title="Добавить в корзину"><img src="/images/shop.gif"></a>';  
      }    
}

/* подсказка */ 
function hint(s){
	
}

function changePhone(){
ph=document.getElementById('PhoneTXT');

if (ph.innerHTML=='796 94 96'){
ph.style.color='#505050';
ph.innerHTML='729 98 42';

} else {
ph.style.color='#808080';
ph.innerHTML='796 94 96';
}

}


function onLoadBody(){
document.getElementById('tFind').focus();

//setInterval('changePhone()', 3000);
}



function clickTextToFind(s){
		obj=document.getElementById("tFind");
		obj.value=s
		setFind(0,	obj);
}

function setValuteDate(obj){
    
var div0=document.getElementById("divAll");
    if (div0.style.display=='block'){
        div0.style.display="none";
    }else{

        v1=document.getElementById("procValue1").value;
        ajaxStart("includes/ajax_functions.php", "?page=setValuteDate&word="+v1, "divAll");
        
        obj_pos=getAbsolutePos(obj); 
        div0.style.top=(obj_pos.y+20); 
        div0.style.left=(obj_pos.x-150); 
        div0.style.width='150px';
        div0.style.display="block";
        
    }    
    
}

function chValuteDate(dT){
    ajaxStart("includes/ajax_functions.php", "?page=chValuteDate&word="+dT, "", 1);
    setValuteDate(0);
}




function setprocValue(e, eId){  //установка процента

    
    v1=document.getElementById("procValue1").value;
    v2=document.getElementById("procValue2").value;
    v3=document.getElementById("procValue3").value;
    v4=document.getElementById("procValue4").value;
    ajaxStart("includes/ajax_functions.php", "?page=setprocValue&word="+v2+"&elementID="+eId+"&valute="+v1+"&pr="+v3+"&res="+v4, "procDiv");
}



function setprocValueClient(e, eId){  //установка процента
    v1=document.getElementById("procValueClient1").value;
    v2=document.getElementById("procValueClient2").value;

    ajaxStart("includes/ajax_functions.php", "?page=setprocValueClient&v1="+v1+"&elementID="+eId+"&v2="+v2, "procDivClient");
}


function changeCenterText(turn, s, type){
	if (turn==1){
	if (type==1){
		document.getElementById("centerText").style.display='none';
		obj=document.getElementById("centerTextOver");
		obj.innerHTML='<table width=100%><tr><td width=40 class="white2"><a href="#null" onclick="changeCenterText(0)"><img src="/images/backFind.gif" title="Вернуть поиск" alt="Вернуть поиск"></a></td><td class="white2"> <img style="vertical-align:middle" src="/images/loaderOval.gif" alt="Пожалуйста, подождите..." title="Пожалуйста, подождите..."></td></tr></table>';
		obj.style.display='block';
		ajaxStart("includes/ajax_functions.php", "?page=changeCenterText&ID="+s,  "centerTextOver");
	

	}else{
		document.getElementById("centerText").style.display='none';
		obj=document.getElementById("centerTextOver");
		obj.innerHTML=s;
		obj.style.display='block';
	}
	}else{
		document.getElementById("centerText").style.display='block';
		obj=document.getElementById("centerTextOver");
		obj.innerHTML="";
		obj.style.display='none';
	}
}


function addProductForPrice(id, s){
		var parent = document.getElementById("pAll");
		child =  document.createElement('DIV');
		input = parent.appendChild(child);
		input.id = "pAll_"+id;
		input.innerHTML='<input type="hidden" name="products[]" value="'+s+'"><b>'+s+'</b>';
		
		
		
	
}

/* курсы валют */
function viewAllValute(){

	thisCheckBoxes = document.getElementById('tabValute').getElementsByTagName('tr');
		for (i = 0; i < thisCheckBoxes.length; i++){
		
			fo=thisCheckBoxes[i].id;
			
			if (fo.substring(0, 9)=='trValute_')
				document.getElementById(fo).style.display='block';
			
		}
}


/* соообщение */ 
function conf(s){
		if (confirm(s))
			return true;
		else
			return false;
}


var tempClass;
/* изменить класса */ 
function changeClass(obj, n, type, h){

	hint(h);
	if (type=='class'){
		tempClass=obj.className;
		obj.className=n;
	}else{
		tempClass=obj.style;
		obj.style=n;
	}
	
	
}


/* возрат класса */ 
function vernutClass(obj, type){
	hint('');
	if (type=='class'){
		obj.className=tempClass;
	}else{
		obj.style=tempClass;
	}
	tempClass='';
	
}


/* выбрать все */
function CheckAll(form, suff, obj){

if (obj.checked==true)
check=true; else check=false;
	thisCheckBoxes = document.getElementById(form).getElementsByTagName('input');
		for (i = 0; i < thisCheckBoxes.length; i++){
		
			fo=thisCheckBoxes[i].id;
			s=fo.substring(0, (suff.length));
			if (s==suff)
			document.getElementById(fo).checked=check;
			
		}

}



/* новое окно для фото*/
  function ImgShw(ID, width, height, alt)
            {
                var scroll = "no";
                var top=0, left=0;
                if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
                if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
                if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
                width = Math.min(width, screen.width-10);
                height = Math.min(height, screen.height-28);
                var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
                wnd.document.write("<html><head>\n");
                wnd.document.write("<"+"script language='JavaScript'>\n");
                wnd.document.write("<!--\n");
                wnd.document.write("function KeyPress()\n");
                wnd.document.write("{\n");
                wnd.document.write("    if(window.event.keyCode == 27)\n");
                wnd.document.write("        window.close();\n");
                wnd.document.write("}\n");
                wnd.document.write("//-->\n");
                wnd.document.write("</"+"script>\n");
                wnd.document.write("<title>"+(alt == ""? "Картинка":alt)+"</title></head>\n");
                wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n");
                wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\">");
                wnd.document.write("</body>");
                wnd.document.write("</html>");
                wnd.document.close();
            }

			
			
/* новое окно*/
function ShowWnd(Wnd,width,height)
    {
        Wnd_window=open(Wnd, 'Wnd', 'fullscreen=no,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height);
        Wnd_window.focus();
        return(false);
    }

var vF=0;

function hideDiv(div, empty){
var div0=document.getElementById(div);
div0.style.display="none";
if (empty!==false)
div0.innerHTML='';
if (div0=='divFind') vF=0;
} 
	
function viewDiv(div, t, l, s, w, h){
			obj=document.getElementById(div);
			obj.style.display="block";
			if (s) obj.innerHTML=s;
			if (w) obj.style.width=w;
			if (h) obj.style.height=h;
			if (t) obj.style.top=t;
			if (l) obj.style.left=l;
}


function viewDivFlash(obj, url, w, h){
		obj_pos=getAbsolutePos(obj); 
		s='<div align=center class=bord style="padding:5px"><script type="text/javascript" src="/js/player/swfobject.js"></script><script type="text/javascript">AC_FL_RunContent("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0","wmode","opaque","width","'+w+'","height","'+h+'","src","'+url+'","quality","high","pluginspage","http://www.macromedia.com/go/getflashplayer","movie","'+url+'");</script><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+w+'" height="'+h+'"><param name="wmode" value="opaque"><param name="movie" value="'+url+'.swf"><param name="quality" value="high"><embed wmode="opaque" src="'+url+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></object><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="289" height="175"><param name="movie" value="'+url+'.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><embed src="/images/map_sm.swf" width="'+w+'" height="'+h+'" wmode="opaque" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></noscript><br><a href="#null" onclick="hideDiv(\'divAll\')">закрыть</a></div>';
		
		viewDiv("divAll", obj_pos.y*1-(h/2), obj_pos.x, s, (w+11), (h+25));
}
	
    
function storeCursor(e, obj, t, i){
    
var m=getCoorginatsMouse(e);
var p=getAbsolutePos(obj); 
if (m.y>(p.y+15)){
    if (t=='over'){
        obj.src='/images/str_hb.png';
    }else if (t=='out'){
        obj.src='/images/str.png';
    }else if (t=='down'){
        obj.src='/images/str_b.png';
        if ( document.getElementById('storeKol_'+i).value >= 1)
        document.getElementById('storeKol_'+i).value=(document.getElementById('storeKol_'+i).value*1-1);
        viewStore('red', i, document.getElementById('storeKol_'+i).value);
    }
    
 }else
 {
    if (t=='over'){
        obj.src='/images/str_ht.png';
    }else if (t=='out'){
        obj.src='/images/str.png';
    }else if (t=='down'){
        obj.src='/images/str_t.png';
        document.getElementById('storeKol_'+i).value=(document.getElementById('storeKol_'+i).value*1+1);
        viewStore('red', i, document.getElementById('storeKol_'+i).value);
    }
     
 }

}    


    
function calcCursor(e, obj, t, id){
    
var m=getCoorginatsMouse(e);
var p=getAbsolutePos(obj); 
if (m.y>(p.y+12)){
    if (t=='over'){
        obj.src='/images/str_hb.png';
    }else if (t=='out'){
        obj.src='/images/str.png';
    }else if (t=='down'){
        obj.src='/images/str_b.png';

        document.getElementById('procValueClient2').value=(document.getElementById('procValueClient2').value*1-1);
        setprocValueClient(e, id);
    }
    
 }else
 {
    if (t=='over'){
        obj.src='/images/str_ht.png';
    }else if (t=='out'){
        obj.src='/images/str.png';
    }else if (t=='down'){
        obj.src='/images/str_t.png';

        document.getElementById('procValueClient2').value=(document.getElementById('procValueClient2').value*1+1);
        setprocValueClient(e, id);
    }
     
 }


} 
    
function getCoorginatsMouse(e){
  var r= { x:0, y: 0 };;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    r.x = e.pageX;
    r.y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    r.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    r.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  return r;
}


function getAbsolutePos(el)
{
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;
}





function checkFind(e){
/*	var evt=e||window.event;
	var target = evt.target||evt.srcElement;

		alert(target.innerHTML);
		
		if(target.id!=='findDivOne' && target.id!=='findAOne'){}
			*/
				if (vF==1) {
			vF=0;
			setTimeout("hideDiv('divFind')", 100);
			
				}
		
		
	
}


function setFind(e, obj){
str=obj.value;
	if (obj.value=='' || str.length<=1){
		var div0=document.getElementById("divFind");
		div0.style.display="none";
		vF=0;
	}else if (str.length>1){
		var div0=document.getElementById("divFind");
		div0.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="BgWhite"><table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5" class="findLbg"></td><td align=center style="background: URL(/images/loading.gif) no-repeat" height=19><img src="/images/spacer.gif" width=1 height=1></td><td width="5" class="findRbg"></td></tr></table></td></tr><tr><td height=10><table style="width:100%" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height=10 width=11 class="findBL"><img src="/images/spacer.gif" width=1 height=1></td><td class="findB"><img src="/images/spacer.gif" width=1 height=1></td><td width=11 align=right class="findBR"><img src="/images/spacer.gif" width=1 height=1></td></tr></table></td></tr></table>';
        
		ajaxStart("includes/ajaxFind.php", "?page=viewFind&word="+obj.value,  "divFind");
		
		obj_pos=getAbsolutePos(obj); 
	  	div0.style.top=(obj_pos.y+20); 
		div0.style.left=(obj_pos.x-11); 
		div0.style.width='431px';
		div0.style.display="block";
		vF=1;
	}	
}
/*
function setFind(e, obj){
  str=obj.value;
  var div0=$("#lSearch");

	if (obj.value=='' || str.length<=1){
		
    div0.hide();
		vF=0;

	} else if (str.length>1){

		div0.innerHTML='123';
        
		ajaxStart("includes/ajaxFind.php", "?page=viewFind&word="+obj.value,  "lSearch");
    // <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="BgWhite"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">              <tr>                <td width="5" class="findLbg">                </td>                <td align=center style="background: URL(/images/loading.gif) no-repeat" height=19>                  <img src="/images/spacer.gif" width=1 height=1></td><td width="5" class="findRbg">                </td>              </tr>            </table>          </td>        </tr>        <tr>          <td height=10>            <table style="width:100%" border="0" cellpadding="0" cellspacing="0" width="100%">              <tr>                <td height=10 width=11 class="findBL">                  <img src="/images/spacer.gif" width=1 height=1>                </td>                <td class="findB">                  <img src="/images/spacer.gif" width=1 height=1>                </td>                <td width=11 align=right class="findBR">                  <img src="/images/spacer.gif" width=1 height=1>                </td>              </tr>            </table>          </td>        </tr>      </table>	
    div0.show();
		vF=1;
	}	
}
*/

function setFindPrice(e, obj, id){
str=obj.value;

    if (obj.value=='' || str.length<=2){
        var div0=document.getElementById("divFind");
        div0.style.display="none";
        vF=0;
    }else if (str.length>2){


    
        var div0=document.getElementById("divFind");
        div0.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td class="BgWhite"><table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5"></td><td align=center style="background: URL(/images/loading.gif) no-repeat" height=19><img src="/images/spacer.gif" width=1 height=1></td><td width="5"></td></tr></table></td></tr><tr><td height=10><table style="width:100%" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height=10 width=11><img src="/images/spacer.gif" width=1 height=1></td><td><img src="/images/spacer.gif" width=1 height=1></td><td width=11 align=right><img src="/images/spacer.gif" width=1 height=1></td></tr></table></td></tr></table>';

        ajaxStart("includes/ajaxFind.php", "?page=viewFind&price="+id+"&word="+obj.value, "divFind", 2);
        
        obj_pos=getAbsolutePos(obj); 
          div0.style.top=(obj_pos.y+21); 
        div0.style.left=(obj_pos.x); 
        div0.style.width='250px';
        div0.style.display="block";
        vF=1;
    
}  
}


function changePic(obj, id, type, width, height, title){
	if (type==0)
		obj.src='/images/sectionIcons/'+id+'_on.png';
	else if (type==1)
		obj.src='/images/sectionIcons/'+id+'.png';
	else if (type==2)
		obj.src=id;
	else if (type==3){
		div0=document.getElementById(obj);
		div0.src=id;
		div0.width=width;
	}
    document.getElementById('divTitleImg').innerHTML=title;
}

var ajaxStatus=0;
var evFunc='';
function ajaxStart(request, action, obj, type)
{
    if (type==2)
        ajaxStatus=1;
    
        div0=document.getElementById('divAx');
        div0.style.display="block"


	var http_request = false;
	if(window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	
	http_request.onreadystatechange = function()
	{
		if(http_request.readyState == 4)
		{
			if(http_request.status == 200)
			{
				if (type==1){
					eval(http_request.responseText);
                    div0.style.display="none";
				}else if (type==2){
                    document.getElementById(obj).innerHTML=http_request.responseText;
                    div0.style.display="none";
                        if (evFunc)
                        {
                            alert(evFunc);
                            evFunc='';
                        }
                        ajaxStatus=0;
                }else{
					document.getElementById(obj).innerHTML=http_request.responseText;
                    div0.style.display="none";
                    
				}
				
				
			}
		}
                            
	}
	
	http_request.open('GET', 'http://'+location.host+'/'+request+action, true);
	http_request.send(null);

    
}
/*
$(document).ready(function(){
  $('#lSearch').find('li').live('mouseover', function(){
    $(this).addClass('ls_active');
  });
  $('#lSearch').find('li').live('mouseout', function(){
    $(this).removeClass('ls_active');
  })
})
*/
$('#NEW_COMMENT').live('click', function () {
    
    if($(this).val() == 'Оставьте комментарий') {
      $(this).val('');  
    }

  });



