// JavaScript Document
<!--//
var all_text = new Array();
var scroll_div;
var scroll = true;
var width = 0;
var curr_index = 0;
var curr_index2 = 1;
var timeout_id = null;
var div1 = null;
var div2 = null;

//editable area
var scroll_name = "scroll";//the id of the html element that will containt he scroller
var pause = 3000;//The amount of time to pause when text reaches the left margin
var scroll_speed = 30;//The speed of the scroller - 1000 equals one second
var pixel_reduction = 1;//The number of pixels to remove with each pass
var stop_padding = 2;//stop this many pixels from the left margin
var w_resize_able = true;//whether or not to resize the width of the scroll with the window resizes
var w_offset = 318;//if the scroll is resizable subtract this from the scroll with, else this is the scroller width
var left_margin = 10;//left margin of the scroller

//messages - create as many as you want, you need at least one
all_text[0] = "Specializing in first time and <a href='courses.html#first' class='links'>16 year old programs</a>.";
all_text[1] = "<a class='links' href='about.html'>Patient &amp; professional instructors</a>, we cater to the <a class='links' href='testimonials.html'>needs of all our students</a>.";
//end editable area

function init(){
	div1 = div(0);
	div2 = div(1);
	scroll_div = document.getElementById(scroll_name);
	if(w_resize_able)
		width = get_width()-w_offset;
	else
		width = w_offset;
	scroll_div.style.width=width;
	scroll_div.style.overflow="hidden";
	scroll_div.style.marginLeft=left_margin;
	
	if (window.addEventListener){//firefox
		scroll_div.addEventListener("mouseover", stop, false);
		scroll_div.addEventListener("mouseout", start, false);
		if(w_resize_able)
			window.addEventListener("resize", reset_window, false);
	}
	else if (window.attachEvent){//ie
		scroll_div.attachEvent("onmouseover", stop);
		scroll_div.attachEvent("onmouseout", start);
		if(w_resize_able)
			window.attachEvent("onresize", reset_window);
	}
	else{//anything else
		scroll_div.onmouseover=stop;
		scroll_div.onmouseout=start;
		if(w_resize_able)
			window.onresize = reset_widnow;
	}
	
	if(all_text.length == 1)
		all_text[1] = all_text[0];
	
	scroll_text();
}


function reset_window(){
	width = get_width()-w_offset;
}

function get_width(){
	if (document.body.clientWidth)
		winW = document.body.clientWidth;
	else if(window.innerWidth)
		winW = window.innerWidth;
	else if(document.body.offsetWidth)
		winW = document.body.offsetWidth;
	winW = winW - (winW > 980?winW-980:0);
	return winW;
}

function get_hieght(){
	var winW;
	if (document.body.clientHeigth)
		winW = document.body.clientHeight;
	else if(window.innerHeigth)
		winW = window.innerHeight;
	else if(document.body.offsetHeight)
		winW = document.body.offsetHeight;
	return winW;
}

function div(index){
	temp = new Object();
	temp.index = index;
	temp.left = index==0?stop_padding:width+stop_padding;
	return temp;
}

function stop(){
	if(timeout_id != null && !scroll)
		window.clearTimeout(timeout_id);
	scroll = false;
}

function start(){
	scroll=true;
	scroll_text();
}

function update_id(last_updated){
	if(last_updated == 0 && div2.index == div1.index)
		div1.index++;
	else if(last_updated == 1 && div2.index == div1.index)
		div2.index++;
		
	if(div2.index >= all_text.length)
		div2.index = 0;
	else if(div1.index >= all_text.length)
		div1.index = 0;
}

function check_scroll(){
	if(div1.left == stop_padding){
		div2.index++;
		if(div2.index >= all_text.length)
			div2.index = 0;
		update_id(1)
		div2.left = width+stop_padding;
		stop();
		timeout_id = window.setTimeout("start()", pause);
	}
	else if(div2.left == stop_padding){
		div1.index++;
		if(div1.index >= all_text.length)
			div1.index = 0;
		update_id(0)
		div1.left = width+stop_padding;
		stop();
		timeout_id = window.setTimeout("start()", pause);
	}	
}

function scroll_text(){
	
	for(i=0;i<pixel_reduction;i++){
		check_scroll();
		div1.left = div1.left-1;
		div2.left = div2.left-1;
	}
	
	scroll_div.innerHTML = "<div style='position:absolute;width:"+width+"px;clip:rect(0 "+width+" 40 0);overflow:hidden;'><div style='position:relative;left:"+div1.left+"px;white-space:nowrap;'>"+all_text[div1.index]+"</div><div style='position:relative;top:-14px;left:"+div2.left+"px;white-space:nowrap;'>"+all_text[div2.index]+"</div></div>";
	
	if(scroll)
		setTimeout("scroll_text()", scroll_speed);
}

//-->
