﻿function setLogo(objImg,titleDiv)
	{
	objImg.style.display='none';
	document.all[titleDiv].style.display='';
	}
function goBack()
{
  var go = document.getElementById("goBack").value;
  if(go == "")
  {
    go = 1;
  }
  history.go("-" + go);

}
function setSearchVal(obj,isSearch)
{
  if(isSearch == 1)
  {
     document.getElementById("isSearch").value= '1';
  }
  obj.action = window.location.href.substring(0,window.location.href.indexOf("&cpg=")) + "&cpg=1";
  obj.submit();
}
function setCheckBoxes()
{     try
      {
            var selectedProducts  = updateProductsCart(0,2);
            var type;
            var cells = document.getElementsByTagName("input");

            for (var i = 0; i < cells.length; i++) 
            {
               type = cells[i].getAttribute("type");
               if(type == "checkbox")
               {
                   if(selectedProducts.indexOf(cells[i].id + ",") >= 0)
                   cells[i].checked = true;
               }
            }
      }
      catch(ex)
      {
         //alert(ex.message);
      }
}
function isdigit(num)
{
        if(num == 1)
         {
      	     if ((window.event.keyCode>47 && window.event.keyCode<58) || window.event.keyCode==46 || window.event.keyCode==45)
    	      {
    	      return true;
    	     }
    	     else
    	     {
             return false;
             }
        }
        if(num == 0)
         {
      	     if ((window.event.keyCode>47 && window.event.keyCode<58))
    	      {
    	      return false;
    	     }
    	     else
    	     {
             return true;
             }
        }
}
function validateforminput(obj)
{     try
      {

            var type;
            var chkfax = false;
            var chkemail = false;
            var fax = "";
            var mail = "";
            var cells = obj.getElementsByTagName("input");

            for (var i = 0; i < cells.length; i++) 
            {
                 if (cells[i].name == "chkfax")
                 {
                    if(cells[i].checked)
                    chkfax = true
                 }
                 if (cells[i].name == "chkemail")
                 {
                    if(cells[i].checked)
                    chkemail = true
                 }
                 if (cells[i].name == "mail")
                 {
                    mail = cells[i].value
                 }
                 if (cells[i].name == "fax")
                 {
                    fax = cells[i].value
                 }
               type = cells[i].getAttribute("required");
                 if(type == "true")
                 {
  
                     if(cells[i].value == "")
                     {

                       if(cells[i].name == "name")
                       {alert("חובה להזין את שם המזמין");}

                       if(cells[i].name == "phone")
                       {alert("חובה להזין מספר טלפון");}

                       if(cells[i].name == "institute")
                       {alert("חובה להזין  שם המוסד");}

                        if(cells[i].name == "laboratory")
                       {alert("חובה להזין שם מעבדה");}


                       cells[i].focus();
                       return false;

                     }
                 }
                 if(cells[i].name == "mail")
                 {
                    if(cells[i].value != "")
                     {
                       var at = cells[i].value.indexOf("@");
                       var p = cells[i].value.indexOf(".");
                       
                       if(at > 0 && p > 0 && p > at)
                       {
                       }
                       else
                       {
                          alert("פורמט מייל לא תקין");
                         cells[i].focus();
                         return false;
                       }  
                     }
                 }
                  if(cells[i].name == "phone" || cells[i].name == "cellphone")
                 {
                       if(cells[i].value != "")
                       {
    
                         if(cells[i].value.length < 9)
                         {
                            alert("מספר לא תקין");
                           cells[i].focus();
                           return false;
                         }
    
                       }
                }
            }

        if(chkemail == false && chkfax  == false)
          {
              alert("חובה לסמן אמצעי להתקשרות : פקס או כתובת דואר אלקטרוני");
              return false;
         }
        if(chkemail == true && chkfax  == true)
          {
              if(fax.length < 9)
              {
               alert(" נא הזן מספר פקס תקין");
              return false;
              }

               if(mail == "")
              {
               alert("נא הזן כתובת דואר אלקטרוני");
              return false;
             }

          }

          if(chkemail == false && chkfax  == true)
          {
              if(fax.length < 9)
              {
               alert(" נא הזן מספר פקס תקין");
              return false;
              }
         }

      if(chkemail == true && chkfax  ==false)
          {
              if(mail == "")
              {
               alert("נא הזן כתובת דואר אלקטרוני");
              return false;
              }
         }

      }
      catch(ex)
      {
         alert(ex.message);
      }
}
function setquantity()
{     try
      {

            var type;
            var cells = document.getElementsByTagName("input");
            var productsquantity = "";
            for (var i = 0; i < cells.length; i++) 
            {
               type = cells[i].getAttribute("type");
               if(type == "text")
               {
                    if(cells[i].value.length > 0)
                    {
                       if(cells[i].value > 0)
                       {
                         productsquantity += cells[i].id.replace("t","") + "!" + cells[i].value + ",";
                       }
                    }
               }
            }
            if(updateProductsCartQuantity(productsquantity) == "1")
            {
              alert("בוצע בהצלחה");
            }
            else
            {
               alert("Error");
            }

      }
      catch(ex)
      {
         alert(ex.message);
      }
}
function getPriceOffer(opt)
{
  switch (opt)
  {
    case 1: 
    {
      document.getElementById("trcart1").style.display = 'none';
      document.getElementById("trcart2").style.display = 'none';
      document.getElementById("trgetpriceoffer").style.display = 'none';
      document.getElementById("trordernow").style.display = 'inline';
      break
    }
    case 2:
    {

      document.getElementById("trcart1").style.display = 'none';
      document.getElementById("trcart2").style.display = 'none';
      document.getElementById("trgetpriceoffer").style.display = 'inline';
      document.getElementById("trordernow").style.display = 'none';
      break
    }
    case 3:
    {
      document.getElementById("trcart1").style.display = 'inline';
      document.getElementById("trcart2").style.display = 'inline';
      document.getElementById("trgetpriceoffer").style.display = 'none';
      document.getElementById("trordernow").style.display = 'none';
      break
    }
  }
}

