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 = 320;
  }
  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=add&id='+id+'&count='+$F('count_'+id)+'&SID='+get_cookie('SID')+'&sec='+tmp_time;
  start_ajax_work('card_out');
  AjaxUpdate('card_out',BaseURL,par,'get');
  ShowPopup(event,'out_popup','Товар добавлен в корзину');
  setTimeout(kill_win,4000);
}
function kill_win()
{
    KillPopup('out_popup');
}
