/**
 * remove cookie function
 *	@param c	cookie name
 *	@param r	redirect url
 */
function logout(c, r)
{
	document.cookie = c + '=; path=/; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	document.location = r;
	return false;
}


/**
*	clone block and append it to container
*
*	sContainer		container
*	sTarget			source element to clone
*	sPostfix		unique postfix for id
*	idArray			array with ids to change
*/
function cloneBlock(vContainer, vTarget, sPostfix, idArray)
{
	oContainer = Var2Obj(vContainer);
	oTarget = Var2Obj(vTarget);
	
	oContainer.appendChild(oTarget.cloneNode(true));

	oNewBlock = oContainer.lastChild;

	iRand = sPostfix;

	str = oNewBlock.innerHTML;

	for(i = 0; i < idArray.length; i++)
		str = str.replace(new RegExp('id="' + idArray[i] + '[0-9]*"', "ig"), 'id="' + idArray[i] + iRand + '"');

	for(i = 0; i < idArray.length; i++)
		str = str.replace(new RegExp('id=' + idArray[i] + '[0-9]*', "ig"), 'id="' + idArray[i] + iRand + '"');
		
	oNewBlock.id = String(oNewBlock.id).replace(new RegExp('[0-9]*', "ig"), '') + iRand;

	oNewBlock.innerHTML = str;
	
	return oNewBlock;
}


/**
 * Search element by id in specified container
 *
 * @param	variant	vContainer
 * @param	string	sTargetId
 *
 * @return	object					found element
 */
function getElementById(vContainer, sTargetId)
{
	vContainer = Var2Obj(vContainer);
	
	if(vContainer.id == sTargetId)
		return vContainer;
		
	vContainer = vContainer.firstChild;
	
	oRes = null;
	
	while(isVal(vContainer))
	{
		if(vContainer.id == sTargetId)
			return vContainer;
			
		oRes = getElementById(vContainer, sTargetId);
		
		if(isVal(oRes) && oRes.id == sTargetId)
			return oRes;
			
		vContainer = vContainer.nextSibling;
	}
	
	return null;
}





/**
 * Return object, that is parent for specified child and it's ID like specified ID
 * 
 * @param	variant	vChild
 * @param	string	sTrgetId
 * @return	object
 */
function getParentById(vChild, sTargetId)
{
	vChild = Var2Obj(vChild);
	
	
	while(vChild.id != undefined && !isVal(vChild.id.match(new RegExp(sTargetId, 'ig'))))
		vChild = vChild.parentNode;
	
	return isVal(vChild.id) ? vChild : null;
}


/**
 * Insert HTML code into specified container before specified child
 * 
 * @param	string	sNewHtml
 * @param	variant	vContainer
 * @param	variant	vChild
 */
function insertHtmlBefore(sNewHtml, vContainer, vChild)
{
	vChild = Var2Obj(vChild);
	vContainer = vChild.parentNode; 
		
	oTxt = document.createElement('div');
	oTxt.innerHTML = sNewHtml;
	oNewNode = oTxt.firstChild;
		
	while(isVal(oNewNode))
	{
		vContainer.insertBefore(oNewNode.cloneNode(true), vChild);
		oNewNode = oNewNode.nextSibling;
	}
	
	delete(oTxt);
}

/**
 * Find element in string HTML code by ID
 * 
 * @param	string	sNewHtml
 * @param	string	sId
 *
 * @return	object
 */
function getElementFromHtml(sNewHtml, sId)
{
	oTmp = document.createElement('div');
	oTmp.innerHTML = sNewHtml;
	
	return getElementById(oTmp, sId);
}


/**
 * Set hover effects for all form elements (text inputs, passwords inputs, textareas)
 * 
 */
function hoverEffects() {
	//get all 
	var elements = document.getElementsByTagName('input');
	var j = 0;
	var hovers = new Array();
	for (var i4 = 0; i4 < elements.length; i4++) {
		if((elements[i4].type=='text')||(elements[i4].type=='password')) {
			hovers[j] = elements[i4];
			++j;
		}
	}
	elements = document.getElementsByTagName('textarea');
	for (var i4 = 0; i4 < elements.length; i4++) {
		hovers[j] = elements[i4];
		++j;
	}
	
	//add focus effects
	for (var i4 = 0; i4 < hovers.length; i4++) {
		hovers[i4].onfocus = function() {this.className += "Hovered";}
		hovers[i4].onblur = function() {this.className = this.className.replace(/Hovered/g, "");}
	}
}


