var main_news = function(pnl_id)
{
    this.pnl = dxsoft_library.GetElement(pnl_id);
    var divs = this.pnl.getElementsByTagName("DIV");
    for(var i=0;i<divs.length;++i)
        if(divs[i].className=="descr")
        {
            this.descr = divs[i];
            break;
        }
    dxsoft_library.DoTask(this.pnl,dxsoft_library.CreateMethod(this,function(){this.descr.style.color="#000";}),"mouseover");
    dxsoft_library.DoTask(this.pnl,dxsoft_library.CreateMethod(this,function(){this.descr.style.color="";}),"mouseout");
}

var rat_operator = function(mainpnl_id,lnkshow_id,lnkhide_id,short_id,full_id)
{    
    this.mainpnl = dxsoft_library.GetElement(mainpnl_id);
    this.lnkshow = dxsoft_library.GetElement(lnkshow_id);
    this.lnkhide = dxsoft_library.GetElement(lnkhide_id);
    this.table =   this.mainpnl.getElementsByTagName("TABLE")[0];
    
    this.shortpnl = dxsoft_library.GetElement(short_id);
    this.fullpnl = dxsoft_library.GetElement(full_id);
    
    dxsoft_library.DoTask(this.lnkshow,dxsoft_library.CreateMethod(this,function(){ this.shortpnl.style.display="none";this.fullpnl.style.display="block";this.table.className="sel"; }),"click");
    dxsoft_library.DoTask(this.lnkhide,dxsoft_library.CreateMethod(this,function(){ this.shortpnl.style.display="block";this.fullpnl.style.display="none";this.table.className=""; }),"click");
}

var news_imgprev = function(img_id,clickpnl_id,pager_id,imglist)
{
    
    this.img = dxsoft_library.GetElement(img_id);
    this.pager = dxsoft_library.GetElement(pager_id);
    this.imglist = imglist;
    this.clickpnl = dxsoft_library.GetElement(clickpnl_id);
    
    dxsoft_library.DoTask(this.clickpnl,function(){dximgviewer.ShowImg("/img/news/large/"+imglist[0]);},"click");
    
    if(imglist.length<1)
        return;        
    this.span = document.createElement("span");
    this.span.innerHTML = "1";
    this.pager.appendChild(this.span);
    this.curpage = null;
               
    for(var i=0;i<this.imglist.length;++i)
    {
        a = document.createElement("a");
        a.href="javascript:;";
        a.innerHTML = i+1;
        a.picurl = this.imglist[i];
        a.ctrl = this;
        if(i==0)
        {
            a.style.display="none";
            this.curpage = a;
        }
        this.pager.appendChild(a);
        dxsoft_library.DoTask(a,dxsoft_library.CreateMethod(a,this.OnChangeImg),"click");
    }
}

news_imgprev.prototype ={
    OnChangeImg:function()
    {        
        this.ctrl.span.innerHTML = this.innerHTML;
        this.ctrl.pager.insertBefore(this.ctrl.span,this);
        this.ctrl.curpage.style.display="";
        this.ctrl.curpage=this;
        this.style.display="none";
        this.ctrl.img.src="/img/news/small/"+this.picurl;
        //this.ctrl.link.href="javascript:dximgviewer('/img/news/large/"+this.picurl+"');";
    }
}

var current_contacts_map = null;
var current_contacts_mapimg = null;
var contacts_footermover = null;

var contactsmap = function(pnl_id,img_id,link_id,imgurl,closetext)
{
    this.pnl = dxsoft_library.GetElement(pnl_id);
    this.img = dxsoft_library.GetElement(img_id);
    this.img.style.cssText+="cursor:hand; cursor:pointer;"
    this.link = dxsoft_library.GetElement(link_id);
           
    this.imgurl = imgurl;
    this.closetext = dxsoft_library.DecodeText(closetext);
    this.isshow = false;
    
    dxsoft_library.DoTask(this.link,dxsoft_library.CreateMethod(this,this.OnClick),"click");       
/*    if(!current_contacts_mapimg)
    {
        current_contacts_mapimg = this.img;
        dxsoft_library.DoTask(this.img,dxsoft_library.CreateMethod(this,this.Hide),"click");
    }*/
}

contactsmap.prototype = {
    OnClick:function()
    {
        if(this.onClickMap)        
            dxsoft_library.ClearTask(this.img,this.onClickMap,"click");                    
        if(!this.isshow)
        {
            dxsoft_library.DoTask(this.img,this.onClickMap = dxsoft_library.CreateMethod(this,this.Hide),"click");
            if(current_contacts_map && current_contacts_map!=this)
                current_contacts_map.Hide();
            current_contacts_map=  this;
            this.showtext = this.link.innerHTML;
            this.link.innerHTML = this.closetext;            
            var i = new Image();
            dxsoft_library.DoTask(i,dxsoft_library.CreateMethod(this,this.OnImgLoad),"load");
            i.src = this.imgurl;
            this.img.src = this.imgurl;
            this.link.parentNode.appendChild(this.pnl);
            this.pnl.style.display= "block";            
            this.link.style.color = "#f00";
            this.isshow = true;             
            this.OnImgLoad();           
        }else
        {
            if(contacts_footermover)
                contacts_footermover.style.display="none";
            this.isshow = false;
            this.link.innerHTML = this.showtext;
            this.pnl.style.display= "none";
            this.link.style.color = "";
        }
    },
    Hide:function()
    {
        if(this.onClickMap)        
            dxsoft_library.ClearTask(this.img,this.onClickMap,"click");      
        if(contacts_footermover)
            contacts_footermover.style.display="none";
        this.pnl.style.display= "none";
        this.isshow = false;
        this.link.innerHTML = this.showtext;
        this.link.style.color = "";
    },
    OnImgLoad:function()
    {
        if(this.isshow && contacts_footermover)
        {
            var ap = dxsoft_library.GetAbsolutePos(this.pnl.parentNode.parentNode,contacts_footermover.parentNode);
            var dy = this.pnl.parentNode.parentNode.parentNode.offsetTop;
            contacts_footermover.style.height = "1px";
            contacts_footermover.style.display = "block";
            var pp = contacts_footermover.offsetTop;
            ap.y+=this.pnl.offsetHeight-dy;            
            if(ap.y>pp)
            {
                contacts_footermover.style.height = (ap.y-pp+80)+"px";
                contacts_footermover.style.display = "block";
            }
        }
    }
}

