var AutoLoad = new Array();

/* Функция записывает выбранные типы в сессию и включает или выключает галочку и блок типа в календаре */
/* 
id : ID типа в календаре 
type : Тип действия (включить или выключить галочку и блок)
*/

function set_calendar_variable(id,type)
{	
	var CalendarAjax = new Ajax(SitePath + "/ajax/", {data: Object.toQueryString({"action":"set_calendar_variable", "id":id,"type":type}),method: 'get',evalResponse:true});
	CalendarAjax.request();
	
	switch(type)
	{
		default:
			alert("Error: x33201: javascript(function set_calendar_variable():file(function.js)).");
		break;
					
		case 'check':
			//alert($("calendar_id_" + id).getAttribute('checked'));
			$("indicator_" + id).setAttribute('checked','checked');
			$('block_' + id).style.display = "block";
			$('calendar_id_' + id).onclick = function x(){set_calendar_variable(id,'uncheck');};
		break;
					
		case 'uncheck':
			//alert($("calendar_id_" + id).getAttribute('checked'));
			$("indicator_" + id).removeAttribute('checked');
			$('block_' + id).style.display = "none";
			$('calendar_id_' + id).onclick = function x(){set_calendar_variable(id,'check');};
		break;	
	}	
	
	return false;
}

/* Функция выбирает фотографию при переключении в левом слайдере */
/* 
id : ID элемента в галерее 
*/
function FetchLeftImage(id)
{	
	var ImageAjax = new Ajax(SitePath + "/ajax/", {data: Object.toQueryString({"action":"fetch_left_image", "id":id, "lang":"ru"}),method: 'get',evalResponse:true,onComplete: function(){
		$('imageHref').href = SitePathWithCurrentLang + "collection/_show/image/_id/" + id;
		$('smallSliderImage').src = smallImage;
		$('smallSliderImageInfo').innerHTML = smallImageInfo;
	}});
	ImageAjax.request();
}

/* Функция инициализирует слайдер для прокрутки списка картин при просмотре одной картины */
/* 
element : Элемент содержащий изображения
left_control: Стрелка для прокрутки налево
right_control: Стрелка для прокрутки направо
*/
function initSlider(element,left_control,right_control)
{
	if(element)
	{
		options = new Array();
					
		images = element.getElements('span'); // забираем все картинки из div
		options.count = images.length; 
		options.photos = new Array();
			
		var a = 0;
		//alert(images);
		images.each(function(image,index) // перебираем по очереди
		{
			var preload = image;
			//alert(preload.getProperty('src'));
			//preload['src'] = preload['src'].replace("/_not_to_load_","");
				
			if(preload['rel'] == 'selected')
			{
				preload.setProperty('className',"selected_img");
			}
								
			options.photos[index] = preload;
							
			//image.setStyle('display','none');
		});
			
		//alert(options.photos.length);		
		
		var step = 0;
		
		if(options.photos.length > 8)
		{
			options.photos.each(function(image,index)
			{
				if(image.getProperty('rel') == 'selected')
				{
					if(index > 4)
					{
						step = index-4;
					}
					
					if(index >= (options.photos.length-3))
					{
						step = options.photos.length-8;
					}
				}
			});
		}
					
		var i = step;
		var table = $("table");
		tds = table.getElements('td'); 
					
		tds.each(function(td,index)
		{
			td.empty();
		
			if(options.photos[i])
			{
				//alert(options.photos[i].getProperty('src'));
				if(options.photos[i].getProperty('rel') == 'selected')
				{
					td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' class='selected_img' border='0'>";
				}
				else
				{
					td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='" + options.photos[i].getProperty('rel') + "'><img src='" + options.photos[i].getProperty('src') + "' border='0'></a>";
				}
				
				i++;
			}
			else
			{
				td.innerHTML = "&nbsp;";
			}
		});
	};
	
					
	if(right_control)
	{					
		right_control.addEvent('click',function()
		{
			if(step < (options.count-8))
			{
				step++;
				var i = step;
				var table = $("table");
				tds = table.getElements('td'); // забираем все картинки из div
								
				tds.each(function(td,index)
				{
					td.empty();
					if(options.photos[i])
					{				
						if(options.photos[i].getProperty('rel') == 'selected')
						{
							td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' class='selected_img' border='0'>";
						}
						else
						{
							td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='" + options.photos[i].getProperty('rel') + "'><img src='" + options.photos[i].getProperty('src') + "' border='0'></a>";
						}
						
						i++;
					}
					else
					{
						td.innerHTML = "&nbsp;";
					}
				});
			}
		});
	}
	
	if(left_control)
	{					
		left_control.addEvent('click',function()
		{
			if(step > 0)
			{
				step--;
				var i = step;
				var table = $("table");
				tds = table.getElements('td'); // забираем все картинки из div
								
				tds.each(function(td,index)
				{
					td.empty();
					if(options.photos[i])
					{
						if(options.photos[i].getProperty('rel') == 'selected')
						{
							td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' class='selected_img' border='0'>";
						}
						else
						{
							td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='" + options.photos[i].getProperty('rel') + "'><img src='" + options.photos[i].getProperty('src') + "' border='0'></a>";
						}
						
						i++;
					}
					else
					{
						td.innerHTML = "&nbsp;";
					}
				});
			};
		});
	};
	
	//alert($('table').innerHTML);
};