/**
 * Check is variable is defined and not empty or null
 *
 * @param	string	name
 * @return	bool
 */
function isVal(variable)
{
	return (variable != '' && variable != undefined && variable != null);
}


/*
*	Search element in array
*/
function arraySearch(needle, haystack)
{
	var found = false;
	
	for(var i = 0; i < haystack.length; i++)
	{
		if(haystack[i] == needle)
		{
			found = true;
			break;
		}
	}
	
	if(found)
		return i
	else
		return -1;
}


/*
*	Delete element by value
*/
function arrayDelElement(value, haystack)
{
	return arrayMoveL(arraySearch(value, haystack), haystack);
}


/*
*	Delete element by index
*/
function arrayDelElementByIndex(index, haystack)
{
	return arrayMoveL(index, haystack);
}


/*
*	Move all elements one position left starting from index position
*/
function arrayMoveL(index, haystack)
{
	if(index < 0 || index > haystack.length)
		return haystack;
		
	for(var i = index; i < haystack.length-1; i++)
		haystack[i] = haystack[i+1];
		
	haystack.pop();
		
	return haystack;
}


/*
*	Print Array Information
*/
function printArrayInfo(array)
{
	alert(array + "\n"+array.length);
}


/**
 * Set cookie with specified name and value
 *
 * @param	string	name
 * @param	string	value
 * @param	int		hours			experiation time
 * @return
 */
function setCookie(name, value, hours)
{
	if(!isVal(hours))
		hours = 12;
		
	if(hours)
	{
		var date = new Date();
		date.setTime(date.getTime()+(hours*3600));
		var expires = "; expires=" + date.toGMTString();
	}
	else
		var expires = "";
	document.cookie = name+'='+value+expires+'; path=/';
}


/**
 * Get cookie by name
 *
 * @param	string	name
 * @return	string
 */
function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


/**
 * Unset Cookie by name
 *
 * @param	string	name
 */
function unsetCookie(name)
{
	set_cookie(name,"",-1);
}


/*
*	Hide preload screen
*/
function hideScreen()
{
	hideObject('ploading');

	//hideObject('loading');

	//hideObject('screen');
	//hideObject('screenMessage');
}

/*
*	Show preload screen
*/
function showScreen()
{
//	var o;
//	o1 = Var2Obj('screen');	
//	o1.style.top = getScroll () + "px";
//	o1 = Var2Obj('screenMessage');
//	o1.style.top = getScroll () + "px";	
//	showObject('screen');
//	showObject('screenMessage');

//	loading ('LOADING');

	showObject('ploading');
//	var e = document.getElementById('page_is_loading');
//	if (e) e.style.display = 'block';
}


/**
 * create and display loading message
 */
