function showInfo(){
	document.getElementById("foto_div").style.display='none';
	document.getElementById("param_div").style.display='none';
	document.getElementById("feedback_div").style.display='none';
	document.getElementById("info_div").style.display='block';

	document.getElementById("info_td").className='td_list_active';
	document.getElementById("foto_td").className='td_list';
	document.getElementById("param_td").className='td_list';
	document.getElementById("feedback_td").className='td_list';
}

function showFoto(){
	document.getElementById("param_div").style.display='none';
	document.getElementById("feedback_div").style.display='none';
	document.getElementById("info_div").style.display='none';
	document.getElementById("foto_div").style.display='block';

	document.getElementById("info_td").className='td_list';
	document.getElementById("foto_td").className='td_list_active';
	document.getElementById("param_td").className='td_list';
	document.getElementById("feedback_td").className='td_list';
}

function showParam(){
	document.getElementById("foto_div").style.display='none';
	document.getElementById("feedback_div").style.display='none';
	document.getElementById("info_div").style.display='none';
	document.getElementById("param_div").style.display='block';

	document.getElementById("info_td").className='td_list';
	document.getElementById("foto_td").className='td_list';
	document.getElementById("param_td").className='td_list_active';
	document.getElementById("feedback_td").className='td_list';
}

function showFeedback(){
	document.getElementById("foto_div").style.display='none';
	document.getElementById("param_div").style.display='none';
	document.getElementById("info_div").style.display='none';
	document.getElementById("feedback_div").style.display='block';

	document.getElementById("info_td").className='td_list';
	document.getElementById("foto_td").className='td_list';
	document.getElementById("param_td").className='td_list';
	document.getElementById("feedback_td").className='td_list_active';
}

function show_image(img,item){
	document.getElementById("change_img").src=img;
	for(var i=1; i<16; i++){
		if(document.getElementById('span'+i)) document.getElementById('span'+i).className='pic_span';
	}
	document.getElementById('span'+item).className='pic_span_red';
}

function changeBox(count){
	for(var i=1; i<11; i++){
		if(i==count) {
			document.getElementById("rating").value = i;
			document.getElementById("num_"+i).className='num_td_bold';
		}

		if(i<=count) {
			document.getElementById("box_"+i).className='rating_red';
		}

		if(i!=count) {
			document.getElementById("num_"+i).className='num_td';
		}

		if(i>count) {
			document.getElementById("box_"+i).className='rating_gray';
		}

	}
}

//---------------------------------------------------------------------------------------------------------------------------------
// Функции реализующие асинхронное взаимодействие с сервером
//---------------------------------------------------------------------------------------------------------------------------------
var xmlHttp = createXmlHttpRequestObject();
//---------------------------------------------------------------------------------------------------------------------------------
function createXmlHttpRequestObject(){
			
var xmlHttp;

if(window.ActiveXObject){ // Если IE
     try
        {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
             {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
             }
            catch (e) {}
        }

}

else{ // Все остальные браузеры
					
	try{
		xmlHttp = new XMLHttpRequest();
	}
	
	catch (e){
		xmlHttp = false;
	}
}

if(!xmlHttp){ // Не удалось создать
	Alert('Не удалось создать объект XmlHttpRequest'); 
}

else return xmlHttp; 
}
//---------------------------------------------------------------------------------------------------------------------------------
function Process(){
	if ((xmlHttp.readyState == 4) || (xmlHttp.readyState == 0)){
		id = document.getElementById('tone').value;		
		xmlHttp.open("GET","/_get_colors.php?id="+id,true); 
		xmlHttp.onreadystatechange = handleServerResponse;
		if(window.ActiveXObject){ // Если IE
			xmlHttp.send();
		}
		
		else{ // Все остальные браузеры
			xmlHttp.send(null);
		}				
	}
}
//---------------------------------------------------------------------------------------------------------------------------------
function handleServerResponse(){ 
	if (xmlHttp.readyState == 4){ 
		
		if (xmlHttp.status == 200){
			
			try{								
				
				var xmlResponse = xmlHttp.responseXML;
				xmlRoot = xmlResponse.documentElement;
				
				id = xmlRoot.getElementsByTagName('id');
				title = xmlRoot.getElementsByTagName('title');
								
				var sel = document.getElementById('colorbox');

				while (sel.childNodes.length) {
    				if (sel.firstChild.tagName == 'OPTGROUP') {
        				while (sel.firstChild.childNodes.length) {
            				sel.firstChild.removeChild(sel.firstChild.firstChild);
        				}
    				}
    				sel.removeChild(sel.firstChild);
				}					

				sel.options[sel.options.length] = new Option("-все-",0);
				for (var i=0; i<id.length; i++){
					id_text  = id.item(i).firstChild.data;
					title_text = title.item(i).firstChild.data;					
					sel.options[sel.options.length] = new Option(title_text,id_text);
					
				}
				
				var string   = location.href;				
				var position = string.search('c_color');
				string = string.slice(position,position+30);
				
				var pos_start=string.indexOf('=');
				var pos_finish=string.indexOf('&');				
				string = string.slice(pos_start+1,pos_finish);
				
				var value=parseInt(string);
				
				if (string!=''){							
					document.getElementById('colorbox').value=value;				
				}
				
			}
			
			
			catch(e){
				//alert("0шибка чтения ответа:"+e.toString());
			}
		
		} 
		else {}
	}
}
//---------------------------------------------------------------------------------------------------------------------------------

