﻿window.onload = function(){InitializeControls();var mailto = El("mailto");if (mailto != null){mailto.href = "mailto:" + "info" + "@" + "ehome.by";mailto.innerHTML = "info" + "@" + "ehome.by";}
Rotator();};var PostType = { Click: -1, Form: 0 }
var D = new function(){this.HttpRequest;this.IsHttpRequest = false;this.Type = PostType.Click;this.FormID = "";this.Constructor = function(){if (window.XMLHttpRequest){this.HttpRequest = new XMLHttpRequest();this.IsHttpRequest = true;}
else if (window.ActiveXObject){try{this.HttpRequest = new ActiveXObject("Msxml2.XMLHTTP");this.IsHttpRequest = true;}
catch (e){try{this.HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");this.IsHttpRequest = true;}
catch (e){}}}};this.Post = function(xmlRequest, postType, formID){try{this.Type = postType;if (this.Type == PostType.Click){var htmlPanel = El("wait");htmlPanel.style.display = "block";Dialog.SetPosition(htmlPanel);}
if (this.Type == PostType.Form){this.FormID = formID;Dialog.SetWaitMode(this.FormID);}
if (!this.HttpRequest)
this.Constructor();this.HttpRequest.open("POST", "Dinamic.ashx" + window.location.search, true);this.HttpRequest.onreadystatechange = this.PostHandler;this.HttpRequest.send(xmlRequest);}	
catch (e){alert(e.message);}
return false;};this.PostHandler = function(){if (D.HttpRequest.readyState == 4){if (D.HttpRequest.status == 200){try{var response = eval(D.HttpRequest.responseText);if (response.Error.length != 0){if (D.Type == PostType.Form){Dialog.SetMessage(D.FormID, response.Error);}
else{alert(response.Error);}}
else{for (index = 0; index < response.Refresh.length; index++){El(response.Refresh[index].Id).innerHTML = response.Refresh[index].Html;}
if (response.CloseForm.length != 0){Dialog.Hide(D.FormID);Dialog.Reset(D.FormID);}
if (response.UpdateForm.length != 0){Dialog.SetCompleteMode(D.FormID, response.UpdateForm);Dialog.Reset(D.FormID);}
if (response.LoadForm.length != 0){for (index = 0; index < response.LoadForm.length; index++){El(response.LoadForm[index].Id).innerHTML = response.LoadForm[index].Html;Dialog.SetDataMode(D.FormID);}}
if (response.Cookie.length != 0){document.cookie = response.Cookie;}
if (response.Url.length != 0){window.location = response.Url;}
InitializeControls();}}
catch (e){alert(e.message);}}
else{if (D.Type == PostType.Form){Dialog.SetMessage(D.FormID, "Сервер не отвечает, попробуйте повторить позже.");}}
if (D.Type == PostType.Click){El("wait").style.display = "none";}}};this.Close = function(name, value, ev){try{if (!ev){ev = window.event;}
ev.cancelBubble = true;this.Post(
(typeof(value) != "undefined") ? 
"<Action id=\"" + name + "\" cookies=\"" + Cookie.Load("state") + "\" value=\"" + value + "\" />" :
"<Action id=\"" + name + "\" cookies=\"" + Cookie.Load("state") + "\" />",
PostType.Click);}	
catch (e){alert(e.message);}
return false;};this.C = function(name, value, event1){try{
		
this.Post(
(typeof(value) != "undefined" || value != null) ? 
"<Action id=\"" + name + "\" cookies=\"" + Cookie.Load("state") + "\" value=\"" + value + "\" />" :
"<Action id=\"" + name + "\" cookies=\"" + Cookie.Load("state") + "\" />",
PostType.Click);}	
catch (e){alert(e.message);}
return false;};this.FormValue = function(value){value = value.replace(/&/g, "&amp;");value = value.replace(/</g, "&lt;")
value = value.replace(/>/g, "&gt;")
value = value.replace(/\"/g, "&quot;")
return value;};this.Load2 = function(name, action, id){var xml = "<Action id=\"" + action + "\" key=\"" + id + "\" cookies=\"" + Cookie.Load("state") + "\">";xml += "<Item id=\"FormID\" value=\"" + name + "\"/>";xml += "</Action>";this.Post(xml, PostType.Form, name);}
this.Submit = function(id, action){try{var xml = "<Action id=\"" + action + "\" cookies=\"" + Cookie.Load("state") + "\">";var inputs = NEl("textarea", "Form_" + id);for (var index = 0; index < inputs.length; index++){var input = inputs[index];xml += "<Item id=\"" + input.id + "\" value=\"" + D.FormValue(input.value) + "\"/>";}
var inputs = NEl("iframe", "Form_" + id);for (var index = 0; index < inputs.length; index++){var input = inputs[index];xml += "<Item id=\"" + input.id + "\" value=\"" + D.FormValue(editorDocument.body.innerHTML) + "\"/>";}
var inputs = NEl("select", "Form_" + id);for (var index = 0; index < inputs.length; index++){var input = inputs[index];xml += "<Item id=\"" + input.id + "\" value=\"" + input.value + "\"/>";}
var inputs = NEl("input", "Form_" + id);for (var index = 0; index < inputs.length; index++){var input = inputs[index];if (input.tagName.toLowerCase() == "input" &&
input.type.toLowerCase() != "button" &&
input.type.toLowerCase() != "image" &&
input.id != ""){if (input.type.toLowerCase() == "checkbox" ||
input.type.toLowerCase() == "radio"){if (input.checked)
xml += "<Item id=\"" + input.id + "\" value=\"1\"/>";}
else{xml += "<Item id=\"" + input.id + "\" value=\"" + D.FormValue(input.value) + "\"/>";}	}}
xml += "</Action>";this.Post(xml, PostType.Form, id);}	
catch (e){alert(e.message);}
return false;};this.SubmitForum = function(id, action, emptyId){try{if (editorDocument.body.innerHTML == "<br>" ||
editorDocument.body.innerHTML == ""){Dialog.Show(emptyId);return false;}
var xml = "<Action id=\"" + action + "\" cookies=\"" + Cookie.Load("state") + "\">";xml += "<Item id=\"FormID\" value=\"" + id + "\"/>";xml += "<Item id=\"WYSIWYGEditor\" value=\"" + D.FormValue(editorDocument.body.innerHTML) + "\"/>";xml += "</Action>";this.Post(xml, PostType.Click, "");}	
catch (e){alert(e.message);}
return false;};}
var DF ={Submit: function(f){try{f.submit();}
catch (e){alert(e.message);}
return true;},
Loaded: function(id, formID){try{var i = document.getElementById(id);var d = window.frames[id].document;if (d && d.location.href == "about:blank"){return;}
try{var response = eval(d.body.innerHTML);if (response.CloseForm.length != 0){Dialog.Hide(response.CloseForm);Dialog.Reset(response.CloseForm);}
if (response.Action.length != 0){top.D.C(response.Action);}
    
			    }
catch (e){alert(e.message);}}
catch (e){alert(e.message);}}}
function InitializeControls(){try{XFocus.Init("table");var searchBox = El("searchBox");if (searchBox != null){if (searchBox.value == "" || searchBox.value == "Поиск"){searchBox.style.fontStyle = "italic";searchBox.style.color = "#999999";searchBox.value = "Поиск";}
searchBox.onfocus = function(){if (this.value == "Поиск"){this.style.fontStyle = "normal";this.style.color = "#000000";this.value = "";}};searchBox.onblur = function(){if (this.value == ""){this.style.fontStyle = "italic";this.style.color = "#999999";this.value = "Поиск";}};}
var searchType = El("searchType");if (searchType != null){searchType.onclick = function(){var searchTypeBox = El("searchTypeBox");searchTypeBox.style.display =(searchTypeBox.style.display != "block") ? "block" : "none";ShowLinkedElement(this, searchTypeBox, 21, 1);};}
var links = document.getElementsByTagName("a");for (var linkIndex = 0; linkIndex < links.length; linkIndex++){				
if (links[linkIndex].className == "itemButton"){links[linkIndex].onfocus = function(){this.style.backgroundPosition = this.style.backgroundPosition.split(" ")[0] + " 0";};links[linkIndex].onblur = function(){this.style.backgroundPosition = this.style.backgroundPosition.split(" ")[0] + " -52px";};links[linkIndex].onmouseover = function(){this.style.backgroundPosition = this.style.backgroundPosition.split(" ")[0] + " 0";};links[linkIndex].onmouseout = function(){this.style.backgroundPosition = this.style.backgroundPosition.split(" ")[0] + " -52px";};}}
var elements = document.getElementsByTagName("div");for (index = 0; index < elements.length; index++){var position = elements[index].id.indexOf("CategoryHeader.");if (position != -1){var categoryData = El("CategoryData." + elements[index].id.substring("CategoryHeader.".length));var categoryHeader = elements[index].getElementsByTagName("a")[0];if (Cookie.Load(categoryData.id) == "-1"){categoryHeader.className = "Collapse";categoryData.style.display = "block";}
else{categoryHeader.className = "Expand";}
var visiblePanel = false
if (categoryData.style.display != "none"){visiblePanel = true;}
categoryData.style.display = "block";categoryData.style.height = categoryData.offsetHeight + "px";if (!visiblePanel){categoryData.style.display = "none";}
new Toggle(categoryHeader, categoryData);}}}
catch (e){alert(e.message);}}
var XFocus = new function(){this.Init = function(controlName){var objects = NEl(controlName);for (var index = 0; index < objects.length; index++){objects[index].onfocus = this.FocusIn;objects[index].onblur = this.FocusOut;objects[index].onmouseover = this.FocusIn;objects[index].onmouseout = this.FocusOut;}}
this.FocusIn = function(cn, ev){try{switch (this.className){case "X2":
if (!ev)
ev = window.event;if (ev)
ev.cancelBubble = true;this.parentNode.parentNode.style.backgroundColor = '#ff696e';break;}}
catch (e){alert(e.message);}};this.FocusOut = function(cn, event1){};}
function El(id){return document.getElementById(id);}
function NEl(name, id){return (typeof(id) == "undefined") ?
document.getElementsByTagName(name) :
El(id).getElementsByTagName(name);}
function SubmitHandler(url, form){try{var resultUrl = "";if (form.id == "SearchForm"){if (El("searchBox").value == "" || El("searchBox").value == "Поиск"){return false;}
resultUrl = url.replace("{0}", encodeURIComponent(El("searchBox").value)).replace("{1}", encodeURIComponent(El("searchTypeValue").value))}
if (form.id == "FilterForm"){var parameters = "";var formInputs = form.getElementsByTagName("input");for (var index = 0; index < formInputs.length; index++){var formInput = formInputs[index];if (formInput.type.toLowerCase() == "checkbox"){if (formInput.checked)
parameters += formInput.id + ";";}
if (formInput.type.toLowerCase() == "text"){if (formInput.value.length > 0)
parameters += formInput.id + "=" + formInput.value + ";";}	}
resultUrl = url.replace("{0}", encodeURIComponent(parameters))}
window.location = resultUrl;}
catch (ex){}
return false;}
function ShowLinkedElement(htmlButton, htmlPanel, x, y){var vXOffset = 0;var vYOffset = 0;var htmlElement = htmlButton;while (htmlElement != null){vXOffset += htmlElement.offsetTop;vYOffset += htmlElement.offsetLeft;htmlElement = htmlElement.offsetParent;}
htmlPanel.style.top = (vXOffset + x + "px");htmlPanel.style.left = (vYOffset + y + "px");}
var Dialog = new function(){this.linkedButton = null;this.LinkedShow = function(htmlButton, formId, action, key){try{var htmlPanel = El("Dialog." + formId).parentNode.parentNode.parentNode;ShowLinkedElement(htmlButton, htmlPanel, 22, 1);if (this.linkedButton == htmlButton){htmlPanel.style.display = (htmlPanel.style.display == "block") ? "none" : "block";}
else{this.linkedButton = htmlButton;htmlPanel.style.display = "block";El("Data." + formId).style.height = "40px";El("Error." + formId).innerHTML = "";D.Load2(formId, action, key);}}
catch (e){alert(e.message);}
return false;}
this.SetPosition = function(htmlPanel){var body = document.body;var html = body.parentNode;windowWidth = html.clientWidth;windowHeight = html.clientHeight;if (window.opera){windowHeight = (html.clientHeight == body.offsetHeight) ? body.clientHeight : html.clientHeight;}
htmlPanel.style.left = (windowWidth - htmlPanel.clientWidth) / 2 + "px";htmlPanel.style.top = (windowHeight - htmlPanel.clientHeight) / 2 + Math.max(body.scrollTop, html.scrollTop) + "px";}
this.Show = function(id, parameters){try{if (typeof(parameters) != "undefined"){var inputs = NEl("input", "Form_" + id);for (i = 0; i < parameters.length; i += 2){for (var j = 0; j < inputs.length; j++){if (inputs[j].id == parameters[i]){inputs[j].value = parameters[i + 1];break;}}}}
var htmlPanel = El("Dialog." + id).parentNode.parentNode.parentNode;this.SetZIndex(htmlPanel);htmlPanel.style.display = (htmlPanel.style.display != "block") ? "block" : "none";this.SetPosition(htmlPanel);if (D.HttpRequest != null){if (D.HttpRequest.readyState != 0 && D.HttpRequest.readyState != 4){D.HttpRequest.abort();}}
this.SetDataMode(id);El("Error." + id).innerHTML = "";El("Caption." + id).onmousedown = Dialog.Moving;}
catch (e){alert(e.message);}
return false;}
this.Load = function(id, action, value){Dialog.Show(id);D.Load2(id, action, value);}
this.SetZIndex = function(htmlPanel){var htmlPanels = NEl("div");for (var index = 0; index < htmlPanels.length; index++){if (htmlPanels[index].id.indexOf("Dialog.") != -1 &&
htmlPanel != htmlPanels[index]){var zIndex = parseInt(htmlPanels[index].style.zIndex);if (zIndex > 0){htmlPanels[index].style.zIndex = zIndex - 1;}}}
htmlPanel.style.zIndex = 1;}
this.Hide = function(id){try{El("Dialog." + id).parentNode.parentNode.parentNode.style.display = "none";}
catch (e){alert(e.message);}
return false;}
this.SetWaitMode = function(id){try{El("Wait." + id).style.height = (El("Data." + id).clientHeight + "px");El("Wait." + id).style.display = "block";El("Data." + id).style.display = "none";var links = NEl("a", "Dialog." + id);for (index = 1; index < links.length; index ++){links[index].style.display = "none";}}
catch (e){alert(e.message);}
return false;}
this.SetCompleteMode = function(id, html){try{El("Wait." + id).style.display = "none";El("Data." + id).style.display = "none";El("Result." + id).innerHTML = html;El("Result." + id).style.display = "block";var links = NEl("a", "Dialog." + id);for (index = 1; index < links.length - 1; index ++){links[index].style.display = "block";}}
catch (e){alert(e.message);}
return false;}
this.SetDataMode = function(id){try{El("Data." + id).style.display = "block";El("Wait." + id).style.display = "none";El("Result." + id).style.display = "none";var links = NEl("a", "Dialog." + id);for (index = 1; index < links.length; index ++){links[index].style.display = "block";}}
catch (e){alert(e.message);}
return false;}
this.SetMessage = function(id, message){try{El("Error." + id).innerHTML = message;}
catch (e){alert(e.message);}
return false;}
this.Reset = function(id){try{El("Form_" + id).reset();}
catch (e){alert(e.message);}
return false;}
this.Moving = function(event){try{var ev = event || window.event;var htmlCaption = this;var htmlPanel = htmlCaption.parentNode.parentNode.parentNode.parentNode;Dialog.SetZIndex(htmlPanel);var offsetX = htmlPanel.offsetLeft - ev.clientX;var offsetY = htmlPanel.offsetTop - ev.clientY;(ev.stopPropagation) ? ev.stopPropagation() : ev.cancelBubble = true;(ev.preventDefault) ? ev.preventDefault() : ev.returnValue = false;htmlCaption.MoveHandler = function(event){var ev = event || window.event;if (navigator.appName == "Microsoft Internet Explorer"){if (ev.button == 0){document.onmousemove = null;return;}}
htmlPanel.style.opacity = "0.6";if (ev.clientX + offsetX + htmlPanel.clientWidth < document.body.parentNode.scrollWidth &&
ev.clientX + offsetX > 0){htmlPanel.style.left = (ev.clientX + offsetX) + "px";}
if (ev.clientY + offsetY + htmlPanel.clientHeight < document.body.parentNode.scrollHeight &&
ev.clientY + offsetY > 0){htmlPanel.style.top = (ev.clientY + offsetY) + "px";}
(ev.stopPropagation) ? ev.stopPropagation() : ev.cancelBubble = true;(ev.preventDefault) ? ev.preventDefault() : ev.returnValue = false;}
htmlCaption.MouseUpHandler = function(event){htmlPanel.style.opacity = "1.0";document.onmousemove = null;}
document.onmousemove = htmlCaption.MoveHandler;document.onmouseup = htmlCaption.MouseUpHandler;}
catch (e){alert(e.message);}}}
function Toggle(htmlHeader, htmlBody){var $ = this;$.duration = 400;$.startTime = null;$.timerId = null;$.state = 0;$.headerPanel = htmlHeader;$.bodyPanel = htmlBody;$.length = parseInt(($.bodyPanel.style.display == "none") ? $.bodyPanel.style.height : $.bodyPanel.offsetHeight);$.Click = function(){if ($.bodyPanel != null){
		
			
$.headerPanel.className = ($.headerPanel.className != "Expand") ? "Expand" : "Collapse";$.startTime = new Date();$.state = ($.bodyPanel.style.display == "none") ? -1 : 1;if ($.timerId != null){clearInterval($.timerId);$.timerId = null;}
$.timerId = setInterval($.Processing, 15);}
return false;}
$.headerPanel.onclick = $.Click;$.Processing = function(){var stepTime = new Date();if (stepTime - $.startTime > $.duration){clearInterval($.timerId);$.timerId = null;if ($.state == 1){$.bodyPanel.style.height = "0px";$.bodyPanel.style.display = "none";}
else{$.bodyPanel.style.height = parseInt($.length) + "px";$.bodyPanel.style.display = "block";}
Cookie.Save($.bodyPanel.id, $.state);}
else{$.bodyPanel.style.display = "block";var n = stepTime - $.startTime;pos = ($.state * (n /= $.duration) * (n - 2));now = (pos > 0) ? ($.length * pos) : ($.length + ($.length * pos));$.bodyPanel.style.height = parseInt(now) + "px";}}}
var Cookie ={Save : function(name, value, minutes){var expires = "";document.cookie = name + "=" + value + expires + "; path=/";},
 
Load : function(name){ 		var cookieName = name + "=";var cookiePairs = document.cookie.split(";");for (var index = 0; index < cookiePairs.length; index++){var cookiePair = cookiePairs[index];var startIndex = cookiePair.indexOf(cookieName)
if (startIndex != -1){return unescape(cookiePair.substring(startIndex + cookieName.length, cookiePair.length));}}
 
return "";}}
function Rotator(){var $ = this;$.change = 7000;$.duration = 400;$.startTime = null;$.timerId = null;$.outTimerId = null;$.direction = -1;$.bodyPanel = null;$.navigationPanel = null;$.navigationItems = null;$.marginLeft = 0;$.count = 0;$.width = 180;$.index = 0;$.Init = function(){try{$.bodyPanel = document.getElementById("list");$.count = $.bodyPanel.getElementsByTagName("li").length;var lastLi = document.createElement("li");lastLi.innerHTML = $.bodyPanel.getElementsByTagName("li")[0].innerHTML;$.bodyPanel.appendChild(lastLi);$.bodyPanel.style.width = (($.count + 1) * $.width + "px");$.navigationPanel = document.getElementById("navigation");$.navigationItems = $.navigationPanel.getElementsByTagName("li");$.navigationItems[$.index].style.background = "#ffffff";for (var index = 0; index < $.navigationItems.length; index++){$.navigationItems[index].onclick = $.GoTo;$.navigationItems[index].index = index;}
$.outTimerId = setInterval($.Step, $.change);}
catch (e){}}
$.GoTo = function(){if ($.outTimerId != null){clearInterval($.outTimerId);$.outTimerId = null;}
for (var index = 0; index < $.navigationItems.length; index++){if ($.navigationItems[index] == this){$.index = index;$.navigationItems[index].style.background = "#ffffff";}
else{$.navigationItems[index].style.background = "transparent";}}
$.marginLeft = $.index * $.width * $.direction;$.bodyPanel.style.marginLeft = $.marginLeft + "px";}
$.Step = function(){if ($.bodyPanel != null){$.startTime = new Date();if ($.timerId != null){clearInterval($.timerId);$.timerId = null;}
$.timerId = setInterval($.Processing, 15);}}
$.Processing = function(){var stepTime = new Date();if (stepTime - $.startTime > $.duration){clearInterval($.timerId);$.timerId = null;$.index += 1;if ($.index >= $.count){$.index = 0}
$.navigationPanel.getElementsByTagName("li")[$.index].style.background = "#ffffff";$.navigationPanel.getElementsByTagName("li")[($.index > 0) ? $.index - 1 : $.count - 1].style.background = "transparent";$.marginLeft = $.index * $.width * $.direction;$.bodyPanel.style.marginLeft = $.marginLeft + "px";}
else{var n = stepTime - $.startTime;var pos = ($.direction * (n /= $.duration) * (n - 2));$.bodyPanel.style.marginLeft = (($.index * $.width) + ((pos > 0) ? $.width * pos : $.width * pos + $.width)) * $.direction + "px";}}
$.Init();}
function setCaretPosition(elemId, caretPos){var elem = document.getElementById(elemId);    if(elem != null)
    {        if(elem.createTextRange)
        {            var range = elem.createTextRange();            range.move('character', caretPos);            range.select();        }
        else
        {            if(elem.selectionStart)
            {                elem.focus();                elem.setSelectionRange(caretPos, caretPos);            }
            else
            {                elem.focus();            }
        }
    }}
var WE ={Init: function(url){editorUrl = url;editorFrame = frames["WYSIWYGEditor"] ? frames["WYSIWYGEditor"] : El("WYSIWYGEditor");if (editorFrame){editorWindow = editorFrame.contentWindow || editorFrame.window;editorDocument = editorFrame.contentDocument || editorFrame.document;if (editorDocument.body){editorDocument.body.style.padding = "5px";editorDocument.body.style.margin = "0";editorDocument.body.style.font = "normal 12pt arial";}
editorDocument.designMode = "on";}},
InsertHtml: function(html){editorWindow.focus();if (editorDocument.body){if (navigator.appVersion.indexOf("MSIE") != -1){var range = editorDocument.selection.createRange();range.pasteHTML(html);range.collapse(false);range.select();}
else{editorDocument.execCommand("InsertHTML", null, html);}}	},
InsertImage: function(name){WE.InsertHtml("<img alt=\"\" src=\"" + editorUrl + "Smiles/" + name + ".gif\" />");return false;},
Reply : function(name, messageId){var message = El("Message" + messageId).cloneNode(true);for (index = 0; index < message.children.length; index ++){if (message.children[index].className == "replyMessage"){message.removeChild(message.children[index]);break;}}
var html = "<div id=\"" + messageId + "\" class=\"replyMessage\" style=\"margin-bottom:5px;padding:5px;background:#E3EFFF;font:normal 10pt arial;border:solid 1px #b7d4f7;\">" + message.innerHTML + "</div>";if (!editorDocument.selection){html += "<br/>";}
WE.InsertHtml(html);return false;}}
function OpenSocial(template){template = template.replace("{0}", encodeURIComponent(location.href)).replace("{1}", encodeURIComponent(document.title));{window.open(template, "SocialWindow", "menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,width=800,height=600");}}

