

/* подсказка */ 
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 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 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){

	if (obj.value==''){
		var div0=document.getElementById("divFind");
		div0.style.display="none";
		vF=0;
	}else{
		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/ajax_functions.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='391px';
		div0.style.display="block";
		vF=1;
	}	
}


function changePic(obj, id, type, width, height){
	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;
	}
}


function ajaxStart(request, action, obj, type)
{

	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);
				}else{
					document.getElementById(obj).innerHTML=http_request.responseText;
				}
				
				
			}
		}
	}
	
	http_request.open('GET', 'http://'+location.host+'/'+request+action, true);
	http_request.send(null);


}
