var clipTop = 0;
var clipWidth = 390;//value to be same as css width value
var clipBottom = 200;
var topper = 150;//scrolling height
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML,mytemplate;

function Is(){
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('netscape') != -1)));
    this.moz = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('netscape') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ns6 = (this.ns && (this.major >= 5));	
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.moz = (this.moz && (this.major == 5));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);	
}
var is = new Is();

function init(mytemplate,myTop)
{
	Is();
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	if(mytemplate == '1'){
		var x = new getObj('textcontent1');
		clipWidth = 395;
		clipBottom = 272;
		topper = myTop;
		document.getElementById('textcontent1').style.top = myTop 
	}
	else if(mytemplate == '2'){
		var x = new getObj('textcontent2');
		clipWidth = 700;
		clipBottom = 170;
		topper = myTop;
		document.getElementById('textcontent2').style.top = myTop 
	}
	else if(mytemplate == '3'){
		var x = new getObj('textcontent3');
		clipWidth = 700;
		clipBottom = 270;
		topper = myTop;
		document.getElementById('textcontent3').style.top = myTop 
	}
	else{
		var x = new getObj('textcontent4');
		clipWidth = 700;
		clipBottom = 345;
		topper = myTop;
		document.getElementById('textcontent4').style.top = myTop 
	
	}	
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
	}
	adjust(mytemplate);
}

function adjust(mytemplate)
{
	
	if(is.ie){
		 winWidth =  parseInt(document.body.clientWidth);
	}
	else{
	   winWidth = parseInt(window.innerWidth);
	}
	if(mytemplate == '1'){
		if(winWidth > 600){
			myTempPos = parseInt((winWidth - 740)/2);
			myPos = myTempPos + 269 + 30;
		}	
		else{
			myPos = 300;		
		}
		
	}	
	else if((mytemplate == '2') || (mytemplate == '3') || (mytemplate == '4')){
		if(winWidth > 600){
			myTempPos = parseInt((winWidth - 740)/2);
			myPos = myTempPos + 30;
		}	
		else{
			myPos = 300;		
		}
		
	}	
	if(mytemplate == '1'){
		document.getElementById('textcontent1').style.left = myPos;
	}
	else if(mytemplate == '2'){
		document.getElementById('textcontent2').style.left = myPos;
	}
	else if(mytemplate == '3'){
		document.getElementById('textcontent3').style.left = myPos;
	}	
	else if(mytemplate == '4'){
		document.getElementById('textcontent4').style.left = myPos;
	}	
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+', '+clipWidth+', '+clipBottom+', 0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper;
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function vis(val)
{
	if (!DHTML) return;
	var f = new getObj('textcontent1');
	f.style.visibility = val;
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}