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 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;
};
	
// Сахер
var $ = function(id)
{
    return document.getElementById(id);
}
window.onload = function()
{
//    if ($('main_menu')) menuInit($('main_menu'));
//    if ($('days')) menuInit($('days'));
}
	
var Box = {

    openWin: function(obj, filter)
    {
	if (!$('imgbox') && !$('imgdark'))
	{
	    imageDark = document.createElement('div');
	    imageDark.id = 'imgdark';
	    imageDark.style.background = '#000';
	    if (isIE || isIE7)
		imageDark.style.filter = 'Alpha(opacity=60)';
	    else
		imageDark.style.opacity = '0.6';

	    if (!isIE)
	    {
		imageDark.style.position = 'fixed';
		imageDark.style.top = '0';
	    }
	    else
	    {
		imageDark.style.position = 'absolute';
	    }

	    imageDark.style.left = '0';
	    imageDark.style.bottom = '0';
	    imageDark.style.right = '0';
	    imageDark.style.zIndex = '1000';

	    //imageDark.style.border = 'solid 1px red';
	    imageDark.onclick = function() {
		$('imgbox').style.display = 'none';
		$('imgdark').style.display = 'none'
	    }
	    document.getElementsByTagName('body')[0].appendChild(imageDark)

	    imageBox = document.createElement('div');
	    if (!isIE)
	    {
		imageBox.style.position = 'fixed';
		imageBox.style.top = '50%';
		imageDark.style.height = '100%';
		imageDark.style.width = '100%';
	    }
	    else
	    {
		imageBox.style.position = 'absolute';
		imageBox.style.top = document.documentElement.scrollTop +150+'px';
		imageDark.style.top = document.documentElement.scrollTop;
		imageDark.style.height = document.documentElement.clientHeight + 'px';
		imageDark.style.width = document.documentElement.clientWidth + 'px';
	    }

	    imageBox.id = 'imgbox';
	    imageBox.style.background = '#fff';
	    imageBox.style.padding = '15px';
	    imageBox.style.left = '50%';
	    imageBox.style.zIndex = '1001';
	    imageBox.style.marginLeft = '-32px';
	    imageBox.style.marginTop = '-32px';
	    document.getElementsByTagName('body')[0].appendChild(imageBox);

	}
	$('imgbox').style.width = 'auto';
	openedImage = '<img style="visibility: hidden" onload="Box.winPosition(this)" alt="'+obj.title.replace('"', '')+'" id="loading_img" src="'+obj.rel+(filter?'/':'')+filter+'" />';
	$('imgdark').innerHTML = openedImage;

	$('imgbox').style.marginLeft = '-32px';
	$('imgbox').style.marginTop = '-32px';
	$('imgbox').style.display = 'block';
	$('imgdark').style.display = 'block';
	$('imgbox').innerHTML = '<img alt="x" style="position: absolute; right: -8px; top: -8px; cursor: pointer;" onclick="$(\'imgbox\').style.display = \'none\'; $(\'imgdark\').style.display = \'none\'" src="/images/x.gif" /><img id="boxed_img" alt="" src="/images/pl.gif" />';

	if (isIE) window.onscroll = function()
	{
	    $('imgbox').style.top = document.documentElement.scrollTop + 150 +'px';
	    $('imgdark').style.top = document.documentElement.scrollTop + 'px';
	}

	if (isIE) window.onresize = function()
	{
	    imageDark.style.height = document.documentElement.clientHeight + 'px';
	    imageDark.style.width = document.documentElement.clientWidth + 'px';
	}

	return false;
    },

    winPosition: function(obj)
    {
	$('boxed_img').src=obj.src;

	$('imgbox').innerHTML += (obj.alt?'<p style="font-size: 1.2em">'+obj.alt+'</p>':'')
	$('imgbox').style.width = obj.offsetWidth + 'px';

	if (!isIE)
	    $('imgbox').style.marginTop=-(parseInt(obj.offsetHeight/2))+'px';
	$('imgbox').style.marginLeft=-(parseInt(obj.offsetWidth/2))+'px';
    }
}

