function changefontsize(flag) 
{
	var step=10;
	if (document.getElementById('content_article').style.fontSize == '' ) {
		document.getElementById('content_article').style.fontSize = '110%';
	}

	var current=parseInt(document.getElementById('content_article').style.fontSize.substring(-1,3));
	
	if(flag) {
		if(current<160) {
			document.getElementById('content_article').style.fontSize=current+step+'%';
		}
	} else {
		if(current>110) {
			document.getElementById('content_article').style.fontSize=current-step+'%';
		}
	}
	return false;
}

function newWindow2(url, width, height, windowName) {
	var left = (screen.availWidth / 2) - (width / 2);
	var top = (screen.availHeight / 2) - (height / 2);
	var newWindow;

	if(!windowName) {
		var windowName = 'newWindow' + Math.floor(Math.random() * 100);
	}

	newWindow = window.open( url, windowName, 'top=' + top + 'px,left=' + left + 'px,screenX=' + left + 'px,screenY=' + top + 'px,width=' + width + 'px,height=' + height + 'px,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
  if(!document.all)
		newWindow.focus();
	return false;
}

function fbs_click(u) {
  t='';
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&#038;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436')
  ;return false;
}

var mall_incr1 = 0;
var mall_interval_time1 = 3000;
var mall_play1 = true;
var mall_last1 = document.getElementById('today_news_link_'+mall_incr1);
var mall_interval1;

function play_today_news_next(reset_interval){
	mall_incr1++;
	if(mall_incr1>mall_count1) mall_incr1=1;
	
	if(mall_last1) mall_last1.style.display="none";
	if(document.getElementById('today_news_link_'+mall_incr1))
		document.getElementById('today_news_link_'+mall_incr1).style.display="block";
	else
		clearInterval(mall_interval1);

	mall_last1 = document.getElementById('today_news_link_'+mall_incr1);
	if(reset_interval && mall_play1){
		clearInterval(mall_interval1);
		mall_interval1 = setInterval('play_today_news_next(false)',mall_interval_time1)
	}
}

function today_news_play_pause(){
	mall_play1 = !mall_play1;
	if(!mall_play1) clearInterval(mall_interval1);
	if(mall_play1) mall_interval1 = setInterval('play_today_news_next(false)',mall_interval_time1);
}

function slideshow_today_news_invoke(){
	if(mall_count1)
	mall_interval1 = setInterval('play_today_news_next(false)',mall_interval_time1);
	play_today_news_next();
}

var GalleryLine = ({
  init:function() {
    var isGalPage = $('galeria');
    if (null != isGalPage) {
      this.curEl = $('nmb');
      var curElement = $('nmb').get('html');
      this.bigImg = $('bigImg');
      this.boxZdielat = $('zdielat');
      this.thumbPics = $$('.thumbpic');
      this.prevEl = $('prevpic');
      this.nextEl = $('nextpic');
      this.thumbs = $('thumbs');
      this.boxWidth = 589;
      this.allWidths = 0;
      this.bigImg.addEvent('mouseover', GalleryLine.showZdielat.bindWithEvent(this));
      this.boxZdielat.addEvent('mouseover', GalleryLine.showZdielat.bindWithEvent(this));
      this.bigImg.addEvent('mouseout', GalleryLine.hideZdielat.bindWithEvent(this));
      for (i=0; i<this.thumbPics.length; i++) {
        var size = this.thumbPics[i].getSize();
        this.allWidths = this.allWidths + size.x + 8;
      }
      if ((this.allWidths-3) <= this.boxWidth) {
        this.nextEl.className = 'disablenext';
      } else {
        this.prevEl.addEvent('click', GalleryLine.showPrevPic.bindWithEvent(this));
        this.nextEl.addEvent('click', GalleryLine.showNextPic.bindWithEvent(this));
      }

      if (curElement>0 && (this.allWidths-3) > this.boxWidth) {
        this.setBeginLeft(curElement);
      }
      
    }
  },
  setBeginLeft:function(curElement) {
    var showElsWidth = 0;
    var actual_left = this.thumbs.offsetLeft;
    for (i=0; i<this.thumbPics.length; i++) {
      if (curElement > i) {
        var size = this.thumbPics[i].getSize();
        showElsWidth = showElsWidth + size.x + 8;
      } else {
        if (showElsWidth==this.allWidths) {
          this.nextEl.className = 'disablenext';
        }
        left_output = actual_left-showElsWidth;
        this.thumbs.style.cssText = 'left:' + left_output + 'px';
        this.prevEl.className = 'actPrev';
        break;
      }
    }
  },
  showZdielat:function(el) {
    this.boxZdielat.style.display = 'block';
  },
  hideZdielat:function(el) {
    this.boxZdielat.style.display = 'none';
  },
  showNextPic:function(el) {
    var showElsWidth = 0;
    var actual_left = this.thumbs.offsetLeft;
    for (i=0; i<this.thumbPics.length; i++) {
      var size = this.thumbPics[i].getSize();
      showElsWidth = showElsWidth + size.x + 8;
      if (showElsWidth > -(actual_left-this.boxWidth)+4) {
        if (showElsWidth==this.allWidths) {
          this.nextEl.className = 'disablenext';
        }
//        left_output = actual_left-(showElsWidth+actual_left-this.boxWidth)+5; alert(actual_left);
        dif = showElsWidth-this.boxWidth+actual_left;
        left_output = actual_left-dif+3;// alert(actual_left);
        this.thumbs.style.cssText = 'left:' + left_output + 'px';
        this.prevEl.className = 'actPrev';
        break;
      }
    }
  },
  showPrevPic:function(el) {
    var prevElsWidth = 0;
    var actual_left = this.thumbs.offsetLeft;
    if (actual_left < -3) {
      for (i=0; i<this.thumbPics.length; i++) {
        var showBeforeElWidth = prevElsWidth;
        var size = this.thumbPics[i].getSize();
        prevElsWidth = prevElsWidth + size.x + 8;
        if ((prevElsWidth+6) >= -actual_left) {
          this.thumbs.style.cssText = 'left:-' + (showBeforeElWidth+3) + 'px';
          this.nextEl.className = 'actNext';
          if (this.thumbs.offsetLeft>=-3) {
            this.prevEl.className = 'disablePrevious';
          }
          break;
        }
      }
    }
  }
});
window.addEvent('domready', GalleryLine.init.bind(GalleryLine));

