hostname = window.location.hostname
serverhost = hostname.split('.');
subdomain1 = serverhost[2];
subdomain2 = serverhost[3];

if(subdomain1=="br" || subdomain2=="br")
{
	sluitknop = "Fechar";
}
else
{
	sluitknop = "close";
}

function makeDiv(user,soort)
{
	//document.getElementById('fog').style.visibility = 'visible';
	try {
      newdiv = document.createElement("<div id='foo' class='fillscreen' />");
	} catch (e) {
	  newdiv = document.createElement('div');
	  newdiv.setAttribute('id', 'foo');
	  newdiv.setAttribute('class', 'fillscreen');
	}
	 newdiv.innerHTML = '<div style="float:right"><a href="#" onclick="javascript:closeDiv(); return false;" class="bigger"><img src="/icon/cross.gif" width="16" height="16" border="0" /> '+sluitknop+'</a></div><div id="friends"></div>';
	 document.getElementById('header').appendChild(newdiv);

	 document.getElementById('fog').style.height= document.body.scrollHeight + 'px';
	 document.getElementById('foo').style.top = '100px';
	 position();
	 if(soort == 'same')
	 {
	 	processthree('retrievesamefriends',user,'view','1');
	 }
	 else
	 {
	 	processthree('retrievefriends',user,'view','1');
	}
}

function makeDiv2(user)
{
	document.getElementById('left_block').style.display = 'none';
	document.getElementById('right_block').style.display = 'none';
	//document.getElementById('fog').style.visibility = 'visible';
	try {
      newdiv = document.createElement("<div id='foo' class='fillscreen' />");
	} catch (e) {
	  newdiv = document.createElement('div');
	  newdiv.setAttribute('id', 'foo');
	  newdiv.setAttribute('class', 'fillscreen');
	}
	 newdiv.innerHTML = '<a href="#" onclick="javascript:closeDiv(); return false;" class="bigger"><img src="/icon/cross.gif" width="16" height="16" border="0" /> '+sluitknop+'</a><div id="friends"></div>';
	 document.getElementById('header').appendChild(newdiv);

	 document.getElementById('fog').style.height= document.body.scrollHeight + 'px';
	 document.getElementById('foo').style.top = '200px';
	 position();
	 processthree('retrievefriends',user,'view','1');
}


function showVideo(vidId)
{
	//document.getElementById('fog').style.visibility = 'visible';
	try {
      newdiv = document.createElement("<div id='foo' class='videopopup' />");
	} catch (e) {
	  newdiv = document.createElement('div');
	  newdiv.setAttribute('id', 'foo');
	  newdiv.setAttribute('class', 'videopopup');
	}
	 newdiv.innerHTML = '<a href="#" onclick="javascript:closeDiv(); return false;" class="bigger" style="float: right"><img src="/icon/cross.gif" width="16" height="16" border="0" /></a>';
	 document.getElementById('header').appendChild(newdiv);

	http.open('get', '/process.php?action=viewvideo&id='+vidId);
    http.onreadystatechange = handleResponse;
    http.send(null);

	 document.getElementById('fog').style.height= document.body.scrollHeight + 'px';
	 document.getElementById('foo').style.top = '100px';
	 position();
}
function getsize() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
return myHeight;
}

