/***********************************************
* Автомеханика www.autom.com.ua
***********************************************/
/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
/*
NS6 = (document.getElementById&&!document.all); 
IE = (document.all); 
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4"); 

if (window.opera) { 
   IE = false; 
   NS6 = true; 
}
*/


var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject(){
var xmlHttp;

if(window.ActiveXObject)
{
	try{
	xmlHttp = new XmlHttpRequest();
	}
	catch(e){
	var XmlHttpVersions = new Array ("MSXML2.XMLHTTP.6.0",
									"MSXML2.XMLHTTP.5.0",
									"MSXML2.XMLHTTP.4.0",
									"MSXML2.XMLHTTP.3.0",
									"MSXML2.XMLHTTP",
									"Microsoft.XMLHTTP");
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++){
			try{
			xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch (e) {}
		}
	}
}

// если сценарий запущен под управлением Mozilla или др.

else
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = false;
}
}
if (!xmlHttp)
alert ("Ошибка создания объекта XMLHttpRequest");
else
return xmlHttp;

//-----------------
}

function process (ids){
	if (xmlHttp){
		try{
		xmlHttp.open("GET", "basket.php?product_id="+ids+"&product_amount=1", true);
		xmlHttp.onreadystatechange = handleRequestStateChange;
		xmlHttp.send(null);
		}
		catch (e){
			alert ("Невозможно соединиться с сервером:\n" + e.toString());
		}
	}
}

function handleRequestStateChange(){
	if (xmlHttp.readyState == 4){
		if (xmlHttp.status == 200){
			try{
			handleServerResponse();
			}
			catch (e){
			alert ("Ошибка чтения ответа: " + e.toString());
			}
		}
		else {
		alert ("Возникли проблемы во время получения данных: \n" + xmlHttp.StatusText);
		}
	}
}

function handleServerResponse(){
var xmlResponse = xmlHttp.responseText;
var fine = xmlResponse.indexOf('strSummaBezNds>');
var fina = xmlResponse.indexOf('<b id="fine">');
var na = xmlResponse.indexOf('id=total>');
var nb = xmlResponse.indexOf('<b id="tot"');
var numb = xmlResponse.substring((na+9),nb);
var rezul = xmlResponse.substring((fine+15),(fina-3));
myDiv = document.getElementById ("sum");
myDiv1 = document.getElementById ("nume");
myDiv.value = rezul;
myDiv1.value = numb;
}

// OPTIMIZATION  begin

function opa(a,b,c,d,e,m){
var aa = document.getElementById(a);
var bb = document.getElementById(b);
var cc = document.getElementById(c);
var dd = document.getElementById(d);
var ee = document.getElementById(e);
//alert (m);
aa.style.background = "#dadada";
bb.style.color  ="#6a6a6a";
cc.style.display = "none";
dd.style.display = "inline-block";
if (m == 1) ee.style.display = "inline-block";

}




function fop(a){
var aa = document.getElementById(a);
aa.style.background="#ffffff";
}
function fob(a){
var aa = document.getElementById(a);
aa.style.background="#dadada";
}
// OPTIMIZATION  end


function mnu(el,mmel,n) {

    var nel;

	var mind = document.getElementById(mmel);

	var m=n+1;
    if (navigator.appName=="Netscape") {
        nel=document.getElementsByName(el); 
        nel=nel[0]; 
		nel.className=(nel.className=="vis1")?"vis2":"vis1";
        }
		
	else {
	
	for (var y=1; y<m; y++){
	var num = "qas"+y;
	ind = document.getElementById(num);
	
	if ((ind == mind) && (mind.style.display=="inline-block")) {mind.style.display="none"; break;}
	
	if (ind == null) break;
	
	if (ind != mind) ind.style.display="none"; 
	else {mind.style.display="inline-block";}
		//else { if (mind.style.display=="none") mind.style.display="inline-block"; else mind.style.display="none";}
	}
	
	//if (mind != null) {if (mind.style.display=="none") {mind.style.display="inline-block";} else {mind.style.display="none";}}
	}
	
}
	

var defaultMenuWidth="800px"; //set default menu width
var defaultLeftPos  ="505"; //set default left position
var defaultTopPos   ="50px"; //set default top position

var left_pos=new Array();
var top_pos=new Array();
var m_width=new Array();
var linkset=new Array();
var it=new Array();

var defaultMenuWidtht="150px"; //set default menu width
var defaultLeftPost  ="309"; //set default left position
var defaultTopPost   ="101px"; //set default top position

var left_post=new Array();
var top_post=new Array();
var m_widtht=new Array();
var linksett=new Array();
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='';
linkset[1]='';
linkset[2]='';
linkset[3]='';
linkset[4]='';
linkset[5]='';
linkset[6]='';
linkset[7]='';
linkset[8]='';


