//MENU

var SSHOW='';
var SSHOW2='';
    var hi= new Array;
    hi['101']=1;
    hi['102']=1;
    hi['103']=1;
    hi['104']=1;
    hi['105']=1;
    hi['306']=1;

    var hi2= new Array;
    hi2['104101']=1;
    hi2['104102']=1;
    hi2['104103']=1;
    hi2['105101']=1;
    hi2['105102']=1;
    hi2['306101']=1;
    hi2['306102']=1;

function GetAjaxPage(url,param,meth)
{
    if (!meth) meth='post';
    var myAjax = new Ajax.Request(
                    url,
                    {method: meth, parameters: param, onComplete: OutAjaxPage}
                    );
}
function AjaxUpdate(block,url,param,meth)
{
    if (!meth) meth='post';
    var myAjax = new Ajax.Updater(block,
                    url,
                    {method: meth, parameters: param, evalScripts:'true'}
                    );
}

function start_ajax_work(div_name)
{
//    $(div_name).innerHTML='<img src="images/ajax.gif" border="0" >';
}
function clear(div_name)
{
    $(div_name).innerHTML='';
}
	
function ShowPopup(event,name,text)
{
    $(name).innerHTML=text;
    $(name).style.display='';
    var xy=event.pageY || (event.clientY +(document.documentElement.scrollTop || document.body.scrollTop));
    $(name).style.left=event.screenX+13;
    $(name).style.top=xy+15;
}
function KillPopup(name)
{
    $(name).style.display='none';
    $(name).style.left=-1000;
}

function openWin(w,h,url)
{
    par='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+w+',height='+h;
    window.open(url, '',par);
}
    
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
  if (document.cookie.length > 0) {
      offset = document.cookie.indexOf(search)
      if (offset != -1) {
        offset += search.length
        end = document.cookie.indexOf(";", offset);
        if (end == -1) end = document.cookie.length;
        returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
 return returnvalue;
}

function imageView(windowGUID, imgName, imgTitle, width, height) {
  if (width == null || width == 0) {
    width = 620;
  }
  if (height == null || height == 0) {
    height = 470;
  }
    if(!isDOM || isOpera) {
    window.open(imgName, '', 'width=' + (width + 20) + ', height='+(height + 25));
    } else {
	if(!imgTitle) imgTitle='';
	viewPhoto = window.open('', windowGUID, 'width=' + (width+20) + ', height=' + (height+25));
	viewPhoto.document.write('<html><head><title>' + imgTitle + '</title></head><body><strong style="font-family: Helvetica;">' + imgTitle + '</strong><br><table width="100%" height="100%" align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%" height="100%" align="center" valign="middle"><img src="' + imgName + '" border="0" alt="' + imgTitle + '"></td></tr></table></body></html>');
    }
}
function add(event,id)
{
  var d = new Date();
  var tmp_time=d.getSeconds()+'_'+d.getMinutes()+'_'+d.getHours()+'_'+d.getDate();
  var par='action=addi&art='+id+'&count='+$F('count_'+id)+'&SID='+get_cookie('SID')+'&sec='+tmp_time;
//  start_ajax_work('card_out');
      window.location='/?'+par;
//  AjaxUpdate('card_out',BaseURL,par,'get');
//  ShowPopup(event,'out_popup','Товар добавлен в корзину');
//  setTimeout(kill_win,4000);
}
function kill_win()
{
    KillPopup('out_popup');
}

function show_sub(id)
{
    hide_sub();
    var elem=document.getElementById('sub_0');
    if (elem)
            elem.className='hide';
    var elem=document.getElementById('sub_'+id);
    if (elem)
        elem.className='show';
    else
        document.getElementById('sub_0').className='show';

    $('mm_'+id).style.backgroundImage ="url('/images/shinawest_38_over.jpg')";
    now_b_on=id;

}
function hide_sub()
{
    ssub_hide(SSHOW);
    ssub_hide(SSHOW2);
    SSHOW='';
    SSHOW2='';
    for (i=0;i<=5;i++)
    {
        var elem=document.getElementById('sub_'+i);
        if (elem)
            elem.className='hide';

        var elem=document.getElementById('mm_'+i);
        if (elem)
	    elem.style.backgroundImage ="url('/images/shinawest_38.jpg')";
//        $('mm_'+id).style.backgroundImage ="url('/images/shinawest_38.jpg')";

    }
   var elem=document.getElementById('sub_0');
    if (elem)
            elem.className='show';

}


function b_on(id,nosub)
{

    $('bu_'+id).rows[0].cells[0].style.backgroundImage ="url('/images/ob1.jpg')"
    $('bu_'+id).rows[0].cells[1].style.backgroundImage ="url('/images/ob2.jpg')"
//    $('log').innerHTML="ON: "+id;
    if (hi[id])
    {
        ssub_hide(SSHOW);
        ssub_hide(SSHOW2);
        SSHOW='';
        SSHOW2='';
    }
    if (hi2[id])
    {
        ssub_hide(SSHOW2);
        SSHOW2='';
    }
    now_b_on=id;
    var elem=$('sub_bu_'+id);
    if (elem)
    {
        $('bu_'+id).rows[0].cells[2].style.backgroundImage ="url('/images/ob3.jpg')";
//	alert($('bu_'+id).rows[0].cells[0].style.left)
	if (!nosub)
	{
	    ssub_show($('budiv_'+id),'sub_bu_'+id);
	    SSHOW='sub_bu_'+id;
	}
    }
    else
    {
	var elem=$('subr_bu_'+id);
	if (elem)
	{
	    $('bu_'+id).rows[0].cells[2].style.backgroundImage ="url('/images/ob3_r.jpg')";
//	alert($('bu_'+id).rows[0].cells[0].style.left)
	    if (!nosub)
	    {	
		ssubr_show($('budiv_'+id),'subr_bu_'+id);
		SSHOW2='subr_bu_'+id;
	    }
	}
	else
	{
            $('bu_'+id).rows[0].cells[2].style.backgroundImage ="url('/images/ob4.jpg')";
	}
    }

}
function b_off(id)
{
    $('bu_'+id).rows[0].cells[0].style.backgroundImage ="";
    $('bu_'+id).rows[0].cells[1].style.backgroundImage ="";
    $('bu_'+id).rows[0].cells[2].style.backgroundImage ="";
    now_b_on=-1;
}


function ssub_show(event,id)
{
    $(id).style.display='';
    $(id).style.left=event.offsetLeft+'px';
    var atop;
    if (isMSIE)
	atop=30;
    else
	atop=15;
    $(id).style.top=event.offsetTop+atop+'px';
}

function ssubr_show(event,id)
{
    $(id).style.display='';
    var elem=event;
    var left=0;
    var top=0;
    while (elem!=document)
    {
	elem=elem.parentNode;
	if (elem.id!='a2')
	{
        left+=elem.offsetLeft?elem.offsetLeft:0;
        top+=elem.offsetTop?elem.offsetTop:0;
//	$('log').innerHTML=$('log').innerHTML+elem.offsetLeft+"|"+elem.offsetTop+"|"+elem.id+"<br>";
	}
    }

    left+=13;
    $(id).style.left=left+'px';
//    $('log').innerHTML="off: "+event.offsetLeft;
    var atop=0;
//    if (isMSIE)
//	atop=30;
//    else
//	atop=15;
    $(id).style.top=top+'px';
}

function ssub_hide(id)
{
    if (id!='')
    {
//        SSHOW='';
//        SSHOW2='';
	$(id).style.display='none';
    }
//    $(name).style.left=-1000;
}

