var timer = 0;
var width = 946;
var width_multiplyer = 0;

$(document).ready(function(){
						   	
	//alert('hello');
	
	var stop_at = $('ul#home_banner_array li').size(); // method // action // no perameters
	
	//alert(stop_at);
	
	function myAnimation(direction) { // function // method
	
		if(direction == 'left'){
			
			if(width_multiplyer <= 0){
				
				width_multiplyer = stop_at-1;
				
			}
			else {
				width_multiplyer--;
			}
			var animate_left = '-'+(width*width_multiplyer);
			
		}
		else if(direction == 'right'){
			
			if(width_multiplyer >= (stop_at-1)) { // > < == >= <= !=
				width_multiplyer = 0;
			} //if
			else {
				width_multiplyer++;	
			}
			var animate_left = '-'+(width*width_multiplyer);
			
		}
		else{
			
			if(width_multiplyer >= (stop_at-1)) { // > < == >= <= !=
				width_multiplyer = 0;
			} //if
			else {
				width_multiplyer++;	
			}
			var animate_left = '-'+(width*width_multiplyer);
			
		}
		
		$('ul#home_banner_array').animate({left: animate_left}, 1000);
			
	} // function
	
	
	
	
	timer = setInterval(myAnimation, 7000, 'auto'); // 2 perameters
	
	//clearInterval(timer);
	
	$('a#arrow_left').click(function(){
		clearInterval(timer);
		myAnimation('left');
	});
	
	$('a#arrow_right').click(function(){
		clearInterval(timer);							 
		myAnimation('right');
	});
	
	
	
	//FANCYBOX
	
	$('a.copy_img_a').fancybox();
	
	
	// CONTACT FORM
	/* */
	$(".esd_contact").fancybox({
		'width'				: 420,
		'height'			: 500,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	
	$('a.headlink_a').each(function(){
	
		var this_is = $(this);
		var this_link_name = $(this).html();
		//alert(this_link_name);
		
		$(this).parent().find('ul li a').each(function(i){

			//alert(i);
			var this_a = $(this);
			var this_a_href = this_a.attr('href');
			var this_link_a_name = $(this).html();
			//alert(this_link_a_name);
			
			if(this_link_name == this_link_a_name){
			
				//alert(this_a_href);
				this_is.attr('href',this_a_href);
				this_a.hide();
				
			
			}
			
		
		});
		
	
	});
	
			
}); // ready



