//Определение браузера
opera = (window.opera)? true : false;	
dom = (document.getElementById)? true : false;
ie4 = (document.all && !dom)? true : false;
nn4 = (document.layers)? true : false;

//получение значения пременной передаваемой GET-ом
function getParam(sParamName){
    var Params = location.search.substring(1).split("&"); // отсекаем «?» и вносим переменные и их значения в массив
    var variable = "";
    for (var i = 0; i < Params.length; i++){ // пробегаем весь массив
        if (Params[i].split("=")[0] == sParamName){ // если это искомая переменная — бинго!
            if (Params[i].split("=").length > 1) variable = Params[i].split("=")[1]; // если значение параметра задано, то возвращаем его
            return variable;
        }
    }
    return "";
}

//вызов блокнота
 function notepad(id) 
 {
   if(id=='0')  { win_notepad=window.open('/user/notepad/','notepad','scrollbars=1,resizable=1,width=600, height=500,toolbar=0');
   }
   else{
      win_notepad=window.open('/user/notepad/?product_id='+id,'notepad','scrollbars=1,resizable=1,width=600, height=500,toolbar=0');
   }	 
   win_notepad.window.focus();
 }

 
//описание характеристики 
 function hint(id)
 {
  win_hint=window.open('/catalog/hint/'+id+'/','hint','scrollbars=1,resizable=1,width=400, height=300,toolbar=0');
  win_hint.window.focus();
 } 

//описание характеристики 
 function info(id)
 {
  win_hint=window.open('/info/win/'+id+'.html','info','scrollbars=1,resizable=1,width=600, height=500,toolbar=0');
  win_hint.window.focus();
 } 


 
function main(url)
{
  window.opener.location.href=url;
  window.opener.focus(); 
}


//вызов корзины
function basket(id) 
{
  q='b_count';
  kol = document.getElementById(q).value;
  if(id=='0')  { window.location.href='/user/basket/';
  }
  else{
    window.location.href='/user/basket/?add='+id+'&q='+kol; 
  }	 

 win.window.focus();
}

//вызов поиска
function go_search(id) 
{
 var q;
 var url;
 q = document.getElementById(id).value;
 url='/search/index.php?str=1&q='+q;
 window.location=url;
 win=top.location.href=url;
// win.window.focus();
}

function basket_var(id) 
{
 sel='b_var'+id;
 q='b_count';
 element = document.getElementById(sel);
 kol = document.getElementById(q).value;
 
 for (i=0; i < element.length; i++) 
 {
   if (element.options[i].selected == true)
   { 
    select_id=element.options[i].value;
   } 
 }
 window.location.href='/user/basket/?add='+select_id+'&q='+kol; 
  
}

function act_submit(i_id,id) {
if(dom){
	def=document.getElementById(i_id);
	subm=document.getElementById(id);
	if(def.value.length>=0)
     subm.disabled=false; 
	else
     subm.disabled=true; 
	} 
	 
}


function email (login)
{
	serv = "bask-outdoor.de";
	eml = login +  "@" + serv;
	return eml;
}


function mylo (login)
{
 document.write (email(login));
}

function namylo (login, subj)
{
eml = "mailto:" + email(login);
re= /\s/;
while(subj.search(re)>0)
subj=subj.replace(re, "%20");

if (subj != "") eml += "?subject=" + subj;
window.location.href = eml;
}

//увелечение картинки в статье
function zoomImg(id,w,h) 
{
 win_h=h+30;
 win_w=w;
 win=window.open('/info/img.php?id='+id,'img','scrollbars=0,resizable=1,width='+win_w+', height='+win_h+',toolbar=0');
 win.window.focus();
}



////// работа с куками

function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;

    document.cookie =
        name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{
    var exp  = new Date();
    var cval = GetCookie (name);

    exp.setTime (exp.getTime() - 1);  // This cookie is history
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


////

