var cinematica

function popup( id )
{
 width = 710;
 height = 500;
 if ( cinematica )
 {
  cinematica.close()
  cinematica = window.open( 'http://cinematica.ru/cgi-bin/add_compare.cgi?id=' + id, 'cinematica', 'width='+width+',height='+height+',resizable=1,scrollbars=1,menubar=0,status=0, left='+Math.max(0,(screen.width-width)/2)+', top='+Math.max(0,(screen.height-height)/2))
  cinematica.focus()
 }
 else
 {
  cinematica = window.open( 'http://cinematica.ru/cgi-bin/add_compare.cgi?id=' + id, 'cinematica', 'width='+width+',height='+height+',resizable=1,scrollbars=1,menubar=0,status=0, left='+Math.max(0,(screen.width-width)/2)+', top='+Math.max(0,(screen.height-height)/2))
  cinematica.focus()
 }

}

function popup_ids( ids )
{
 width = 710;
 height = 500;
 if ( cinematica )
 {
  cinematica.close()
  cinematica = window.open( 'http://cinematica.ru/cgi-bin/compare.cgi?' + ids, 'cinematica', 'width='+width+',height='+height+',resizable=1,scrollbars=1,menubar=0,status=0, left='+Math.max(0,(screen.width-width)/2)+', top='+Math.max(0,(screen.height-height)/2))
  cinematica.focus()
 }
 else
 {
  cinematica = window.open( 'http://cinematica.ru/cgi-bin/compare.cgi?' + ids, 'cinematica', 'width='+width+',height='+height+',resizable=1,scrollbars=1,menubar=0,status=0, left='+Math.max(0,(screen.width-width)/2)+', top='+Math.max(0,(screen.height-height)/2))
  cinematica.focus()
 }

}

function compare( form ) {
 ids = '';
 for(i=0; i<form.length; i++ ) {
  if( form[i].value != '' ) {
   if( !form[i].checked ) {
    continue
   }
   if( ids ) {
    ids = ids + "&id=" + form[i].value
   } else {
    ids = "id=" + form[i].value
   }
  }
 }
 if( !ids ) {
  alert( "Вы должны выбрать товары для сравнения" )
  return false
 }

 popup_ids( ids )
 return false
}
