﻿var Tribes = Class.create();
 Tribes.prototype = { initialize: function(content, container) { this.content = content["GetItemListResult"];
 this.applicationRoot = applicationRoot || "/";
 this.container = $(container);
 this.tribeList = new Array();
 this.browser = new Browser();
 this.insertHtml();
 }, insertHtml: function() { var count = this.content["@Count"];
 if(count == 0) return;
 if(count == 1) this.tribeList.push(this.content["Item"]);
 else for(var i=0;
 i<this.content["Item"].length;
 i++) this.tribeList.push(this.content["Item"][i]);
 this.addTribeBlock(this, 0);
 }, addTribeBlock: function(evt, index) { this.container.clear();
 var prop = this.tribeList[index]["Properties"]["Property"];
 if(prop[0]["Value"] != undefined) var title = prop[0]["Value"];
 var div = document.createElement("div");
 var img_1 = document.createElement("img");
 img_1.src = this.applicationRoot + prop[2]["Value"];
 div.appendChild(img_1);
 var span = document.createElement("span");
 if(index != 0) { var leftArrow = document.createElement("img");
 leftArrow.src = "/Images/tribeLArr.gif";
 span.appendChild(leftArrow);
 leftArrow.onclick = this.addTribeBlock.bindAsEventListener(this, index-1);
 } span.appendChild(document.createTextNode(title));
 if(index+1 != this.tribeList.length) { var rightArrow = document.createElement("img");
 rightArrow.src = "/Images/tribeRArr.gif";
 span.appendChild(rightArrow);
 rightArrow.onclick = this.addTribeBlock.bindAsEventListener(this, index+1);
 } var img_2 = document.createElement("img");
 img_2.src = this.applicationRoot + prop[1]["Value"];
 var b = document.createElement("b");
 var subDiv = document.createElement("div");
 subDiv.appendChild(img_2);
 b.appendChild(subDiv);
 var img_3 = document.createElement("img");
 img_3.src = "/Images/their.gif";
 this.container.appendChild(div);
 this.container.appendChild(span);
 this.container.appendChild(b);
 this.container.appendChild(img_3);
 PngTransform.applyTransform(img_1);
 PngTransform.applyTransform(img_2);
 } };
 var EventFotos = Class.create();
 EventFotos.prototype = { initialize: function(content, container, fotosContainer) { this.content = content;
 this.container = $(container);
 this.fotosBlock = $(fotosContainer);
 this.fotosContainer = $("EventFoto");
 this.topArrow = $("EventTopArr");
 this.bottomArrow = $("EventBotArr");
 this.applicationRoot = applicationRoot || "/";
 this.itemGroupList = null;
 this.maxCount = 4;
 this.startFromIndex = 0;
 this.curItem = 0;
 this.sortList = [];
 this.browser = new Browser();
 this.initFotos();
 }, initFotos: function() { var groupList = this.content["GetItemGroupListResult"];
 this.itemGroupList = groupList["ItemGroup"];
 if(groupList["@Count"] == 0) return;
 if(groupList["@Count"] > 1) { for(var i=0;
 i<this.itemGroupList.length;
 i++) this.sortGroup(this.itemGroupList[i]);
 } else this.addGroup(this.itemGroupList);
 if(groupList["@Count"] > this.maxCount) { this.bottomArrow.src = "/Images/bottomarrow.gif";
 this.bottomArrow.onclick = this.scrollBlock.bindAsEventListener(this);
 this.bottomArrow.style.cursor = "pointer";
 } }, sortGroup: function(itemGroup) { var fId = itemGroup["ID"];
 var catalog = itemGroup["Catalog"]["ID"];
 var folder = {name: itemGroup["Name"], index: this.startFromIndex};
 var block = {id: 0, container: "", category: "itemList", params: {folderId: fId, catalogId: catalog}, itemsCount: 1, orderSettings: [{column: "Date", rule: "DESC"}]};
 var fotoBlock = new Block(block);
 fotoBlock.getItemList();
 fotoBlock.blockCallback = this.addToSortList.bind(this, folder);
 }, addToSortList: function(folder, container, content) { var itemList = content["GetItemListResult"];
 if(itemList["@Count"] == 0) return;
 var dateValue = itemList["Item"]["Properties"]["Property"][2]["Value"];
 var d = (dateValue.substring(0,2).charAt(0) == "0")? dateValue.substring(1,2) : dateValue.substring(0,2);
 var m = (dateValue.substring(3,5).charAt(0) == "0")? dateValue.substring(4,5) : dateValue.substring(3,5);
 var y = dateValue.substring(6,10);
 this.sortList.push({date: new Date(y,m,d), fld: folder, block: container, cnt: content});
 if(this.sortList.length == this.itemGroupList.length) { this.sortList.sort(this.cmp);
 for(var i=0;
 i<this.itemGroupList.length;
 i++) this.addToList(this.sortList[i].fld, this.sortList[i].block, this.sortList[i].cnt);
 } }, cmp: function(a, b) { if (a.date > b.date) return -1;
 if (a.date < b.date) return 1;
 return 0;
 }, addGroup: function(itemGroup) { var fId = itemGroup["ID"];
 var catalog = itemGroup["Catalog"]["ID"];
 var folder = {name: itemGroup["Name"], index: this.startFromIndex};
 var block = {id: 0, container: "", category: "itemList", params: {folderId: fId, catalogId: catalog}, itemsCount: 1, orderSettings: [{column: "Date", rule: "DESC"}]};
 var fotoBlock = new Block(block);
 fotoBlock.getItemList();
 fotoBlock.blockCallback = this.addToList.bind(this, folder);
 }, addToList: function(folder, container, content) { this.loadFotoToList(folder, content);
 }, loadFotoToList: function(folder, content) { var itemList = content["GetItemListResult"];
 if(itemList["@Count"] == 0) return;
 var props = itemList["Item"]["Properties"]["Property"];
 var pItem = {folderId: itemList["Item"]["Parent"]["ID"], catalogId: itemList["Item"]["Catalog"]["ID"], name: folder.name, index: folder.index};
 var tr = document.createElement("tr");
 var td = document.createElement("td");
 var span = document.createElement("span");
 var mask = document.createElement("img");
 mask.src = "/Images/fotoBorder.png";
 mask.alt = folder.name;
 span.appendChild(mask);
 mask.onclick = this.loadFotosBlock.bindAsEventListener(this, pItem);
 var img = document.createElement("img");
 img.src = this.applicationRoot + props[3]["Value"] + "&w=36&h=36&crop=1";
 var dateField = props[2]["Value"];
 var date = dateField.substring(0,dateField.length-12) + dateField.substring(8, 11);
 td.appendChild(span);
 td.appendChild(img);
 td.appendChild(document.createTextNode(date));
 tr.appendChild(td);
 this.container.appendChild(tr);
 PngTransform.applyTransform(mask);
 PngTransform.applyTransform(img);
 }, loadFotosBlock: function(evt, pItem) { this.fotosBlock.style.width = "630px";
 this.fotosContainer.clear();
 this.fotosContainer.innerHTML = "<img src='/Images/preload.gif' style='margin: 200px 0 0 270px' alt=''/>";
 var block = {id: 0, container: this.fotosContainer, category: "itemList", params: {folderId: pItem.folderId, catalogId: pItem.catalogId}, orderSettings: [{column: "Date", rule: "DESC"}]};
 var fotos = new Block(block);
 fotos.getItemList();
 fotos.blockCallback = this.addFotosList.bind(this, pItem.name);
 }, addFotosList: function(groupName, container, content) { var list = content["GetItemListResult"];
 if(list["@Count"] == 0) return;
 this.fotoList = list["Item"];
 this.groupName = groupName;
 this.addFotos(this, 0);
 }, addFotos: function(evt, index) { this.fotosContainer.clear();
 var item = (this.fotoList.length != undefined)? this.fotoList[index] : this.fotoList;
 var props = item["Properties"]["Property"];
 var title = props[0]["Value"];
 var fotoSrc = props[3]["Value"];
 var span = document.createElement("span");
 var p = document.createElement("p");
 var a = document.createElement("a");
 a.appendChild(document.createTextNode(this.groupName));
 p.appendChild(a);
 if(title != undefined) p.appendChild(document.createTextNode(" / " + title));
 var b = document.createElement("b");
 var mask = document.createElement("img");
 mask.src = "/Images/bigFotoBorder.png";
 b.appendChild(mask);
 var span2 = document.createElement("span");
 var foto = document.createElement("img");
 foto.src = this.applicationRoot + fotoSrc + "&w=528&h=383&crop=1";
 span2.appendChild(foto);
 var buttons = document.createElement("span");
 Element.addClassName(buttons, "buttons");
 if(index != 0) { var lBut = document.createElement("img");
 lBut.src = "/Images/prev.png";
 lBut.onclick = this.addFotos.bindAsEventListener(this, index-1);
 buttons.appendChild(lBut);
 } if(index < this.fotoList.length-1) { var rBut = document.createElement("img");
 rBut.src = "/Images/next.png";
 rBut.onclick = this.addFotos.bindAsEventListener(this, index+1);
 buttons.appendChild(rBut);
 } span.appendChild(p);
 span.appendChild(b);
 span.appendChild(span2);
 span.appendChild(buttons);
 this.fotosContainer.appendChild(span);
 if(this.fotoList.length == undefined) return;
 var divL = document.createElement("div");
 if(index != 0) { var emL = document.createElement("em");
 var prevItem = this.fotoList[index-1];
 var prevFoto = prevItem["Properties"]["Property"][3]["Value"];
 var imgL = document.createElement("img");
 imgL.src = this.applicationRoot + prevFoto + "&w=264&h=191";
 emL.appendChild(imgL);
 divL.appendChild(emL);
 } var b = document.createElement("b");
 var divR = document.createElement("div");
 if(index < this.fotoList.length-1) { var emR = document.createElement("em");
 var nextItem = this.fotoList[index+1];
 var nextFoto = nextItem["Properties"]["Property"][3]["Value"];
 var imgR = document.createElement("img");
 imgR.src = this.applicationRoot + nextFoto + "&w=264&h=191";
 emR.appendChild(imgR);
 divR.appendChild(emR);
 } this.fotosContainer.appendChild(divL);
 this.fotosContainer.appendChild(b);
 this.fotosContainer.appendChild(divR);
 PngTransform.applyTransform(mask);
 PngTransform.applyTransform(foto);
 if(lBut != null) PngTransform.applyTransform(lBut);
 if(rBut != null) PngTransform.applyTransform(rBut);
 }, scrollBlock: function(evt) { var elem = Event.element(evt);
 this.curItem = (elem == this.topArrow)? this.curItem-4 : this.curItem+4;
 this.topArrow.src = (this.curItem == 0)? "/Images/blank.gif" : "/Images/toparrow.gif";
 this.topArrow.onclick = (this.curItem == 0)? null : this.scrollBlock.bindAsEventListener(this);
 this.topArrow.style.cursor = (this.curItem == 0)? "default" : "pointer";
 this.bottomArrow.src = (this.curItem-4 >= this.itemGroupList.length-1)? "/Images/blank.gif" : "/Images/bottomarrow.gif";
 this.bottomArrow.onclick = (this.curItem-4 >= this.itemGroupList.length-1)? null : this.scrollBlock.bindAsEventListener(this);
 this.bottomArrow.style.cursor = (this.curItem-4 >= this.itemGroupList.length-1)? "default" : "pointer";
 var offset = parseInt(this.container.parentNode.offsetTop);
 this.container.parentNode.style.top = (elem == this.topArrow)? offset+72+"px" : offset-72+"px";
 } };
 var Persons = Class.create();
 Persons.prototype = { initialize: function(content, container, fotoContainer) { this.applicationRoot = applicationRoot || "/";
 this.content = content;
 this.container = $(container);
 this.fotoContainer = $(fotoContainer);
 this.month = ["январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"];
 this.curItem = null;
 this.fotos = new Array();
 this.leftArrow = $("PersonLArrow");
 this.rightArrow = $("PersonRArrow");
 this.fullCount = this.content["GetItemListResult"]["@Count"];
 this.maxCount = 12;
 this.loadedItems = 0;
 this.container.clear();
 this.loadIcons(this.content);
 }, loadIcons: function(content) { if(this.loadedItems == 0) this.container.clear();
 var itemList = content["GetItemListResult"];
 if(this.fullCount == 0) return;
 if(itemList["Item"].length != undefined) { for(var i=0;
 i<this.maxCount;
 i++) { var td = this.addIcon(itemList["Item"][i], this.loadedItems+i);
 this.container.appendChild(td);
 } } else { var td = this.addIcon(itemList["Item"], this.loadedItems);
 this.container.appendChild(td);
 } this.lastItem = this.maxCount;
 }, addIcon: function(item, index) { var props = item["Properties"]["Property"];
 var ico = props[3]["Value"];
 var ico_a = props[4]["Value"];
 var icon = (ico != undefined)? this.applicationRoot + ico : "/Images/ico4.gif";
 var icon_a = (ico_a != undefined)? this.applicationRoot + ico_a : "/Images/ico4.gif";
 var dateField = props[1]["Value"];
 var date = dateField.substring(0,dateField.length-12) + dateField.substring(8, 11);
 var title = props[0]["Value"];
 var td = document.createElement("td");
 var div = document.createElement("div");
 var img = document.createElement("img");
 img.src = icon;
 img.onmouseover = this.swapSrc.bindAsEventListener(this, icon_a);
 img.onmouseout = this.swapSrc.bindAsEventListener(this, icon);
 if(title != undefined) img.alt = title;
 div.appendChild(img);
 div.appendChild(document.createTextNode(date));
 var fotoItem = {props: props, pItem: img, index: index};
 this.fotos.push(fotoItem);
 img.onclick = this.loadInfo.bindAsEventListener(this, fotoItem);
 if(index == this.fullCount-1) { this.curItem = fotoItem;
 this.loadInfo(this, fotoItem);
 } td.appendChild(div);
 return td;
 }, swapSrc: function(evt, source) { Event.element(evt).src = source;
 }, loadInfo: function(evt, item) { this.fotoContainer.clear();
 if(this.curItem != undefined) { Element.removeClassName(this.curItem.pItem.parentNode, "active");
 var icon = this.curItem.props[3]["Value"];
 this.curItem.pItem.src = (icon != undefined)? this.applicationRoot+icon : "/Images/ico4.gif";
 this.curItem.pItem.onmouseout = this.swapSrc.bindAsEventListener(this, this.curItem.pItem.src);
 } this.curItem = item;
 this.curItem.index = item.index;
 Element.addClassName(this.curItem.pItem.parentNode, "active");
 var curIndex = this.curItem.index;
 this.leftArrow.src = (curIndex > 0)? "/Images/pArrL.gif" : "/Images/blank.gif";
 this.leftArrow.cursor = (curIndex > 0)? "pointer" : "default";
 this.leftArrow.onclick = (curIndex > 0)? this.initCurItem.bindAsEventListener(this) : null;
 this.rightArrow.src = (curIndex < this.fullCount-1 || (curIndex == 0 && this.fullCount != 1))? "/Images/pArrR.gif" : "/Images/blank.gif";
 this.rightArrow.cursor = (curIndex < this.fullCount-1 || (curIndex == 0 && this.fullCount != 1))? "pointer" : "default";
 this.rightArrow.onclick = (curIndex < this.fullCount-1 || (curIndex == 0 && this.fullCount != 1))? this.initCurItem.bindAsEventListener(this) : null;
 var dateField = item.props[1]["Value"];
 var year = dateField.substring(6, 10);
 var m = dateField.substring(3, 5);
 var month = (m.charAt(0) == "0")? m.substring(1, 2) : m;
 var date = this.month[parseInt(month)-1] + " " + year;
 var title = item.props[0]["Value"];
 var foto = this.applicationRoot + item.props[2]["Value"];
 var ico = item.props[4]["Value"];
 var icon_a = (ico != undefined)? this.applicationRoot + ico : "/Images/ico4.gif";
 var comment = item.props[5]["Value"];
 var div = document.createElement("div");
 Element.addClassName(div, "photo");
 var photo = document.createElement("img");
 photo.src = foto;
 item.pItem.src = icon_a;
 item.pItem.onmouseout = null;
 div.appendChild(photo);
 if(item.props[7]["Value"] != null && item.props[7]["Value"] != undefined)
 {
 	photo.title = "Увеличить";
    photo.style.cursor = "pointer";
    var bSrc = this.applicationRoot + item.props[7]["Value"];
    photo.onclick = this.showBigCalendar.bindAsEventListener(this, bSrc);
 }
 var infoDiv = document.createElement("div");
 Element.addClassName(infoDiv, "faces");
 var h5 = document.createElement("h5");
 var b = document.createElement("b");
 if(title != undefined) b.appendChild(document.createTextNode(title));
 var span = document.createElement("span");
 span.appendChild(document.createTextNode(" " + date));
 h5.appendChild(b);
 h5.appendChild(span);
 var text = document.createElement("div");
 if(comment != undefined) text.innerHTML = comment;
 infoDiv.appendChild(h5);
 infoDiv.appendChild(text);
 this.fotoContainer.appendChild(div);
 this.fotoContainer.appendChild(infoDiv);
 if(item.index != 0) { if(item.index >= this.fotos.length/2 && this.loadedItems < this.fullCount) { var index = this.fotos.length+1;
 var block = {id: 0, container: "", category: "itemList", params: {folderId: "0", catalogId: "2"}, itemsCount: "6", startIndex: index, orderSettings: [{column: "Date", rule: "DESC"}]};
 this.loadedItems = this.fotos.length;
 this.curItem.index = item.index;
 var nextFotos = new Block(block);
 nextFotos.getItemList();
 nextFotos.blockCallback = this.preloadFotos.bind(this);
 } } }, initCurItem: function(evt) { var next = (Event.element(evt) == this.rightArrow)? parseInt(this.curItem.index) + 1 : parseInt(this.curItem.index) - 1;
 if((this.curItem.index+2 > this.lastItem && Event.element(evt) == this.rightArrow) || (this.curItem.index-1 < this.lastItem-this.maxCount && Event.element(evt) == this.leftArrow)) { var left = parseInt(this.container.parentNode.parentNode.offsetLeft);
 this.container.parentNode.parentNode.style.left = (Event.element(evt) == this.rightArrow)? left-54+"px" : left+54+"px";
 this.lastItem = (Event.element(evt) == this.rightArrow)? this.lastItem+1 : this.lastItem-1;
 } this.loadInfo(this, this.fotos[next]);
 }, preloadFotos: function(container, content) { this.loadIcons(content);
 },
	showBigCalendar: function(evt, bSrc)
	{
	    if(bSrc == null)
	        return;
	        
   		var div = document.createElement("div");
 	    Element.addClassName(div, "bigCalendar");
 	    var p = document.createElement("p");
 	    Element.addClassName(p, "fon");
   	    var sp1 = document.createElement("span");
        var sp2 = document.createElement("span");
 	    var img = document.createElement("img");
 	    img.src = bSrc;
 	    sp2.appendChild(img);
 	    sp1.appendChild(sp2);
   		div.appendChild(p);
   		div.appendChild(sp1);   		
 	    $("StudioPersonDiv").appendChild(div);
 	    img.onclick = function(){
 	        Element.remove(div);
 	        };
	} };
	
 var Ipix = Class.create();
 Ipix.prototype = { initialize: function(content, container, ipixContainer) { this.content = content;
 this.ipixContainer = $(ipixContainer);
 this.container = $(container);
 this.applicationRoot = applicationRoot || "/";
 this.selectedItem = null;
 this.itemsList = [];
 this.leftArrow = $("ipixLArrow");
 this.rightArrow = $("ipixRArrow");
 this.browser = new Browser();
 this.initIcons();
 }, initIcons: function() { this.container.clear();
 var itemList = this.content["GetItemListResult"];
 if(itemList["@Count"] == 0) return;
 if(itemList["@Count"] > 1) for(var i=0;
 i<itemList["@Count"];
 i++) this.addIcon(itemList["Item"][i]);
 else this.addIcon(itemList["Item"]);
 }, addIcon: function(item) { var props = item["Properties"]["Property"];
 var img = document.createElement("img");
 var icon = (props[1]["Value"] != undefined)? this.applicationRoot + props[1]["Value"] + "&w=49&h=49" : "/Images/white.gif";
 var icon_a = (props[2]["Value"] != undefined)? this.applicationRoot + props[2]["Value"] + "&w=49&h=49" : "/Images/green.gif";
 var item = {title: props[0]["Value"], icon: icon, icon_a: icon_a, index: props[3]["Value"], image: img};
 this.itemsList.push(item);
 img.src = item.icon;
 img.onmouseover = this.showInfo.bindAsEventListener(this, item);
 img.onmouseout = this.hideInfo.bindAsEventListener(this, item);
 img.onclick = this.loadIpix.bindAsEventListener(this, item);
 this.container.appendChild(img);
 PngTransform.applyTransform(img);
 if(item.index == 1) this.loadIpix(this, item);
 }, showInfo: function(evt, item) { var img = Event.element(evt);
 img.src = item.icon_a;
 PngTransform.applyTransform(img);
 if(item.title == undefined) return;
 var b = document.createElement("b");
 var b2 = document.createElement("b");
 b.style.cssFloat = "left";
 b2.appendChild(document.createTextNode(item.title));
 b.appendChild(b2);
 this.container.insertBefore(b, this.container.firstChild);
 b.style.position = "relative";
 b2.style.position = "absolute";
 b2.style.left = (53*item.index - 53) - 180 + "px";
 b2.style.top = "-26px";
 item.info = b;
 }, hideInfo: function(evt, item) { var img = Event.element(evt);
 if(item != this.selectedItem) { img.src = item.icon;
 PngTransform.applyTransform(img);
 } if(item.info != undefined) Element.remove(item.info);
 }, loadIpix: function(evt, item) { this.ipixContainer.clear();
 var ipix = new IpixModule(item, 558, 291, this.ipixContainer).PutIPX();
 this.ipixContainer.style.display = (!ipix)? "none" : "block";
 if(!ipix) return;
 if(this.selectedItem != null) { this.selectedItem.image.src = this.selectedItem.icon;
 PngTransform.applyTransform(this.selectedItem.image);
 } this.selectedItem = item;
 this.selectedItem.image.src = item.icon_a;
 PngTransform.applyTransform(this.selectedItem.image);
 this.rightArrow.src = (item.index == this.itemsList.length && item.index != 1)? "/Images/blank.gif" : "/Images/aRarr.gif";
 this.rightArrow.style.cursor = (item.index == this.itemsList.length)? "default" : "pointer";
 this.rightArrow.onclick = (item.index == this.itemsList.length)? null : this.loadIpix.bindAsEventListener(this, this.itemsList[this.selectedItem.index]);
 this.leftArrow.src = (item.index == 1)? "/Images/blank.gif" : "/Images/aLarr.gif";
 this.leftArrow.style.cursor = (item.index == 1)? "default" : "pointer";
 this.leftArrow.onclick = (item.index == 1)? null : this.loadIpix.bindAsEventListener(this, this.itemsList[this.selectedItem.index-2]);
 } };
 var FullJ = Class.create();
 FullJ.prototype = { initialize: function(content, container) { this.content = content;
 this.container = $(container);
 this.descrBlock = null;
 this.textContainer = null;
 this.applicationRoot = applicationRoot || "/";
 this.initContent();
 }, initContent: function() { this.container.clear();
 var itemList = this.content["GetItemListResult"];
 if(itemList["@Count"] == 0) return;
 if(itemList["@Count"] > 1) for(var i=0;
 i<itemList["@Count"];
 i++) this.addItem(itemList["Item"][i], i);
 else this.addItem(itemList["Item"], 0);
 }, addItem: function(item, index) { var props = item["Properties"]["Property"];
 var title = props[0]["Value"];
 var description = props[1]["Value"];
 var imageSrc = this.applicationRoot + props[2]["Value"];
 var div = document.createElement("div");
 var img = document.createElement("img");
 img.src = imageSrc;
 if(title != undefined) img.alt = title;
 div.appendChild(img);
 this.container.appendChild(div);
 if(description == undefined) return;
 var item = {description: description, container: null};
 item.Y = parseInt((index + 3)/3);
 item.X = ((index + 1) - ((item.Y-1)*3));
 img.onmouseover = this.showInfo.bindAsEventListener(this, item, img);
 }, showInfo: function(evt, item, img) { if(this.descrBlock == null) { var div = document.createElement("div");
 div.style.cursor = "hand";
 Element.addClassName(div, "fotoDescr");
 var subdiv = document.createElement("div");
 var table = document.createElement("table");
 var tbody = document.createElement("tbody");
 var tr = document.createElement("tr");
 var td = document.createElement("td");
 td.appendChild(document.createTextNode(item.description));
 tr.appendChild(td);
 tbody.appendChild(tr);
 table.appendChild(tbody);
 subdiv.appendChild(table);
 div.appendChild(subdiv);
 this.container.insertBefore(div, this.container.firstChild);
 this.descrBlock = subdiv;
 this.textContainer = td;
 } else { this.descrBlock.style.visibility = "visible";
 this.textContainer.innerHTML = "";
 this.textContainer.innerHTML = item.description;
 } this.descrBlock.style.left = (item.X == 3)? 171*item.X - 335 + "px" : 171*item.X - 164 + "px";
 this.descrBlock.style.top = 167*item.Y - 161 + "px";
 document.onmousemove = this.hideInfo.bindAsEventListener(this, img);
 }, hideInfo: function(evt, img) { var x = Event.pointerX(evt);
 var y = Event.pointerY(evt);
 if(!Position.within(img, x, y)) { this.descrBlock.style.visibility = "hidden";
 document.onmousemove = null;
 } } };
 var BrendList = Class.create();
 BrendList.prototype = { initialize: function(content, container) { this.content = content;
 this.container = $(container);
 this.applicationRoot = applicationRoot || "/";
 this.button = $("brendButton");
 this.lastIndex = 1;
 this.fullCount;
 this.browser = new Browser();
 this.initImages(this.content);
 }, initImages: function(content) { this.container.clear();
 var itemList = content["GetItemListResult"];
 this.fullCount = itemList["@Count"];
 if(this.fullCount == 0) return;
 if(itemList["Item"].length != undefined) for(var i=0;
 i<itemList["Item"].length;
 i++) this.addItem(itemList["Item"][i], i);
 else this.addItem(itemList["Item"], 0);
 if(this.fullCount > 4) this.button.onclick = this.getRandom.bindAsEventListener(this);
 }, addItem: function(item, index) { var imageSrc = (item["Properties"]["Property"]["Value"] != null)? this.applicationRoot + item["Properties"]["Property"]["Value"] : this.applicationRoot + "/Images/blank.gif";
 var div = document.createElement("div");
 var cl = "divB"+(index+1);
 Element.addClassName(div, cl);
 var img = document.createElement("img");
 img.src = imageSrc;
 div.appendChild(img);
 this.container.appendChild(div);
 PngTransform.applyTransform(img);
 }, getRandom: function() { var random = parseInt(Math.ceil((Math.random()*(this.fullCount-3))));
 if(random == this.lastIndex && this.fullCount > 10) { this.getRandom();
 return;
 } this.lastIndex = random;
 var block = {category: "itemList", params: {folderId: 0, catalogId: 7}, itemsCount: 4, startIndex: random, filter: [{column: "MainLogo", value: '%', condition: "Like"}], propertyList: ["MainLogo"]};
 var brendBlock = new Block(block);
 brendBlock.getItemList();
 brendBlock.blockCallback = this.newList.bind(this);
 }, newList: function(container, content) { this.initImages(content);
 } };
 var SelfProjects = Class.create();
 SelfProjects.prototype = { initialize: function(content, container) { this.content = content;
 this.container = $(container);
 this.pagerContainer = $("ImagePager");
 this.fotoContainer = null;
 this.itemImages = null;
 this.textContainer = null;
 this.fullCount = content["GetItemListResult"]["@Count"];
 this.curItem = 1;
 this.maxCount = 6;
 this.lastIndex = 6;
 this.curFotoPage = null;
 this.pageCount = Math.ceil(this.fullCount/this.maxCount);
 this.applicationRoot = applicationRoot || "/";
 this.loadPager = new ListPager(this.curItem, this.pageCount, this.pagerContainer, this.loadPage.bind(this));
 this.initImages(this.content);
 }, initImages: function(content) { this.container.clear();
 var itemList = content["GetItemListResult"];
 if(this.fullCount == 0) return;
 if(itemList["Item"].length != undefined) for(var i=0;
 i<itemList["Item"].length;
 i++) this.addItem(itemList["Item"][i], i);
 else this.addItem(itemList["Item"], 0);
 }, addItem: function(item, index) { var props = item["Properties"]["Property"];
 var title = item["Name"];
 var type = item["Description"];
 var imageSrc = this.applicationRoot + props["Value"] /*+ "&w=124&h=89&crop=1"*/;
 var div = document.createElement("div");
 var img = document.createElement("img");
 img.src = imageSrc;
 img.onclick = this.callInfo.bindAsEventListener(this, item["ID"]);
 div.appendChild(img);
 if(title != undefined) { var a = document.createElement("a");
 a.href = "javascript:void(0)";
 a.appendChild(document.createTextNode(title));
 div.appendChild(a);
 a.onclick = this.callInfo.bindAsEventListener(this, item["ID"]);
 } if(type != undefined) { div.appendChild(document.createElement("br"));
 div.appendChild(document.createTextNode(type));
 } this.container.appendChild(div);
 }, loadPage: function(evt, index) { this.curItem = index;
 this.container.clear();
 this.container.innerHTML = "<img src='/Images/preload.gif' style='margin: 200px 0 0 130px' alt=''/>";
 this.pagerContainer.clear();
 this.loadPager = new ListPager(this.curItem, this.pageCount, this.pagerContainer, this.loadPage.bind(this));
 var start = (index == 1)? 1 : index*this.maxCount-this.maxCount+1;
 var block = {category: "itemList", params: {folderId: '', catalogId: 12}, itemsCount: this.maxCount, startIndex: start, filter: [{column: "Client_ItemID", value: 86, condition: "Equal"}], orderSettings: [{column: "ShippingDate", rule: "DESC"}], propertyList: ["MainImage"]};
 var imageBlock = new Block(block);
 imageBlock.getItemList();
 imageBlock.blockCallback = this.imagesList.bind(this);
 }, imagesList: function(container, content) { this.initImages(content);
 }, callInfo: function(evt, itemId) { var block = {category: "item", params: {id: itemId, folderId: '', catalogId: 12}};
 var pBlock = new Block(block);
 pBlock.getItem();
 pBlock.blockCallback = this.initInfo.bind(this);
 }, initInfo: function(content) { var item = content["GetItemResult"];
 this.showInfo(this, item);
 }, sortArray: function(itemList) { var listItems = [];
 var newListItems = [];
 var inFormat = true;
 if(itemList.length == undefined) { var props = itemList["Properties"]["Property"];
 var im = (props[1]["Value"] != null)? props[1]["Value"] : "/Images/blank.gif";
 var comm = (props[0]["Value"] != null)? props[0]["Value"] : "";
 var t = (props[2]["Value"] != null)? props[2]["Value"] : "";
 listItems.push({name: itemList["Name"], comment: comm, image: im, text: t});
 return listItems;
 } else { for(var i=0;
 i<itemList.length;
 i++) { var props = itemList[i]["Properties"]["Property"];
 var im = (props[1]["Value"] != null)? props[1]["Value"] : "/Images/blank.gif";
 var comm = (props[0]["Value"] != null)? props[0]["Value"] : "";
 var t = (props[2]["Value"] != null)? props[2]["Value"] : "";
 listItems.push({name: itemList[i]["Name"], comment: comm, image: im, text: t});
 } for(var i=0;
 i<listItems.length;
 i++) { if(isNaN(parseInt(listItems[i].name.charAt(0)))) { inFormat = false;
 break;
 } } if(inFormat) { newListItems = [];
 for(var i=0;
 i<listItems.length;
 i++) { var j;
 j = parseInt(listItems[i].name.charAt(0));
 if(!isNaN(parseInt(listItems[i].name.charAt(1)))) { var h = j.toString();
 j = parseInt(h + listItems[i].name.charAt(1));
 } newListItems[j] = listItems[i];
 } var newListItems2 = [];
 for(var i=0;
 i<newListItems.length;
 i++) { if(newListItems[i] != undefined && newListItems[i] != null) { var elm = newListItems[i];
 newListItems2.push(elm);
 } } return newListItems2;
 } else return listItems;
 } }, showInfo: function(evt, item) { var props = item["Properties"]["Property"];
 var title = item["Name"];
 var type = item["Desctiption"];
 var wtype = props[1]["Value"];
 var link = props[3]["Value"];
 var linkText = props[2]["Value"];
 var images = props[7]["Value"];
 var mainImageSrc = (props[6]["Value"] != null)? this.applicationRoot + props[6]["Value"] : "/Images/blank.gif";
 var itemImages = this.sortArray(images["Item"]);
 this.itemImages = new Array();
 var div = document.createElement("div");
 Element.addClassName(div, "itemInfo");
 var div2 = document.createElement("div");
 var table = document.createElement("table");
 var tbody = document.createElement("tbody");
 var tr = document.createElement("tr");
 var td = document.createElement("td");
 var fotoDiv = document.createElement("div");
 var fotoDiv2 = document.createElement("div");
 fotoDiv2.style.height = "auto";
 var tDiv = document.createElement("p");
 this.textContainer = tDiv;
 Element.addClassName(fotoDiv, "itemFoto");
 this.fotoContainer = fotoDiv2;
 fotoDiv.appendChild(fotoDiv2);
 fotoDiv.appendChild(tDiv);
 td.appendChild(fotoDiv);
 tDiv.style.textAlign = "center";
 tDiv.style.padding = "0px";
 var pagerDiv = document.createElement("div");
 Element.addClassName(pagerDiv, "itemPager");
 var pDiv = document.createElement("div");
 var table1 = document.createElement("table");
 var tbody1 = document.createElement("tbody");
 var tr1 = document.createElement("tr");
 this.pageContainer = pagerDiv;
 this.pager = table1;
 var td2 = document.createElement("td");
 if(title != undefined) { var h3 = document.createElement("h3");
 h3.appendChild(document.createTextNode(title));
 td2.appendChild(h3);
 } if(type != undefined) { var h5 = document.createElement("h5");
 h5.appendChild(document.createTextNode(type));
 td2.appendChild(h5);
 } var div3 = document.createElement("div");
 div3.innerHTML = wtype;
 td2.appendChild(div3);
 var count = (images["@Count"] == 0)? 1 : parseInt(images["@Count"]);
 for(var i=1;
 i<=count;
 i++) { var pg = document.createElement("a");
 pg.href = "javascript:void(0)";
 pg.appendChild(document.createTextNode(i));
 var td1 = document.createElement("td");
 td1.appendChild(pg);
 var item = {element: pg, props: props, index: i-1};
 if(parseInt(images["@Count"]) != 0) item.images = (itemImages.length == undefined)? itemImages : itemImages[i-1];
 if(i == 1) { this.curFotoPage = item.element;
 Element.addClassName(this.curFotoPage, "active");
 } this.itemImages.push(item);
 if(parseInt(images["@Count"]) != 0) pg.onclick = this.loadItemImage.bindAsEventListener(this, item);
 tr1.appendChild(td1);
 } tbody1.appendChild(tr1);
 table1.appendChild(tbody1);
 pDiv.appendChild(table1);
 pagerDiv.appendChild(pDiv);
 td.appendChild(pagerDiv);
 if(parseInt(images["@Count"]) == 0) { var img = document.createElement("img");
 img.src = mainImageSrc;
 fotoDiv.appendChild(img);
 } else this.loadItemImage(this, this.itemImages[0]);
 var div4 = document.createElement("div");
 var b = document.createElement("b");
 var linkText = (linkText != null)? linkText : "фото готового продукта";
 b.appendChild(document.createTextNode("В жизни:"));
 var a = document.createElement("a");
 if(link != null && link != "" && link != "http://") a.target = "_blank";
 a.href = (link != null && link != "" && link != "http://")? link : "javascript:void(0)";
 a.appendChild(document.createTextNode(linkText));
 div4.appendChild(b);
 div4.appendChild(a);
 td2.appendChild(div4);
 var cl = document.createElement("img");
 cl.src = "/Images/close1.gif";
 cl.alt = "Закрыть";
 cl.onclick = this.removeInfo.bindAsEventListener(this, div);
 tr.appendChild(td);
 tr.appendChild(td2);
 tbody.appendChild(tr);
 table.appendChild(tbody);
 div2.appendChild(table);
 div.appendChild(div2);
 div.appendChild(cl);
 this.container.insertBefore(div, this.container.firstChild);
 }, removeInfo: function(evt, div) { this.curFotoPage = null;
 this.rightArrow = null;
 this.leftArrow = null;
 Element.remove(div);
 }, loadItemImage: function(evt, item) { if(parseInt(item.index) == this.lastIndex) { this.pager.style.left = parseInt(this.pager.offsetLeft) - 24 + "px";
 this.lastIndex++;
 } if(parseInt(item.index) == this.lastIndex-7 && Event.element(evt) == this.leftArrow) { this.pager.style.left = parseInt(this.pager.offsetLeft) + 24 + "px";
 this.lastIndex--;
 } if(parseInt(item.index) == parseInt(this.itemImages.length-1)) { if(this.rightArrow != null) { Element.remove(this.rightArrow);
 this.rightArrow = null;
 } } else { if(this.rightArrow == null) { this.rightArrow = document.createElement("img");
 this.rightArrow.src = "/Images/wR1Arr.gif";
 Element.addClassName(this.rightArrow, "right");
 this.pageContainer.appendChild(this.rightArrow);
 } this.rightArrow.onclick = this.loadItemImage.bindAsEventListener(this, this.itemImages[item.index+1]);
 } if(parseInt(item.index) == 0) { if(this.leftArrow != null) { Element.remove(this.leftArrow);
 this.leftArrow = null;
 } } else { if(this.leftArrow == null) { this.leftArrow = document.createElement("img");
 this.leftArrow.src = "/Images/wL1Arr.gif";
 this.pageContainer.appendChild(this.leftArrow);
 } this.leftArrow.onclick = this.loadItemImage.bindAsEventListener(this, this.itemImages[item.index-1]);
 } if(this.curFotoPage != null) { Element.removeClassName(this.curFotoPage, "active");
 this.curFotoPage = item.element;
 Element.addClassName(this.curFotoPage, "active");
 } this.fotoContainer.innerHTML = "";
 this.textContainer.innerHTML = "";
 var img = document.createElement("img");
 img.src = item.images.image;
 this.fotoContainer.appendChild(img);
 this.textContainer.innerHTML = item.images.comment;
 } };
 