function FetchAndRebuild(id)
{
	options.photos.each(function(photo,index)
	{
		photo['className'] = '';
		if(photo.getProperty('rel') == id)
		{
			options.photos[index]['className'] = 'selected_img';
		}
	});
	
	FetchLeftImage(id);
	initSliderSmall($('slider_small'),$('left_small'),$('right_small'));	//  Инициализируем слайдер картин, если мы находимся в просмотре картины :-)			
}
var init;

function initSliderSmall(element,left_control,right_control)
{
	
	
	if(element)
	{
		if(!init)
		{
			options = new Array();
			images = element.getElements('span'); // забираем все картинки из div
			options.count = images.length; 
			options.photos = new Array();
			onclick = new Array();
				
			images.each(function(image,index) // перебираем по очереди
			{			
				options.photos[index] = image;
				onclick[index]= "FetchAndRebuild(" + image.getProperty('rel') + ")";
				
				image.setStyle('display','none');
				
				image.remove();
			});
			
			init = "true";
		}
		
		var step = 0;
		
		if(options.photos.length > 3)
		{
			options.photos.each(function(image,index)
			{
				if(image.className == 'selected_img')
				{
					if(index >= 2)
					{
						step = index-1;
					}
					
					if(index >= (options.photos.length-2))
					{
						step = options.photos.length-3;
					}
				}
			});
		}
					
		var i = step;
		var table = $("table");
		tds = table.getElements('td'); 
					
		tds.each(function(td,index)
		{
			td.empty();
			
			if(options.photos[i])
			{
				if(options.photos[i].className == 'selected_img')
				{
					td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' rel='" + options.photos[i].getProperty('rel') + "' class='selected_img'>";
					
				}
				else
				{
					td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='javascript: void(0);' onclick='" + onclick[i] + "'><img src='" + options.photos[i].getProperty('src') + "'></a>";
				}
				
				i++;
			}
			else
			{
				td.innerHTML = "&nbsp;";
			}
		});
	};
					
	if(right_control)
	{					
		right_control.addEvent('click',function()
		{
			if(step < (options.count-3))
			{
				step++;
				var i = step;
				var table = $("table");
				tds = table.getElements('td'); // забираем все картинки из div
								
				tds.each(function(td,index)
				{
					td.empty();
					if(options.photos[i])
					{				
						if(options.photos[i].className == 'selected_img')
						{
							td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' class='selected_img'>";
						}
						else
						{
							td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='javascript: void(0);' onclick='" + onclick[i] + "'><img src='" + options.photos[i].getProperty('src') + "'></a>";
						}
						
						i++;
					}
					else
					{
						td.innerHTML = "&nbsp;";
					}
				});
			}
		});
	}
	
	if(left_control)
	{					
		left_control.addEvent('click',function()
		{
			if(step > 0)
			{
				step--;
				var i = step;
				var table = $("table");
				tds = table.getElements('td'); // забираем все картинки из div
								
				tds.each(function(td,index)
				{
					td.empty();
					if(options.photos[i])
					{
						if(options.photos[i].className == 'selected_img')
						{
							td.innerHTML = "<img alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' src='" + options.photos[i].getProperty('src') + "' class='selected_img'>";
						}
						else
						{
							td.innerHTML = "<a alt='" + options.photos[i].getProperty('title') + "' title='" + options.photos[i].getProperty('title') + "' href='javascript: void(0);' onclick='" + onclick[i] + "'><img src='" + options.photos[i].getProperty('src') + "'></a>";
						}
						
						i++;
					}
					else
					{
						td.innerHTML = "&nbsp;";
					}
				});
			};
		});
	};
};

