//start light scroller
function light_up_scroller() {
	for (i=1;i<=10;i++)
	{
		document.getElementById('scroll_img_'+i).src = 'images/home/scroll_info_'+i+'.jpg';
	}
}

function light_down_scroller() {
	for (i=1;i<=10;i++)
	{
		document.getElementById('scroll_img_'+i).src = 'images/home/scroll_info_'+i+'_grey.jpg';
	}
}
//end light scroller

//start hide/show div
function changediv(divname) {
	
	var lyr=document.getElementById(divname);
	var aryTest = ['left_sub_menu_design_and_consultancy','left_sub_menu_control_rooms','left_sub_menu_server_room_infrastructure','left_sub_menu_support_and_maintenance'];
	for (i=0;i<aryTest.length;i++)
	
	{
	
		if (aryTest[i] == divname) {
		
			if (lyr.style.visibility == 'visible')
			{
				lyr.style.visibility = 'hidden';
				lyr.style.position = 'absolute';
			} else {
				lyr.style.visibility = 'visible';
				lyr.style.position = 'static';
			}
		} else {
			document.getElementById(aryTest[i]).style.visibility = 'hidden';
			document.getElementById(aryTest[i]).style.position = 'absolute';
		}

	}
}
//end hide/show div


//close div
function closediv(divname) {
	
	var lyr=document.getElementById(divname);
	lyr.style.visibility = 'hidden';
	lyr.style.position = 'absolute';
	
}
//end hide/show div

//show video div
function showvideo(video_name, video_width, video_height) {
	video_location = '/assets/videos/'+video_name+'/'+video_name+'.html';
	
	document.getElementById('video_frame').src=video_location;
	document.getElementById('video_frame').width=video_width;
	document.getElementById('video_frame').height=video_height;

	var lyr=document.getElementById('video_back');
	lyr.style.visibility = 'visible';
	lyr.style.position = 'absolute';
}
//end hide/show div

//hide video div
function hidevideo() {
	var lyr=document.getElementById('video_back');
	lyr.style.visibility = 'hidden';
	lyr.style.position = 'absolute';
	document.getElementById('video_frame').src='/assets/videos/blank.html';	
}
//end hide/show div

//show image div
function showimage(image_name) {
	new_location = '/assets/images/view_large/'+image_name
	document.getElementById('image_frame').src=new_location;

	var lyr=document.getElementById('image_back');
	lyr.style.visibility = 'visible';
	lyr.style.position = 'absolute';
}
//end hide/show div

//hide image div
function hideimage() {
	var lyr=document.getElementById('image_back');
	lyr.style.visibility = 'hidden';
	lyr.style.position = 'absolute';
	document.getElementById('image_frame').src='/assets/images/view_large/blank.gif';	
}
//end hide/show div


//start scroll div
window.onDomReady = DomReady;

function DomReady(fn) {
//W3C
if(document.addEventListener) {
document.addEventListener("DOMContentLoaded", fn, false);
}
//IE
else {
document.onreadystatechange = function(){readyState(fn)}
}
}

//IE execute function
function readyState(fn) {
//dom is ready for interaction
if(document.readyState == "interactive" || document.readyState == "complete") {
fn();
}
}

// auto scroll code
scrollStep=1;

timerLeft="";
timerRight="";

function toLeft(id){
document.getElementById(id).scrollLeft=0;
}

function scrollDivLeft(id){
clearTimeout(timerLeft);
clearTimeout(timerRight);
document.getElementById(id).scrollLeft+=scrollStep;
timerRight=setTimeout("scrollDivLeft('"+id+"')",10);
}

function scrollDivRight(id){
clearTimeout(timerLeft);
clearTimeout(timerRight);
document.getElementById(id).scrollLeft-=scrollStep;
timerLeft=setTimeout("scrollDivRight('"+id+"')",10);
}

function scrollAutoRight(id){
clearTimeout(timerLeft);
clearTimeout(timerRight);
document.getElementById(id).scrollLeft+=scrollStep;

	if (document.getElementById(id).scrollLeft > 1032) {
		scrollAutoLeft(id);
	} else {
		timerRight=setTimeout("scrollAutoRight('"+id+"')",10);	
	}
}

function scrollAutoLeft(id){
clearTimeout(timerLeft);
clearTimeout(timerRight);
document.getElementById(id).scrollLeft-=scrollStep;

	if (document.getElementById(id).scrollLeft == 0) {
		scrollAutoRight(id);
	} else {
		timerLeft=setTimeout("scrollAutoLeft('"+id+"')",10);	
	}
}

function toRight(id){
document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth;
}

function stopMe(){
clearTimeout(timerRight) ;
clearTimeout(timerLeft);
}

//end scroll div
