
window.onload = function() { initLinks() }

	var isIE = (navigator.appName == "Microsoft Internet Explorer");
	var isFF = (!isIE && !(navigator.appVersion.indexOf("MSIE")>-1));
	var isOPR = (navigator.userAgent.indexOf("Opera")!=-1);
	var isIE6 = navigator.userAgent.indexOf("MSIE 6.0") >= 0;
	var isIE7 = navigator.userAgent.indexOf("MSIE 7.0") >= 0;
	var isIE8 = navigator.userAgent.indexOf("MSIE 8.0") >= 0;
	if (isOPR || isIE7) { isIE = false; }

function initLinks()
	{
	
	var menuL = document.getElementById('menu').getElementsByTagName('IMG');
	function $A(C){if(!C){return[]}if(C.toArray){return C.toArray()}var B=C.length||0,A=new Array(B);while(B--){A[B]=C[B]}return A}Object.extend=function(A,C){for(var B in C){A[B]=C[B]}return A};Object.extend(Object,{inspect:function(A){try{if(Object.isUndefined(A)){return"undefined"}if(A===null){return"null"}return A.inspect?A.inspect():A.toString()}catch(B){if(B instanceof RangeError){return"..."}throw B}},toQueryString:function(A){return $H(A).toQueryString()},toHTML:function(A){return A&&A.toHTML?A.toHTML():String.interpret(A)},keys:function(A){var B=[];for(var C in A){B.push(C)}return B},values:function(B){var A=[];for(var C in B){A.push(B[C])}return A},isElement:function(A){return A&&A.nodeType==1},isArray:function(A){return A&&A.constructor===Array},isHash:function(A){return A instanceof Hash},isFunction:function(A){return typeof A=="function"},isString:function(A){return typeof A=="string"},isNumber:function(A){return typeof A=="number"},isUndefined:function(A){return typeof A=="undefined"}});var Class={create:function(){var E=null,D=$A(arguments);if(Object.isFunction(D[0])){E=D.shift()}function A(){this.initialize.apply(this,arguments)}Object.extend(A,Class.Methods);A.superclass=E;A.subclasses=[];if(E){var B=function(){};B.prototype=E.prototype;A.prototype=new B;E.subclasses.push(A)}for(var C=0;C<D.length;C++){A.addMethods(D[C])}if(!A.prototype.initialize){A.prototype.initialize=function(){}}A.prototype.constructor=A;return A}};Class.Methods={addMethods:function(G){var C=this.superclass&&this.superclass.prototype;var B=Object.keys(G);if(!Object.keys({toString:true}).length){B.push("toString","valueOf")}for(var A=0,D=B.length;A<D;A++){var F=B[A],E=G[F];if(C&&Object.isFunction(E)&&E.argumentNames().first()=="$super"){var H=E,E=Object.extend((function(I){return function(){return C[I].apply(this,arguments)}})(F).wrap(H),{valueOf:function(){return H},toString:function(){return H.toString()}})}this.prototype[F]=E}return this}};



	

	var xPos;
	var yPos;

	for (i=0; i<menuL.length; i++)
		{
		if (menuL[i].parentNode.href && !/\_a.gif$/.test(menuL[i].src))
			{
			menuL[i].onmouseover = function () { if (!/\._a.gif\$/.test(this.src)) { this.src = this.src.replace('.gif', '_a.gif'); } }
			menuL[i].onmouseout = function () { this.src = this.src.replace('_a.gif', '.gif'); }
			}
		}

	if (document.getElementById('services'))
		{

		var servicesL = document.getElementById('services').getElementsByTagName('IMG');
		for (i=0; i<servicesL.length; i++)
			{
			if (servicesL[i].parentNode.href)
				{
				servicesL[i].onmouseover = function () { if (!/\._a.gif\$/.test(this.src)) this.src = this.src.replace('.gif', '_a.gif'); }
				servicesL[i].onmouseout = function () { this.src = this.src.replace('_a.gif', '.gif'); }
				}
			}
		}
	}


	var $ = function(id)
		{
		return document.getElementById(id)
		}


	function getElementsByClass(searchClass,node,tag)
		{
        var classElements = new Array();
        if (node == null) node = document;
        if (tag == null) tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++)
        	{
			if (pattern.test(els[i].className))
				{
				classElements[j] = els[i];
				j++;
				}
			}
		return classElements;
		}


	var prevComment;
	var prevCommentIH;
	var answerForm = '';
	function commentAnswer(parent_id)
		{
		formsList = getElementsByClass('add_comment');
		for (i=0; i<formsList.length; i++)
			{
			formsList[i].style.innerHTML = 'commentAnswer('+formsList[i].id.replace('answer_','')+'); return false;" href="#">ответить</a>';
			}

//		$('new_comment_form').style.display = 'none';

		if (prevComment)
			{
			prevComment.innerHTML = prevCommentIH;
			}
		prevComment = $('answer_'+parent_id);
		prevCommentIH = $('answer_'+parent_id).innerHTML;

		answerForm = '<div class="add_comment">\r\n';
		answerForm += '<form method="post" action="/work/comment.work.html" target="server">\r\n';
		answerForm += '<input type="hidden" name="parent_id" value="'+parent_id+'" />\r\n';
		answerForm += '<p class="name"><small>имя</small><input type="text" id="name" name="title" /><span class="error" id="err_title_'+parent_id+'"></span></p>\r\n';
		answerForm += '<p class="email"><small>e-mail</small><input type="text" id="email" name="email" /><span class="error" id="err_email_'+parent_id+'"></span></p>\r\n';
		answerForm += '<p class="txt"><small>текст</small><textarea id="txt" name="text"></textarea><span class="error" id="err_text_'+parent_id+'"></span></p>\r\n';
		answerForm += '<p class="captcha"><img src="/api/capcha.api.php"/><input type="text" id="capcha" name="capcha" /><span class="error" id="err_capcha_'+parent_id+'"></span></p>\r\n';
		answerForm += '<span><input type="submit" value="написать" /></span>\r\n';
		answerForm += '</form>';
		answerForm += '</div>';
		document.getElementById('answer_'+parent_id).innerHTML = answerForm;
		return false;
		}


	//аякс
	function getHTTP()
		{
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
			try
				{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					}
				catch (E)
					{
					xmlhttp = false;
					}
				}
		@else
			xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
			{
			try
				{
				xmlhttp = new XMLHttpRequest();
				}
			catch (e)
				{
				xmlhttp = false;
				}
			}
		return xmlhttp;
		}

	function lookup(lookupSettings)
		{
		if (!lookupSettings) lookupSettings = new Object();

		if (!lookupSettings.values)   lookupSettings.values   = '';
		if (!lookupSettings.dest)  lookupSettings.dest = false;
		if (!lookupSettings.cache)  lookupSettings.cache = false;
		if (!lookupSettings.postFunction)   lookupSettings.postFunction   = '';


		if (lookupSettings.url)
			{
			if (lookupSettings.cache && cacheStore[lookupSettings.url+'?'+lookupSettings.values])
				{
				try { document.getElementById(lookupSettings.dest).innerHTML = cacheStore[lookupSettings.url+'?'+lookupSettings.values].responseText }
				catch (e) { }
				if (lookupSettings.postFunction) lookupSettings.postFunction(cacheStore[lookupSettings.url+'?'+lookupSettings.values]);
				}
			else
				{
				this.working = false;
				if (!this.working && (this.http = getHTTP()))
					{
					var http = this.http;
					this.http.open("POST", lookupSettings.url, true);
					this.http.onreadystatechange = function()
						{
						if (http.readyState == 4)
							{
							if (lookupSettings.cache)
								{
								cacheStore[lookupSettings.url+'?'+lookupSettings.values] = http;
								}
							try { destObj = document.getElementById(lookupSettings.dest).innerHTML = http.responseText }
							catch (e) { }
							if (lookupSettings.postFunction) lookupSettings.postFunction(http);
							this.working = false;
							this.http = false;
							}
						}
					this.working = true;
					this.http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					this.http.send(lookupSettings.values);
					}
				}
			}
		}