Fx.Morph = Fx.Styles.extend(
{
	start: function(className)
	{
		var to = {};
				 
		$each(document.styleSheets, function(style)
		{
			var rules = style.rules || style.cssRules;
			$each(rules, function(rule)
			{
				if (!rule.selectorText.test('\.' + className + '$')) return;
				Fx.CSS.Styles.each(function(style)
				{
					if (!rule.style || !rule.style[style]) return;
					var ruleStyle = rule.style[style];
					to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
				});
			});
		});
		
		return this.parent(to);
	}	 
});
 
Fx.CSS.Styles = ["backgroundColor", "backgroundPosition", "color", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
	 
Fx.CSS.Styles.extend(Element.Styles.padding);
Fx.CSS.Styles.extend(Element.Styles.margin);
					 
Element.Styles.border.each(function(border)
{
	['Width', 'Color'].each(function(property)
	{
		Fx.CSS.Styles.push(border + property);
	});
});

var image_full_size = new Array();

function initBox(target,element,time,size,image)
{
	target.addEvent('click',function(event)
	{	
		var start_coords = new Array();
		var dimension = new Array();
		dimension['start'] = new Array();

		//alert(image.width + "x" + image.height);
		//size.height = image.height;
		if(!isNaN(target.getAttribute('rel'))) { /* [Отсекаем под видео] */
			if(image.height >= (document.body.offsetHeight-((document.body.offsetHeight/100)*15).toInt()))
			{
				size.height = (document.body.offsetHeight-((document.body.offsetHeight/100)*15).toInt());
			}
			else
			{
				size.height = (image.height-((image.height/100)*15).toInt());
			}
			
			if(image.width >= (document.body.offsetWidth-((document.body.offsetWidth/100)*15).toInt()))
			{
				size.width = (document.body.offsetWidth-((document.body.offsetWidth/100)*15).toInt());
			}
			else
			{
				size.width = (image.width-((image.width/100)*15).toInt());
			}
			//size.width = image.width;
			
			image_full_size = size;
		}
		dimension['start']['width'] = $('big_img').getCoordinates().width;
		dimension['start']['height'] = $('big_img').getCoordinates().height;
		
		//dimension['start']['width'] = 100;//$('big_img').getCoordinates().width;
		//dimension['start']['height'] = 100;/$('big_img').getCoordinates().height;
		
		var event = new Event(event)
		
		start_coords['x'] = (event.page.x - $('big_img').getCoordinates().left);
		start_coords['y'] = (event.page.y - $('big_img').getCoordinates().top);
		
		element.setStyle('height',document.body.scrollHeight);
		element.setStyle('width',document.body.scrollWidth);
		element.setStyle('display',"block");

		element.addEvent('click',function()
		{
			box.empty();
			
			new Fx.Styles(box, {duration:(time*2), wait:false}).start(
			{
				'height': '0',
				'width': '0',
				'opacity':'0',
				'top': ((box.getStyle('top').toInt()) + ((size.height/2).toInt())).toInt(),
				'left': ((box.getStyle('left').toInt()) + ((size.width/2).toInt())).toInt()
			}).addEvent('onComplete',function()
			{
				box.remove();
				fImage="";
				new Fx.Morph('brararabra', {duration:(time*2),wait: false}).start('hidebra');
			});
		});
		
		if(BrowserDetect.browser == 'Explorer')
		{
			window_size_x = document.body.offsetWidth;
			window_size_y = document.body.offsetHeight;
		}
		else
		{
			window_size_x = window.getSize().size.x;
			window_size_y = window.getSize().size.y;
		}

		if(!isNaN(target.getAttribute('rel'))) { /* [Отсекаем под видео] */
		var Table = "<table cellspacing='0' cellpadding='0' border='0'>";
		Images.each(function(item)
		{
			if(item)
			{
				Table += "<tr>";
				item.each(function(item2)
				{
					if(item2)
					{
						Table += "<td style=\"background: #CCCCCC;background-image: url('/pictures/" + item2.src + "');width: " + item2.width + "px;height: " + item2.height + "px;float:left;padding: 0px;margin: 0px;\"></td>";
					}
				});
				Table += "</tr>";
			}
		});
		
		Table += "</table>";
		} else {
			image.setStyle('display', 'block');
			var Table = "<table cellspacing='0' cellpadding='0' border='0'><tr style=\"background-color: #ccc; width: "+ image.getStyle('width') +"; height: "+ image.getStyle('height') +";padding: 0px;margin: 0px;\"><td>";
			Table += image.getAttribute('rel');
			Table += "</td></tr></table>";
		}		
		new Fx.Morph('brararabra', {duration:(time*2),wait:false}).start('showbra').addEvent('onComplete',function()
		{			 
			box = new Element('div');
			box.className = "box";
			box.id = 'box';
			box.setStyle('left',(window_size_x/2));
			box.setStyle('top',(window_size_y/2));
			box.setOpacity('0');
			
			box.close = function()
			{
				box.empty();
				
				new Fx.Styles(box, {duration:(time*2), wait:false}).start(
				{
					'height': '0',
					'width': '0',
					'opacity':'0',
					'top': ((box.getStyle('top').toInt()) + ((size.height/2).toInt())).toInt(),
					'left': ((box.getStyle('left').toInt()) + ((size.width/2).toInt())).toInt()
				}).addEvent('onComplete',function()
				{
					box.remove();
					fImage="";
					new Fx.Morph('brararabra', {duration:(time*2),wait: false}).start('hidebra');
				});	
			}
			
			document.body.appendChild(box);
			
			
			new Fx.Styles(box, {duration:time, wait:false}).start(
			{
				'height': size.height,
				'width': size.width,
				'opacity':'1',
				'left': ((window_size_x/2).toInt())-((size.width/2).toInt()),
				'top': ((window_size_y/2).toInt())-((size.height/2).toInt())
				
			}).addEvent('onComplete',function()
			{
				
				var correct = 0;
				
				var close = new Element('Div');
				close.setAttribute("id","close");
				close.setStyle("position","absolute");
				close.setStyle("z-index","5800");
				close.setStyle("right","-6px");
				close.setStyle("top","-5px");
				close.setStyle("width","1px");
				close.setStyle("margin","0px");
				close.setStyle("height","1px");
				close.innerHTML = "<a href='#'><img src='/design/standart/ru/images/close.gif' onclick='box.close();' border='0'></a>";
				
				if(BrowserDetect.browser != 'Explorer')
				{
					close.setStyle("right","14px");
					correct = ((box.getStyle('padding').toInt())/2)	
				}
				
				box.appendChild(close);
				
				box.innerHTML +="<div id='containment' style='height: " + ((size.height)-(correct)) + "px;width: " + ((size.width)-(correct)) + "px;'><div id='slide' style='z-index: 0;width:" + image.width + "px;height:" + image.height + "'></div></div>";
				
				$('slide').innerHTML = Table;
				var container = $('containment');
					
				CursorFunction($('containment'),"/design/standart/ru/images/hand.gif","true");
				if(!isNaN(target.getAttribute('rel'))) {
					var dragger = new Drag.Move('slide',{limit: {x:new Array(((image.width-size.width)*(-1)),"0"),y:new Array(((image.height-size.height)*(-1)),"0")},onStart: function(){CursorFunction($('containment'),"/design/standart/ru/images/chand.gif","true");},onComplete: function(){CursorFunction($('containment'),"/design/standart/ru/images/hand.gif","true");}});
 				}	
 				var end_coords = new Array();
 					
 				dimension['end'] = new Array();
		
				dimension['end']['width'] = $('slide').getCoordinates().width;
				dimension['end']['height'] = $('slide').getCoordinates().height;
 					
				end_coords['x'] = start_coords['x'] * (dimension['end']['width']/dimension['start']['width']);
 				end_coords['y'] = start_coords['y'] * (dimension['end']['height']/dimension['start']['height']);
 					
 				var size_a = new Array();
				size_a['width'] = $('containment').getCoordinates().width;
				size_a['height'] = $('containment').getCoordinates().height;
							
				var image_a = new Array();
				image_a['width'] = $('slide').getCoordinates().width;
				image_a['height'] = $('slide').getCoordinates().height;
							
				var max_left = (image_a.width-size_a.width)*(-1);
				var max_top = (image_a.height-size_a.height)*(-1);
					
				var min_left = "0";
				var min_top = "0";
					
				var to_top = ((end_coords['y'].toInt()*(-1)) + (size_a.height/2));
				var to_left = ((end_coords['x'].toInt()*(-1)) + (size_a.width/2));
 					
				if(to_top < max_top)
				{
					to_top = max_top;	
				}
						
				if(to_top > min_top)
				{
					to_top = min_top;	
				}
						
				if(to_left < max_left)
				{
					to_left = max_left;	
				}
						
				if(to_left > min_left)
				{
					to_left = min_left;	
				}
 				$('slide').setStyle('left',to_left);
 				$('slide').setStyle('top',to_top);
 					
				var mouseevent = new Array();
				var mouseevent_new = new Array();
			});
			
		});
	});
}

function fetchImage(id,target,element,time,size)
{
	var ImageAjax = new Ajax(SitePath + "/ajax/", {data: Object.toQueryString({"action":"fetch_image", "id":id}),method: 'get',evalResponse: true,onComplete: function(){
		initBox(target,element,time,size,fullimage_src);
	}});
	ImageAjax.request();
	
}

function uncheck_all(element)
{
	var checks = element.getElements('input');
	
	checks.each(function(item,index)
	{	
		item.removeProperty('checked');
		set_calendar_variable(item.getAttribute('rel'),'uncheck');
	});
}

function check_all(element)
{
	var checks = element.getElements('input');
	
	checks.each(function(item,index)
	{
		item.setProperty('checked','checked');
		set_calendar_variable(item.getAttribute('rel'),'check');
	});
}

function CursorFunction(element,link,withmouse)
{
	
	if(BrowserDetect.browser == "Explorer")
	{
		if($$(".asdasd3").length > 0)
		{
			$$(".asdasd3").each(function(item,index)
			{
				item.remove();
			});
		}
		
		if(!cursor)
		{
			var cursor = new Element("Div");
			document.body.appendChild(cursor);
			element.removeEvents("mousemove");
			element.removeEvents("mouseout");
			
			element.addEvent("mousemove",function(event)
			{
				var event = new Event(event);
				
				cursor.setStyle("display","block");
				cursor.setStyle('left',event.page.x-10);
				cursor.setStyle('top',event.page.y+15);
			});
			
			element.addEvent("mouseout",function(){
				cursor.setStyle('display',"none");
			});
			
			cursor.innerHTML="";
			cursor.innerHTML = "<div class='asdasd3'><img src='" + link + "'></div>";
		}
	
		cursor.setStyle('position',"absolute");
		cursor.setStyle('z-index',"999999");
		
		element.setStyle("cursor","url(/design/standart/ru/images/spacer.cur)");
		cursor.setStyle("cursor","url(/design/standart/ru/images/spacer.cur)");
		
		if(withmouse != "true")
		{
			element.addEvent("click",function(){
				cursor.setStyle('display',"none");
			});
		}
	}
}

/*######### ------- АВТОЗАГРУЗКА ------- #########*/
/*###										   ###*/
/*###	Здесь куски кода которые будут грузи-  ###*/
/*###	ться автоматически при загрузке        ###*/
/*###	страницы.							   ###*/
/*###						       			   ###*/
/*################################################*/

AutoLoad[0] = function()
{
	initSlider($('slider'),$('left'),$('right'));	//  Инициализируем слайдер картин, если мы находимся в просмотре картины :-)			
	initSliderSmall($('slider_small'),$('left_small'),$('right_small'));	//  Инициализируем слайдер картин, если мы находимся в просмотре картины :-)			
}
				
AutoLoad[1] = function()
{
	if($('big_img'))
	{
		var temp_height = (document.body.offsetHeight-100);
		var temp_width = (document.body.offsetHeight-100);
		if((document.body.offsetHeight-100) >= document.body.offsetWidth)
		{
			temp_width = (document.body.offsetWidth-100);
		}
		
		fetchImage($('big_img').getProperty('rel'),$('big_img'),$('brararabra'),100,{height:temp_height,width:temp_width});		
	};					
}

AutoLoad[2] = function()
{
	if($('brararabra'))
	{
		window.onresize = function()
		{
			$('brararabra').setStyle('height',document.body.scrollHeight);
			$('brararabra').setStyle('width',document.body.scrollWidth);	
			
			if(BrowserDetect.browser == 'Explorer')
			{
				window_size_x = document.body.offsetWidth;
				window_size_y = document.body.offsetHeight;
			}
			else
			{
				window_size_x = window.getSize().size.x;
				window_size_y = window.getSize().size.y;
			}
			
			
			
			var size = new Array();
			if(image_full_size.height >= (document.body.offsetHeight-((document.body.offsetHeight/100)*15).toInt()))
			{
				size.height = (document.body.offsetHeight-((document.body.offsetHeight/100)*15).toInt());
			}
			else
			{
				size.height = (image_full_size.height-((image_full_size.height/100)*15).toInt());
			}
			
			if(image_full_size.width >= (document.body.offsetWidth-((document.body.offsetWidth/100)*15).toInt()))
			{
				size.width = (document.body.offsetWidth-((document.body.offsetWidth/100)*15).toInt());
			}
			else
			{
				size.width = (image_full_size.width-((image_full_size.width/100)*15).toInt());
			}
			
			to_height = size.height;
			to_width = size.width;
			
			///
			/*
			var to_height = (document.body.offsetHeight-100);
			var to_width = (document.body.offsetHeight-100);
			*/
			//alert($('brararabra').offsetHeight);
			//alert(image_full_size.height);
			if((document.body.offsetHeight-100) >= document.body.offsetWidth)
			{
				to_width = (document.body.offsetWidth-100);
			}
			
			var correct = 0;
					
			if(BrowserDetect.browser != 'Explorer')
			{
				correct = ((box.getStyle('padding').toInt())/2)	
			}
			var start;
			
			if($('slide'))
			{
				var image = new Array();
				image["height"] = $('slide').getStyle('height').toInt();
				image["width"] =  $('slide').getStyle('width').toInt();
			
				if(start != 'true')
				{
					start = 'true'
				
					new Fx.Styles($('box'), {duration:300, wait:false}).start(
						{
							'height': to_height,
							'width': to_width,
							'left': ((window_size_x/2).toInt())-((to_width/2).toInt()),
							'top': ((window_size_y/2).toInt())-((to_height/2).toInt())
						}).addEvent('onComplete',function(){start = 'false'});
						
					new Fx.Styles($('containment'), {duration:300, wait:false}).start(
						{
							'height': to_height-correct,
							'width': to_width-correct
						}).addEvent('onComplete',function(){start = 'false'});	
					
					
					dragger = new Drag.Move('slide',{limit: {x:new Array(((image.width-to_width)*(-1)),"0"),y:new Array(((image.height-to_height)*(-1)),"0")}});
				}
			}
		}
	}
}

AutoLoad[3] = function()
{
	if($('big_img'))
	{
		$('big_img').addEvent("mouseover",function(){
			CursorFunction($('big_img'),"/design/standart/ru/images/zoomin.gif","false","false");
		});
	}
}

AutoLoad[4] = function()
{
	var i = 1;
	titles = new Array();
	$$("a[rel=lightbox]").each(function(item,index)
	{
		item.setProperty("id","lighthack" + i);
		titles["lighthack" + i] = $("lighthack" + i).getProperty('title');
		
		var str = $("lighthack" + i).getProperty('title').replace("<b>","");
		var strs = str.replace("</b>","");
		var strss = strs.replace("<br>","");
		var strsss = strss.replace("<br />","");
		
		$("lighthack" + i).setProperty('title',strsss);
		i++;
	});
	
}

AutoLoad[5] = function() {
	if($('show_video')) {
		var value = $('show_video').getAttribute('rel');
		var current_width = value.substr(value.indexOf("width") + 7, 3);
		var current_height = value.substr(value.indexOf("height") + 8, 3);
		initBox($('show_video'),$('brararabra'),100,{height: current_height, width: current_width},$('show_video'));
	}
	
}

