// Multiple onload callback support.
// usage: window.attachOnload (func_name());
(function() {
  var onloads = [];
  window.attachOnload = function(func) {
    onloads[onloads.length] = func;
  }
  window.executeOnloads = function() {
    for (var i=0; i<onloads.length; i++) onloads[i]();
  }
})();

function Show(someform){
parent.document.location.href=someform.vibor.options[someform.vibor.selectedIndex].value;
}


function changeImage(layer,imgName,imgObj) {
	if (document.images) {
		if (document.layers) eval('document.images["'+imgName+'"].src = '+imgObj+'.src')
		else document.images[imgName].src = eval(imgObj+".src")
	}
}

function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function mapwindow(url) {
	window.open(url, 'map', 'width=500,height=600,left=50,top=50,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function mapwin(url) {
	window.open(url, 'map', 'width=800,height=600,left=0,top=0,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function newWindow(nameFile, myW, myH) {
	var msgWindow = window.open ("", "MapWindow", "height="+(myH+70)+",width="+(myW+20)+",status=no,toolbar=no,menubar=no,location=no,resizable=1,scrollbars=0");
	msgWindow.document.open()
	msgWindow.document.write("<html><head><title>Новая Альтернатива</title>");
	msgWindow.document.write("<style>#PBold {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; color : #006699; font-weight: bold;}");
	msgWindow.document.write("body {margin-top:0; margin-left:0;} #PRegular {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; color : #006699;}</style></head>");
	msgWindow.document.write("<body bgcolor=#F4FCFF marginheight=0 marginwidth=0><p align=center><img src='"+nameFile+"' width='"+myW+"' height='"+myH+"' border='0'></p>")
	msgWindow.document.write("<p align=center id=PRegular><a href='javaScript:window.close()'><b id=PBold>ЗАКРЫТЬ ОКНО</b></a></p>")
	msgWindow.document.close()
	msgWindow.focus();
}

function imgOpen(imgURL,imgWidth,imgHeight,Title) {
var imgWndw=window.open('','_blank','width='+imgWidth+',height='+
  imgHeight+',toolbar=no,menubar=no,location=no,status=no,'+
  'resizable=yes,scrollbars=no');
var imgTitle=(Title)?Title:imgURL+": "+imgWidth+'x'+imgHeight;
with (imgWndw.document){
  open();
  write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+
  '</he'+'ad><bo'+'dy leftmargin="0" topmargin="0" '+
  'rightmargin="0" bottommargin="0" marginwidth="0" '+
  'marginheight="0"><img src="'+imgURL+'" width="'+imgWidth+
  '" height="'+imgHeight+'" border="0" alt="'+imgTitle+
  '"></bo'+'dy></ht'+'ml>');
  close();
}
}

<!-- открытие картинки в новом окне -->

function imgOp(imgURL,imgWidth,imgHeight,Title) {
var imgWndw=window.open('','_blank','width='+imgWidth+',height='+
  (imgHeight+40)+',toolbar=no,menubar=no,location=no,status=no,'+
  'resizable=yes,scrollbars=no');
var imgTitle=(Title)?Title:imgURL+": "+imgWidth+'x'+imgHeight;
with (imgWndw.document){
  open();
	imgWndw.document.open()
	imgWndw.document.write("<html><head><title>'"+imgTitle+"'</title>");
	imgWndw.document.write("<style>#PBold {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; color : #666; font-weight: bold;}");
	imgWndw.document.write("body {margin-top:0; margin-left:0;} #PRegular {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; color : #006699;}</style></head>");
	imgWndw.document.write("<body bgcolor=#ffffff marginheight=0 marginwidth=0><p align=center><a href='javaScript:window.close()'><img src='"+imgURL+"' width='"+imgWidth+"' height='"+imgHeight+"' border='0'></a></p>")
	imgWndw.document.write("<p align=center id=PRegular><a href='javaScript:window.close()'><b id=PBold>ЗАКРЫТЬ ОКНО</b></a></p>")
	imgWndw.document.close()
	imgWndw.focus();
  close();
}
}

<!-- открытие картинки в новом окне -->
function imgopen2(imgf,tit){

rand_id='image'+(Math.round(Math.random()*1000));

outf="<html>"
 +"<head>"
 +"<title>"+tit+"</title>"
 +"<style>body{margin:0px}</style>"
 +"</head>"
 +"<body leftmargin=0 topmargin=0>"
 +"<img alt=\""+tit+"\" src=\""+imgf+"\">";

iopen="iwin=self.open('"+imgf+"', '"+rand_id+"', 'width='+(img1.width)+',height='+(img1.height)+',top=0,left=0');"
 +"iwin.document.write('"+outf+"');"
 +"iwin.focus();";

img1=new Image();
img1.src=imgf;

if(img1.width!=0) eval(iopen);

else{
iwin = self.open('about:blank', 'f'+rand_id, 'width=100,height=100,top=0,left=0');
iwin.document.write("<html>"
+"<body>Загрузка...<br>"
 +"<"+"script>"
  +"function imo(img1){"+iopen
  +"self.close();"
 +"}<"+"/script>"
 +"<img src='"+imgf+"' onload='imo(this);'>");
 }
}

function changeimage(x) {
   if (document.images) {
      if(x<11) {
         imagen.src="images/villacampestri/p-villacampestri"+x+".jpg";
         }
      else {
         imagen.src=x+".jpg";

         }
      document["imagen"].src = eval("imagen.src");

      }
   }

<!-- скрипт для фотогалереи -->

var iFiPh=0; var iLaPh=12; var iCuPh=0; var thePath=""; var thepip=""; var Photos=new Array("1","2","3","4","5","6","7","8","9","10","11","12","13"); function fLoadP(){ var k=iCuPh+1; if (Photos){ document.images['thePhoto'].src=Photos[iCuPh]+".jpg"; } } function fNP(){ if (iCuPh>=iLaPh) iCuPh=-1; iCuPh++; fLoadP(); return void(0); } function fPP(){ if (iCuPh<=0) iCuPh=iLaPh+1; iCuPh--; fLoadP(); return void(0); } function fGP(iToP){ iCuPh=iToP-1; fLoadP(); return void(0); }



<!-- скрипт открытия окна для фотогалереи -->

function w_open(script_name,window_name,window_height,window_width)
	{ window.open(script_name, window_name, 'resizable=1,scrollbars=0,height='+window_height+',width='+window_width); }



<!-- скрипт перехода через список -->

function CS_goByList(){
	if (document.selector.vibor.options[document.selector.vibor.selectedIndex].value != "none") {
		location = document.selector.vibor.options[document.selector.vibor.selectedIndex].value
	}
}

<!-- функции обрезания пробелов слева/справа в строке -->
function trim(s) {
  return rtrim(ltrim(s));
}

function ltrim(s) {
  return s.replace(/^\s+/, '');
}

function rtrim(s) {
  return s.replace(/\s+$/, '');
}
