

//Constant Variables
var LEFT_BLOCK = 'scroller_left_';
var RIGHT_BLOCK = 'scroller_right_';
var LEFT_BLOCK_LEFT = '-473px';
var MARGIN_MIN = 0;
var MARGIN_MAX = 473;
var LEFT_MIN = -473;
var LEFT_MAX = 0;

// Global Variables
var current_left_block;
var current_right_block;
var target_left_block;
var target_right_block;


//////////////////////////
/////Mouseover Links//////
//////////////////////////
var service_array = [];
service_array[0] = 'service_default';
service_array[1] = 'cnc_programming';
service_array[2] = 'cnc_process_documentation';
service_array[3] = 'cnc_process_simulation_verification';
service_array[4] = 'inspection_metrology';
service_array[5] = 'fixture_tooling_design';

var solutions_left_array = [];
solutions_left_array[0] = 'cam_train_left';
solutions_left_array[1] = 'post_dev_left';
solutions_left_array[2] = 'post_lib_left';
solutions_left_array[3] = 'man_dat_left';
solutions_left_array[4] = 'automation_left';

var solutions_right_array = [];
solutions_right_array[0] = 'cam_train_right';
solutions_right_array[1] = 'post_dev_right';
solutions_right_array[2] = 'post_lib_right';
solutions_right_array[3] = 'man_dat_right';
solutions_right_array[4] = 'automation_right';

function slideBoth(direction, final_style_left_margin, final_style_left) {
	
	var style_left_margin, style_left;
	
	if (direction == 'left') {
		
		style_left = parseInt(current_left_block.style.left) - 24;
		style_left_margin = parseInt(current_right_block.style.marginLeft) - 24;

		if (style_left_margin <= final_style_left_margin) {
			current_left_block.style.left = final_style_left +"px";
			current_right_block.style.marginLeft = final_style_left_margin +"px";
			return;
			//		alert("leaving slideDiv due to margin at min");
		}
		else {
			current_left_block.style.left = '' +style_left+ 'px';
			current_right_block.style.marginLeft = '' +style_left_margin+ 'px';
			setTimeout("slideBoth('" +direction+ "','" +final_style_left_margin+ "','" +final_style_left+ "')", 10);
		}
	}
	
	else if (direction == 'right') {
		
		style_left = parseInt(target_left_block.style.left) + 24;
		style_left_margin = parseInt(current_right_block.style.marginLeft) + 24;

		if (style_left_margin >= MARGIN_MAX) {
			target_left_block.style.left = LEFT_MAX +"px";
			current_right_block.style.marginLeft = MARGIN_MAX +"px";
			return;
		}
		else {
			target_left_block.style.left = '' +style_left+ 'px';
			current_right_block.style.marginLeft = '' +style_left_margin+ 'px';
			setTimeout("slideBoth('" +direction+ "','" +MARGIN_MAX+ "','" +LEFT_MAX+ "')", 10);
		}
	}
	
}

//Function to toggle the content layers
function toggleLayer(which_layer, which_array)
{  
	var elem, vis;
	
	//alert(which_array.length);
		
	for (i=0; i<which_array.length; i++)
	{

	if( document.getElementById ) // this is the way the standards work    
		elem = document.getElementById( which_array[i] );  

	else if( document.all ) // this is the way old msie versions work      
		elem = document.all[which_array[i]];  

	else if( document.layers ) // this is the way nn4 works    
		elem = document.layers[which_array[i]];  
	
	vis = elem.style;  
	
	// if the style.display value is blank we try to figure it out here  
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  

	if (elem.id == which_layer)
	  vis.display = 'block';
	else 
	  vis.display = 'none';

	}		
}

function defaultContent() {
			
	for (i=1; i<service_array.length; i++) {
		getElm(service_array[i]).style.display = 'none';
		getElm(service_array[0]).style.display = 'block';
	}
}

function slideLeft(whichDiv, direction, final_coord) {
	
	getTargetBlocks(whichDiv);
	
	if (parseInt(target_left_block.style.left) == final_coord) {
		return;
	}

	if ((parseInt(current_right_block.style.marginLeft) == MARGIN_MIN) && (current_left_block.id == target_left_block.id)) {
		return;
	}
	if ((parseInt(current_right_block.style.marginLeft) == MARGIN_MIN) && (current_left_block.id != target_left_block.id)) {
		slideBoth('right', MARGIN_MAX, LEFT_MAX);
		return;
	}
	
	if (direction == 'left') {

	left_style = parseInt(target_left_block.style.left) - 24;
		
	if (left_style <= final_coord) {
			target_left_block.style.left = final_coord +"px";
			return;
			//		alert("leaving slideDiv due to margin at min");
		}
		else {
			target_left_block.style.left = left_style+ "px";
			setTimeout("slideLeft('" +whichDiv+ "','" +direction+ "','" +final_coord+ "')", 10);
		}
	}
	
	else if (direction == 'right') {
		
	left_style = parseInt(target_left_block.style.left) + 24;
		
	if (left_style >= final_coord) {
			target_left_block.style.left = final_coord +"px";
			return;
			//		alert("leaving slideDiv due to margin at min");
		}
		else {
			target_left_block.style.left = '' +left_style+ "px";
			setTimeout("slideLeft('" +whichDiv+ "','" +direction+ "','" +final_coord+ "')", 10);
		}
	}
}

function clickService(){
	
	slideBoth('right', 473, 0);
}

function initBlocks(whichDiv){
	if( document.getElementById ) { // this is the way the standards work    
		current_left_block = document.getElementById( LEFT_BLOCK +whichDiv+ '');  
		current_right_block = document.getElementById( RIGHT_BLOCK +whichDiv+ '');  
	}

	else if( document.all ) { // this is the way old msie versions work      
		current_left_block = document.all[LEFT_BLOCK +whichDiv+ ''];  
		current_right_block = document.all[RIGHT_BLOCK +whichDiv+ ''];
	}

	else if( document.layers ) {// this is the way nn4 works    
		current_left_block = document.layers[LEFT_BLOCK +whichDiv+ ''];
		current_right_block = document.layers[RIGHT_BLOCK +whichDiv+ ''];
	}
}

function getTargetBlocks(whichDiv) {
	if( document.getElementById ) { // this is the way the standards work    
		target_left_block = document.getElementById( LEFT_BLOCK +whichDiv+ '');  
		target_right_block = document.getElementById( RIGHT_BLOCK +whichDiv+ '');  
	}

	else if( document.all ) { // this is the way old msie versions work      
		target_left_block = document.all[LEFT_BLOCK +whichDiv+ ''];  
		target_right_block = document.all[RIGHT_BLOCK +whichDiv+ ''];
	}

	else if( document.layers ) {// this is the way nn4 works    
		target_left_block = document.layers[LEFT_BLOCK +whichDiv+ ''];
		target_right_block = document.layers[RIGHT_BLOCK +whichDiv+ ''];
	}
}