linksett[0]='';
linksett[1]='';
linksett[2]='';
linksett[3]='';
linksett[4]='';

top_post[0]=99;



top_pos[0]=defaultTopPos;
top_pos[1]=defaultTopPos;
top_pos[2]=defaultTopPos;
top_pos[3]=defaultTopPos;
top_pos[4]=defaultTopPos;
top_pos[5]=defaultTopPos;
top_pos[6]=defaultTopPos;
top_pos[7]=defaultTopPos;
/*
it[0]=482;
it[1]=389;
it[2]=296;
it[3]=203;
it[4]=110;
*/
it[0]=106;
it[1]=214;
it[2]=322;
it[3]=430;
it[4]=538;
it[5]=646;
it[6]=754;
it[7]=862;
it[8]=970;
it[9]=1078;
it[10]=1186;

left_pos[0]=470;
left_pos[1]=570;
left_pos[2]=688;
left_pos[3]=783;
left_pos[4]=878;
left_pos[5]=955;



////No need to edit beyond here
var ie5=document.all && !window.opera;
var ns6=document.getElementById;

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body;
}

if (ie5||ns6)
{
var draw_div = '<div id="popitmenu" style="position: absolute; left: 415px; top: 451px; z-index:10" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>';
 // alert(draw_div);
 document.write(draw_div);
}

function showmenu(e, which, t, bidman, dlina, optWidth)
{
//alert (bidman);
var leng=bidman*1+295;
if (t == 0) leng=295;
//alert (dlina);
//alert (t);
/*
alert('e: '+e+', which: '+which+', optWidth: '+optWidth+', t: '+t+', left_pos['+t+']: '+left_pos[t]);
*/
//alert("Number: "+bidman);
if (!document.all&&!document.getElementById) return;
clearhidemenu();
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu");
menuobj.innerHTML=which;
menuobj.style.width=(typeof optWidth!="undefined")? 800 : dlina;
//alert (document.body.clientWidth);
menuobj.style.left=leng;
menuobj.style.top=(typeof t!="undefined")? 170 : defaultTopPos;
menuobj.contentwidth=menuobj.offsetWidth;
menuobj.contentheight=menuobj.offsetHeight;
eventX=ie5? event.clientX : e.clientX;
eventY=ie5? event.clientY : e.clientY;
//alert((leng-205));
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX;
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY;
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
{
 //move the horizontal position of the menu to the left by it's width
 // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px";
}
else
{
  //position the horizontal position of the menu where the mouse was clicked
  // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px";
}
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px";
}
else
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px";
}
menuobj.style.visibility="visible";
return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
function showmenu1(e, which, t, bidman, spartanci, optWidth)
{
/*
alert('e: '+e+', which: '+which+', optWidth: '+optWidth+', t: '+t+', left_pos['+t+']: '+left_pos[t]);
*/
//alert (spartanci);
if (!document.all&&!document.getElementById) return;
clearhidemenu();
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu");
menuobj.innerHTML=which;
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidtht;
menuobj.style.left= defaultLeftPost;
menuobj.style.top=(typeof t!="undefined")? (bidman*30+43+(spartanci-2)*29) : defaultTopPost;
menuobj.contentwidth=menuobj.offsetWidth;
menuobj.contentheight=menuobj.offsetHeight;
eventX=ie5? event.clientX : e.clientX;
eventY=ie5? event.clientY : e.clientY;
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX;
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY;
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
{
 //move the horizontal position of the menu to the left by it's width
 // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px";
}
else
{
  //position the horizontal position of the menu where the mouse was clicked
  // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px";
}
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px";
}
else
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px";
}
menuobj.style.visibility="visible";
return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj) menuobj.style.visibility="hidden";
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement)) hidemenu();
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) hidemenu();
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500);
}

function clearhidemenu(){
if (window.delayhide) clearTimeout(delayhide);
}

// Added by Shkodenko V. Taras 27/06/2006
// Auto set left position of left menu in float tables
function t_auto_set_left_pos() {
  for(var i=0;i<top_pos.length;i++) {
    left_pos[i] = parseInt(defaultLeftPos);
    if(i>0) {
        for(var j=i; j>0; j--) {
            eval("left_pos["+i+"] += parseInt(document.getElementById('t"+j+"').offsetWidth)+5;");
        }
    }
  }
  
  for(var i=0;i<top_post.length;i++) {
	left_post[i] = parseInt(defaultLeftPost);
    if(i>0) {
        for(var j=i; j>0; j--) {
			eval("left_post["+i+"] += parseInt(document.getElementById('t"+j+"').offsetWidth);");
        }
    }
  }
  for(var t=0; t<left_pos.length; t++)
   left_pos[t] = left_pos[t]+"px";
  for(var t=0; t<left_post.length; t++)
   left_post[t] = left_post[t]+"px";

}

if (ie5||ns6)
document.onclick=hidemenu;