﻿// JScript File
var magazineArchive;

window.onload=function()
{
    if($('archive_years'))
    
    new MagazineArchive(language,magazineType);
 
}
var MagazineArchive = Class.create()
MagazineArchive.prototype = {
   initialize:function(lang,type)
   {
         
         this.container =$('archive_years');
         this.archive = $('archive_gallary');  
            this.years = new Array();
            this.getArchiveTitle();
            this.currentType=type;
            this.currentYear;
            this.page="/"+lang+"/archive/ajax/";
   
   
   },
   getArchiveTitle:function()
   {
            //debugger;
           
            this.years = this.container.childNodes;
            
            this.bindEvents();
   },
    bindEvents:function()
    {
            for(var i=0;i<this.years.length;i++)
            {
                this.years[i].onmouseover=this.onmouseover.bindAsEventListener(this);
                this.years[i].onmouseout=this.onmouseout.bindAsEventListener(this);
                this.years[i].onclick=this.onclick.bindAsEventListener(this);
                
            }
    },
    onmouseover:function(e)
    {
        //Event.element(e);
        //debugger;
       var div=elementFromEvent(e);
         if(div.className.indexOf("admin_anchor_cell")!=-1)
         {
        div.style.color ="#EF3124";  
         }
    },
    onmouseout:function(e)
    {
        //debugger;
        var div=elementFromEvent(e);
        if(div.className.indexOf("admin_anchor_cell")!=-1)
        {
            div.style.color ="";   
        }
    },
    
    onclick:function(e)
    {
         
         var div=elementFromEvent(e);
         div.style.color ="";
         if(div.className=="")return;
    
         for(var i=0;i<this.years.length;i++)
         {
             this.years[i].className="admin_anchor_cell";
         }
        
         div.className="";
         
         
         for(var i=0;i<this.years.length;i++)
         {
             if(this.years[i].className=="")
             this.currentYear = i;
         }
        
         var url = this.page +this.currentType+"/"+ this.currentYear;
       this.archive.hide();
         send("",url,this.generateArchive.bindAsEventListener(this),false);
   
    
    },
    generateArchive:function(r)
    {
    
       this.archive.innerHTML =  r.responseText;
       
       this.archive.show();
    }
   

}