
//dv = document.getElementById('test');

function showLoad(id)
{

	dv = document.getElementById(id);
	//alert(dv.style.opacity);
	//dv.style.display='inline';
	if(parseFloat(dv.style.opacity)<1)
	{
		dv.style.opacity=parseFloat(dv.style.opacity)+0.05 ;
		dv.style.filter='alpha(opacity='+(parseFloat(dv.style.opacity)*100)+')' ;
		//alert(dv.style.filter);
		setTimeout('showLoad("'+id+'");',1);
	}

}
function stopLoad(id,sLink)
{

	dv = document.getElementById(id);
	//dv.style.display='inline';
	if(parseFloat(dv.style.opacity)>0)
	{
		//alert(dv.style.opacity);
		dv.style.opacity=parseFloat(dv.style.opacity)-0.1;
		dv.style.filter='alpha(opacity='+(parseFloat(dv.style.opacity)*100)+')' ;
		setTimeout('stopLoad("'+id+'","'+sLink+'");',1);
	}
	else {
		location.replace(sLink);
	}

}
function startFade(id)
{

	//dv=obj;
	//alert('yoo');
	//document.getElementById(textId).style.color='white';
	dv = document.getElementById(id);
	if(parseFloat(dv.style.opacity)==0)
	setTimeout('showLoad("'+id+'");',1);

}
function endFade(id,sLink)
{
	//document.getElementById(textId).style.color='#999';
	//dv=obj;
	//alert('yoo');
	dv = document.getElementById(id);
	//if( parseFloat(dv.style.opacity)==1)
	setTimeout('stopLoad("'+id+'","'+sLink+'");',1);

}










function showLoadImage(id,sLimit)
{

	dv = document.getElementById(id);
	//alert(dv.style.opacity);
	//dv.style.display='inline';
	if(parseFloat(dv.style.opacity)<parseFloat(sLimit))
	{
		dv.style.opacity=parseFloat(dv.style.opacity)+0.1;
		dv.style.filter='alpha(opacity='+(parseFloat(dv.style.opacity)*100)+')' ;
		//alert(dv.style.filter);
		setTimeout('showLoadImage("'+id+'","'+sLimit+'");',1);
	}

}
function stopLoadImage(id)
{

	dv = document.getElementById(id);
	//dv.style.display='inline';
	if(parseFloat(dv.style.opacity)>0)
	{
		//alert(dv.style.opacity);
		dv.style.opacity=parseFloat(dv.style.opacity)-0.2;
		dv.style.filter='alpha(opacity='+(parseFloat(dv.style.opacity)*100)+')' ;
		setTimeout('stopLoadImage("'+id+'");',1);
	}
	else {
		//alert('ddd');
		document.getElementById(id).style.zIndex='-15';
		document.getElementById(id).innerHTML='';
	}

}
//увеличивает из превюхив большое изображение
function fnEnlarge(path,width,height)
{

	document.getElementById('img_big').innerHTML='<img onclick="endFadeImage();" style=\'cursor:pointer;\' src="'+path+'">';
	document.getElementById('imgBlock').style.marginLeft='-' +(parseFloat(width)/2)+'px';
	document.getElementById('imgBlock').style.marginTop='-' +(parseFloat(height)/2+40)+'px';

}


function startImage(sLink,width,height,hotel_key)
{
	document.getElementById('imgBlock').style.backgroundColor="none";
	//	document.getElementById('imgBlock').style.textAlign="center";

	document.getElementById('imgBlock').innerHTML='<div id="img_big"><img onclick="endFadeImage();" style="cursor:pointer;" src="'+sLink+'"></div><div style="width:500px; text-align:center;"';

	JsHttpRequest.query(
	'load_info_fade.php', // backend
	{
		// pass a text value
		'action': 'get_image_by_key',
		'hotel_key': hotel_key
	},
	// Function is called when an answer arrives.
	function(result, errors) {
		if (errors && errors!=='') {
			//document.getElementById('test').appendChild(document.createTextNode(errors));
			//alert(errors);
		}
		// Write errors to the debug div.
		// document.getElementById("debug").innerHTML = errors;
		// Write the answer.
		if (result) {
			//alert(result['res']);
			for(i=0;i<result.length;i++)
			{
				res=result[i];
				document.getElementById('imgBlock').innerHTML+='<img onclick="fnEnlarge(\''+res['full_path']+'\',\''+res['width']+'\',\''+res['height']+'\');" style="cursor:pointer;" src="'+res['path_70']+'">';

			}
		}
	},
	true  // do not disable caching
	);
	//alert(document.body.scrollTop);

	//??????? ??????
	document.body.style.overflow='hidden';
	//alert(document.getElementById('imgBack').style.zIndex);
	//??????? ?????? ??????
	document.getElementById('imgBack').style.zIndex='3';
	document.getElementById('imgBlock').style.zIndex='4';

	//?????????????
	document.getElementById('imgBlock').style.marginLeft='-' +(parseFloat(width)/2)+'px';
	//alert(height);
	document.getElementById('imgBlock').style.marginTop='-' +(parseFloat(height)/2+40)+'px';

	id='imgBack';
	dv = document.getElementById(id);
	//if(parseFloat(dv.style.opacity)==0)
	setTimeout('showLoadImage("'+id+'","0.5");',1);


	id='imgBlock';
	dv = document.getElementById(id);
	//	if(parseFloat(dv.style.opacity)==0)
	setTimeout('showLoadImage("'+id+'","1");',1);

}
function endFadeImage()
{
	id='imgBlock';

	dv = document.getElementById(id);
	//if( parseFloat(dv.style.opacity)==1)
	setTimeout('stopLoadImage("'+id+'");',1);

	id='imgBack';

	dv = document.getElementById(id);
	//if( parseFloat(dv.style.opacity)==1)
	setTimeout('stopLoadImage("'+id+'");',1);

	document.body.style.overflow='auto';
}

function fnShowBlock(out)
{
	//alert(newNum);

	width=500;
	height=500;
	document.getElementById('imgBlock').style.backgroundColor="#fff";
	document.getElementById('imgBlock').style.width=parseInt(width+5)+"px";
	document.getElementById('imgBlock').style.height=parseInt(height)+"px";

	//out='Посмострите новое видео у нас на сайте ';
	
	
	
	document.getElementById('imgBlock').innerHTML=out;

	//??????? ??????
	document.body.style.overflow='hidden';
	//alert(document.getElementById('imgBack').style.zIndex);

	document.getElementById('imgBack').style.zIndex='3';
	document.getElementById('imgBlock').style.zIndex='4';

	//?????????????
	document.getElementById('imgBlock').style.marginLeft='-' +(parseFloat(width)/2)+'px';
	
	document.getElementById('imgBlock').style.marginTop='-' +(parseFloat(height)/2)+'px';

	id='imgBack';
	dv = document.getElementById(id);
	//if(parseFloat(dv.style.opacity)==0)
	setTimeout('showLoadImage("'+id+'","0.5");',1);


	id='imgBlock';
	dv = document.getElementById(id);
	//	if(parseFloat(dv.style.opacity)==0)
	setTimeout('showLoadImage("'+id+'","1");',1);

}


