// JavaScript Document

// SUPPORT MENU
var menu_right_action;

function support_scroll(direction, left_arrow_id, right_arrow_id){
	id = 'the_support_menu';
	
	if(!slide_occuped[id]){
		slide_occuped[id] = direction;
		pos_slide_max[id] = (p_max[id] - p_show[id]) * p_size[id] * -1;
		
		//new pos calculating
		if(!new_pos[id] || new_pos[id] == "undefined") new_pos[id] = current_pos[id];
		if(!pos_slide_min[id]) pos_slide_min[id] = 0;
		
		if( direction == 'left' && current_pos[id] > pos_slide_max[id]){
			new_pos[id] = new_pos[id] - (p_show[id] * p_size[id]);
			if(document.getElementById(left_arrow_id).style.visibility == 'hidden') apparition(left_arrow_id, 100);
			if(new_pos[id] < pos_slide_max[id]){
				new_pos[id] = pos_slide_max[id];
				disparition(right_arrow_id, 0);
			}
		}
		else if( direction == 'right' && current_pos[id] < pos_slide_min[id] ){
			new_pos[id] = new_pos[id] + (p_show[id] * p_size[id]);
			if(document.getElementById(right_arrow_id).style.visibility == 'hidden') apparition(right_arrow_id, 100);
			if(new_pos[id] + 2 > pos_slide_min[id]){
				new_pos[id] = pos_slide_min[id];
				disparition(left_arrow_id, 0);
			}
		}
		
		slide_deceleration[id] = (new_pos[id] + current_pos[id]) / 2;
		//move
		if(direction == 'left' && new_pos[id] >= pos_slide_max[id]){
			new_pos[id] = new_pos[id] - 2;
			p_first[id] = p_first[id] + p_show[id];
			p_last[id] = p_last[id] + p_show[id];
			slide_move(id);
		}
		else if(direction == 'right' && new_pos[id] <= pos_slide_min[id]){
			p_first[id] = p_first[id] - p_show[id];
			p_last[id] = p_last[id] - p_show[id];
			slide_move(id);
		}
		else{
			slide_occuped[id] = false;
			slide_deceleration[id] = false;
		}
	}
}

function enabled_support_menu(state){
	
	id = "supports_menu";
	id2 = "support_slide";
	
	if(!state){
		document.getElementById(id).className = "barre_support disabled";
		document.getElementById(id2).style.display = 'none';
	}
	else{
		document.getElementById(id).className = "barre_support";
		document.getElementById(id2).style.display = 'block';
	}
}

function enabled_support_search(state){
	id = "search_support";
	
	if(!state) document.getElementById(id).className = 'disabled';
	else document.getElementById(id).className = '';
}

function enabled_support_list(state){
	id = 'menu_right_name';
	id_slide = 'slide-right';
	
	if(state){
		document.getElementById(id).className = 'hover';
		show_section_list(); //ouvre ou ferme le menu selon son état
	}
	else{
		document.getElementById(id).className = 'disabled';
		//open_menu_right(id_slide, false); //fermeture du menu
	}
}
function show_section_list(){
	id = 'slide-section';
	sendRequest('ajax_response7.php', 'slide-section');
	display = document.getElementById(id).style.display;
	
	if(!display || display != 'block'){
		open_menu_right(id, true)
		/*document.getElementById('menu_right_name').innerHTML = 'SELECT BY NAME';
		document.getElementById('menu_right_name').className = 'hover';*/
	}
	else{
		open_menu_right(id, false)
		/*document.getElementById('menu_right_name').innerHTML = 'SELECT BY TYPE';
		document.getElementById('menu_right_name').className = '';*/
	}
}
function show_support_list(){
	id = 'slide-right';
	
	display = document.getElementById(id).style.display;
	
	if(!display || display != 'block'){
		open_menu_right(id, true)
		/*document.getElementById('menu_right_name').innerHTML = 'SELECT BY NAME';
		document.getElementById('menu_right_name').className = 'hover';*/
	}
	else{
		open_menu_right(id, false)
		/*document.getElementById('menu_right_name').innerHTML = 'SELECT BY TYPE';
		document.getElementById('menu_right_name').className = '';*/
	}
}

var slide_arr = new Array();
function show_txt_right(num, total){
	slide_arr[num].toggle();
	if(document.getElementById('box-title'+num).className == 'case-right hover') document.getElementById('box-title'+num).className = 'case-right';
	else document.getElementById('box-title'+num).className = 'case-right hover';
	//total = total + 1;
	
	for(i=0;i<total;i++){
		if(i != num){
			slide_arr[i].slideOut();
			document.getElementById('box-title'+i).className = 'case-right';
		}
	}
}

function category_support_menu_hover(num, id, total){
	id1 = 'support';
	id2 = 'category';
	
	for(i=0;i<=total;i++){
		if(i == num){
			document.getElementById(id2+i).className = 'hover';
			document.getElementById(id1+i).value = 1;
		}
		else{
			document.getElementById(id2+i).className = '';
			document.getElementById(id1+i).value = 2;
		}
		//alert(document.getElementById(id1+i).value);
	}
	menuSlider.init('support_menu','support_slide');
}

function submit_search(){
	words = document.getElementById('support_search2').value;
	//sendRequest('ajax_response3.php?words='+words, 'stab');
	sendRequest('test.php?words='+words, 'stab');
}

function change_arianne(tnew){
	if(tnew){
		document.getElementById('arianne').innerHTML = '&gt;&gt; '+tnew+'&nbsp;';
		document.getElementById('arianne_old').className = "arianne";
	}
	else{
		document.getElementById('arianne').innerHTML = '';
		document.getElementById('arianne_old').className = "arianne_hover";
	}
}

function toggle_support_type(id, num, total){
	for(i=0;i<total;i++){
		if(i != num) document.getElementById(id+i).style.display = 'none';
		else{
			if(document.getElementById(id+i).style.display == 'inline') document.getElementById(id+i).style.display = 'none';
			else document.getElementById(id+i).style.display = 'inline';
		}
	}
}

function refuserToucheEntree(event){
    // Compatibilité IE / Firefox
    if(!event && window.event) {
        event = window.event;
    }
    // IE
    if(event.keyCode == 13) {
        event.returnValue = false;
        event.cancelBubble = true;
		submit_search();
    }
    // DOM
    if(event.which == 13) {
        event.preventDefault();
        event.stopPropagation();
		submit_search();
    }
}

