/////////////////////////////////////////////////////////////////////
//** ESHOP ALBUM SCRIPT FILE

var app = navigator.appName;
var ver = parseInt(navigator.appVersion.substring(0,1));
var is_ie4 = ((app == "Microsoft Internet Explorer") && (ver >= 4)); //browser_check && ((document.all)    ? true : false);
var is_ns  = ((app == "Netscape") && (ver >= 3)); //browser_check && ((document.layers) ? true : false);
var browser_check = is_ie4 || is_ns;

function findElement(parent,tagName,id){return findNamedItem(parent.getElementsByTagName(tagName),id);};
function findNamedItem(nodeList,name)
{
	for (var i = 0; i < nodeList.length; i++) {
		var node = nodeList.item(i);
		if (node.id == name) return node;
	};
	return null;
};

function ShowZoomImage(imgID,sUrlParams)
{
	sUrlParams = String(sUrlParams);
	if (sUrlParams == "undefined") sUrlParams = "";
	if (is_ie4) {
		var windowWidth = 800, windowHeight = 600;
		if (window.screen) {
			windowWidth = screen.availWidth-8;
			windowHeight =  screen.availHeight-27;
		};

	  var t = "";

		t += '<html>\n';
		t += '<head>\n';
		t += '<title>Êàðòèíêà</title>\n';
		t += '<style type="text/css">\n';
		t += 'BODY { padding:0px; margin:0px; }\n';
		t += '.hand { cursor:hand; }\n';
		t += '</style>\n';
		t += '<script language="JScript">\n';
		t += 'var imageIDS = ['+imgID+'];\n';
		t += 'var sPictureBaseUrl = "'+sPictureBaseUrl+'";\n';
		t += 'var sUrlParams = "'+sUrlParams+'"';
		t += '</script>\n';
		t += '<script language="JScript" src="album.js"></script>\n';
		t += '</head>\n';
		t += '<body onload="DisplayImages()">\n';
		t += '<div id="ROOT" style="position:absolute;left:0px;top:0px;width:100%;height:100%;margin:0px;padding:0px;">\n';
		t += '<table width="100%"><tr><td valign="middle" align="center">\n';
		t += '<img border=0 id="big_image">';
		t += '<br/>';
		t += '<font color="#000000" font-family="Tahoma" size="2"><b><a style="color:#000000" href="javascript:window.close()">ÇÀÊÐÛÒÜ ÎÊÍÎ</a></b></font>\n';
		t += '</td></tr></table>\n';
		t += '</div>\n';
		t += '</body>\n';
		t += '</html>\n';

	  var settings = 'scrollbars=yes,left=0,top=0,width='+windowWidth.toString()+',height='+windowHeight.toString();
		var wnd = window.open("","image",settings);
		wnd.document.write(t);
		wnd.document.close();
		wnd.focus();
	} else {
		var sURL = sPictureBaseUrl + "&image="+imgID;
		window.open(sURL);
	};
};


//** client code - album

var theDoc = null;

function MIN(a,b){return(a<b)?a:b;};
function MAX(a,b){return(a>b)?a:b;};
function BOUND(a,min,max){return(a<min)?min:(a>max)?max:a;};

function RAW_COPY(id,app){var res="";var ttt=document.all[id];if(!ttt)return res;if(app)ttt.insertAdjacentHTML("BeforeEnd",app);res=ttt.outerHTML;ttt.style.visibility="hidden";return res;};
function CreateElement(type,id,style,cls,parent){if(!theDoc)theDoc=document;var res=theDoc.createElement(type);if(!res)return null;res.id=id;if(style)ApplyStyles(res,style);if(cls)res.className=cls;if(parent)parent.appendChild(res);return res;};
function ApplyStyles(obj,styles){var temp=styles;while(temp.length>0){var i=temp.indexOf(":");var style_name=temp.substring(0,i);var ii=style_name.indexOf("-");if(ii!=-1) {var ttt=style_name.substring(0,ii);ttt+=style_name.substring(ii+1,ii+2).toUpperCase();ttt+=style_name.substring(ii+2,style_name.length);style_name=ttt;};var j=temp.indexOf(";");var value=temp.substring(i+1,j);temp=temp.substring(j+1,temp.length);eval('obj.style.'+style_name+'='+'"'+value+'"');};return true;};

function nop() { event.cancelBubble=true; event.returnValue=false; return false; };

var oImgNavigator = null;
var oBigImage = null;

var NAV_VIEW = null;

//** navigator clip frame, in %
var navClipLeft = 0;
var navClipTop  = 0;
var navClipWidth = 100;
var navClipHeight = 100;

var clientWidth  = 0;
var clientHeight = 0;
var clientAR = 0;

var sURL = "";


function DisplayImages()
{
	theDoc = document;
	sURL = sPictureBaseUrl + "&image="+imageIDS[0];

	theDoc.body.onselect = nop;
	theDoc.body.onselectstart = nop;
	theDoc.body.ondragstart = nop;

	clientWidth  = document.body.clientWidth-8;
	clientHeight = document.body.clientHeight-50;
	clientAR = clientWidth / clientHeight;

	oBigImage = new Image;
	oBigImage.onload = fn_BigImageLoaded;
	oBigImage.src = GenerateImageURL();
};

function fn_BigImageLoaded()
{
	var BIG_IMAGE = document.all["big_image"];
	BIG_IMAGE.src = oBigImage.src;
	setTimeout('document.all["big_image"].style.visibility = "inherit"',200);
	SetupBigImage(document.all["big_image"]);
};

function RoundPrec(fltNum,prec)
{
	prec = Math.pow(10,prec);
	return Math.round(fltNum * prec) / prec;
};

function GenerateImageURL()
{
	var crop = "";
	if (navClipLeft > 0 || navClipTop > 0 || navClipWidth < 100 || navClipHeight < 100) {
		crop = "&crop=Left="+RoundPrec(navClipLeft,1)+"%;Top="+RoundPrec(navClipTop,1)+"%;Width="+RoundPrec(navClipWidth,1)+"%;Height="+RoundPrec(navClipHeight,1)+"%;";
	};
	return sURL + "&wid="+clientWidth+"&hei="+clientHeight+crop+sUrlParams;
};

function SetupBigImage(oImage)
{
	var ar = oImage.width / oImage.height;



};

