function stopError() {

  return true;

}

//window.onerror = stopError;



setBrowserType();



function vote(query_string) {

	answid = get_radio_value('voteform', 'vote');

	window.open('/vote.php?id='+query_string+'&answid='+answid, '', 'width=400, height=350, location=no, menubar=no, resizable=no, scrollbars=yes, status=no');

}



function show_tmark(id) {

	window.open('/tmark.php?id='+id, '', 'width=480, height=500, location=no, menubar=no, resizable=no, scrollbars=yes, status=no');

}

function show_shop_gallery(base_url, id)
{
	window.open(base_url+'shops/gallery.php?id='+id, '', 'width=800, height=600, location=no, menubar=no, resizable=no, scrollbars=yes, status=no');
}



function know(id) {

	window.open('/know-'+id+'.html', '', 'width=700, height=450, location=no, menubar=no, resizable=no, scrollbars=yes, status=no');

}



function shop_vote(query_string) {

	window.open('vote.php?id='+query_string, '', 'width=300, height=320, location=no, menubar=no, resizable=no, scrollbars=yes, status=no');

	//location.reload();

}



function get_radio_value(form_name, element) {

   for (var i=0; i < document.forms[form_name].elements[element].length; i++) {

      if (document.forms[form_name].elements[element][i].checked) {

         var rad_val = document.forms[form_name].elements[element][i].value;

         return rad_val;

      }

   }

   return 1;

}



function printPage() {

    if (window.print) {

	    if (confirm("Распечатать эту страницу?")) {

	    	hiddenImg = new Image();

	    	hiddenImg.src = "/print.php";

	      window.print();

	    }

	}

  }





function setBrowserType(){

	if (navigator.appName=='Microsoft Internet Explorer'){

		if(document.getElementById)

			this.IEnew=true;

		else

			this.IEold=true;

	}else if(navigator.appName=='Netscape'){

		if(parseInt(navigator.appVersion)==4)

			this.NNold=true;

		else if(parseInt(navigator.appVersion)>=5)

			this.NNnew=true;

	}

}



function menu_state(divName, val) {

	if (val) {

	  if (this.IEold) {

	    	eval(divName+'.style.visibility="visible"');
	    	eval(divName+'.style.zindex="1000"');

		} else if(this.NNold) {

		    eval('document.'+divName+'.visibility="show"');
		    eval('document.'+divName+'.zindex="1000"');

		} else if (this.NNnew) {

		    document.getElementById(divName).style.visibility="visible";
		    document.getElementById(divName).style.zindex="1000";

		} else if (this.IEnew) {

		    document.getElementById(divName).style.visibility="visible";
		     document.getElementById(divName).style.zindex="1000";

		} else {

			  document.getElementById(divName).style.visibility="visible";
			  document.getElementById(divName).style.zindex="1000";

		}

	} else {

		if(this.IEold) eval(divName+'.style.visibility="hidden"');

		else if(this.NNold) eval('document.'+divName+'.visibility="hide"');

		else if(this.NNnew || this.IEnew) document.getElementById(divName).style.visibility="hidden";

		else document.getElementById(divName).style.visibility="hidden";

	}

}



function setVisible(visible){

	if(visible){

		//this.hideOverMenus();

		if(this.IEold) eval(this.id+'.style.visibility="visible"');

		else if(this.NNold) eval('document.'+this.id+'.visibility="show"');

		else if(this.NNnew || this.IEnew) document.getElementById(this.id).style.visibility="visible";

	}else{

		if(this.IEold) eval(this.id+'.style.visibility="hidden"');

		else if(this.NNold) eval('document.'+this.id+'.visibility="hide"');

		else if(this.NNnew || this.IEnew) document.getElementById(this.id).style.visibility="hidden";

	}

}



function MenuBar(){

	this.menus=new Array(); //массив хранящий объекты типа Menu

	this.timer=0; //поле для связи с запущенным "таймером"

	this.addMenu=addMenu;

	this.show=show;

	this.hide=hide;

}



function addMenu(id){

	var length=this.menus.length;

	this.menus[length]=new Menu(id);

}



function Menu(id){

	this.id=id; //id слоя связанного с меню

	this.NNold=this.NNnew=this.IEold=this.IEnew=false; //тип броузера

	this.setBrowserType=setBrowserType;

	this.setVisible=setVisible;

	this.setBrowserType(); //вызываем метод для установления типа броузера

}



function show(id){

	clearTimeout(this.timer);

	this.timer=0;



	for(var i=0; i<this.menus.length; i++){

		if(this.menus[i].id==id){

			this.menus[i].setVisible(true);

		}else{

			this.menus[i].setVisible(false);

		}

	}

}

var tmpObject;

function hide(id){

	for(var i=0; i<this.menus.length; i++){

		if(this.menus[i].id==id){

		    tmpObject=this.menus[i];

			this.timer=setTimeout("tmpObject.setVisible(false)", 200);

			break;

		}

	}

}



var ImgArr,ImgLen;



function Preload(imgname)

{

if(document.images)

{

if(!ImgArr)

{

ImgArr=new Array();

ImgLen=0;

}

ImgArr[ImgLen]=new Image();

ImgArr[ImgLen].src=imgname;

ImgLen++;

}

}



function chimage(x,y)

{

var s="";

if (document.images && ImgArr)

{

with(document)

{

s=images[x].src ;

images[x].src=ImgArr[y].src;

ImgArr[y].src=s;

}

}

}

//Preload('/images/m2.gif');

//Preload('/images/m2on.gif');



  var m = new MenuBar();

  m.addMenu('news');

  var m2 = new MenuBar();

  m2.addMenu('articles');

  function bannerResize(id, height)
  {
    $('#banner_'+id).css('height', height);
  	$('#ad_'+id).css('height', height);
  	if (id==1)
  	{
  		$('#ad_'+id).parent().css('height', height);
  	}
  }