function loading (sid)
{
	var d = document.getElementById ("loading");
	var e = document.body; // getElementById('content');

	if (d)
	{
		d.firstChild.innerHTML = sid + "...";
		d.style.top = getScroll() - 30 + "px";
		d.style.left = 0 + "px";
		d.style.display = "inline";
	}
	else
	{
		var t = document.createTextNode(sid + "...");
		var d = document.createElement("div");
		var s = document.createElement("span");

		e.appendChild (d);

		d.id = "loading";
/*		
		d.style.position = "absolute";
		d.style.zIndex = "50000";
		d.style.textAlign = "center";
		d.style.width = e.clientWidth + "px";
		d.style.height = (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px";
		d.style.top = getScroll() - 30 + "px";
		d.style.left = 0 + "px";
		d.style.display = "inline";
		d.style.backgroundImage = "url(/img/loading_bg.gif)";		
*/		
		d.style.cssText = "z-index:50000;position:absolute;top:" + (getScroll() - 30) + "px; left:0px;width:" + e.clientWidth + "px;height:" + (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px;filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;background-color:#ccc;text-align:center";
		
		s.style.border = "1px solid #B5B5B5";
		s.style.backgroundColor = "#F3F3F3";
		s.style.color = "#333333";
		s.style.padding = "20px";
		s.style.fontWeight = "bold";
		s.style.lineHeight = d.style.height;
		s.style.cssText += ';alpha(opacity=100);-moz-opacity:1.0;opacity:1.0';

		d.appendChild(s);
		s.appendChild(t);
	}
}


/**
*	Hide object by Id
*	@param	int		id
*/
function hideObject(id)
{
	var oObject = Var2Obj(id);
	if (oObject) oObject.style.display = 'none';
}


/**
*	Show object by Id
*	@param	int		id
*/
function showObject(id)
{
	var oObject = Var2Obj(id);
	if (oObject) oObject.style.display = 'block';
}


/**
 * Add for with stated parameters and content and submit it
 *
 * @param	string	sAction
 * @param	string	sContent
 * @param	string	sWndName		target frame to submit into
 * @param	string	sFileName
 * @TODO	remove last parameter and test the function
 */
function addSubmitForm(sAction, sContent, sWndName, sFileName)
{
	sId = String(sWndName).match(/[0-9]+/);
	
	if(isVal(document.getElementById(sWndName)))
	{
		//	frame and form are already created then submit form
		document.getElementById("addImgForm" + sId).submit();
		return false;
	}
	
	
	//	create iframe - trget frame for submission
	oWnd = getBrowserType() == 'ie' ? document.createElement('<' + 'iframe' + ' name="' + sWndName + '">') : document.createElement('iframe');
	oWnd.name = sWndName;
	oWnd.id = sWndName;
	oWnd.className = 'hidden';
	
	
	//	create form for submission
	oFrm = getBrowserType() == 'ie' ? document.createElement('<form' + ' name="addImgForm' + sId + '" enctype="multipart/form-data">') : document.createElement('form');
	oFrm.action = sAction;
	oFrm.innerHTML = sContent;
	oFrm.method = 'post';
	oFrm.name = "addImgForm" + sId;
	oFrm.id = oFrm.name;
	oFrm.enctype = "multipart/form-data";
	oFrm.className = 'hidden';
	oFrm.target = sWndName;
	
	document.body.appendChild(oFrm);
	document.body.appendChild(oWnd);
	
	oFrm.appendChild(document.getElementById('addImgFldReal' + sId));
	
	oFrm.submit();
	
	document.getElementById('addImgItmReal' + sId).innerHTML = '';
	hideObject('addImgItmReal' + sId);
	document.getElementById('addImgFldReal' + sId).parentNode.removeChild(document.getElementById('addImgFldReal' + sId));
}


/**
 * Create and return created hidden input with specified name and value
 *
 * @param	string	sName
 * @param	string	sValue
 * @return	object
 */
function addHiddenInput(sName, sValue)
{
	oRnd = getBrowserType() == 'ie' ? document.createElement('<input name="' + sName + '">') : document.createElement('input');
	oRnd.type = 'hidden';
	oRnd.className = 'hidden';
	oRnd.name = sName;
	oRnd.value = sValue;
	
	return oRnd;
}


/**
 * Return object with specified by vVar
 * If vVar is object then returns it directly
 *
 * @param	variant	vVar		ID of object
 * @return	object
 */
function Var2Obj(vVar)
{
	return typeof(vVar) != 'object' ? document.getElementById(vVar) : vVar;
}


/**
 * Returns browser type
 *
 * @return	string			browser type
 */
function getBrowserType()
{
	// browser name
	ua = navigator.userAgent.toLowerCase(); 
	res = '';
	
	res	= (ua.indexOf('gecko') != -1) ? 'gecko' : res;
	res	= ((ua.indexOf('gecko') != -1) && ua.indexOf("gecko/") + 14 == ua.length) ? 'mozilla' : res;
	res	= ((ua.indexOf('gecko') != -1) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) ) ? 'netscape' : res;
	res	= ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ) ? 'ie' : res;
	res	= (ua.indexOf("opera") != -1) ? 'opera' : res;
	
	return res;
}