var partnersctrl = function(shortpnl_id,show_id,pnlfull_id,hide_id)
{
    this.shortpnl = dxsoft_library.GetElement(shortpnl_id);
    this.show = dxsoft_library.GetElement(show_id);
    this.pnlfull = dxsoft_library.GetElement(pnlfull_id);
    this.hide = dxsoft_library.GetElement(hide_id);
    
    dxsoft_library.DoTask(this.show,dxsoft_library.CreateMethod(this,function(){this.shortpnl.style.display="none";this.pnlfull.style.display="";}),"click");
    dxsoft_library.DoTask(this.hide,dxsoft_library.CreateMethod(this,function(){this.shortpnl.style.display="";this.pnlfull.style.display="none";}),"click");
}


var career_vac = function(butlist_id,vaclist_id)
    {
        this.linklist = Array();
        this.vaclist = Array();
        var lis = dxsoft_library.GetElement(butlist_id).getElementsByTagName("li");
        for(var i=0;i<lis.length;++i)
        {
            var a = new Object();
            a.li = lis[i];
            a.span = lis[i].getElementsByTagName("SPAN")[0];
            a.link = lis[i].getElementsByTagName("A")[0];
            a.id = lis[i].getElementsByTagName("INPUT")[0].value; 
            a.ctrl = this;           
            this.linklist[i]=a;
            if(a.li.className=="sel")
                this.current_elem = a;
            dxsoft_library.DoTask(a.link,dxsoft_library.CreateMethod(a,this.OnChange),"click");            
        }        
        
        lis = dxsoft_library.GetElement(vaclist_id).getElementsByTagName("li");
        for(var i=0;i<lis.length;++i)
        {
            var a = new Object();
            a.span = lis[i].getElementsByTagName("SPAN")[0];
            a.link = lis[i].getElementsByTagName("A")[0];
            a.id = lis[i].getElementsByTagName("INPUT")[0].value; 
            this.vaclist[i]=a;
        }
    }
    
career_vac.prototype ={
    OnChange:function()
    {
        if(this.ctrl.current_elem)
        {
            var a = this.ctrl.current_elem;
            a.link.style.display="block";
            a.span.style.display="none";
            a.li.className="unsel_1";
        }
        this.ctrl.current_elem = this;
        this.link.style.display="none";
        this.span.style.display="block";
        this.li.className="sel";
        
        var vaclist = this.ctrl.vaclist;
        for(var i=0;i<vaclist.length;++i)
        {
            if(this.id==0 || this.id==vaclist[i].id)
            {
                vaclist[i].link.style.display="block";
                vaclist[i].span.style.display="none";
            }
            else
            {
                vaclist[i].link.style.display="none";
                vaclist[i].span.style.display="block";            
            }
        }        
    }
}


var projpictures = function(imgpnl_id,linkpnl_id,pager_id,imglist)
{
    this.imgpnl = dxsoft_library.GetElement(imgpnl_id);
    this.linkpnl = dxsoft_library.GetElement(linkpnl_id);
    this.pager = dxsoft_library.GetElement(pager_id);
    
    this.largimglist = Array();
    for(var i=0;i<imglist.length;++i)    
        this.largimglist[i] = '/img/projects/large/'+imglist[i];        
      
    if(imglist.length>0)
        this.linkpnl.picture_url = '/img/projects/large/'+imglist[0];
        
    if(imglist.length>1)
    {
        this.imglist = Array();
        for(var i=0;i<imglist.length;++i)
        {
            var obj = new Object();
            obj.span = document.createElement("span");
            obj.span.innerHTML = (i+1);
            obj.a = document.createElement("A");
            obj.a.href = "javascript:;";
            obj.a.innerHTML = (i+1);
            obj.ctrl = this;
            obj.imgurl = imglist[i];
            this.imglist[i] = obj;
        
            if(i==0)
            {
                obj.a.style.display="none";                
            }
            else
                obj.span.style.display="none";
            this.pager.appendChild(obj.a);
            this.pager.appendChild(obj.span);
            dxsoft_library.DoTask(obj.a,dxsoft_library.CreateMethod(obj,this.OnChangeImg),"click");        
        }
    }
    dxsoft_library.DoTask(this.linkpnl,dxsoft_library.CreateMethod(this,this.OnShowPicture),"click");
}

projpictures.prototype = {
    OnShowPicture:function()
    {        
        dximgviewer.picview_obj.SetPictures(this.largimglist);
        dximgviewer.ShowImg(this.linkpnl.picture_url);
    },
    OnChangeImg:function()
    {
        var ilist = this.ctrl.imglist;    
        for(var i=0;i<ilist.length;++i)
        {
            if(ilist[i].a.style.display=="none")
            {
                ilist[i].a.style.display="";
                ilist[i].span.style.display="none";
                break;
            }
        }
        this.a.style.display="none";
        this.span.style.display="";
        this.ctrl.imgpnl.style.backgroundImage="url('/img/projects/small/"+this.imgurl+"')";
    }
}