function SubCat(num,sign,close) {
  var i,other;
  if (sign=='p')
    other='m';
  else
    other='p';
  if (document.getElementById("m1p")=='undefined')
    return;
  for (i=1; i<20; i++) {
    if (document.getElementById("m"+i+"p")) {
      if (num==i) {
        document.getElementById("m"+i+sign).style.display = "none";
        document.getElementById("m"+i+other).style.display = "block";
      }
      else if (close) {
        document.getElementById("m"+i+"p").style.display = "block";
        document.getElementById("m"+i+"m").style.display = "none";
      }
    }
  }
}

var basket = '';
var url    = '/cgi-bin/site.cgi?m=buy&id=';

function ToBasket(p_id,col,tester) {
  if (!basket.closed && basket.location) {
    basket.location.href = url + p_id + '&c=' + col + '&t=' + tester;
  }
  else {
    basket=window.open(url + p_id + '&c=' + col + '&t=' + tester,'basket','width=300,height=100,scrollbars=0,resizable=0');
  }
  basket.focus();
  return false;
}

function OpenBasket() {
  if (basket.closed || !basket.location) {
    basket=window.open('','basket','width=300,height=100,scrollbars=0,resizable=0');
  }
  return false;
}

var packbasket = '';
var packurl    = '/cgi-bin/site.cgi?m=packbuy&id=';

function PackToBasket(p_id) {
  if (!packbasket.closed && packbasket.location) {
    packbasket.location.href = packurl + p_id + '&comm=' + encodeURI(eval('document.pack.comm_'+p_id+'.value'));
  }
  else {
    packbasket=window.open(packurl + p_id + '&comm=' + encodeURI(eval('document.pack.comm_'+p_id+'.value')),'packbasket','width=300,height=100,scrollbars=0,resizable=0');
  }
  packbasket.focus();
  return false;
}

function ShowHide(name) {
  if (!document.getElementById(name))
    return
  if (document.getElementById(name).style.display=='block')
    document.getElementById(name).style.display='none'
  else
    document.getElementById(name).style.display='block'
}

function MayOrder() {
  dpr=document.palette.radio;
  flag=0;
  if (dpr==undefined)
    return;
  if (dpr.length) {
    for (i=0;i<dpr.length;i++) {
      if (dpr[i].selected) {
        flag=1;
        break;
      }
    }
  }
}

function CheckFace() {
  if (document.step2.bo.value==3) {
    document.step2.skin.disabled=false;
    document.step2.age.disabled=false;
  }
  else {
    document.step2.skin.disabled=true;
    document.step2.skin.value=0;
    document.step2.age.disabled=true;
    document.step2.age.value=0;
  }
}

function CheckComment() {
  if (comment.name.value!='' && comment.name.value!='' && comment.text.value!='') 
    comment.submit()
  else
    alert('Заполните, пожалуйста, все поля (только e-mail не обязательно)')
}

function RightTimeSpan(from, to) {
  tf=document.getElementById("time_from");
  tt=document.getElementById("time_to");
  tf_index=tf.selectedIndex;
  tt_index=tt.selectedIndex;

  if (from) {
    if (tt_index<tf_index) {
      tt.selectedIndex=tf_index
    }
  }
  else {
    if (tf_index>tt_index) {
      tf.selectedIndex=tt_index
    }
  }
}

function CreateBookmarkLink() {
  title = "Интернет-магазин косметики Love and Care"; 
  url = "http://beauty.loveandcare.ru/";

  if (window.sidebar) { // Mozilla Firefox Bookmark
    window.sidebar.addPanel(title, url,"");
  } else if( window.external ) { // IE Favorite
    window.external.AddFavorite( url, title); }
  else if(window.opera && window.print) { // Opera Hotlist
    return true; }
}
