var run = true;
var run2 = true;
var run3 = true;
var validatedFields = new Array();


function in_array(needle, arr)
{
	for(var i = 0, l = arr.length; i < l; i++)
	{
		if(arr[i] == needle)
		{
			return true;
		}
	}
}

function SelectTab(tabSelectedObj)
{
	var tabSelected = tabSelectedObj.getAttribute("rel");
	var tabs = document.getElementById("tabs").getElementsByTagName("a");
	var subcontentids = [];
	for (var i=0; i<tabs.length; i++)
	{
		subcontentids[subcontentids.length] = tabs[i].getAttribute("rel")
		tabs[i].className = (tabs[i].getAttribute("rel") == tabSelected)? "selected_tab" : "normal_tab"
	}
	for (var i=0; i<subcontentids.length; i++)
	{
		subcontent = document.getElementById(subcontentids[i]);
		subcontent.style.display = (subcontent.id == tabSelected) ? "block" : "none";
	}
}

function displayflashTo(source, width, height, flashvars, targetId)
{
	var fl = "";
	var t = document.getElementById(targetId);
	if(t)
	{
		fl = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'"  align="middle">' + "\n"
		+ '    <param name="allowScriptAccess" value="sameDomain">' + "\n"
		+ '    <param name="movie" value="'+source+'">' + "\n"
		+ '    <param name="menu" value="false">' + "\n"
		+ '    <param name="quality" value="high">' + "\n"
		+ '    <param name="wmode" value="transparent">' + "\n"
		+ '    <param name="scale" value="noscale">' + "\n"
		+ '    <param name="bgcolor" value="">' + "\n"
		+ '    <param name="FlashVars" value="'+flashvars+'">' + "\n"
		+ '    <embed FlashVars="'+flashvars+'" wmode="transparent" src="'+source+'" menu="false" quality="high" scale="noscale" bgcolor="" width="'+width+'" height="'+height+'"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' + "\n"
		+ '</object>' + "\n";
		t.innerHTML = fl;
	}
}

function getXhr()
{
	var xhr = null; 
	if(window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest(); 
	}
	else if(window.ActiveXObject)
	{
		try
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{
		alert("Error, your browser may not support ajax"); 
		xhr = false; 
	}
	return xhr
}

function getModelsSelect(brandId)
{
	var xhr = getXhr();
	updatedElement = document.getElementById("modelsSelect");
	document.getElementById("enginesSelect").innerHTML = "";
	
	xhr.onreadystatechange = function()
	{
		if (xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					updatedElement.innerHTML = xhr.responseText;
				}
			}
		}
	}
	
	var toUrl = "/tunning/modelsSelect/brandId/"+brandId;
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}


function getEnginesSelect(modelId)
{
	var xhr = getXhr();
	updatedElement = document.getElementById("enginesSelect");
	
	xhr.onreadystatechange = function()
	{
		if (xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					updatedElement.innerHTML = xhr.responseText;
				}
			}
		}
	}
	
	var toUrl = "/tunning/enginesSelect/modelId/"+modelId;
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}

function enableSubmit(val)
{
	if(val != 0)
	{
		document.getElementById("searchSubmit").disabled = false;
	}
	else
	{
		document.getElementById("searchSubmit").disabled = true;
	}
}

function updateTag(updatedElementId, toUrl, text)
{
	var xhr = getXhr();
	updatedElement = document.getElementById(updatedElementId);
	xhr.onreadystatechange = function()
	{
		if (xhr.readyState != 4 || xhr.status != 200)
		{
			if (document.getElementById && text != "") 
			{
				updatedElement.innerHTML = text;
			}
		}
		else if (xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					updatedElement.innerHTML = xhr.responseText;
				}
			}
		}
	}
	
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}

function changeLinkedSelects(selectElement, forSelect, val, hide)
{
	id = selectElement.value;
	forSelectElement = document.getElementById(forSelect);
	var xhr = getXhr();
	
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState != 4 || xhr.status != 200)
		{
				if (document.getElementById)
				{
					forSelectElement.innerHTML = "<option value=''>loading ...</option>";
				}
		}else if(xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					forSelectElement.style.display = "inline";
					forSelectElement.innerHTML = "<option value=''>selsect</option>" + xhr.responseText;
					for(i=0; i<forSelectElement.options.length; i++)
					{
						if(forSelectElement.options[i].value == val) forSelectElement.options[i].selected= "selected";
					}
				}
				else if(hide)
				{
					forSelectElement.style.display = "none";
				}
			}
		}
	}
	if (id == '')
	{
		forSelectElement.innerHTML = "<option value=''>selsect</option>";
		return;
	}
	toUrl="/lists/getLinkedListItems/id/"+id;
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}

