var pos = 250;
var interval = 0;
var intervalUp = 0;
var intervalDown = 0;

var posContent = 0;
var scrollHeight = 200;

var myWidth;
var myHeight =20;


function InitSize(){
	var ie_offset = 0;
		if( typeof( window.innerWidth ) == 'number' ) {  
		//Non-IE  
		myWidth = window.innerWidth;  
		myHeight = window.innerHeight;  
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {  
		//IE 6+ in 'standards compliant mode'  
		myWidth = document.documentElement.clientWidth;  
		myHeight = document.documentElement.clientHeight;  
		myHeight = myHeight - 60; //footer
		ie_offset = 345;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {  
		//IE 4 compatible  
		myWidth = document.body.clientWidth;  
		myHeight = document.body.clientHeight;  
	} 


	if(document.getElementById("down")){
		myHeight = (myHeight - 240)/80;
		myHeight = Math.floor(myHeight)*80 + 240;

		if(myHeight - scrollHeight-40<0)
		{
			document.getElementById("down").style.backgroundImage  = "url(img/down1.png)";
		}
		else {
	    	document.getElementById("righttext").style.marginTop  = "50px";
			document.getElementById("down").style.display = "none";
			document.getElementById("up").style.display = "none";
		}
		if (myHeight < 430 )
			myHeight = 430;
	    document.getElementById("mainContent").style.height  = ((myHeight-350)  + "px");
    	document.getElementById("down").style.top  = ((myHeight-340+ie_offset)  + "px");
	}

}


function moveIt() {
      pos = pos +  16;
      document.getElementById("curtain").style.top  = (pos  + "px");
      document.getElementById("curtain").style.height  = ((1200-pos)  + "px");
	  if(pos >= 1000) {
    	window.clearInterval(interval);
	  }
}
function startIt() {
	interval = window.setInterval("moveIt()", 10);
}

function moveUp() {
      posContent = posContent -  2;
	  if(posContent <= myHeight - scrollHeight) {
    	stopUp();
	  }
	  else
	  {
	      document.getElementById("leftside").style.top  = (posContent  + "px");
    	  document.getElementById("rightside").style.top  = (posContent  + "px");
	  }
}
function startUp() {
	document.getElementById("up").style.backgroundImage  = "url(img/up1.png)";
	document.getElementById("down").style.backgroundImage  = "url(img/down2.png)";
	intervalUp = window.setInterval("moveUp()", 10);
}

function stopUp() {
	if(posContent <= myHeight - scrollHeight)
		document.getElementById("down").style.backgroundImage  = "none";
	else
		document.getElementById("down").style.backgroundImage  = "url(img/down1.png)";
	
   	window.clearInterval(intervalUp);
}

function moveDown() {
      posContent = posContent +  2;
	  if(posContent >= 0) {
    	stopDown();
	  }
	  else
	  {
	      document.getElementById("leftside").style.top  = (posContent  + "px");
    	  document.getElementById("rightside").style.top  = (posContent  + "px");
		  
	  }
}
function startDown() {
	document.getElementById("up").style.backgroundImage  = "url(img/up2.png)";
	document.getElementById("down").style.backgroundImage  = "url(img/down1.png)";
	intervalDown = window.setInterval("moveDown()", 10);
}

function stopDown() {
	if(posContent >= 0)
		document.getElementById("up").style.backgroundImage  = "none";
	else
		document.getElementById("up").style.backgroundImage  = "url(img/up1.png)";

   	window.clearInterval(intervalDown);
}