aBxMeta =
{
	'article_frozen_for_adding' : 'Article is frosen for editing',
	'blocks_deleted': 'Blocks were deleted',
	'compare'	:	'Compare',
	'close'		:	'Close',
	'view'		:	'View',
	'add_category_form' : 'Add Category',
	'edit_category_form' : 'Edit Category'
};


/**
 * Language function (show words by metas)
 *
 * @param	string	sMeta		metaword
 * @return	string				real phrase, associated with specified metaword
 */
function w(sMeta)
{
	
	if(isVal(aBxMeta[sMeta]))
		return aBxMeta[sMeta];
		
	return '_js_' + sMeta + '_';
}


/**
 * Out specified text in new browser window
 *
 * @param	variant	s		text to show
 */
function debugOut(s)
{
	wnd = window.open();
	wnd.document.write(s);
}

/**
 * get center browser point by horizontally
 */
function getCenterHor ()
{
	return document.body.clientWidth / 2;
}

/**
 * get center browser point by vertically
 */
function getCenterVer ()
{
	var y;

    if (navigator.appName == "Microsoft Internet Explorer")
        y = document.documentElement.scrollTop
    else
        y = window.pageYOffset;

	y += (window.innerHeight ? (window.innerHeight + 30) : screen.height) / 2;
	
	return y;
}


// -------------------------------------------


function getScroll()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
//		return document.body.scrollTop;
		return document.documentElement.scrollTop
	}
	else
	{
		return window.pageYOffset;
	}
}

function correctPNG() 
{
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
}

var oldHandler = window.onload;
if(typeof window.onload != 'function') {
	window.onload = correctPNG;
}
else {
	window.onload = function() {
		if(oldHandler) oldHandler();
		correctPNG();
	}
}


function eHeight (e)
{
	if (!e) return 0;
	return e.clientHeight > 0 ? e.clientHeight : e.offsetHeight;
}

function fixTreeHeight ()
{
	var eCart = document.getElementById ('shopping_cart');
	var h = eHeight(eCart);
	var eZone = document.getElementById ('zone');
	if (!eZone) return;
	if (eHeight(eZone) < (470+h)) eZone.style.height = 470 + h + 'px';
}


/**
 * show login form
 */
function showLoginForm2 ()
{
	showScreen();

	var $this = this;

	var h = function (r)
	{		
		showHTML (r, 400, 200);
		
		hideScreen();
	}

	new BxXslTransform (aBxConfig['urlRoot'] + "Join/login_form", aBxConfig['urlRoot'] + "system/layout/default/xsl/login_form.xsl", h);

	return false;
}


/**
 * show search form
 */
function showSearchForm ()
{
	showScreen();

	var $this = this;

	var h = function (r)
	{		
		showHTML (r, 400, 200);
		
		hideScreen();
	}

	new BxXslTransform (aBxConfig['urlRoot'] + "Join/search_form", aBxConfig['urlRoot'] + "system/layout/default/xsl/search_form.xsl", h);

	return false;
}


/**
 * show resend activation letter form
 */
function showResendActivationForm ()
{
	showScreen();

	var $this = this;

	var h = function (r)
	{		
		showHTML (r, 400, 200);
		
		hideScreen();
	}

	new BxXslTransform (aBxConfig['urlRoot'] + "Join/resend_activation_form", aBxConfig['urlRoot'] + "system/layout/default/xsl/resend_activation_form.xsl", h);

	return false;
}


/**
 * show resend activation letter form
 */
function showForgotPasswordForm ()
{
	showScreen();

	var $this = this;

	var h = function (r)
	{		
		showHTML (r, 400, 200);
		
		hideScreen();
	}

	new BxXslTransform (aBxConfig['urlRoot'] + "Join/forgot_pwd_form", aBxConfig['urlRoot'] + "system/layout/default/xsl/forgot_pwd_form.xsl", h);

	return false;
}


function hideHTML ()
{
	var l = document.getElementById ("show_html");
	
	if (l)
	{
		document.body.removeChild(l);
	}
}