function showPic(blockID, picID)
{
	blockElement = document.getElementById(blockID);
	blockElement.className = picID;
	blockElement.innerHTML = "<img border='0' src='/media/display/id/" + picID + "' />";
}

function getNextPic(blockID, allElements)
{
	blockElement = document.getElementById(blockID);
	elementName = blockElement.className;
	var ind = 0;
	var mySplitResult = allElements.split(",");
	var splitCount = mySplitResult.length;
	for (i = 0; i < splitCount; i++)
	{
		if (elementName == mySplitResult[i])
		{
			ind = i+1;
			if (ind >= splitCount)
			{
				ind = 0;
			}
		}
	}
	if (ind >= 0)
	{
		blockElement.className = mySplitResult[ind];
		blockElement.innerHTML = "<img border='0' src='/media/display/id/" + mySplitResult[ind] + "' />";
	}
}

function getPrevPic(blockID, allElements)
{
	blockElement = document.getElementById(blockID);
	elementName = blockElement.className;
	var ind = 0;
	var mySplitResult = allElements.split(",");
	var splitCount = mySplitResult.length;
	for (i = 0; i < splitCount; i++)
	{
		if (elementName == mySplitResult[i])
		{
			ind = i-1;
			if (ind < 0)
			{
				ind = splitCount-1;
			}
		}
	}
	if (ind >= 0)
	{
		blockElement.className = mySplitResult[ind];
		blockElement.innerHTML = "<img border='0' src='/media/display/id/" + mySplitResult[ind] + "' />";
	}
}

function setActive(id,id2,id3)
{
	var elm = document.getElementById(id);
	var len = elm.options.length;
	if (elm.options[elm.options.selectedIndex].value == 'other')
	{
		document.getElementById(id3).style.display = 'block';
		document.getElementById(id2).readOnly = false;
		document.getElementById(id2).focus();
		document.getElementById(id2).style.border = "solid 1px red";
	}else{
		document.getElementById(id2).value = '';
		document.getElementById(id2).readOnly = true;
		document.getElementById(id2).blur();
		document.getElementById(id2).style.border = "solid 1px #A8ACAF";
		document.getElementById(id3).style.display = 'none';
	}

}

