var xs_exp=new Date(); xs_exp.setTime(xs_exp.getTime()+(14*24*60*60*1000));
var miz=' moet ingevuld zijn';
var foto1 = null;
var foto2 = null;

function CaricaFoto(img)
{
  foto1= new Image();
  foto1.src=('http://www.opluxefoto.nl/hspics/'+img+'.JPG');
  Control(img);
}                      

function Control(img)
{
  if((foto1.width>50)&&(foto1.height>50))
  {          
    viewPicture(img, 'http://www.opluxefoto.nl/hspics/'+img+'.JPG', foto1.width+7, foto1.height+32);
  }
  else
  {          
    func="Control('"+img+"')";
    interv=setTimeout(func,50);
  }
}

function viewPicture(stitle, img, picwidth, picheight)
{
  var picleft, pictop;

  if(navigator.appName == "Microsoft Internet Explorer") 
  {
    picleft = ((window.screen.availWidth - picwidth) / 2);
    pictop = ((window.screen.availHeight - picheight) / 2);
  }
  else 
  {
    picleft = (((window.outerWidth - picwidth) / 2) - pageXOffset);
    pictop = (((window.outerHeight - picheight) / 2) - pageYOffset);
  }

  winpropjes="width="+picwidth+",height="+picheight+",left="+picleft+",top="+pictop+",titlebar=0";
  newWindow=window.showModalDialog(img,"","dialogHeight: "+picheight+"px; dialogWidth: "+picwidth+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll: No;");
}

function floatButton() 
{
  document.all.topButton.style.pixelTop = document.body.scrollTop + 10;
}

function initButton() 
{
  document.all.topButton.style.pixelLeft = document.body.clientWidth - document.all.topButton.offsetWidth - 5;
  document.all.topButton.style.visibility = 'visible'; 
}

function OpenPopup(sPage)
{
  winprops = "fullscreen=no,menubar=no,width=400,height=250";
  window.open(sPage, "popupPage", winprops);
}                      
                        
function OpenLink(sPage)
{
  window.open(sPage, "popupPage");
  return null;
}                      
                      
function ShowIframe()
{
  resp = document.frames.addcart.document.body.innerHTML;
  if (resp>"")
    alert(resp)
}

function AddToCart(sArtCode)
{                                
  aObject=document.getElementsByName(sArtCode); 
  aObject[0].src="images/cart2.gif";
  x=document.hspartssearch;
  sOrder=x.SORDER.value;
  siPos1=sOrder.indexOf(sArtCode+",");
  if (siPos1==-1)
    sOrder=sOrder+sArtCode+','+"1;"
  else
  {
    sPart1=sOrder.substr(0, siPos1);
    sPart2=sOrder.substr(siPos1, sOrder.length-siPos1);
    siPos1=sPart2.indexOf(",");
    siPos2=sPart2.indexOf(";");
    sPart3=sPart2.substr(siPos2+1, sPart2.length-siPos2-1);
    sNumber=sPart2.substr(siPos1+1, siPos2-siPos1-1);
    sOrder=sPart1+sPart3+sArtCode+","+(parseInt(sNumber)+1)+";";
  }  
  x.SORDER.value=sOrder;
  return null;
}

function ShowWw()
{                      
  document.hspartssearch.action = 'hsshowcart.php';
  document.hspartssearch.submit();
  return null;
}

function UpdateWw()
{
  var coll = document.all.tags("Input");       
  var sWw = ''
  if (coll!=null) 
  {
    for (i=0; i<coll.length; i++) 
      if (coll.item(i).name.substr(0, 4) == 'ATK_')
        sWw = sWw + coll.item(i).name + "^^" + coll.item(i).value + "$$"
  }                                      
  document.hsshoworder.SUPDATE.value=sWw
  document.hsshoworder.submit();
  return null;
}  
                                      
function BackWw()
{
  document.hsshoworder.action = 'hsparts.php';
  document.hsshoworder.submit();
  return null;
}

function ClearWw()
{
  var coll = document.all.tags("Input");       
  var sWw = ''
  if (coll!=null) 
  {
    for (i=0; i<coll.length; i++) 
      if (coll.item(i).name.substr(0, 4) == 'ATK_')
        sWw = sWw + coll.item(i).name + "^^" + 0 + "$$"
  }                                      
  document.hsshoworder.SUPDATE.value=sWw
  document.hsshoworder.submit();
  return null;
}  
                                      
function OrderWw()
{
  document.hsshoworder.action = 'hsclient.php';
  document.hsshoworder.submit();
  return null;
}  
                                      
function RegClient()
{
  x=document.bupclient
  sCompany=x.COMPANY.value
  sContact=x.CONTACT.value
  sAddress=x.ADDRESS.value
  sPostal=x.POSTALCODE.value
  sCity=x.CITY.value
  sPhone=x.PHONE.value
  sFax=x.FAX.value
  sEmail=x.EMAIL.value
  at=x.EMAIL.value.indexOf("@")
  x.REMARKS.value=x.REMARKS.value.substr(0,150)
  sError=""

  submitOK="True"

  if (sContact.length < 1)
  {
    sError=sError + "Contactpersoon" + miz + unescape("%0D")
    submitOK="False"
  }

  if (sCompany.length < 1)
  {
    sError=sError + "Bedrijfsnaam" + miz + unescape("%0D")
    submitOK="False"
  }

  if (submitOK=="True")
  {
    pmsSetCookie('pmsweb', "COMPANY="+sCompany+
                           ";CONTACT="+sContact+
                           ";ADDRESS="+sAddress+
                           ";POSTALCODE="+sPostal+
                           ";CITY="+sCity+
                           ";PHONE="+sPhone+
                           ";FAX="+sFax+
                           ";EMAIL="+sEmail,
                           xs_exp,
                           "/",
                           '');
    document.bupclient.action = 'bupregclient.php';
    document.bupclient.submit()
  }
  else
  {
    alert(sError)
  }
  return null;
}

function ConfirmOrder()
{
  document.hsplaceorder.submit();
  return null;
}

function pmsGetCookieVal (offset)
{
  var endstr=document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr=document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function pmsGetCookieValue(sName)
{
  var sCookie=unescape(document.cookie.substring(1, document.cookie.length));
  var bgnstr=sCookie.indexOf (sName);
  if (bgnstr == -1)
    return "";

  bgnstr=bgnstr + sName.length + 1;
  var endstr=sCookie.indexOf (";", bgnstr);
  if (endstr == -1)
    endstr=sCookie.length;
  return sCookie.substring(bgnstr, endstr);
}

function pmsGetCookie (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 pmsGetCookieVal (j);
    i=document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function pmsSetCookie (name,value,expires,path,domain,secure)
{
  document.cookie=name + "=" + escape (value) +
  ((expires) ? "; expires=" + expires.toGMTString() : "") +
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" + domain : "") +
  ((secure) ? "; secure" : "");
}

