﻿
Article = new Class({
    initialize  :   function(){
        this.divRateMain = $('divRateMain');
        
        this.divRate = $('divRate');
        
  
        this.btnUp = $('btnUp');
        if(this.btnUp != null)
            this.btnUp.addEvent('click', this.btnUp_Click.bind(this));
    
        this.btnDown = $('btnDown');
        if(this.btnDown != null)
            this.btnDown.addEvent('click', this.btnDown_Click.bind(this));

        if(this.divRate != null){
            this.rateSlide = new Fx.Slide(this.divRate, {
	            transition: 'circ:out',
	            duration: 'long'
            }).hide(); 
        }

    
        this.btnRateIt = $('btnRateIt');
        if(this.btnRateIt != null)
            this.btnRateIt.addEvent('click', this.btnRateIt_Click.bind(this));
    },

    btnUp_Click         :   function(){
       this.Rate(1);
    },
    
    btnDown_Click       :   function(){
       this.Rate(0);
    },
    
    btnRateIt_Click       :   function(){
       this.rateSlide.toggle();
    },
    
    Rate                :   function(rate){
    
    
        /* RATING URL */ 

    
//        var url = window.location.href;
//        var urlparts = url.split('/');
//        
//        alert(urlparts[0]);
//        alert(urlparts[1]);
//        alert(urlparts[2]);
//        alert(urlparts[3]);
//        alert(urlparts[4]);
//        alert(urlparts[5]);
    
//        Lomo.Send('/service/postrating.ashx','','pid=28&ratingType='+rate,function(result){
//            this.divRate.innerHTML='';
//            var frmChart = new IFrame({
//                src: "/chart.aspx?t=2",
//                id : "frmChart",
//                styles: {
//                    border: "none"
//                }
//            });
//            frmChart.inject(this.divRate);
//            var prt = this.divRate.getParent();
//            prt.set('morph', {duration: 'long', transition: 'circ:out'});
//            prt.morph({height: 200, width: 250});
//            this.divRate.setStyle('padding','0');
//            frmChart.set('morph', {duration: 'long', transition: 'circ:out'});
//            frmChart.morph({height: 200, width: 203});
//            this.divRate.set('morph', {duration: 'long', transition: 'circ:out'});
//            this.divRate.morph({height: 200, width: 203});
//            this.btnRateIt.removeEvent('click');

//        }.bind(this));
    }
});


window.addEvent('domready', function() {
	var i = new Article();
	
    var toggles = $$('.ArcContentText');
    var content = $$('.TeksatirClass');
 
    //set up your object var
    //create a "new" Accordion object
    //set the toggle array
    //set the content array
    var AccordionObject = new Accordion(toggles, content);
    

    
    /* ARTICLE */
  
    var el = $('AuthorDetails');
    if(el != null){
	    var authorInfoHeight=el.getStyle('height').toInt();
	    
	    
        el.set('morph', {duration: 'long', transition: 'circ:out'});
        el.morph({height: 62});
	   
	   var version=/MSIE \d+.\d+/

        if(navigator.appVersion.match(version) == "MSIE 6.0"){
            authorInfoHeight +=20;
        }
	   
	   
	   if (authorInfoHeight<62) 
	   {
	    $('btnAuthorInfo').setStyle('display', 'none');
	   } 
	   else {
	        $('btnAuthorInfo').addEvent('click', function(){
              el.morph({height: authorInfoHeight});
             $('btnAuthorInfo').setStyle('display', 'none');
            });
        }
    }
    
});