// Комплитар
var Autocompleter = { }
Autocompleter = Class.create({
    initialize: function(element, url) {

	var autocompleter = this;

	this.id = element;
	this.selected = null;
	this.lis = new Array;
	this.input = null;
	this.url = url;
	this.focused = false;

	autocompleter.ac = {};

	this.input = $(this.id);
	//$(this.id).autocomplete = 'off';
	this.input.onkeyup = function(event) {
	    if (!this.value && $('ac_'+this.id) && !autocompleter.focused) {
		$('ac_'+this.id).style.display='none';
	    }
	    autocompleter.autocomplete(autocompleter, event, this);
	    return false
	};
	this.input.onblur = function() {
	    if ($('education')) cloneEdu($('education'));
	    if ($('ac_'+this.id)) $('ac_'+this.id).style.display = 'none'
	};
	this.input.onfocus = function(event) {
	    if (this.value == '') autocompleter.acFocus(autocompleter, this, event)
	}
	this.initialized = true;
    },

    autocomplete: function(autocompleter, event, obj) {
	//$('test').innerHTML += this.selected + '<br />';
	event = event || window.event;
	//obj.autocomplete = 'off';

	if ((event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13) && obj.value)
	{
	    autocompleter.focused = false;
	    obj.onkeydown = function(event) {
		autocompleter.autocompleteNavigation(autocompleter,event)
	    }

	    lookup({
		url:'/api/'+autocompleter.url,
		values:'query='+encodeURIComponent(obj.value),
		postFunction: function(transport)
		{
		    if (!$('ac_'+obj.id))
		    {
			newAC = document.createElement('span')
			newAC.id = 'ac_'+obj.id;
			newAC.className = 'autocompliter';
			newAC.style.position = 'absolute';
			newAC.style.zIndex = '20';
			obj.parentNode.style.position = 'relative';
			newAC.style.top = obj.offsetHeight + obj.offsetTop + 'px';
			obj.parentNode.appendChild(newAC);
			autocompleter.ac = newAC;
		    }

		    autocompleter.ac.style.display = 'block';
		    autocompleter.ac.innerHTML = transport.responseText;
		    //$('test').innerHTML = newAC.innerHTML;
		    autocompleter.lis = $(autocompleter.ac.id).getElementsByTagName('a');
		    autocompleter.selected = null;
		    for (i=0; i<autocompleter.lis.length; i++)
		    {
			//$('test').innerHTML += this.lis[i]+'<br />'
			autocompleter.lis[i].num = i;
			autocompleter.lis[i].onmousedown = function() {
			    obj.value = this.innerHTML.replace(/<small>(.*?)<\/small>/i,'');
			    obj.value = obj.value.replace(/<(.*?)>/ig,'');
			    if ($(obj.id+'_id')) {
				$(obj.id+'_id').value=this.id;
			    }
			    $('ac_'+obj.id).style.display = 'none';
			}
			autocompleter.lis[i].onmouseover = function() {
			    if (autocompleter.selected) {
				autocompleter.selected.className = '';
			    }
			    autocompleter.selected = this;
			    this.className = 'active'
			}
			autocompleter.lis[i].onmouseout = function() {
			    this.className = ''
			}
		    }
		//alert(autocompleter.lis)
		}
	    });
	}
    },

    autocompleteNavigation: function(autocompleter,event)
    {
	event = event || window.event;

	if (event.keyCode == 40)
	{
	    if (event.preventDefault)
		event.preventDefault();
	    else
		event.returnValue = false;

	    if (!autocompleter.selected && this.lis.length>0)
	    {
		autocompleter.selected = this.lis[0];
		autocompleter.lis[0].className = 'active';
	    }
	    else
	    {
		autocompleter.selected.className = '';
		if (autocompleter.selected.num != autocompleter.lis.length-1 )
		    autocompleter.selected = autocompleter.lis[autocompleter.selected.num+1];
		else
		    autocompleter.selected = autocompleter.lis[0];

		autocompleter.selected.className = 'active';
	    }
	}

	if (event.keyCode == 38)
	{
	    if (event.preventDefault)
		event.preventDefault();
	    else
		event.returnValue = false;

	    if (!autocompleter.selected)
	    {
		autocompleter.selected = autocompleter.lis[autocompleter.lis.length-1];
		autocompleter.lis[autocompleter.lis.length-1].className = 'active';
	    }
	    else
	    {
		autocompleter.selected.className = '';
		if (autocompleter.selected.num != 0)
		    autocompleter.selected = autocompleter.lis[autocompleter.selected.num-1];
		else
		    autocompleter.selected = autocompleter.lis[autocompleter.lis.length-1]

		autocompleter.selected.className = 'active';
	    }
	}

	if (event.keyCode == 13)
	{
	    if (event.preventDefault)
		event.preventDefault();
	    else
		event.returnValue = false;

	    autocompleter.input.value = autocompleter.selected.innerHTML.replace(/<small>(.*?)<\/small>/i,'');
	    autocompleter.input.value = autocompleter.input.value.replace(/<(.*?)>/ig,'');
	    autocompleter.ac.style.display = 'none';
	    if ($(autocompleter.input.id+'_id')) $(autocompleter.input.id+'_id').value=autocompleter.selected.id;
	}
    },

    acFocus: function(autocompleter, obj, event)
    {
	autocompleter.focused = true;
	obj.onkeydown = function(event) {
	    autocompleter.autocompleteNavigation(autocompleter,event)
	}

	lookup({
	    url:'/api/'+autocompleter.url,
	    values:'empty=true',
	    postFunction: function(transport)
	    {

		if (!$('ac_'+obj.id))
		{
		    newAC = document.createElement('span')
		    newAC.id = 'ac_'+obj.id;
		    newAC.className = 'autocompliter';
		    newAC.style.position = 'absolute';
		    newAC.style.zIndex = '20';
		    obj.parentNode.style.position = 'relative';
		    newAC.style.top = obj.offsetHeight + obj.offsetTop + 'px';
		    obj.parentNode.appendChild(newAC);
		    autocompleter.ac = newAC;
		}

		autocompleter.ac.style.display = 'block';
		autocompleter.ac.innerHTML = transport.responseText;
		//$('test').innerHTML = newAC.innerHTML;
		autocompleter.lis = $(autocompleter.ac.id).getElementsByTagName('a');
		autocompleter.selected = null;
		for (i=0; i<autocompleter.lis.length; i++)
		{
		    //$('test').innerHTML += this.lis[i]+'<br />'
		    autocompleter.lis[i].num = i;
		    autocompleter.lis[i].onmousedown = function() {
			obj.value = this.innerHTML.replace(/<small>(.*?)<\/small>/i,'');
			obj.value = obj.value.replace(/<(.*?)>/ig,'');
			if ($(obj.id+'_id')) {
			    $(obj.id+'_id').value=this.id;
			}
			$('ac_'+obj.id).style.display = 'none';
		    }
		    autocompleter.lis[i].onmouseover = function() {
			if (autocompleter.selected) {
			    autocompleter.selected.className = '';
			}
			autocompleter.selected = this;
			this.className = 'active'
		    }
		    autocompleter.lis[i].onmouseout = function() {
			this.className = ''
		    }
		}
	    //alert(autocompleter.lis)
	    }
	});

    }
});
	
