function Microsoft()
{
  if (document.all&&document.styleSheets) return true;
  return false;
}

function Netscape()
{
  if (navigator.appName=="Netscape") return true;
  return false;
}

function Mozilla()
{
  if (document.getElementById&&!document.all) return true;
  return false;
}

function Opera()
{
  var userAgent=navigator.userAgent;
  if (userAgent.search("Opera")!=-1) return true;
  return false;
}

function FocusFormElement(formName,elementName)
{
  if (document.forms[formName]) eval("document.forms[formName]."+elementName+".focus()");
  else if (document.GetElementById) eval("document.GetElementById(formName)."+elementName+".focus();");
}

function GetFormObject(formName)
{
  if (document.forms[formName]) return document.forms[formName];
  else if (document.GetElementById) return document.GetElementById(formName);
}

function SubmitForm(name)
{
  if (document.forms[name]) document.forms[name].submit();
  else if (document.GetElementById) document.GetElementById(name).submit();
/*
  if (!Netscape()||Mozilla()) eval('document.forms["'+name+'"].submit();');
  else eval('document.'+name+'.submit();');
*/
}

function SetFormEnabled(formName,elementName,value)
{
  if (!Netscape()||Mozilla()) document.forms[formName].elements[elementName].disabled=value^1;
  else eval('document.'+formName+'.'+elementName+'.disabled='+value^1);
}

function SetFormValue(formName,elementName,value)
{
  if (!Netscape()||Mozilla()) document.forms[formName].elements[elementName].value=value;
  else eval('document.'+formName+'.'+elementName+'.value='+value);
}

function GetCheckboxValue(formName,elementName)
{
//alert(document.forms[formName].elements[elementName].checked);
  if (!Netscape()||Mozilla()) return document.forms[formName].elements[elementName].checked;
  else return eval('document.'+formName+'.'+elementName+'.checked');

}

function AskDelete(dropId,link)
{
  var txt="Sind Sie sicher den Datensatz mit der Id '"+dropId+"' zu entfernen?";
  if (confirm(txt))
  {
    location.href=link;
  }
}

function ChangeLayerContent(name,content)
{
  if (!Netscape())
  {
    document.all[name].innerHTML=content;
  }
  else
  {
    if (!Mozilla())
    {
      document.layers[name].document.open();
      document.layers[name].document.write(content);
      document.layers[name].document.close();
    }
    else document.getElementById(name).innerHTML=content;
  }
}

function Round(wert,stellen)
{
  addstr=Math.pow(10,stellen).toString().substring(1)
  wert=Math.round(wert*Math.pow(10,stellen))/Math.pow(10,stellen)

  if(wert.toString().indexOf(".")==-1)
  wert=wert+"."+addstr;
  else
  {
    if(wert.toString().substring(wert.toString().indexOf(".")+1).length<addstr.length)
    wert=wert.toString()+addstr.substr(0,(addstr.length-wert.toString().substring(wert.toString().indexOf(".")+1).length))
  }
  return wert;
}

var productDetailPicArray;
function ChangeProductDetailPic(dropDownNr)
{
  var formObj;
  if (document.forms["addToBasketForm"]) formObj=document.forms["addToBasketForm"];
  else if (document.GetElementById("addToBasketForm")) formObj=document.GetElementById("addToBasketForm");
  else alert("form not found");

//  var pos=document.forms['addToBasketForm'].elements['varPosArray['+dropDownNr+']'].value;
  var pos=formObj.elements['varPosArray['+dropDownNr+']'].value;

  var htmlStr;
  if (productDetailPicArray[dropDownNr][pos-1]) htmlStr="<img src='"+productDetailPicArray[dropDownNr][pos-1]+"'>";
  else return;
  ChangeLayerContent("productPic",htmlStr);
}

var productDetailGraduatedPiecesArray=Array();
var productDetailGraduatedPriceArray=Array();
function ChangeProduktDetailPrice(obj,maxGraduatedSteps)
{
  if (maxGraduatedSteps<=1) return;
  var value=obj.value;
  var htmlStr;


  for (i=0;i<maxGraduatedSteps;i++)
  {
    if (value<productDetailGraduatedPiecesArray[i])
    {
      if (i==0) htmlStr=productDetailGraduatedPriceArray[0];
      else htmlStr=productDetailGraduatedPriceArray[i-1];
      break;
    }
    else if (i>=maxGraduatedSteps-1)
    {
      htmlStr=productDetailGraduatedPriceArray[i];
    }
  }

  ChangeLayerContent("productPrice",htmlStr);
}

function IsEmailValid(email)
{
  if (email.search(/.+@+./)==-1) return false;
  if (email.search(/.+[.]+./)==-1) return false;
  if (email.length<5) return false;
  return true;
}

var globalMousePosX=0;
var globalMousePosY=0;

function SaveMousePos(e)
{
  if(Netscape()||Mozilla())
  {
    globalMousePosX=e.pageX;
    globalMousePosY=e.pageY;
  }
  else if(Microsoft()||Opera())
  {
    globalMousePosX=document.body.scrollLeft+event.clientX;
    globalMousePosY=document.body.scrollTop+event.clientY;
  }
}

function IsIE6_And_SP_Installed()
{
  if (typeof (navigator.appMinorVersion) != "undefined")
  {
    if (navigator.appMinorVersion.substr(1,2)=='SP') return true;
  }
  return false;
}