function checkConditionsRead(value, buttonIdToDisable)
{
	var element = document.getElementById(buttonIdToDisable);
	if (value)
	{
		element.disabled = false;
	}
	else
	{
		element.disabled = true;
	}
}
function validateField(fieldid, url, exec)
{
	if(run === false && typeof(exec) == "undefined" && in_array(fieldid, validatedFields))
	{
		return;
	}
	el = document.getElementById(fieldid);
	if (el)
	{
		var value = el.value;
		value = encodeURIComponent(value);
		if(url.indexOf("?") < 0) url += "?";
		var xhr = getXhr()
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4 && xhr.status == 200)
			{
				var resp = xhr.responseText;
				if (document.getElementById)
				{
					reciever = document.getElementById(fieldid+"Error");
				}
				else if (document.all)
				{
					reciever = document.all[fieldid+"Error"];
				}
				if (resp == "ok")
				{
					reciever.innerHTML = "";
					reciever.className = "valid";
				}
				else
				{
					var obj = document.getElementById(fieldid);
					if(obj)
					{
						var objvalue = obj.value.replace(/^\s+|\s+$/g, '');
						if(obj.attributes['required'] || objvalue != "")
						{
							reciever.innerHTML = resp;
							reciever.className = "error";
						}
						else
						{
							reciever.innerHTML = "";
							reciever.className = "valid";
						}
					}
				}
				validateEditForm();

				setTimeout('validateField("'+fieldid+'", "'+url+'", true)', 1000);
				run = false;
				validatedFields[validatedFields.length] = fieldid;
			}
		}
		xhr.open("GET",url+"&value="+value,true);
		xhr.send(null);
	}
}
function validateEditForm(exec)
{
	if(run2 === false && typeof(exec) == "undefined")
	{
		return;
	}
	var el = document.getElementById("form").elements;
	var len = el.length;
	var ok = true;
	for(i = 0 ; i < len ; i++)
	{
		var element = el[i];
		if (document.getElementById)
		{
			var errObj = document.getElementById(element.name+"Error");
		}
		else if (document.all)
		{
			var errObj = document.all[element.name+"Error"];
		}
		if (errObj)
		{
			var errClass = errObj.className;
			if (element.attributes['required'] && ((errClass != "valid") && (errClass != "")))
			{
				ok = false;
			}
			if ((!element.attributes['required']) && (errClass == "error"))
			{
				ok = false;
			}
		}
		else
		{
			if (element.attributes['required'])
			{
				var val = element.value.replace(/^\s+|\s+$/g, '');
				if (val == "")
				{
					ok = false;
				}
			}
		}
	}
	if (ok)
	{
		document.getElementById('btnSubmit').disabled = false;
		document.getElementById('btnSubmit').className = "save_btn";
	}
	else
	{
		document.getElementById('btnSubmit').disabled = true;
		document.getElementById('btnSubmit').className = "save_btndisabled";
	}
	setTimeout('validateEditForm(true)', 1000);
	run2 = false;
}
function validateCompare(id1, id2, err, exec)
{
	if(run3 === false && typeof(exec) == "undefined")
	{
		return;
	}
	reciever = document.getElementById(id1+"Error");
	el1 = document.getElementById(id1);
	el2 = document.getElementById(id2);
	if(el1.value != el2.value)
	{
		reciever.innerHTML = err;
		reciever.className = "error";
	}else{
		reciever.innerHTML = "";
		reciever.className = "valid";
	}
	validateEditForm();
	setTimeout('validateCompare("'+id1+'", "'+id2+'", "'+err+'", true)', 1000);
	run3 = false;
}
function updateCategory(elementId1, elementId2, catId)
{
	updatedElement2 = document.getElementById(elementId2);
	if (updatedElement2)
	{
		updatedElement2.innerHTML = '';
	}
	err = document.getElementById('errorBlock');
	if (err)
	{
		err.innerHTML = '';
	}
	url = "/products/category/cat_id/"+catId;
	updateTag(elementId1, url, '');
}
function updateSubCategory(elementId, catId, objId, errFlag)
{
	if (errFlag == 1)
	{
		err = document.getElementById('errorBlock');
		if (err)
		{
			err.innerHTML = '';
		}
	}
	url = "/products/subcategory/sub_id/"+catId+'/product_id/'+objId;
	updateTag(elementId, url, '');
}
function updateTag(updatedElementId, toUrl, text)
{
	var xhr = getXhr();
	updatedElement = document.getElementById(updatedElementId);
	xhr.onreadystatechange = function()
	{
		if (xhr.readyState != 4 || xhr.status != 200)
		{
			if (document.getElementById && text != "")
			{
				updatedElement.innerHTML = text;
			}
		}
		else if (xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					updatedElement.innerHTML = xhr.responseText;
					initLightbox();
				}
			}
		}
	}
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}
function changeLinkedSelects(selectElement, forSelect, val, hide)
{
	id = selectElement.value;
	forSelectElement = document.getElementById(forSelect);
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState != 4 || xhr.status != 200)
		{
			if (document.getElementById)
			{
				forSelectElement.innerHTML = "<option value=''>loading ...</option>";
			}
		}else if(xhr.readyState == 4 && xhr.status == 200)
		{
			if (document.getElementById)
			{
				if (xhr.responseText != "")
				{
					forSelectElement.style.display = "inline";
					forSelectElement.innerHTML = "<option value=''>selsect</option>" + xhr.responseText;
					for(i=0; i<forSelectElement.options.length; i++)
					{
						if(forSelectElement.options[i].value == val) forSelectElement.options[i].selected= "selected";
					}
				}
				else if(hide)
				{
					forSelectElement.style.display = "none";
				}
			}
		}
	}
	if (id == '')
	{
		forSelectElement.innerHTML = "<option value=''>selsect</option>";
		return;
	}
	toUrl="/lists/getLinkedListItems/id/"+id;
	xhr.open("GET",toUrl,true);
	xhr.send(null);
}
function showPic(blockID, picID)
{
	blockElement = document.getElementById(blockID);
	blockElement.className = picID;
	blockElement.innerHTML = "<img border='0' src='/media/display/id/" + picID + "' />";
}
function getNextPic(blockID, allElements)
{
	blockElement = document.getElementById(blockID);
	elementName = blockElement.className;
	var ind = 0;
	var mySplitResult = allElements.split(",");
	var splitCount = mySplitResult.length;
	for (i = 0; i < splitCount; i++)
	{
		if (elementName == mySplitResult[i])
		{
			ind = i+1;
			if (ind >= splitCount)
			{
				ind = 0;
			}
		}
	}
	if (ind >= 0)
	{
		blockElement.className = mySplitResult[ind];
		blockElement.innerHTML = "<img border='0' src='/media/display/id/" + mySplitResult[ind] + "' />";
	}
}
function getPrevPic(blockID, allElements)
{
	blockElement = document.getElementById(blockID);
	elementName = blockElement.className;
	var ind = 0;
	var mySplitResult = allElements.split(",");
	var splitCount = mySplitResult.length;
	for (i = 0; i < splitCount; i++)
	{
		if (elementName == mySplitResult[i])
		{
			ind = i-1;
			if (ind < 0)
			{
				ind = splitCount-1;
			}
		}
	}
	if (ind >= 0)
	{
		blockElement.className = mySplitResult[ind];
		blockElement.innerHTML = "<img border='0' src='/media/display/id/" + mySplitResult[ind] + "' />";
	}
}
function setActive(id,id2,id3)
{
	var elm = document.getElementById(id);
	var len = elm.options.length;
	if (elm.options[elm.options.selectedIndex].value == 'other')
	{
		document.getElementById(id3).style.display = 'block';
		document.getElementById(id2).readOnly = false;
		document.getElementById(id2).focus();
		document.getElementById(id2).style.border = "solid 1px red";
	}else{
		document.getElementById(id2).value = '';
		document.getElementById(id2).readOnly = true;
		document.getElementById(id2).blur();
		document.getElementById(id2).style.border = "solid 1px #A8ACAF";
		document.getElementById(id3).style.display = 'none';
	}
}
function checkConditionsRead(value, buttonIdToDisable)
{
	var element = document.getElementById(buttonIdToDisable);
	if (value)
	{
		element.disabled = false;
	}
	else
	{
		element.disabled = true;
	}
}
var loadingImage = '/images/loading.gif';
var closeButton = '/images/close.jpg';
function getPageScroll()
{
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}
function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}
function pause(numberMillis)
{
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
		return;
	}
}
function getKey(e)
{
	if (e == null)
	{
		keycode = event.keyCode;
	}
	else
	{
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	if(key == 'x')
	{
		hideLightbox();
	}
}
function listenKey ()
{
	document.onkeypress = getKey;
}
function showLightbox(objLink)
{
	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');
	var objCaption = document.getElementById('lightboxCaption');
	var objImage = document.getElementById('lightboxImage');
	var objLoadingImage = document.getElementById('loadingImage');
	var objLightboxDetails = document.getElementById('lightboxDetails');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	if (objLoadingImage)
	{
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
	imgPreload = new Image();
	imgPreload.onload=function()
	{
		objImage.src = objLink.href;
		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);

		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
		objLightboxDetails.style.width = imgPreload.width + 'px';

		if(objLink.getAttribute('title'))
		{
			objCaption.style.display = 'block';

			objCaption.innerHTML = objLink.getAttribute('title');
		}
		else
		{
			objCaption.style.display = 'none';
		}
		if (navigator.appVersion.indexOf("MSIE")!=-1)
		{
			pause(250);
		}
		if (objLoadingImage)
		{
			objLoadingImage.style.display = 'none';
		}

		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++)
		{
			selects[i].style.visibility = "hidden";
		}
		objLightbox.style.display = 'block';


		arrayPageSize = getPageSize();
		objOverlay.style.height = (arrayPageSize[1] + 'px');


		listenKey();
		return false;
	}
	imgPreload.src = objLink.href;
}
function hideLightbox()
{
	objOverlay = document.getElementById('overlay');
	objLightbox = document.getElementById('lightbox');
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++)
	{
		selects[i].style.visibility = "visible";
	}
	document.onkeypress = '';
}
function initLightbox()
{
	if (!document.getElementsByTagName)
	{
		return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox"))
		{
			anchor.onclick = function ()
			{
				showLightbox(this); return false;
			}
		}

	}
	var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hideLightbox(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var imgPreloader = new Image();
	imgPreloader.onload=function()
	{
		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);

		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);
		imgPreloader.onload=function(){};
		return false;
	}
	imgPreloader.src = loadingImage;
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	//objLink.setAttribute('title','затвори');
	objLink.onclick = function () {hideLightbox(); return false;}
	objLightbox.appendChild(objLink);
	var imgPreloadCloseButton = new Image();
	imgPreloadCloseButton.onload=function()
	{
		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.position = 'absolute';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);
		return false;
	}
	imgPreloadCloseButton.src = closeButton;
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute('id','lightboxDetails');
	objLightbox.appendChild(objLightboxDetails);
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','lightboxCaption');
	objCaption.style.display = 'none';
	objLightboxDetails.appendChild(objCaption);
	var objKeyboardMsg = document.createElement("div");
	objKeyboardMsg.setAttribute('id','keyboardMsg');
	//objKeyboardMsg.innerHTML = '<a href="#" onclick="hideLightbox(); return false;"><kbd>затвори</kbd></a>';
	objLightboxDetails.appendChild(objKeyboardMsg);
}
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}
addLoadEvent(initLightbox);