
function Myimg(name,x,y,alt) {
this.name=name;
this.x=x;
this.y=y;
this.alt=alt;
}


var allimg=new Array();

function GetHeight(elemID) {
var offsetTop = 0;
var offsetTrail = document.getElementById(elemID);
while (offsetTrail) {offsetTop += offsetTrail.offsetTop; offsetTrail = offsetTrail.offsetParent;}
return offsetTop;
}



document.onselectstart = oss; 
function oss() {
return false
}

function DivTop(x,y){
document.getElementById("Frame"+x).style.top=y+"px";
}

function Playmenu(x,y){ 
if (x) {document.getElementById("Menu"+y).style.backgroundImage="url(http://yalta-hotel.crimea.ua/img/goldline1.gif)"; 
document.getElementById("Menu"+y).style.wordSpacing="1px";
} else  {document.getElementById("Menu"+y).style.backgroundImage="url(http://yalta-hotel.crimea.ua/img/goldline.gif)";
document.getElementById("Menu"+y).style.wordSpacing="0px";}
}

function HideByID(id,act) {
if (document.getElementById(id)) { document.getElementById(id).style.visibility=(act) ? "visible" : "hidden";}
}

function SetHeight(act) {
y=GetHeight("PrivyazkaBody")-830+644;
//if (act) {x=GetHeight("PrivyazkaOnePhoto")-180;z=Math.max(650,x,y);} ..уже не надо - онефото плавает
//else {z=Math.max(650,y);}
z=Math.max(650,y);
z=Math.round(z/50)*50;
document.getElementById("Privyazka").style.height = z + "px";
}




//--------------------------
window.onerror = null;
var topMargin = 20;
var slideTime = 500;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
var opera = (navigator.userAgent.indexOf("Opera") ==-1) ? 0 : 1;
var firefox = (navigator.userAgent.indexOf("Firefox") ==-1) ? 0 : 1;
isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >=0) ? true : false;

function layerObject(id,left) {
if (ns6 || firefox) {
this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ie4) {
this.obj = document.all[id].style;
//this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
return this.obj;
   }
}
function layerSetup() {
floatLyr = new layerObject('OnePhoto', pageWidth * 0.5);
window.setInterval("main()", 10)
}


function floatObject() {
if (ns4 || ns6 || firefox) {
findHt = window.innerHeight;
} else if(ie4) {

if (window.innerHeight) {findHt =window.innerHeight;} 
	else if (isIE6CSS) {findHt =document.body.parentElement.clientHeight;}
		 else {if (document.body && document.body.clientHeight) {findHt = document.body.clientHeight; } }
   }//alert(findHt);
} 


function main() {
if (ns4) {
this.currentY = document.layers["OnePhoto"].top;
this.scrollTop = window.pageYOffset;
maintrigger();
}

else if(opera) { //эксперимент
this.currentY = OnePhoto.style.pixelTop;
this.scrollTop = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);  
maintrigger();}

else if(firefox) { //эксперимент

this.currentY = parseInt(document.getElementById("OnePhoto").style.top.replace("px","")); 
this.scrollTop = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);  
maintrigger();}


else if(ns6) {
this.currentY = parseInt(document.getElementById("OnePhoto").style.top.replace("px","")); 
this.scrollTop = scrollY;
maintrigger();

} else if(ie4) {
this.currentY = OnePhoto.style.pixelTop;
if (isIE6CSS) {this.scrollTop = document.body.parentNode.scrollTop;} else {document.body.scrollTop;}
maintrigger();
   }


}


function maintrigger() {
var newTargetY = this.scrollTop + this.topMargin;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
   }
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 2 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
   }
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.OnePhoto.style.pixelTop = newY;
if ( ns4 )document.layers["OnePhoto"].top = newY;
if ( ns6 || firefox )document.getElementById('OnePhoto').style.top = newY + "px";
   }
}
function start() {
if(ns6||ns4 || firefox) {
pageWidth = innerWidth;
pageHeight = innerHeight;
layerSetup();
floatObject();
}
else if(ie4) {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
layerSetup();
floatObject();
   }
}
//---------------

function ShowPhoto(arg,act) {

HideByID("OnePhoto",act);
//HideByID("Heart",!act);
if (act) {
	var name=allimg[arg].name;
	var x=allimg[arg].x;
	var y=allimg[arg].y;
	var alt=allimg[arg].alt || "";
    	
var output ='<div style="text-align:center; position:absolute; left:15px; top:0px; width:'+x+'px;height:15px; z-index:201;"><span class="titul2" style="padding-right: 15px;">'+  alt +'</span></div>';

if (name.indexOf(".swf") == -1) 
{
output+='<div style="position:absolute; left:'+ (x+25) +'px; top:0px; width:15px; height:15px; z-index:202; font-size:14px; font-weight:bold; ">X</div>';
output+='<br><img class="OneImg" src="'+name+'" width="'+x+'" height="'+y+'"  alt="'+alt+'" title="'+alt+'" >';
}
else 
{
output+='<div style="position:absolute; left:'+ (x+18) +'px; top:0px; width:15px; height:15px; z-index:202; font-size:14px; font-weight:bold; ">X</div>';
output+= '<br><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="' + x + '" height="480">';
output+= '<param name="movie" value="' + name + '" /><param name="quality" value="high" />';
output+= '<embed src="' + name + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + x + '" height="' + y + '"></embed></object>';
}

document.getElementById("OnePhoto").innerHTML=output;/**/
SetHeight(act);

start();

document.getElementById("OnePhoto").style.left=Math.round((document.body.clientWidth-x)/2)-50 + "px";


}}

