var request = false;
   try {
     request = new XMLHttpRequest(); 
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request = false;
       }  
     }
   }
   //if (!request)
     //alert("Error initializing XMLHttpRequest!");
	
function $(id) {return document.getElementById(id);}


function set_opacity(el, o)
{
	//var el = document.getElementById(id);
	
	var opacityProp = getOpacityProperty();
	if (opacityProp=="filter")  // Internet Exploder 5.5+
	{
		o*=100;
		el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+o+")";
	}
	else el.style.opacity=o;
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
    return 'opacity';
  else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8 
    return 'MozOpacity';
  else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
    return 'KhtmlOpacity';
  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
    return 'filter';

  return false; //нет прозрачности
}


var timerr;
var initValue=0;
function animateOp(elem, maxValue, inc, pause)
{
	//static timer;
	//alert(parseInt(elem.style.opacity));
	//alert(elem.style.width);
	clearInterval(timerr);
	if ((parseInt(elem.style.opacity) < maxValue) || (isNaN(parseInt(elem.style.opacity))))////break; 
	{
		//alert('!');
		set_opacity(elem, initValue + inc);
		initValue+=inc;
		timerr = setTimeout(function(){animateOp(elem, maxValue, inc, pause);}, pause);
	}else initValue=0;
}


function getStyle(elem, prop)
{
  if (typeof elem!="object") elem = document.getElementById(elem);
  
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+
  if (document.defaultView && document.defaultView.getComputedStyle)
  {
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop);
  }
  
  // external stylesheet for Explorer and Opera 9
  if (elem.currentStyle)
  {
    var i;
    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);
    return elem.currentStyle[prop];
  }
  
  return "";
}

var timer;

function scrollNew()
{
	var height=0;
	var imgs = document.getElementsByName('newThumbs');
	for (var z=0; z<=imgs.length; z++)
	{
		if (imgs[z]!=undefined) height=parseInt(imgs[z].height)+height;
	}
	timer = setTimeout(function(){scrollNewGo(height, 300, parseInt(getStyle($('scrollFrame'), 'top')), $('scrollFrame'))},10);
}

function scrollNewGo(height, init, top, elem)
{
	clearTimeout(timer);
	if ((-1*top+init)+4<height)
	{
		elem.style.top=(top-4)+'px';
		timer = setTimeout(function(){scrollNewGo(height, init, top-4, elem)}, 10);
	}
}
function scrollBack(event)
{
	if (!event) var event = window.event; 
	var relTarg = event.relatedTarget || event.toElement; 
	if (relTarg.id!='m624_img')
	{
		var top = parseInt(getStyle($('scrollFrame'), 'top'));
		scrollBackGo(top, $('scrollFrame'));
	}
}
function scrollBackGo(top, elem)
{
	clearTimeout(timer);
	if (top<0)
	{
		elem.style.top=(top+6)+'px';
		timer = setTimeout(function(){scrollBackGo(top+6, elem)}, 5);
	}
}

function switchBackground(src)
{
	var newImg = new Image();
	newImg.onload=function(){
		$('backgroundChanger').style.background='url('+newImg.src+') 0% 50% no-repeat';
	}
	newImg.src='/a/userfiles/'+src;
}

function changeSrc (src, id) {
	var img = new Image();
	img.onload = function () {
	
		$(id).src=img.src;
	}
	img.src=src;
}