function removeProduct(id)
    {

      try
      {
             updateProductsCart(id,0);
             window.location.href = window.location.href;

       }
      catch(ex)
      {
         //alert(ex.message);
      }
    }
function onSelectedProduct(id)
    {

      try
      {
          var selectedProducts = document.getElementById("selectedProducts");
    
          if(document.getElementById(id).checked)
          {
            selectedProducts.value = updateProductsCart(id,1);
            if(selectedProducts == "99")
            alert("Error");
          }
          else
          {
             selectedProducts.value = updateProductsCart(id,0);
             if(selectedProducts == "99")
             alert("Error");
          }
            //alert(selectedProducts.value);
          }
      catch(ex)
      {
         //alert(ex.message);
      }
    }
function hrefpage(mr,page)
{
  window.location.href = "http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + page;
}
function createPaging(obj,cp,ps,pgs,mr,sor)
{

   var i = 0;
   var counter = 0;
   var paging = "<div style='direction:ltr;border:0px solid red;height:16px;padding:1px;text-align:center;'>";
   var falg = false;
   var regImgName = "s_reg";
   var selectedImgName = "s_selected";
   var ImgWidth = "15px";
   try
   {
       if(sor > ps)
       {
           if(cp > 5)
           {i = (cp - 5);}
           else
           { i = 0;}

           paging += "<div style='margin-top:3px;border:0px solid green;text-align:center;height:16px;'>"
        
           if(cp > 5)
           {
             paging += "<div style='margin-right:1px;margin-left:1px;width:15px;height:14px;float:right'><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=1'><img src='shops/1903/imgbank/firstimg.jpg' alt='First page' width='15px' height='14px' /></a></div>";
           }
           if(cp > 5)
           {
             paging += "<div style='margin-right:1px;margin-left:1px;width:15px;height:14px;float:right'><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + (cp - 1) + "'><img src='shops/1903/imgbank/previmg.jpg' alt='Previous page' width='15px' height='14px' /></a></div>";
           }
        
           while(i < pgs && falg == false)
               {
                     counter++;
        
                     if((i + 1) < 10)
                     {
                          regImgName = "s_reg";
                          selectedImgName = "s_selected";
                          ImgWidth = "15px";
                     }
                     else
                     {
                          regImgName = "b_reg";
                          selectedImgName = "b_selected";
                          ImgWidth = "22px";
                     }
        
                     if((i + 1 ) == cp)
                     {
                       paging += "<div style='margin-right:1px;margin-left:1px;text-align:center;color:#044a85;background-image:url(shops/1903/imgbank/" + selectedImgName + ".jpg);background-repeat:no-repeat;width:" + ImgWidth + ";height:14px;float:right;'         onclick='hrefpage(" + mr + "," + (i + 1) + ");' ><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + (i + 1) + "'>" + (i + 1) + "</a></div>";
                     }
                     else
                     {
                       paging += "<div style='margin-right:1px;margin-left:1px;text-align:center;color:#044a85;background-image:url(shops/1903/imgbank/" + regImgName + ".jpg);background-repeat:no-repeat;width:" + ImgWidth + ";height:14px;float:right;cursor:pointer;' onclick='hrefpage(" + mr + "," + (i + 1) + ");'><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + (i + 1) + "'>" + (i + 1) + "</a></div>";
                     }
                     
                     if(counter == 5)
                     {
                        falg = true;
                     }
                    i++;
            }
        
           if(pgs > 5)
            {
             paging += "<div style='margin-right:1px;margin-left:1px;width:15px;height:14px;float:right'><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + (cp + 1) + "'><img src='shops/1903/imgbank/nextimg.jpg' alt='Next page' width='15px' height='14px' /></a></div>";
            }
           if(pgs > 5 && cp != pgs)
           {
             paging += "<div style='margin-right:1px;margin-left:1px;width:15px;height:14px;float:right'><a class='pager' href='http://www.eldan.biz/eMall/shopProducts.asp?sc=1903&mr=" + mr + "&cpg=" + pgs + "'><img src='shops/1903/imgbank/lastimg.jpg' alt='Last page' width='15px' height='14px' /></a></div>";
        
           }
            paging += "</div>";
            paging += "</div>";

           document.getElementById(obj).innerHTML = paging;
       }
   }
   catch(ex)
   {
    //alert(ex.message);
   }
}
	
	
flyderX=1; //vandret afstand fra kant.Anvendes kun ved absolute position.
flyderY=1; // Lodret afstand fra kant.Anvendes kun ved absolute position. 
talign=""; // Definerer hvilken sk?rmkant flyderX skal regnes fra ved absolut positionering. Top-center-bottom. 
valign="top"; // Definerer placering af elementets visning p? sk?rmen. Top- center-bottom.
forsinkelse=3; // Tidsforsinkelse f?r elementet er positioneret. 0- hurtig/ 3-langsom.