//аякс
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);
	    }
	}
    }
}
		
hightlightChanger = {}
	
hightlightChanger.hightlight = function(obj, settings) {
    obj.t++;
		
    opacity = settings.behavior(obj.t, 0, 1, settings.time);
		
    if (opacity > 1) opacity = 1;
			
    if (!isIE)
    {
	obj.style.opacity = opacity;
	settings.activated.style.opacity = 1 - opacity;
    }
    else
    {
	obj.style.filter = 'Alpha(opacity='+opacity*100+')';
	settings.activated.style.filter = 'Alpha(opacity='+(1 - opacity)*100+')';
    }
			
    if (obj.t == settings.time)
    {
	clearInterval(obj.timer);
			
	if (!isIE)
	{
	    obj.style.opacity = 1;
	    settings.activated.style.opacity = 0;
	}
	else
	{
	    obj.style.filter = 'Alpha(opacity=100)';
	    settings.activated.style.filter = 'Alpha(opacity=0)';
	}
			
	obj.style.position = 'static';
	settings.activated.style.display = 'none';
	settings.activated.style.position = 'absolute';
			
	settings.working = false;

	settings.activated = obj;
    }
}
	
hightlightChanger.change = function(obj, settings) {
		
    settings.working = true;
		
    if (!isIE)
	obj.style.opacity = 0;
    else
	obj.style.filter = 'Alpha(opacity=0)';
		
    obj.t = 0;
		
    obj.style.display = 'block';
		
    obj.timer = setInterval(function() {
	hightlightChanger.hightlight(obj, settings)
    }, settings.delay);
}
	
hightlightChanger.init = function(links, settings) {
		
    this.links = links;
		
    this.destroy = hightlightChanger.destroy;
		
    if (!settings)
	this.settings = {};
    else
	this.settings = settings;
		
    if (!this.settings.time)
	this.settings.time = 10;
    if (!this.settings.delay)
	this.settings.delay = 10;
    else if (!this.settings.delay && this.settings.time)
	this.settings.delay = settings.time;
    if (!this.settings.behavior)
	this.settings.behavior = Linear;
		
    //		this.settings = settings;
		
    var self = this;
		
    for (i=this.links.length-1; i>=0; i--)
    {
	if (!this.settings.thingsToSwitch && this.links[i].id)
	    this.links[i].thingToSwitch = $(this.links[i].id+'_container');
	else
	    this.links[i].thingToSwitch = this.settings.thingsToSwitch[i];
			
	if (!this.settings.activated && this.links[i].thingToSwitch.offsetHeight != 0)
	    this.settings.activated = this.links[i].thingToSwitch;
				
	if (this.links[i].className == 'active')
	    this.prevLink = this.links[i];
			
	this.links[i].onclick = function() {
	    if (this.className == 'active' || self.settings.working) return false;
	    this.className = 'active';
	    self.prevLink.className = '';
	    self.prevLink = this;
	    hightlightChanger.change(this.thingToSwitch, self.settings);
	    return false;
	}
    }
}
	
