function SetCookie(cookieName,cookieValue,nDays)
{
  var today = new Date();
  var expire = new Date();
  if (nDays==null || nDays==0)
  {
    nDays=1;
  }
  document.cookie = cookieName+"="+escape(cookieValue);
}

 
function readCookie(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++)
  {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0)
    {
      return c.substring(nameEQ.length,c.length);
    }
  }
  return null;
}


function navi_hover(element, pic, lang, mode)
{
  var img_path = '/files/vianorde/navi_'+lang+'/';
  
  var img_hover_path = img_path+''+pic+'_1.gif';
  var img_out_path   = img_path+''+pic+'_0.gif';
  
  if(mode == 1)
  {
    element.src = img_hover_path;
  }
  else
  {
    element.src = img_out_path;
  }
}


function make_tabs()
{
  var opentab = 1;
  
  /*if(readCookie('quicksearch-diameter')!=null)
  {
    opentab = 2;
  }*/
  $("#tab_cont").css('visibility', 'hidden');
  var foo=document.getElementById('opentab').value;
  $.tabs("tab_cont", parseInt(opentab));
  $("#tab_cont").css('visibility', 'visible');
}


function checkCaptcha(field, checkNum)
{
  cStr = field.value;
  totalSum = 0;
  for (i = 0, o = 0; i < cStr.length; i++, o++)
  {
    cNum = new Number(cStr.substr(i, 1));
    if (o == 0)
    {
      totalSum += (cNum.valueOf() * 7);
    } 
    if (o == 1)
    {
      totalSum += (cNum.valueOf() * 3);
    } 
    if (o == 2)
    {
      totalSum += cNum.valueOf();
      o = -1;
    } 
  }
  if (totalSum % 10 != checkNum.value)
  {
    alert("Überprüfen Sie bitte die angegebenen Ziffern!");
    return false;
  }
  return true;
}



function checkEnquiry(cap_field, cap_num)
{
  if (document.getElementById('outlet').selectedIndex == 0)
  {
    alert("Auswähl verkaufsstelle!");
    return false;
  } 
  if (!checkCaptcha(cap_field, cap_num))
  {
    return false;
  }
  return true;
}