function showHTML (html, w, h)
{
	var d = document.getElementById ("show_html");
	var e = document.body; 

	if (d)
	{
		var div = d.firstChild;
		div.innerHTML = html;
		d.style.top = getScroll() - 30 + "px";
		d.style.left = 0 + "px";
		d.style.display = "block";
		if (w) div.style.width = w + 'px';
		if (h) div.style.height = h + 'px';
		div.style.top = parseInt(d.style.height)/2 - h/2 + 'px';
		div.style.width = parseInt(d.style.width)/2 - w/2 + 'px';
	}
	else
	{
		var d = document.createElement("div");
		var div = document.createElement("div");

		e.appendChild (d);

		d.id = "show_html";
		d.style.position = "absolute";
		d.style.zIndex = "49000";
		d.style.textAlign = "center";
		d.style.width = e.clientWidth + "px";
		d.style.height = (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px";			
		d.style.top = getScroll() - 30 + "px";
		d.style.left = 0 + "px";
		d.style.display = "inline";
		d.style.backgroundImage = "url("+aBxConfig['urlSystemImg']+"loading_bg.gif)";

		div.innerHTML = html;
		div.style.position = "absolute";
		if (w) div.style.width = w + 'px';
		if (h) div.style.height = h + 'px';
		div.style.top = parseInt(d.style.height)/2 - h/2 + 'px';
		div.style.left = parseInt(d.style.width)/2 - w/2 + 'px';

		d.appendChild(div);
	}
}

/**
 * fly 'o' id html object from (x0,y0) to (x1,y1)
 * after flying completed execute 'run' code
 * addscroll  - determine scroll position, 1 or 0
 */
function fly (o, run, x0, y0, x1, y1, addscroll)
{
	var to = 25;

	var fly = document.getElementById(o)
	if (!fly) return false
	
	if (parseInt(fly.style.left) < 0)
	{
		if (addscroll)
		{
			if (navigator.appName == "Microsoft Internet Explorer")
			{
				y0 += document.documentElement.scrollTop
				x0 += document.documentElement.scrollLeft
			}
			else
			{
				y0 += window.pageYOffset;
				x0 += window.pageXOffset;
			}
		}

		var e = fly.parentNode
		while (e.tagName != 'BODY')
		{
			x0 -= e.offsetLeft;
			y0 -= e.offsetTop;
			e = e.parentNode;
		}	
		

		fly.style.left = x0 + 'px'
		fly.style.top = y0 + 'px'
		setTimeout('fly(\''+o+'\',\''+run+'\','+x0+','+y0+','+x1+','+y1+')', to)
	}
	else
	{
		var x = parseInt(fly.style.left)

		x += x0 < x1 ? 30 : -30;

		var y = (x - x0) * (y1 - y0) / (x1 - x0) + y0

		var exeed_x = 0
		var exeed_y = 0

		if (x0 < x1) exeed_x = x > x1 ? 1 : 0
		else         exeed_x = x < x1 ? 1 : 0

		if (y0 < y1) exeed_y = y > y1 ? 1 : 0
		else         exeed_y = y < y1 ? 1 : 0

		fly.style.left = (exeed_x ? x1 : x) + 'px'
		fly.style.top = (exeed_y ? y1 : y) + 'px'
		
		if (!exeed_x && !exeed_y)
		{
			setTimeout('fly(\''+o+'\',\''+run+'\','+x0+','+y0+','+x1+','+y1+')', to);
		}
		else
		{
			fly.style.left = '-1000px'
			fly.style.top = '-1000px'
			if (run.length) eval (run)				
		}		
	}

	return false
}

function addToCart (iId, e)
{
	var loadComplete = function(oResult)
	{			
		var oRequest = new BxXmlRequest('','','');
		iResultCode = oRequest.getRetNodeValue(oResult, 'resultCode');						
		switch(iResultCode)
		{
			case '0':
				$('shopping_cart').innerHTML = '&nbsp;' + oRequest.getRetNodeValue(oResult, 'resultContent');									
				alert('Product was successfully added to your shopping cart');				
				break;				
			case '1':
				alert('Cannot add product to your shopping cart.\n Please report.');
				break;
			case '2':
				alert('This seller is temporary suspended. Please try again later.');
				break;
			case '3':
				alert('Sorry this expert can not accept any payments');			
				break;				
			case '4':
				alert('Login required');
				showLoginForm();
				break;			
			case '5':
				alert('Wrong product');			
				break;	
			case '6':
				alert("Product is already in your shopping cart");
				break;		
		}						
	}		 
	new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/ExpertsAccount/add_to_cart/" + iId, loadComplete, true);				
}

function deleteFromCart(iId, sRedirectUrl)
{			
	var loadComplete = function(oResult)
	{			
		var oRequest = new BxXmlRequest('','','');
		iResultCode = oRequest.getRetNodeValue(oResult, 'result');						
		switch(iResultCode)
		{
			case '0':											
				alert('Product/s was successfully removed from your shopping cart')	;
				
				if(!sRedirectUrl) sRedirectUrl = "ExpertsAccount/cart_view/";
				document.location = aBxConfig['urlRoot'] + sRedirectUrl;		
				break;
			default:
				alert('Cannot remove product from your shopping cart.\n Please report.');
				break;
		}				
	}	
	
	if(!iId)
	{
		if(!confirm('Are you sure?')) return false;
		new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/ExpertsAccount/empty_cart/", loadComplete, true);						
	}
	else	
		new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/ExpertsAccount/empty_cart/" + iId, loadComplete, true);						
}

function setButtonWait (o, disabled)
{
	if (disabled)
	{
		o.disabled = true;
		if (window._old_title != "Please wait...") window._old_title = o.value;
		o.value = "Please wait...";
	}
	else
	{
		o.disabled = false;
		if (window._old_title)
			o.value = window._old_title;
	}
}

function $(id)
{
    return document.getElementById(id);
}

/*****************************************************
    photos handling functions
*****************************************************/

		function openGalleryBig (iID, iIdImage)
		{
			window.open(aBxConfig['urlRoot'] + "images/gallery/" + iID + (iIdImage ? '/' + iIdImage : '') + "/", 'gallery_big', 'menubar=0,resizable=0,width=260,height=375,');
		}
		
		function openGalleryReal (iID, iIdImage)
		{
			var win = window.open(aBxConfig['urlRoot'] + "images/gallery_real/" + iID + (iIdImage ? '/' + iIdImage : '') + "/", 'gallery_real', 'menubar=0,resizable=0,width=810,height=725,');
			win.moveTo(0,0);
		}
				
        function onClickThumb (sDir, pathBig, iId, iIdImage)
        {
            var imgBig = $('pr_big');

            imgBig.onclick = function () { openGalleryReal(iId, iIdImage) };            
            
            imgBig.src = sDir + pathBig;            

            if (imgBig.readyState && imgBig.readyState != 'complete')
            {
                var img = new Image ();
                img.src = sDir + pathBig;
                img.onload = function () { imgBig.src = this.src; };            
            }
        }

        function moveScrollRightAuto (availWidth, b)
        {
            if (b)
                scrollTimerId = setInterval ('moveScrollRight('+availWidth+')', 100);
            else
                clearInterval (scrollTimerId);
        }

        function moveScrollLeftAuto (b)
        {
            if (b)
                scrollTimerId = setInterval ('moveScrollLeft()', 100);
            else
                clearInterval (scrollTimerId);
        }

        function moveScrollRight (availWidth)
        {
            var step = 10;
            var e=$('photos_scroll'); 

            var left = parseInt(e.style.left ? e.style.left : 0);
            var width = parseInt(e.style.width);

            if (left - step - 13 + width > availWidth)
            {
                e.style.left = left - step + 'px';
            }
            else
            {
                e.style.left = availWidth - width + 13 + 'px';
                moveScrollRightAuto (availWidth, false);
            }
        }

        function moveScrollLeft ()
        {
            var step = 10;
            var e=$('photos_scroll'); 

            var left = parseInt(e.style.left ? e.style.left : 0);

            if (left + step < 0 )
            {             
                e.style.left = left + step + 'px';
            }
            else
            {
                e.style.left = '0px';
                moveScrollLeftAuto (false);
            }
        }
		
		//--- Notifications ---//
		function notifClose(iNotifId, sNotifName) {						
			var loadComplete = function() {
				$('notifPopup_' + iNotifId).style.display = 'none';				
			}			
			new BxXmlRequest(aBxConfig['urlRoot'] + "xcontent/ExpertsAccount/notifClose/" + sNotifName, loadComplete, true);
			
		}
