

//Функция скрытия строк в предложениях от essel
function ShowHideTRs(tableID, TRPrefix, state){
    table=document.getElementById(tableID);
	if (table)
	  for(i=0;i<table.rows.length;i++){
	    row = table.rows[i];
		id = row.id;
		if (id.substr(0, TRPrefix.length)  == TRPrefix)
		  row.style.display = state;
      }
}

function ApplyFilter() {
  if (document.getElementById("filtr")) {
    original = document.getElementById("showOriginal").checked;
    analogs = document.getElementById("showAnalogs").checked; 
    save = document.getElementById("saveFilter").checked;
    ShowHideTRs("offers", "o", original ? "" :  "none");
    ShowHideTRs("offers", "a", analogs ? "" :  "none");
    fs = document.getElementById("filtr_status")
    if (fs)
      fs.style.display = (!original || !analogs) ? "" : "none";
    if (save) {
	setCookie ("showOriginal", original ? "On" : "Off");
	setCookie ("showAnalogs", analogs ? "On" : "Off");
    } else {
	setCookie ("showOriginal", "");
	setCookie ("showAnalogs", "");
    }
  }
  
}
function RestoreFiltr() {
  if (getCookie("showOriginal") || getCookie("showAnalogs")) {
    document.getElementById("showOriginal").checked = getCookie("showOriginal") == "On";
    document.getElementById("showAnalogs").checked = getCookie("showAnalogs") == "On";
    document.getElementById("saveFilter").checked = true;
    ApplyFilter();
  }
}


//error off
function err_handler(msg) {return true;}
window.onerror = err_handler;
//window.onerror = null;


//function testT(){
 //x = window.event ? event.clientX : e.pageX;
 //alert(event.clientX);
  /*
  oCanvas = document.
          getElementsByTagName((document.compatMode && 
              document.compatMode == "CSS1Compat") ? "HTML" : "BODY")[0];

      x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX;
      y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY;
      
    */
   
 // }



var MyDate = new Date();
yearnow=MyDate.getFullYear()+5;

all_count_1=1;
all_count_2=4;






function showMenu(spanName,top,left){

	var curentSpan = window.document.getElementById(spanName); 


	curentSpan.style.visibility = 'visible';

	oCanvas = document.getElementsByTagName((document.compatMode && 
              document.compatMode == "CSS1Compat") ? 'HTML' : 'BODY')[0];

if(navigator.appName=='Netscape'){
	
	//alert(event.clientY);
} else{
	if(left){
	curentSpan.style.left=left;
	}
	else{curentSpan.style.left=event.clientX+oCanvas.scrollLeft-curentSpan.clientWidth/2;}

	if(top){
	curentSpan.style.top=top;
	}
	else{curentSpan.style.top=event.clientY+oCanvas.scrollTop-curentSpan.clientHeight/2;}

}




}

function holdMenu(spanName){
window.document.getElementById(spanName).style.visibility = 'visible';
}


function hideMenu(spanName){
	window.document.getElementById(spanName).style.visibility = 'hidden';
}

function position(){

	setTimeout('document.getElementById("watermark").style.visibility = "visible"', 50);

}

function hideTable(num){
	targetBlock=document.getElementById(num);		
	targetBlock.style.display = 'none';
	
	}


function hideshowTable(num){
	targetBlock=document.getElementById(num);
	if(targetBlock.style.display == 'none'){
			targetBlock.style.display = '';
			
		}else{
			targetBlock.style.display = 'none';
			
		}
	}



//filtr
	
function ShowHideTR(num,count){
	
for(i=1;i<=eval('all_count_'+count);i++){
	
	target=document.getElementById('type'+num+i);
	if(target.style.display == 'none'){
	target.style.display = '';
	
	}else{
		target.style.display = 'none';
		

		}
	 }
}


function HideTR(num,count){
	
for(i=1;i<=eval('all_count_'+count);i++){

	
	target=document.getElementById('type'+num+i);
	if(target.style.display == 'none'){
	target.style.display = '';
	
	}
	
	
	 }
}


//end filtr




function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function getCookie(name) {
var cookie = " " + document.cookie;
var search = " " + name + "=";
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length > 0) {
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = cookie.indexOf(";", offset)
if (end == -1) {
end = cookie.length;
}
setStr = unescape(cookie.substring(offset, end));
}
}
return(setStr);

}




function hideshowTableWithCookies(num,nameC){
	targetBlock=document.getElementById(num);
	if(targetBlock.style.display == 'none'){
			targetBlock.style.display = '';
			setCookie (nameC, 'on', 'Mon, 01-Jan-'+ yearnow + ' 00:00:00 GMT', '/');
			
		}else{
			targetBlock.style.display = 'none';
			setCookie (nameC, 'off', 'Mon, 01-Jan-'+ yearnow + ' 00:00:00 GMT', '/');

			
		}
	}

function openPopUpWin(URL) {
	var win = window.open(URL,"PopUpInfo","left=200,top=30,width=550,height=550,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	win.focus();
}


function position(){

if(navigator.appName=="Opera"){

	if(document.all){
	watermark.style.pixelLeft = document.body.clientWidth-190;
	setTimeout('watermark.style.visibility = "visible"', 50);}
	else if(document.getElementById && !document.all){
			document.getElementById("watermark").style.left=document.body.clientWidth-190;
			setTimeout('document.getElementById("watermark").style.visibility = "visible"', 50);
			}
	

}else{

	if(document.all){
	watermark.style.pixelLeft = document.body.clientWidth-178;
	setTimeout('watermark.style.visibility = "visible"', 50);
	}
	else if(document.getElementById && !document.all){
			document.getElementById("watermark").style.left=document.body.clientWidth-178;
			setTimeout('document.getElementById("watermark").style.visibility = "visible"', 50);
	}



}
}


function colortextnews(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.color = '#666666';
					
}


function colortextnews_restore(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.color = '#000000';
	
}



function padding_change(num){
targetBlockNews=document.getElementById(num);
targetBlockNews.style.padding ='10px';
}

function padding_change_r(num){
targetBlockNews=document.getElementById(num);
targetBlockNews.style.padding ='0px';
}

function news_more(num){
targetBlockNews=document.getElementById(num);
targetBlockNews.style.padding ='10px';
targetBlockNews.style.border ='1px solid #CCCCCC';
}

function news_more_r(num){
targetBlockNews=document.getElementById(num);
targetBlockNews.style.padding ='0px';
targetBlockNews.style.border ='0px solid #CCCCCC';
}






function catalog_vd(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.fontSize = 12;

}

function catalog_vd_res(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.fontSize = 11;					
}

function setBorder(ElementId, Border)
  {
    var oDiv = document.getElementById(ElementId);
    oDiv.style.border = Border;
  }

function catalog50(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.border ='1px solid #CCCCCC';
targetBlockNews.style.padding ='10px';
}

function catalog50_back(num){
targetBlockNews=document.getElementById(num);	
targetBlockNews.style.border ='0px solid #CCCCCC';
targetBlockNews.style.padding ='0px';
}