hightlightChanger.destroy = function() {
    for (i=this.links.length-1; i>=0; i--)
    {
	this.links[i].onclick = function() {  }
    }

    delete this;
}
	
Linear = function (t, b, c, d) {
    return c*t/d + b;
}

//аякс
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);
            }
        }
    }
}

function mainShop(link,type){
    $('link_music').className = $('link_film').className = $('link_book').className = '';
    link.className = 'active';
    $('attach_list').innerHTML = '';
    lookup({
	url: '/api/attach_list.api.php',
	values: 'type='+type,
	postFunction: function(transport)
	{
	    $('attach_list').innerHTML = transport.responseText;
	}
    });

}

function seenAttch(el,id){
    el.onclick = function(){return false;};
    
    lookup({
	url: '/api/attach_seen.api.php',
	values: 'id='+id,
	postFunction: function(transport)
	{
	    $('seen_'+id).innerHTML = transport.responseText;
	}
    });
}

function getElementPosition(obj)
{
	var elem = obj

	var l = 0;
	var t = 0;
	while (elem)
	{
       	l += elem.offsetLeft;
      	t += elem.offsetTop;
     	elem = elem.offsetParent;
	}
  	obj.l = l;
  	obj.t = t;
}

rising = {
	
	get: function(obj, optional) {
		
		if (!optional) optional = {}
		
		getElementPosition(obj)
		
		if (!$('p_'+obj.rel.replace(/\//g,'_')))
			{
			nImg = document.createElement('img');
			nImg.loaded = false;
			
			if (optional.className)
				nImg.className = optional.className;
				
			if (optional.styles)
				{
				for (prop in optional.styles)
					{
					nImg.style[prop] = optional.styles[prop];
					}
				}
			
			nImg.id = 'p_'+obj.rel.replace(/\//g,'_');
			nImg.src = obj.rel;
			nImg.style.position = 'absolute';
			nImg.style.top = '-2000px';
			nImg.style.zIndex = '10000';
			nImg.style.boxShadow = '0 0 10px #000';
			nImg.style.MozBoxShadow = '0 0 10px #000';
			nImg.style.WebkitBoxShadow = '0 0 10px #000';
//			nImg.style.filter = 'progid:DXImageTransform.Microsoft.dropShadow(color=#000, offX=0, offY=0);'
			nImg.style.visibility = 'hidden';
			nImg.style.cursor = 'pointer';
			nImg.onclick = function() { if (this.working) return; this.oot = this.offsetTop; this.ool = this.offsetLeft; this.timer = setInterval(function() { rising.close($('p_'+obj.rel.replace(/\//g,'_'))) }, 15) }
			document.getElementsByTagName('body')[0].appendChild(nImg);
			}
			
		$('p_'+obj.rel.replace(/\//g,'_')).parentImg = obj
		$('p_'+obj.rel.replace(/\//g,'_')).t = 0;
		
		$('p_'+obj.rel.replace(/\//g,'_')).h = obj.offsetHeight;
		$('p_'+obj.rel.replace(/\//g,'_')).w = obj.offsetWidth;
		$('p_'+obj.rel.replace(/\//g,'_')).style.display = 'block';
		
		
		if (!$('p_'+obj.rel.replace(/\//g,'_')).loaded)
			{
			if (optional.preLoadFunction) optional.preLoadFunction();
			$('p_'+obj.rel.replace(/\//g,'_')).onload = function() {
							$('p_'+obj.rel.replace(/\//g,'_')).loaded = true;
							if (optional.onLoadFunction) 
								{
								optional.onLoadFunction();
								}
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.top = obj.t + 'px';
								$('p_'+obj.rel.replace(/\//g,'_')).style.left = obj.l + 'px';
								
								$('p_'+obj.rel.replace(/\//g,'_')).ot = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.top);
								$('p_'+obj.rel.replace(/\//g,'_')).ol = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.left);
								
								if (!$('p_'+obj.rel.replace(/\//g,'_')).realWidth)
									{
									$('p_'+obj.rel.replace(/\//g,'_')).realWidth = nImg.offsetWidth;
									$('p_'+obj.rel.replace(/\//g,'_')).realHeight = nImg.offsetHeight;
									}
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.width = obj.offsetWidth + 'px';
								$('p_'+obj.rel.replace(/\//g,'_')).style.height = obj.offsetHeight + 'px';
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.visibility = 'visible';
								//nImg.style.display = 'none';
								
								$('p_'+obj.rel.replace(/\//g,'_')).timer = setInterval(function() { rising.open($('p_'+obj.rel.replace(/\//g,'_'))) }, 15) 
							}
			}
		else
			{
			$('p_'+obj.rel.replace(/\//g,'_')).timer = setInterval(function() { rising.open($('p_'+obj.rel.replace(/\//g,'_'))) }, 15)
			}
		return false;
	},
	
	open: function(obj) {
		obj.working = true;
		
		obj.t++;
		obj.style.width = parseInt(Linear(obj.t, obj.w, obj.realWidth-obj.w, 10)) + 'px';
		obj.style.height = parseInt(Linear(obj.t, obj.h, obj.realHeight-obj.h, 10)) + 'px';
		
		obj.style.top = parseInt(Linear(obj.t, obj.ot, -(obj.realHeight/2 - obj.parentImg.offsetHeight/2), 10)) + 'px';
		obj.style.left = parseInt(Linear(obj.t, obj.ol, -(obj.realWidth/2 - obj.parentImg.offsetWidth/2), 10)) + 'px';
		
		if (obj.t == 10)
			{
			clearInterval(obj.timer);
			obj.working = false;
			obj.t = 0;
			obj.style.width = obj.realWidth + 'px';
			obj.style.height = obj.realHeight + 'px';
			}
		
	},
	
	close: function(obj) {
		obj.t++;
		obj.working = true;
		obj.style.width = parseInt(Linear(obj.t, obj.realWidth, obj.w-obj.realWidth, 10)) + 'px';
		obj.style.height = parseInt(Linear(obj.t, obj.realHeight, obj.h-obj.realHeight, 10)) + 'px';

		obj.style.top = parseInt(Linear(obj.t, obj.oot, obj.ot - obj.oot, 10)) + 'px';
		obj.style.left = parseInt(Linear(obj.t, obj.ool, obj.ol - obj.ool, 10)) + 'px';
		
		if (obj.t == 10)
			{
			clearInterval(obj.timer);
			obj.timer = null
			obj.working = false;
			obj.t = 0
			obj.style.display = 'none';
			obj.style.width = obj.w + 'px';
			obj.style.height = obj.h + 'px';
			}
	}
}

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;
}

function getElementPosition(obj)
		{
		var elem = obj

    	var l = 0;
    	var t = 0;

    	while (elem)
	   		{
	       	l += elem.offsetLeft;
	      	t += elem.offsetTop;
	     	elem = elem.offsetParent;
	   		}
	   	obj.l = l;
	   	obj.t = t;
		}

getMarks = function (obj, id) {
	$('marks').style.display = 'block';
	getElementPosition(obj.parentNode);
	$('marks').style.top = obj.parentNode.t + 'px'
//	$('marks').style.left = obj.parentNode.l - 340 + obj.parentNode.offsetWidth + 'px'
	$('marks_details').innerHTML = '<img alt="" src="http://im1.zv.innovaterussia.ru/data/zv/images/dpl.gif" />';
	
	if ($('rules_link'))
		$('rules_link').style.display = 'block';
	
	lookup({url:'/api/design.marks.api.php', values: 'id='+id, dest: 'marks_details'});
}

getSMS = function (obj, id) {
	$('marks').style.display = 'block';
	getElementPosition(obj.parentNode);
	$('marks').style.top = obj.parentNode.t + 'px'
//	$('marks').style.left = obj.parentNode.l - 340 + obj.parentNode.offsetWidth + 'px';

	if ($('rules_link'))
		$('rules_link').style.display = 'none';
	
	$('marks_details').innerHTML = '<img alt="" src="http://im1.zv.innovaterussia.ru/data/zv/images/dpl.gif" />';
	$('marks_details').innerHTML = '<p>Отправь SMS с текстом «<b>golos '+id+'</b>» на короткий номер 4443*</p> <p><small style="font-size: 0.7em">* стоимость SMS 5р.</small><br /><small style="font-size: 0.7em">** с одного номера принимается только 1 голос за проект!</small></p>';
	
		
//	lookup({url:'/api/design.marks.api.php', values: 'id='+id, dest: 'marks_details'});
}