(NS6)=false;
(IE6)=(document.all);

if (!IE6)
{NS6=(document.getElementById);}

function adjust() {
    if (NS6) {
    if (lastX==-1 || forsinkelse==0)
    {
    lastX=window.pageXOffset + flyderX;
    lastY=window.pageYOffset + flyderY;
    }
    else
    {
    var dx=Math.abs(window.pageXOffset+flyderX-lastX);
    var dy=Math.abs(window.pageYOffset+flyderY-lastY);
    var d=Math.sqrt(dx*dx+dy*dy);
    var c=Math.round(d/10);
    if (window.pageXOffset+flyderX>lastX) {lastX=lastX+forsinkelse+c;}
    if (window.pageXOffset+flyderX<lastX) {lastX=lastX-forsinkelse-c;}
    if (window.pageYOffset+flyderY>lastY) {lastY=lastY+forsinkelse+c;}
    if (window.pageYOffset+flyderY<lastY) {lastY=lastY-forsinkelse-c;}
    }
    if (NS6){
    //document.getElementById('flyderbanner').style.left=lastX;
    document.getElementById('flyderbanner').style.top=lastY;
    }
    }
    else if (IE6){
    if (lastX==-1 || forsinkelse==0)
    {
    lastX=document.body.scrollLeft + flyderX;
    lastY=document.body.scrollTop + flyderY;
    }
    else
    {
    var dx=Math.abs(document.body.scrollLeft+flyderX-lastX);
    var dy=Math.abs(document.body.scrollTop+flyderY-lastY);
    var d=Math.sqrt(dx*dx+dy*dy);
    var c=Math.round(d/10);
    if (document.body.scrollLeft+flyderX>lastX) {lastX=lastX+forsinkelse+c;}
    if (document.body.scrollLeft+flyderX<lastX) {lastX=lastX-forsinkelse-c;}
    if (document.body.scrollTop+flyderY>lastY) {lastY=lastY+forsinkelse+c;}
    if (document.body.scrollTop+flyderY<lastY) {lastY=lastY-forsinkelse-c;}
    //if (document.body.scrollTop+flyderY>lastY){LastY=LastY+(document.body.scrollTop(0,5-LastY)+1)+'0'}
    }
    //document.all['flyderbanner'].style.posLeft = lastX;
    document.all['flyderbanner'].style.posTop = lastY;
    }
    setTimeout('adjust()',30);
}// Her kan delay yderligere ?ndres.


function setProductsQuantity()
{
      var ProductsQuantity = getProductsCartQuantity();
       //alert(ProductsQuantity);
       var Products = new Array();
       Products = ProductsQuantity.split(",");

       for (var i = 0; i < Products.length; i++)
       {
           var pq = Products[i].split("!");

           if(document.getElementById("t" + pq[0]) != null)
           {
              document.getElementById("t" + pq[0]).value = pq[1];
           }
       }
}


function define()
{
        if (NS6) 
        { 
        if (talign=="left") {flyderX=iflyderX};
        if (talign=="right") {flyderX=window.innerWidth-iflyderX-layerwidth-20};
        if (talign=="center") {flyderX=Math.round((window.innerWidth-20)/2)-Math.round(layerwidth/2)};
        if (valign=="top") {flyderY=iflyderY};
        if (valign=="bottom") {flyderY=window.innerHeight-iflyderY-layerheight};
        if (valign=="center") {flyderY=Math.round((window.innerHeight-20)/2)-Math.round(layerheight/2)};
        }
        if (IE6) 
        {
        if (talign=="left") {flyderX=iflyderX};
        if (talign=="right") {flyderX=document.body.offsetWidth-iflyderX-layerwidth-20}
        if (talign=="center") {flyderX=Math.round((document.body.offsetWidth-20)/2)-Math.round(layerwidth/2)}
        if (valign=="top") {flyderY=iflyderY};
        if (valign=="bottom") {flyderY=document.body.offsetHeight-iflyderY-layerheight}
        if (valign=="center") {flyderY=Math.round((document.body.offsetHeight-20)/2)-Math.round(layerheight/2)}
        }
}  