function doLoad(value,path) {
     	
      page_waiting=document.getElementById('ajax_working');
      if (page_waiting){
      	   page_waiting.style.top = (((document.body.offsetHeight/2)-50)+document.body.scrollTop) + 'px';
           page_waiting.style.display = 'block';
      }
           
         var req = new JsHttpRequest();
         req.onreadystatechange = function() 
               {
             if (req.readyState == 4 ) 
                    {
                    if (req.responseText) alert(req.responseText);

                    switch (req.responseJS.action)
                         {
                         case 'selcol':
                            {
                            	if (req.responseJS.item_id){
	                              var info_title = document.getElementById('color_'+req.responseJS.item_id);
	                              if (info_title){
	                              	info_title.style.display = 'none';
	                              }

                            	}
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         case 'printable':
                            {
	                              var info_title = document.getElementById('table_price');
	                              var contzone = document.getElementById(req.responseJS.par);
//	                              alert(req.responseJS.par);
	                              if (info_title && contzone){
	                              	contzone.style.background = 'none';
	                              	contzone.innerHTML = '<table cellspacing="0" border="0" class="printable">'+info_title.innerHTML+'</table>'+req.responseJS._date;
	                              	
	                              	
//	                              	location.href='?print_version';
	                              }
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         case 'addcheck':
                            {
	                              info_title=document.getElementById('table_price');
	                              if (info_title){
	                              	var send_form = document.getElementById('orderspec');
	                              	if (send_form){	                              		
	                              		if (req.responseJS.par>0){
	                              			send_form.price.value = '<br><br><table border="1" cellspadding="5">'+info_title.innerHTML+'</table>';
	                              		}else {
	                              			send_form.price.value = '';
	                              		}
	                              	}
	                              }
	                              
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         case 'newpar':
                            {
								doLoad('','/ajax/ceilcat/1/1/1/5/');
                            }
                         break;
                         case 'ceilcat':
                            {
	                              info_title=document.getElementById('is2');
	                              if (info_title){
	                              	   showform(2);
	                                   info_title.innerHTML = req.responseJS.content;
	                              }
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         case 'ceiltab':
                            {
//                            	alert(req.responseJS.pric2);
                            	  if (req.responseJS.pric2){
                            	  	if (document.getElementById('pric2'))
                            	  		document.getElementById('pric2').value = req.responseJS.pric2;
                            	  }
                            	  	
	                              info_title=document.getElementById('itog');
	                              if (info_title){
	                                   info_title.innerHTML = req.responseJS.content;
	                              }
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         case 'showpic':
                            {
								  showWindow('gallery');
	                              var oursblock = document.getElementById('gallery');
								  if (oursblock)
									oursblock.style.height = document.body.scrollHeight+20;

	                              info_title=document.getElementById('showpic');
	                              if (info_title){
	                                   info_title.innerHTML = req.responseJS.content;
	                                   info_title.style.width = (navigator.appName=="Netscape" || navigator.appName=="Opera" ? req.responseJS.width : parseInt(req.responseJS.width)+40);
	                                   info_title.style.marginTop = ((parseInt(document.body.clientHeight)-parseInt(req.responseJS.height))/2)+50;
//	                                   setTimeout(function() {info_title.style.top = (parseInt(document.body.clientHeight)-parseInt(info_title.offsetHeight))/2;info_title.style.left = (document.body.clientWidth-info_title.offsetWidth)/2;}, 100);
	                              }    
                              if (page_waiting)
                            	page_waiting.style.display = 'none';
                            }
                         break;
                     
                         case 'inneritem':
                            {
	                              var inneritem = document.getElementById('inneritem');
								  if (inneritem){
								  	 var incontent = document.getElementById('incontent');
								  	 if (incontent){
										 incontent.innerHTML = req.responseJS.content;
									  	 inneritem.style.display = 'block';
									  	 inneritem.style.width = document.body.scrollWidth;
									  	 inneritem.style.height = document.body.scrollHeight+20;//((document.body.scrollHeight-(((document.body.offsetHeight/2)-220)+document.body.scrollTop)))+'px';
									  	 inneritem.style.paddingTop = (((document.body.offsetHeight/2)-220)+document.body.scrollTop) + 'px';
//									  	 inneritem.style.height = document.body.scrollHeight+20-inneritem.style.paddingTop;//((document.body.scrollHeight-(((document.body.offsetHeight/2)-220)+document.body.scrollTop)))+'px';
								  	 }
								  }

                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         
                         
                         case 'region':
                            {
                            	if (req.responseJS.type=='error') {
								  showWindow('gallery');
	                              var oursblock = document.getElementById('gallery');
								  if (oursblock)
									oursblock.style.height = document.body.scrollHeight+20;

	                              info_title=document.getElementById('showpic');
	                              if (info_title){
	                                   info_title.innerHTML = req.responseJS.content;
	                                   info_title.style.width = (navigator.appName=="Netscape" || navigator.appName=="Opera" ? req.responseJS.width : parseInt(req.responseJS.width)+40);
	                                   info_title.style.marginTop = (parseInt(document.body.offsetHeight)-parseInt(req.responseJS.height))/2;
//	                                   setTimeout(function() {info_title.style.top = (parseInt(document.body.clientHeight)-parseInt(info_title.offsetHeight))/2;info_title.style.left = (document.body.clientWidth-info_title.offsetWidth)/2;}, 100);
	                              }
	                              
	                              //document.getElementById('geo_1000000').value='Екатеринбург';
	                              //document.getElementById('city').innerHTML='Екатеринбург';
	                              //setRegion('region_form','nowin');
                            	} 
                            	else if (req.responseJS.type=='saved') {
	                              //document.getElementById('geo_1000000').value=req.responseJS.content;
	                              //document.getElementById('city').innerHTML=req.responseJS.content;
	                              window.location.reload();                     		
                            	}
                            	
                            	
                            	
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;   
                         
                         case 'regions_list':
                            {
                            	if (req.responseJS.type=='error') {
								  showWindow('gallery');
	                              var oursblock = document.getElementById('gallery');
								  if (oursblock)
									oursblock.style.height = document.body.scrollHeight+20;

	                              info_title=document.getElementById('showpic');
	                              if (info_title){
	                                   info_title.innerHTML = req.responseJS.content;
	                                   info_title.style.width = (navigator.appName=="Netscape" || navigator.appName=="Opera" ? req.responseJS.width : parseInt(req.responseJS.width)+40);
	                                   info_title.style.marginTop = (parseInt(document.body.offsetHeight)-parseInt(req.responseJS.height))/2;
	                              }
	                              
                            	} 
                            	else if (req.responseJS.type=='write') {
	                            	//document.getElementById('towns').innerHTML = req.responseJS.content;
	                            	window.location.reload(); 
                            	}
                            	
                            	
                            	
                              if (page_waiting)
                              	page_waiting.style.display = 'none';
                            }
                         break;
                         
                         case 'region_set':
                            {
	                        	if (req.responseJS.type=='saved') {
	                            	window.location.reload(); 
	                        	}

	                            if (page_waiting)
	                              	page_waiting.style.display = 'none';
                            }
                         break;
                         
                                               
                         }
                    }
               }

          if (value!="")
               {
               value=document.getElementById(value);
               }     

         req.open('', path, true);
         req.send( { 'data': value } );
     }  
     
      function discardElement(f)
     {
     }

     
function setRegion(th) {
	doLoad(th,'/ajax/region/');
	return false;
}
     
function get_setTown(town)
{
	doLoad('','/ajax/region_set/'+town+'/');
}

function reg_townsList(region) 
{
	doLoad('','/ajax/regions_list/'+region+'/');
}
     
     
function ClientWidth() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function ClientHeight() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}	

function ScrollLeft() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollLeft:document.body.scrollLeft;
}

function ScrollTop() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollTop:document.body.scrollTop;
}	

    
function commWindow(block){
	var oursblock = document.getElementById(block);
	if (oursblock){
		if (oursblock.style.display == 'block')
			oursblock.style.display = 'none';
		else 
			oursblock.style.display = 'block';
	}
}


function closeWindow(block){
	var oursblock = document.getElementById(block);
	if (oursblock)
		oursblock.style.display = 'none';
}

function showWindow(block){
	var oursblock = document.getElementById(block);
	if (oursblock)
		oursblock.style.display = 'block';
}

function formsubmit(formsubmit, npage){
	formshedule = document.getElementById(formsubmit);
	
	if (formshedule){
		
		if (npage)
			formshedule.spage.value = npage;
	
		formshedule.submit();
	}
}

function showcolor(num,item,color,texture){
	
//	alert(item);
//	alert(color);
	
	if (document.getElementById('color_item'))
		var std1 = document.getElementById('color_item').getElementsByTagName("span");
	if(std1)
	for (c = 0; c < std1.length; c++) {
		std1[c].className = '';
	}
	
	if (num){
	        num.className = 'act';
    } else {
    		if (document.getElementById('col_'+color))
    			document.getElementById('col_'+color).className = 'act';
    }
    
	var s_flash = document.getElementById('flashshow');
	if (s_flash && s_flash.style.display=='block'){
		if (confirm("Выбор потолка будет изменен в соответствии с выбранными цветом и фактурой.\nСохранить?")){
			if (texture){
				doLoad('','/ajax/flashcheck/'+item+'/'+color+'/'+texture+'/');
//				doLoad('','/ajax/ceiltab/price/'+item+'/');
//				/*setTimeout(function() {*/doLoad('','/ajax/newpar/texture/0/');/*}, 300);*/
//				/*setTimeout(function() {*/doLoad('','/ajax/newpar/art_id/0/');/*}, 500);*/
//				/*setTimeout(function() {*/doLoad('','/ajax/newpar/texture/'+texture+'/');/*}, 400);*/
			}
		}
	}else{
//		doLoad('','/ajax/ceiltab/price/'+item+'/');
		doLoad('','/ajax/selcol/'+item+'/'+color+'/');
	}
//				doLoad('','/ajax/ceiltab/price/'+item+'/');

//    doLoad('','/ajax/selcol/'+item+'/'+color+'/');
    /*if (document.getElementById('is2')){
    	location.href='/calc/is2/';
    } else*/ {
    	setTimeout(function() {CloseFlash();}, 300);
    }
    
}

function showform(num){
	
	if (num==6 && document.getElementById('is6')){
		if (document.getElementById('spord'))
			document.getElementById('spord').style.display = 'none';
	} else {
	 	if (document.getElementById('spord'))
			document.getElementById('spord').style.display = 'block';
		if (document.getElementById('print_version')) 
			document.getElementById('print_version').style.display = 'block';
	}
	
	if (num>0) num = (parseInt(num)-1);
	if (document.getElementById('ctop')){
		var std1 = document.getElementById('ctop').getElementsByTagName("td");
				if(std1)
				for (c = 0; c < std1.length; c++) {
					var bl_is = document.getElementById('is'+(c+1));
				    if (bl_is) bl_is.style.display = 'none';
					std1[c].className = '';
					if (c==num){
					  std1[num].className = 'act';
					  if (bl_is) bl_is.style.display = 'block';
					}
				}
	}
	
}

function SendToFlash(item,art_id)
{
	var iscolor = 0;
	
	if (document.getElementById('color_item'))
		var std1 = document.getElementById('color_item').getElementsByTagName("span");
		
	if(std1)
	for (c = 0; c < std1.length; c++) {
		if (std1[c].className == 'act')
			iscolor = std1[c].id.replace('col_','');
	}
	
	var sflash = document.getElementById('flashshow');
// 	sflash.style.top = (((document.body.offsetHeight/2)-320)+document.body.scrollTop) + 'px';
// 	sflash.style.paddingTop = (((document.body.offsetHeight/2)-320)+document.body.scrollTop) + 'px';
// 	sflash.style.height = (document.body.scrollHeight - (((document.body.offsetHeight/2)-320)+document.body.scrollTop)) + 'px';

	var cheight = ClientHeight();
	if (navigator.appName=="Netscape"){
		sflash.style.paddingTop = (((cheight-650)/2)+ScrollTop()) + 'px';
		sflash.style.height = (document.body.scrollHeight - (parseInt(sflash.style.paddingTop))) + 'px';
	}else if (navigator.appName=="Opera"){
//		document.body.style.overflowX='hidden';
		sflash.style.paddingTop = (((cheight-650)/2) + ScrollTop()) + 'px';
		sflash.style.height = (document.body.scrollHeight - (parseInt(sflash.style.paddingTop))) + 'px';
	}else{
		sflash.style.paddingTop = (((cheight-650)/2)+ScrollTop()) + 'px';
		sflash.style.height = (document.body.scrollHeight) + 'px';
	}

	if (sflash){
		   sflash.style.visibility = 'visible';
		   sflash.style.display = 'block';
//		   sflash.style.left = (parseInt(document.body.clientWidth)-942)/2;
		   
		   var cflash = new SWFObject("/DESIGN/VIPS/flash/siling.swf?xml_path=http://www.vipceiling.ru/menu_xml/"+item+"/"+art_id+"/&item="+item+"&color="+iscolor+"", "cflash", "960px", "650px", "8", "#ffffff");
		   cflash.addParam("AllowScriptAccess", "always");
		   cflash.addParam("wmode", "opaque");
		   cflash.write("flashshow");
		   
		   sflash.innerHTML= '<!--[if lte IE 6]><iframe></iframe><![endif]-->'+sflash.innerHTML;
	}	
}

function CloseFlash()
{
//	alert('test_close');
	var s_flash = document.getElementById('flashshow');
	if (s_flash){
	   if (s_flash.style.display=='block'){
		   s_flash.style.display = 'none';

//           var inneritem = document.getElementById('inneritem');
//		   if (inneritem)
//			  	 inneritem.style.display = 'none';
//		if (!document.getElementById('inneritem'))
		   if (document.getElementById('is2')){
			    	location.href='/calc/is2/';
		   } else {
				   location.href='';
		   }
	   }
	}
}

/*var data = "";
function PrintPreview()
{
	data = document.getElementById("itog").outerHTML;
	window.open('/calc/?print_version',null,'target=_blank,status=0,toolbar=0,scrollbars=1,menubar=1');
}
*/

function windowshow(ID){
	window.open("http://www.vipceiling.ru/openpar/"+ID+"/","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left="+((screen.width-800) / 2)+",top="+((screen.height-600) / 2)+"");
}

function checkTable(){
	
	var orderspec = document.getElementById('orderspec');
	var table_price = document.getElementById('table_price');
	if (orderspec && table_price){
		orderspec.price.value = '<br><br><table border=1 cellpadding=5 cellspacing=0>'+(table_price.innerHTML)+'</table>';//.replace('"','')
	}
}