function position () {
	if(document.getElementById('foo')){
	if (self.pageYOffset)
	{
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
	{
		y = document.documentElement.scrollTop;
	}
	else
	{
		y=0;
	}

	//if(y>1000) alert(document.body.clientHeight);
	y = y+(getsize()/2)-250;
//	dump(document.body.scrollTop+ ','+document.body.clientHeight+','+self.pageYOffset+ '\n');
	ycurrent = parseInt(document.getElementById('foo').style.top);
	ynew = ycurrent + Math.floor((y - ycurrent)/3);
	if(ynew<=0) ynew=0;
	document.getElementById('foo').style.top= ynew + 'px';
	//document.getElementById('fog').style.height = ynew + 580 + 'px';
	setTimeout("position()", 10);
	}
}
function closeDiv (){
	document.getElementById('foo').innerHTML = 'dummy';
	document.getElementById('fog').style.visibility = 'hidden';
	document.getElementById('fog').style.display = 'none';
	var d = document.getElementById('header');
    var olddiv = document.getElementById('foo');
    d.removeChild(olddiv);
}
function moveBlog(id, direction){
	if(direction == 'down')
	{
	eindheight = document.getElementById('height_'+id).value;
	document.getElementById('gradient_'+id).style.visibility = 'hidden';
	document.getElementById('more_'+id).innerHTML = '<a href="#" onclick="javascript:moveBlog(\''+id+'\', \'up\'); return false;"><img src="icon/min.gif" width="16" height="16" border="0" /> Cacher</a>';
	huidigeheight = parseInt(document.getElementById('content_'+id).offsetHeight);
	//alert(huidigeheight +', '+ eindheight);
	if(eindheight > huidigeheight+2)
	{
	heightdif = Math.ceil((eindheight-huidigeheight)/5);
	newheight = heightdif + huidigeheight;

	document.getElementById('content_'+id).style.height = parseInt(newheight) + 'px';
	document.getElementById('gradient_'+id).style.top = parseInt(newheight)-150 + 'px';
	setTimeout("moveBlog("+id+",'down')", 10);
	}
	}
	else if (direction == 'up')
	{
	eindheight = 200;
	document.getElementById('gradient_'+id).style.visibility = 'visible';
	document.getElementById('more_'+id).innerHTML = '<a href="#" onclick="javascript:moveBlog(\''+id+'\', \'down\'); return false;"><img src="icon/add.gif" width="16" height="16" border="0" /> Lire plus</a>';
	huidigeheight = parseInt(document.getElementById('content_'+id).offsetHeight);
	//alert(huidigeheight);
	if(eindheight != huidigeheight)
	{
	heightdif = Math.floor((eindheight-huidigeheight)/10);
	newheight = heightdif + huidigeheight;

	document.getElementById('content_'+id).style.height = parseInt(newheight) + 'px';
	document.getElementById('gradient_'+id).style.top = parseInt(newheight)-150 + 'px';
	setTimeout("moveBlog("+id+",'up')", 10);
	}	}
}
function checkRealHeight(number){
	i = 1;
	while (i< number){
		document.getElementById('height_'+i).value = document.getElementById('content_'+i).offsetHeight;
		document.getElementById('content_'+i).style.overflow = 'hidden';
		document.getElementById('content_'+i).style.height = '200px';
		i++;
	}
}
function init(){
    if(document.getElementById){
        obj = document.getElementById("thumbnails");
		obj.style.left = "0px";
    }
}

var where = 0;
var eerste = 1;
function counter(what, number_pics){
	if(eerste == 1){
		max_pics = number_pics;
		eerste = 0;
	}
	old = where;
    if(what == 'plus'){
		where++;
	}else if(what == 'minus'){
		where--;
	}

	if(-where==0){
		document.getElementById("left_button").style.visibility = 'hidden';
	}else if (-where>=1){
				document.getElementById("left_button").style.visibility = 'visible';
	}

	if(-where>=max_pics-3){
		document.getElementById("right_button").style.visibility = 'hidden';
	}else if (-where<max_pics-3){
		document.getElementById("right_button").style.visibility = 'visible';
	}


	if(old > where){
		slideLeft(where);
	}else if(old < where){
		slideRight(where);
	}
}

function slideRight(where){
        if(document.getElementById){
                if(parseInt(obj.style.left) < 110*where){
                        obj.style.left = parseInt(obj.style.left) + 5 + "px";
                        setTimeout("slideRight(where)",20);
                }
        }
}

function slideLeft(where){
        if(document.getElementById){
                if(parseInt(obj.style.left) > 110*where){
                        obj.style.left = parseInt(obj.style.left) - 5 + "px";
                        setTimeout("slideLeft(where)",20);
                }
        }
}

//init();