// JavaScript Document
function ShowDpl(dplIndex) {
	//  
	var tbl = document.getElementById('tblPr');
	var tbl2 = document.getElementById('tblSh');
	var img = document.getElementById('dpl');
	
	var ev = (window.event) ? window.event : e;
	if (ev.pageX) { // Mozilla
		_x = ev.pageX;
		_y = ev.pageY;
	}
	else if (ev.clientX) { // IE
		_x = ev.clientX;
		_y = ev.clientY;
	}
	
	tbl.style.left = _x - 220 ;
	tbl.style.top = _y + 10 + document.body.scrollTop;
	tbl.style.visibility = 'visible';
	tbl2.style.left = _x - 215 ;
	tbl2.style.top = _y + 17 + document.body.scrollTop;
	tbl2.style.visibility = 'visible';
	
	img.src = 'images/diploma'+dplIndex+'_big.jpg';	
}

function HideDpl() { //  
	var tbl = document.getElementById('tblPr');
	var tbl2 = document.getElementById('tblSh');
	var img = document.getElementById('dpl');
	tbl.style.visibility = 'hidden';
	tbl2.style.visibility = 'hidden';
	img.src = 'images/load.gif';
}

function ShowCat(catIndex) {
	// / 
	var tbl = document.getElementById('cat'+catIndex);
	var but = document.getElementById('b'+catIndex);
	if (tbl.style.display == 'none') {
		but.src = 'images/minus.gif';	
		tbl.style.display = '';
	}
	else {
		but.src = 'images/plus.gif';
		tbl.style.display = 'none';	
	}
}

function ShowTarif(catIndex) {
	// / 
	var tbl = document.getElementById('cat'+catIndex);
	var but = document.getElementById('b'+catIndex);
	if (tbl.style.display == 'none') {
		but.src = 'images/up.gif';	
		tbl.style.display = '';
	}
	else {
		but.src = 'images/down.gif';
		tbl.style.display = 'none';	
	}
}

function ShowCatKVplat(catIndex) {

var tbl = document.getElementById(catIndex);
	var but = document.getElementById('b_'+catIndex);
   	var sel = document.getElementById('sel_kv');
	
	if (tbl.style.display == 'none') {
		but.src = 'images/minus.gif';	
		tbl.style.display = '';
		$('#'+catIndex).load('template/tarif/kv_'+sel.value+'_'+catIndex+'.html');
	}
	else {
		but.src = 'images/plus.gif';
		tbl.style.display = 'none';	
	}
}

function ShowCatVoda(catIndex) {

	var tbl = document.getElementById('voda'+catIndex);
	var but = document.getElementById('v'+catIndex);
   	var sel = document.getElementById('sel_voda');
	
	if (tbl.style.display == 'none') {
		but.src = 'images/minus.gif';	

		tbl.style.display = '';
		$('#voda'+catIndex).empty();
		$('#voda'+catIndex).append("<p align = 'center' class='text12'><img src='images/ajax-loader.gif'> Почекайте ... </p>");
	    $('#voda'+catIndex).load('template/tarif/voda_'+sel.value+'_'+catIndex+'.html');
	}
	else {
		but.src = 'images/plus.gif';
		tbl.style.display = 'none';	
	}
}

function getTarif_electro() {
	// / 
   	var sel = document.getElementById('sel_electro');
	 $("#div_electro").load('template/tarif/electro_'+sel.value+'.html');  
}

function getTarif_gaz() {
	// / 
   	var sel = document.getElementById('sel_gaz');
	 $("#div_gaz").load('template/tarif/gaz_'+sel.value+'.html');  
}

function getTarif_teplo() {
	// / 
   	var sel = document.getElementById('sel_teplo');
	 $("#div_teplo").load('template/tarif/teplo_'+sel.value+'.html');  
}

function getTarif_voda() {
	// / 
   	var sel = document.getElementById('sel_voda');
	 $("#div_voda").load('template/tarif/voda_'+sel.value+'.html');  
}

function getTarif_kv() {
	// / 
   	var sel = document.getElementById('sel_kv');
	 $("#div_kv").load('template/tarif/kv_'+sel.value+'.html');  
}

function getTarif_voda_cat(cat) {
	// / 
	 $("#div_voda").load('template/tarif/voda_'+sel.value+'.html');  
}

function ShowAddr(catIndex) { //   
	var tbl = document.getElementById('tbl'+catIndex);
	if (tbl.style.display == 'none') {
		tbl.style.display = '';
	}
	else {
		tbl.style.display = 'none';	
	}
}

function HideAdr(catIndex) { //   
	var tbl = document.getElementById('tbl'+catIndex);
	tbl.style.visibility = 'hidden';   
}

//  
function myfilterkeydown(value) {
	myfilterlen = value.length;  
}		
function myfilterkeyup(value) {
	if (myfilterlen != value.length) {
		myfilterlen = value.length;
		myfilter.set(value);
		AJAX_setStreetRequest();
	}		   
}

function user_pr() {
	frmLog = document.getElementById('UsrValForm');
	frmLog.submit();
}

function submitenter(myfield, e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13) {
		myfield.form.submit();
		return false;
	}
}

function PreloadImages() {
	var d=document; 
	if (d.images) { 
	    if (!d.MM_p) d.MM_p = new Array();
        var i,j=d.MM_p.length, a = PreloadImages.arguments; 
		for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image; d.MM_p[j++].src = a[i];
			}
	}
}

function JSFX_FloatTopDiv()
{
	var placeX = document.body.scrollWidth/2 + 498,
	placeY = 0;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function DeLayer(id)
	{
		var GetElements=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)GetElements.style=GetElements;
		GetElements.sP=function(x,y){this.style.left=x;this.style.top=y;};
		GetElements.y = ns ? pageYOffset : document.body.scrollTop;
		GetElements.y -= placeY;
		return GetElements;
	}
	window.stayTopright=function()
	{
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.x = document.body.scrollWidth/2 + 498;
		ftlObj.y += (pY - ftlObj.y)/15;
		ftlObj.sP(ftlObj.x,ftlObj.y);
		setTimeout("stayTopright()", 10);
	}
	ftlObj = DeLayer("FloatMenu");
	stayTopright();
}

function OpenWindowCounter(id_pl)
{
	//var result = window.showModalDialog("open_pokaz.php?id_pl="+id_pl);
	var result = window.open("open_counter.php?id_pl="+id_pl);
}

function OpenHistory(id_pl)
{
	//var result = window.showModalDialog("history_counter.php?id_pl="+id_pl);
	var result = window.open("history_counter.php?id_pl="+id_pl);
}