
function height() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function check() {
  //alert('window height: '+height()+"\n\n"+'content height: '+(document.getElementById('content').offsetHeight+200));
  var bottom = document.getElementById('bottom');

  var background = document.getElementById('background');

  var content = document.getElementById('content');
	
  if((content.offsetHeight+104) < height()) {
    background.style.height = (height())+'px';
    background.style.overflow = 'hidden';
  } else {
    if(height() < 701) background.style.overflow = 'hidden';
    background.style.height = (content.offsetHeight+104)+'px';
  }
  
  document.getElementById('frameText').height = ((height( ) - 257) + "px");
    
  setTimeout("check()", 1000);
}

var set = 0;
function rollover(obj) {
  if(set == 0) {
    var name = obj.src.replace(".gif", "");
    obj.src = name+"over.gif";
    set = 1;
  } else {
    var name = obj.src.replace("over.gif", "");
    obj.src = name+".gif";
    set = 0;
  }
}

function sliderHeight() {
    var content = document.getElementById('content');
    var TafsirContents = document.getElementById('TafsirContents');
    var TafsirIn = document.getElementById('TafsirIn');
    var TafsirOut = document.getElementById('TafsirOut');

	if(height() < 171)
	{
		TafsirIn.style.height = 50 + 68 + "px";
		TafsirContents.style.height = 37 + "px";
		TafsirOut.style.top = (50 + 68)/2 - 19 + "px";
	}
	else
	{
		if((height() - 166 - 68 - 37) < 0)
		{
			TafsirIn.style.height = 73 + 56 + "px";
			TafsirContents.style.height = 37 + "px";
			TafsirOut.style.top = (50 + 68)/2 - 1 + "px";
		}
		else
		{
			// 122 == footer
			// 44 == scroller window from top
			// 166 == (footer + scroller window from top)
			// 68 == contents from scroller window's top
			// 37 == height of close button
			TafsirIn.style.height = height() - 166 + "px";
			TafsirContents.style.height = height() - 166 - 68 - 56 + "px";
			TafsirOut.style.top = (height() - 166 - 37)/2 - 1 + "px";
		}
	}

  	setTimeout("sliderHeight()", 100);
}


window.onload = function() {
	check();
	sliderHeight();
	//startMenu();
	initPage( {sura: 0, aya: 0, page: 0, juz: 0} );
}
