var oldselect;

function add(id)
	{window.location.href='add2cart.php?id='+id;//alert ('Добавление товара');
}

function go(id)
	{window.location.href='product_detail.php?id='+id;//alert ('Информация о товаре');
}

function checkemail(email) { // возвращает true в случае корректного адреса
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	ret = regex.test(email);
	// if (!ret) alert('Введен неправильный e-mail');
	return ret;
}
function sm(num) { //выпадающее подменю
	smprefix="sm"; 
	mprefix="m";	
	vclass='cat2'; // visibleclass
	hclass='cat';  //hiddenclass
	el=document.getElementById(smprefix+num);
	el.style.display=(el.style.display=='block'?'none':'block');
	el=document.getElementById(mprefix+num);
	el.className=(el.className==hclass?vclass:hclass);
	return true;
}

function checkstyle() {
	catselect = document.getElementById('cat');
	if (catselect==null) return false;
	value = catselect.value;
	if (value==48) 
		hidestyle (1);
	else
		hidestyle (0);
}

function hidestyle (flag) {
	styleselect = document.getElementById('style');
	if (flag) {
		styleselect.style.visibility='hidden';
		oldselect = styleselect.selectedIndex;
		styleselect.selectedIndex = 0;
	} else {
		styleselect.style.visibility='';
		if (styleselect.selectedIndex == 0)
			styleselect.selectedIndex = oldselect ;
	}
		
}

function globalload() {
	checkstyle();
	if (typeof (ODKL)== 'undefined') return 1;
	if (ODKL!==undefined)
		ODKL.init();
}

// Добавить в Избранное 
function add_favorite(a) { 
  title=document.title; 
  url=document.location; 
  try { 
    // Internet Explorer 
    window.external.AddFavorite(url, title); 
  } 
  catch (e) { 
    try { 
      // Mozilla 
      window.sidebar.addPanel(title, url, ""); 
    } 
    catch (e) { 
      // Opera 
      if (typeof(opera)=="object") { 
        a.rel="sidebar"; 
        a.title=title; 
        a.url=url; 
        return true; 
      } 
      else { 
        // Unknown 
        alert('Нажмите Ctrl-D чтобы добавить страницу в закладки'); 
      } 
    } 
  } 
  return false; 
}

