﻿var tu ;
var time = 5000;
var indexer = 2;
var lastProdId = 1;
var lastSpnId = 1;
var deptNumber = 1;
var deptProdsNumber = 0;
var isAutoDisplay = true;
var pSale = "מכירה אישית" ;
var gSale = "מכירה קבוצתית" ;
var rSale = "מכירה רגילה" ;
var supplier_id = "1122";
var lastObj = "0";
var shekel = 'ש"ח';
var insertMailMsg = 'הזן כתובת דוא"ל';
var personalSaleAlt = " מהי מכירה אישית? ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " מכירה אישית הינה מכירה אשר בה אתם קובעים את המחיר, אשר אתם מוכנים לשלם עבור המוצר.   ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " בכל מכירה אישית, ניתן להגיש 6 הצעות לרכישה. ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " בכל פעם שתתנו הצעה תודיע לכם המערכת אם הצעתכם התקבלה או נדחתה.  ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " במידה והצעתך תתקבל ותאושר, תיווצר לך הזמנה באופן מיידי   ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " לזוכה במכירה תינתן האפשרות לרכוש יחידות נוספות באותם תנאי תשלום ומחיר שזכה  בהם - עד למועד סיום המכירה(במידה ולא תהיה הגבלת כמות ללקוח). ";
personalSaleAlt  += "\r\n";
personalSaleAlt  += " רכישה מהנה";
pSale = personalSaleAlt  ;

var groupSaleAlt = "מהי מכירה קבוצתית?";
groupSaleAlt += "\r\n";
groupSaleAlt += "במכירה קבוצתית מוצג מוצר למכירה מוגבלת בכמות ובזמן ובמחיר קבוע ואטרקטיבי במיוחד. ";
groupSaleAlt += "\r\n";
groupSaleAlt += "מאחר ובמכירה זו כל הקודם זוכה, אנו מציעים למהר ולהצטרף במכירה";
groupSaleAlt += "\r\n";
groupSaleAlt += "היות ובמכירה קבוצתית אין צורך בהגשת הצעה, הנך מצטרף ישירות לרשימת הקונים, וכל הקונים זוכים.";
groupSaleAlt += "\r\n";
groupSaleAlt += "במכירה קבוצתית כל לקוח שמצטרף לקבוצת הזוכים במכירה מטופל מיידית";
groupSaleAlt  += " ופרטי ההזמנה מועברים לנציג המכירות  על מנת שידאג להליך אספקה מהיר במיוחד";
groupSaleAlt += "\r\n";
groupSaleAlt += "רכישה מהנה";
gSale  = groupSaleAlt ;


function getImgAlt()
{
return "aaa";
}

var hideMenue = false;

function hideLi(id)
{
   $('#li' + id).hide();
}
function showLiAll()
{
   $('#li9').show(200);
   $('#li10').show(200);
   $('#li11').show(200);
   $('#li12').show(200);
   $('#li13').show(200);
   $('#li14').show(200);
   $('#li15').show(200);
   $('#li16').show(200);
   hideMenue = true;
}
function hideLiAll()
{
  hideMenue = false;
  window.setTimeout("hidex();", 1100);
}

function hidex()
{

  if (hideMenue == false)
  {

    $('#li9').hide();
    $('#li10').hide();
    $('#li11').hide();
    $('#li12').hide();
    $('#li13').hide();
    $('#li14').hide();
    $('#li15').hide();
    $('#li16').hide();
  }


}

function kd(e,type)
{
   try
   {
       var intKey = (window.Event) ? e.which : e.keyCode;

        if (intKey == 13)
       {
           switch(type)
            {
              case 1:
                LogInUser(document.getElementById("iUserName"),document.getElementById("iPassword"),false,0,0);
                break;
              case 2:
                LogInUser(document.getElementById("mUserName"),document.getElementById("mPassword"),false,0,0);
                break;
              case 3:
                sendPasswordToUserByEmail(document.getElementById("fUserName").value);
                break;
             case 4:
                joinToNewsletter(document.getElementById("txtNewsletterMail"),supplier_id,insertMailMsg);
                break;
    
            }
    
        }
   }
   catch(ex)
   {

   }
}

function setUserDetails()
{ 
                

  var e_mail = document.getElementById("udEmail").value;
  var name = document.getElementById("udName").value;
  var phone = document.getElementById("udPhone").value;
  var cellular = document.getElementById("udCellular").value;
  var address = document.getElementById("udAddress").value;
  var fk_city_id = document.getElementById("udFk_city_id").value;
  var zipcode = document.getElementById("udZipcode").value;

  document.getElementById("City").value = fk_city_id ;
  document.getElementById("Name").value = name ;
  document.getElementById("Street").value = address ;
  document.getElementById("index").value = zipcode ;
  document.getElementById("Email").value = e_mail ;
  document.getElementById("Mobile").value = cellular ;


  if(phone.length == 10)
  {
   document.getElementById("PhoneEx").value  = phone.substring(0,3);
   document.getElementById("Phone").value = phone.substring(3,10);
  }
  else
  {
    if(phone.length == 9)
    {
        document.getElementById("PhoneEx").value  = phone.substring(0,2);
        document.getElementById("Phone").value = phone.substring(2,9);
    }
    else
    {
      document.getElementById("Phone").value = phone;
    }
  }

  if(cellular.length == 10)
  {
   document.getElementById("MobileEx").value  = cellular.substring(0,3);
   document.getElementById("Mobile").value = cellular.substring(3,10);
  }
  else
  {
      document.getElementById("Mobile").value = cellular;
  }
}

function setLargeImage(vId,altTxt,defAlt)
{
  try
  {
        var x;
	var y;
	x = document.getElementById("LargeImage").src;
	y = x.substr(x.length-4,4);
	x = x.substr(0,x.length-5);
        document.getElementById("LargeImage").src =x+vId+y ;
         if(altTxt == "")
        {
          document.getElementById("LargeImage").alt = defAlt;
          document.getElementById("LargeImage").title = defAlt;
        }
        else
        {
         document.getElementById("LargeImage").alt = altTxt;
         document.getElementById("LargeImage").title = altTxt;
        }
   }
  catch(ex)
  {
   //alert(ex.message);
  }
}

function OpenDiv(divObj)
    {

        if(document.getElementById(divObj).style.display == "none")
        {

            document.getElementById(divObj).style.display="block";
        }    
        else    
        {
            document.getElementById(divObj).style.display="none";

        }    
        return false;  
    }


function setParamsURLprice(param)
{
    var NewUrl = "departmentpage.asp";
    var isContainParams = false;
    var isContainParam = false;
     //var sURL = window.document.URL.toString();
    var sURL = document.getElementById("pageUrl").value;
    
    
    	var arrParams = sURL.split("?");

        		var arrURLParams = arrParams[1].split("&");

        		var arrParamNames = new Array(arrURLParams.length);
        		var arrParamValues = new Array(arrURLParams.length);
        		
        		var i = 0;
        		for (i=0;i<arrURLParams.length;i++)
        		{
        			var sParam =  arrURLParams[i].split("=");
        			arrParamNames[i] = sParam[0];
        			if (sParam[1] != "")
        				arrParamValues[i] = unescape(sParam[1]);
        			else
        				arrParamValues[i] = "No Value";
        		}
        		
        		for (i=0;i<arrURLParams.length;i++)
        		{
                          if(i == 0)
                           NewUrl += "?" + arrParamNames[i] + "=" + arrParamValues[i];
                          else
                          {
                            if(arrParamNames[i] == "prange" && param != -1)
                            {


                              var arr = arrParamValues[i].split(',');

                              for (var j=0; j < arr.length; j++)
                              {

                                 if(arr[j] == param)
                                 {
                                   isContainParam = true;
                                 }
                              }
                                if(!isContainParam)
                                {
                                   NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i] + "," + param;
                                   isContainParams = true;
                                }
                                else
                                {
                                  if(arrParamValues[i].replace(param + ",","").replace(param ,"") == "")
                                  {
                                     isContainParams = true;
                                  }
                                  else
                                  {
                                    var repParam = arrParamValues[i].replace("," + param,"") ;
                                    repParam = repParam.replace(param + ",","") ;
                                     NewUrl += "&" + arrParamNames[i] + "=" + repParam;
                                     isContainParams = true;
                                  }
                                }
                            }
                            else
                            {
                               if(arrParamNames[i] != "page" || param == -1)
                               { 
                                 if(param == -1)
                                 {
                                    if(arrParamNames[i] != "prange")
                                    {
                                      NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i];
                                    }
                                 }
                                 else
                                 {
                                   NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i];
                                 }

                               }
                            }
                          }
        		}
        		if(!isContainParams && param != -1)
        		{
                          NewUrl += "&" + "prange=" + param;
                        }
                 window.location.href = NewUrl;

}

function setParamsURL(param)
{

          
        var NewUrl = "departmentpage.asp";
        var isContainParams = false;
        var isContainParam = false;
	//var sURL = window.document.URL.toString();
	var sURL = document.getElementById("pageUrl").value;
        	if (sURL.indexOf("?") > 0)
        	{
        		var arrParams = sURL.split("?");
        			
        		var arrURLParams = arrParams[1].split("&");

        		var arrParamNames = new Array(arrURLParams.length);
        		var arrParamValues = new Array(arrURLParams.length);
        		
        		var i = 0;
        		for (i=0;i<arrURLParams.length;i++)
        		{
        			var sParam =  arrURLParams[i].split("=");
        			arrParamNames[i] = sParam[0];
        			if (sParam[1] != "")
        				arrParamValues[i] = unescape(sParam[1]);
        			else
        				arrParamValues[i] = "No Value";
        		}
        		
        		for (i=0;i<arrURLParams.length;i++)
        		{
                          if(i == 0)
                           NewUrl += "?" + arrParamNames[i] + "=" + arrParamValues[i];
                          else
                          {
                            if(arrParamNames[i] == "params" && param != -1)
                            {


                              var arr = arrParamValues[i].split(',');

                              for (var j=0; j < arr.length; j++)
                              {

                                 if(arr[j] == param)
                                 {
                                   isContainParam = true;
                                 }
                              }
                                if(!isContainParam)
                                {
                                   NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i] + "," + param;
                                   isContainParams = true;
                                }
                                else
                                {
                                  if(arrParamValues[i].replace(param + ",","").replace(param ,"") == "")
                                  {
                                     isContainParams = true;
                                  }
                                  else
                                  {
                                    var repParam = arrParamValues[i].replace("," + param,"") ;
                                    repParam = repParam.replace(param + ",","") ;
                                     NewUrl += "&" + arrParamNames[i] + "=" + repParam;
                                     isContainParams = true;
                                  }
                                }
                            }
                            else
                            {
                               if(arrParamNames[i] != "page" || param == -1)
                               { 
                                 if(param == -1)
                                 {
                                    if(arrParamNames[i] != "params")
                                    {
                                      NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i];
                                    }
                                 }
                                 else
                                 {
                                   NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i];
                                 }

                               }
                            }
                          }
        		}
        		if(!isContainParams && param != -1)
        		{
                          NewUrl += "&" + "params=" + param;
                        }
        	}
        	else
        	{
        		alert("No parameters.");
        	}

 //alert(NewUrl);
 window.location.href = NewUrl;
	//return NewUrl;
}


function setPagingURL(pageNumber)
{                    
        var NewUrl = "departmentpage.asp";
	//var sURL = window.document.URL.toString();
	var sURL = document.getElementById("pageUrl").value;

          if (sURL.indexOf("page=") > 0)
          {
        	if (sURL.indexOf("?") > 0)
        	{
        		var arrParams = sURL.split("?");
        			
        		var arrURLParams = arrParams[1].split("&");
        		
        		var arrParamNames = new Array(arrURLParams.length);
        		var arrParamValues = new Array(arrURLParams.length);
        		
        		var i = 0;
        		for (i=0;i<arrURLParams.length;i++)
        		{
        			var sParam =  arrURLParams[i].split("=");
        			arrParamNames[i] = sParam[0];
        			if (sParam[1] != "")
        				arrParamValues[i] = unescape(sParam[1]);
        			else
        				arrParamValues[i] = "No Value";
        		}
        		
        		for (i=0;i<arrURLParams.length;i++)
        		{
                          if(i == 0)
                           NewUrl += "?" + arrParamNames[i] + "=" + arrParamValues[i];
                          else
                          {
                            if(arrParamNames[i] == "page")
                            {
                               if(pageNumber > 1)
                                  NewUrl += "&" + arrParamNames[i] + "=" + pageNumber;
                            }
                            else
                            {
                               NewUrl += "&" + arrParamNames[i] + "=" + arrParamValues[i];
                            }
                          }
        		}
        	}
        	else
        	{
        		alert("No parameters.");
        	}
         }
         else
         {
            if(pageNumber > 1)
            {
              NewUrl = sURL + "&page=" + pageNumber;
            }
            else
            {
              NewUrl =  sURL;
            }
         }
	//alert(NewUrl);
	//window.location.href = NewUrl;
	return NewUrl;
}

function  createPaging(pagesize,pagenumber,totalproducts)
{
       //alert(pagesize);
       //alert(pagenumber);
       //alert(totalproducts);

       var pagerHtml = "<table align='center' cellspacing='0' cellpadding='0' border='0'><tr>";
       var pages  =  totalproducts / pagesize;
       var href = "";
       pages = pages + "";
       var pLoc = pages.indexOf(".");

       if(pLoc > 0)
       {
         pages = (parseInt(pages.substring(0,pLoc)) + 1);
       }
       else
       {
          pages =  parseInt(pages);
       }

       if(pagenumber > 0)
       {
         href = setPagingURL(0);
         pagerHtml += " <td class='pagerFirstBg'><a href='" + href + "' class='pager'></a></td> ";
       }
       if(pagenumber > 0)
       {
         href = setPagingURL((pagenumber - 1));
         pagerHtml += " <td class='pagerPrevBg'><a href='" + href + "' class='pager'></a></td> ";
       }


       if(pages <= 6 )
       {
         var i = 1;
         while(i <= pages)
         {
            var clName = 'pagerPageNumBg';
            if(i == pagenumber || (pagenumber == 0 && i == 1))
            {
              clName = 'pagerPageNumSelBg';
            }
            href = setPagingURL(i);
            pagerHtml += " <td class='" + clName + "'><a href='" + href + "' class='pager'> " +  i + " </a></td> ";
            i++;
         }
       }
       else
       {
         var i = (pagenumber - 2);
         var iTo = (pagenumber + 3);
         if(pagenumber < 4)
         {
           i = 1;
           iTo = 7;
         }
         if(iTo > pages)
         {
           i = (i - (iTo - pages));
           iTo = pages;
         }

         while(i <= iTo && i <= pages)
         {
            var clName = 'pagerPageNumBg';
            if(i == pagenumber || (pagenumber == 0 && i == 1))
            {
              clName = 'pagerPageNumSelBg';
            }
            href = setPagingURL(i);
            pagerHtml += " <td class='" + clName + "'><a href='" + href + "' class='pager'> " +  i + " </a></td> ";
            i++;
         }
       }





        var currentPageNumber = pagenumber;
        if(currentPageNumber == 0)
        {
           currentPageNumber = 1;
        }
       if(pages > 0 && currentPageNumber < pages)
       {
         if(pagenumber == 0)
          {pagenumber = 1;}
         href = setPagingURL((pagenumber + 1));
         pagerHtml += " <td class='pagerNextBg' ><a href='" + href + "' class='pager'></a></td> ";
       }
       if(currentPageNumber < pages)
       {
         href = setPagingURL(pages);
         pagerHtml += " <td class='pagerLastBg' ><a href='" + href + "' class='pager'></a></td> ";
       }
       
        pagerHtml += "</tr></table>";
        document.getElementById("pager").innerHTML =  pagerHtml;
        document.getElementById("pagerbtm").innerHTML =  pagerHtml;


}

function openDeptSubs(sId,obj)
{
       $("#" + obj).show(5000);
       document.getElementById(obj + "img").src = "shops/" + sId + "/images/arr_dwn.jpg";
}
function closeDeptSubs(sId,obj)
{
       //$("#" + obj).slideUp(1);
       document.getElementById(obj).style.display = 'none';
       document.getElementById(obj + "img").src = "shops/" + sId + "/images/arr_left.jpg";
}

function showSubDiv(sId,obj)
{
    if(document.getElementById(obj).style.display == 'block')
    {
       $("#" + obj).slideUp(120);
       document.getElementById(obj + "img").src = "shops/" + sId + "/images/arr_left.jpg";
    }
    else
    {
       $("#" + obj).show(600);
       document.getElementById(obj + "img").src = "shops/" + sId + "/images/arr_dwn.jpg";

       if(lastObj != "0" && lastObj != obj)
       {

         closeDeptSubs(sId,lastObj);

       }
       lastObj = obj;
    }
}
function stopMoveProds()
{
  isAutoDisplay = false;
}
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(obId,opacity) 
{
  if (document.getElementById)
  {
    obj = document.getElementById(obId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+obId+"',"+opacity+")", 65);
    }
  }
}

function setProdCompLogo(sId,obj,compName)
{
  compName = compName.replace(" ","");

  try
  {
    document.getElementById(obj).src = "shops/"+sId+"/"+compName+".jpg";
  }
  catch(ex){document.getElementById(obj).src = "";}

}
function changeDeptBoxBg(className,depId,level)
{
  try
  {
    document.getElementById("divDep" + depId).className = className;
   
   var saleType = "";
   var saleTypeImg = "";
   var saleTypeImgAlt = "";
   var price  = "";
   
   if(document.getElementById("p" + level + "d" + depId + "sale_status").value == 1 && document.getElementById("p" + level + "d" + depId + "sale_quantity").value > 0  )
   {
      saleType = "מחיר : ";
      saleTypeImg = "grp_sm.jpg";
      saleTypeImgAlt = gSale;
      price = document.getElementById("p" + level + "d" + depId + "target_price").value  ;

   }
   else
   {
     if(document.getElementById("p" + level + "d" + depId + "isPersonalSale").value == 1)
     {
        saleType = "הצעות מ : ";
        saleTypeImg = "prt_sm.jpg";
        saleTypeImgAlt = pSale;
        price = document.getElementById("p" + level + "d" + depId + "price").value;
     }
     else
     {
        saleType = "מחיר : ";
        saleTypeImg = "smpl_prc.jpg";
        saleTypeImgAlt = rSale;
        price = document.getElementById("p" + level + "d" + depId + "price").value;
     }
   }
   
    var btn = document.getElementById("d" + depId + "btn_go_to_product_sq_btm");
    btn.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById("p" + level + "d" + depId + "pk_prod_id").value; };

    var pImg = document.getElementById("d" + depId + "prodImg");
    pImg.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById("p" + level + "d" + depId + "pk_prod_id").value; };


    $("#d" + depId + "prodname").html("<a class='a_link_l' href='product.asp?pc=" + $("#p" + level + "d" + depId + "pk_prod_id").val() + "'>" + $("#p" + level + "d" + depId + "productname").val() + "</a>");
    $("#d" + depId + "maxpayments").text($("#p" + level + "d" + depId + "maxpayments").val());
    



    if($("#p" + level + "d" + depId + "self_ship_price").val() != "0")
       $("#d" + depId + "self_ship_price").text($("#p" + level + "d" + depId + "self_ship_price").val() + ".00 ₪" );
    else
      $("#d" + depId + "self_ship_price").text("חינם");



    $("#d" + depId + "price").text(price);

    $("#d" + depId + "priceType").text(saleType);

   document.getElementById("d" + depId + "prodImg").src = document.getElementById("p" + level + "d" + depId + "prodImg").value;
   document.getElementById("d" + depId + "prodImg").alt = document.getElementById("p" + level + "d" + depId + "productname").value;
   document.getElementById("d" + depId + "prodImg").title = document.getElementById("p" + level + "d" + depId + "productname").value;
   document.getElementById("d" + depId + "proddescription").innerHTML = document.getElementById("p" + level + "d" + depId + "productdescription").value;

   try
   {
      document.getElementById("d" + depId + "imgSaleType").style.display= '';
      document.getElementById("d" + depId + "imgSaleType").src = "shops/" + supplier_id + "/images/" + saleTypeImg;
      document.getElementById("d" + depId + "imgSaleType").alt = saleTypeImgAlt;
      document.getElementById("d" + depId + "imgSaleType").title = saleTypeImgAlt;
   }
   catch(ex)
   {
     document.getElementById("p" + level + "d" + depId + "imgSaleType").style.display= 'none';
   }
   try 
   {
      document.getElementById("p" + level + "d" + depId + "prodCompImg").style.display= '';
      document.getElementById("d" + depId + "prodCompImg").src = document.getElementById("p" + level + "d" + depId + "prodCompImg").value.replace(" ","");
      document.getElementById("d" + depId + "prodCompImg").alt = document.getElementById("p" + level + "d" + depId + "manufacturedescription").value.replace(" ","");
      document.getElementById("d" + depId + "prodCompImg").title = document.getElementById("p" + level + "d" + depId + "manufacturedescription").value.replace(" ","");
   }
   catch(ex)
   {
     document.getElementById("p" + level + "d" + depId + "prodCompImg").style.display= 'none';
   }

   }
  catch(ex)
  {
    //alert(ex.message);
    }

}
function changeDeptBg(className,cntProds)
{
              
    document.getElementById("divDeptsProds").className = className;

    switch(className)
    {
      case "divTopDeptProds":
        if(deptNumber != 1)
        {
          deptProdsNumber = cntProds;
          deptNumber = 1;
          SetFirstData(1,cntProds);
          isAutoDisplay = true;
          clearTimeout(tu);
          indexer = 1;
          AutoMoveProducts();
        }
        break;
      case "divMdlDeptProds":
        if(deptNumber != 2)
        {
          deptProdsNumber = cntProds;
          deptNumber = 2;
          SetFirstData(2,cntProds);
          isAutoDisplay = true;
          indexer = 1;
          clearTimeout(tu);
          AutoMoveProducts();
        }
        break;
      case "divBtmDeptProds":
        if(deptNumber != 3)
        {
          deptNumber = 3;
          deptProdsNumber = cntProds;
          SetFirstData(3,cntProds);
          isAutoDisplay = true;
          clearTimeout(tu);
          indexer = 1;
          AutoMoveProducts();
        }
        break;
    }
}

function SetFirstData(id,cntProds)
{


   deptProdsNumber = cntProds;
   lastProdId = 1;
   document.getElementById("spn" + lastSpnId).style.color = "#004B9C";
   lastSpnId = 1;
   document.getElementById("spn1").style.color = "#A3A5A4";

   switch(cntProds)
    {
      case 1:
        document.getElementById("spn2").style.display = "none";
        document.getElementById("spn3").style.display = "none";
        document.getElementById("spn4").style.display = "none";
        document.getElementById("spn5").style.display = "none";
        document.getElementById("spn6").style.display = "none";
        break;
      case 2:
        document.getElementById("spn2").style.display = "inline";
        document.getElementById("spn3").style.display = "none";
        document.getElementById("spn4").style.display = "none";
        document.getElementById("spn5").style.display = "none";
        document.getElementById("spn6").style.display = "none";
        break;
      case 3:
        document.getElementById("spn2").style.display = "inline";
        document.getElementById("spn3").style.display = "inline";
        document.getElementById("spn4").style.display = "none";
        document.getElementById("spn5").style.display = "none";
        document.getElementById("spn6").style.display = "none";
         break;
      case 4:
        document.getElementById("spn2").style.display = "inline";
        document.getElementById("spn3").style.display = "inline";
        document.getElementById("spn4").style.display = "inline";
        document.getElementById("spn5").style.display = "none";
        document.getElementById("spn6").style.display = "none";
         break;
      case 5:
        document.getElementById("spn2").style.display = "inline";
        document.getElementById("spn3").style.display = "inline";
        document.getElementById("spn4").style.display = "inline";
        document.getElementById("spn5").style.display = "inline";
        document.getElementById("spn6").style.display = "none";
         break;
      case 6:
        document.getElementById("spn2").style.display = "inline";
        document.getElementById("spn3").style.display = "inline";
        document.getElementById("spn4").style.display = "inline";
        document.getElementById("spn5").style.display = "inline";
        document.getElementById("spn6").style.display = "inline";
        break;
    }

  var btn = document.getElementById("btnGoToProduct");
  btn.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById("d" + id + "p1pk_prod_id").value; };

  var pImg = document.getElementById("imgProduct");
  pImg.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById("d" + id + "p1pk_prod_id").value; };


  document.getElementById("imgProduct").src = document.getElementById("d" + id + "p1prodImg").value;
  document.getElementById("imgProduct").alt = document.getElementById("d" + id + "p1productname").value;
  document.getElementById("imgProduct").title = document.getElementById("d" + id + "p1productname").value;
  document.getElementById("prodDesc").innerHTML = document.getElementById("d" + id + "p1productdescription").value;

  try 
  {
    document.getElementById("imgProductCompLogo").src = "shops/1122/mf_" + document.getElementById("d" + id + "p1manufacturedescription").value.replace(" ","") + "100.jpg";
    document.getElementById("imgProductCompLogo").alt = document.getElementById("d" + id + "p1manufacturedescription").value;
    document.getElementById("imgProductCompLogo").title = document.getElementById("d" + id + "p1manufacturedescription").value;
  }
  catch(ex){document.getElementById("imgProductCompLogo").src = '';document.getElementById("imgProductCompLogo").style.display= 'none';}

    var p = "מחיר: ";
    var imgSaleIcon = "";
    var imgSaleIconAlt = "";
    var price = "";
  if(document.getElementById("d" + id + "p1sale_status").value == 1 && document.getElementById("d" + id + "p1sale_quantity").value > 0)
  {
     p = "מחיר: ";
     imgSaleIcon = "gr_sale_s.jpg";
     imgSaleIconAlt = gSale;
     price = document.getElementById("d" + id + "p1prodTargetPrice").value ;
  }
  else
  {
   if(document.getElementById("d" + id + "p1isPersonalSale").value == "True")
      {
       p = "הצעות מ: ";
       imgSaleIcon = "prt_sale_s.jpg";
       imgSaleIconAlt = pSale;
       price = document.getElementById("d" + id + "p1prodPrice").value;
      }
      else
      {
        imgSaleIcon = "reg_sale_s.jpg";
        imgSaleIconAlt = rSale;
        price = document.getElementById("d" + id + "p1prodPrice").value;
      }
  }

  document.getElementById("imgSaleTypeIcon").src = "/shops/" + supplier_id + "/images/" + imgSaleIcon;
  document.getElementById("imgSaleTypeIcon").alt = imgSaleIconAlt;
  document.getElementById("imgSaleTypeIcon").title = imgSaleIconAlt;

     
   $("#prodPayments").text($("#d" + id + "p1maxpayments").val());
   $("#prodName").html("<a class='a_link_xl' href='product.asp?pc=" + $("#d" + id + "p1pk_prod_id").val() + "'>" + $("#d" + id + "p1productname").val() + "</a>");
  
if($("#d" + id + "p1self_ship_price").val() != "0")
    $("#prodShip").text($("#d" + id + "p1self_ship_price").val() + ".00 ₪");
else
    $("#prodShip").text("חינם");


   $("#prodPrice").text(p + price);



}

window.setTimeout("AutoMoveProducts();",time);




function AutoMoveProducts()
{
       MoveProducts(indexer,"spn" + indexer + "" + deptNumber, 1);

       tu = window.setTimeout("AutoMoveProducts();",time);
    
         indexer = indexer + 1;

         if(indexer > deptProdsNumber)
         {
            indexer = 1;
         }
}

function MoveProducts(prodNumber,spnId,isAuto)
{
  
  if(isAuto == 0)
  isAutoDisplay = false;

  if(isAutoDisplay || isAuto == 0)
  {
      try
      {
        if(prodNumber == "fwd")
        {           
          if(lastProdId < deptProdsNumber)
          {
            prodNumber = (parseInt(lastProdId) + 1);
          }
          else
          {
            prodNumber = 1;
          }
        }
        else if(prodNumber == "bck")
        {
          if(lastProdId > 1)
          {
            prodNumber = (parseInt(lastProdId) - 1);
          }
          else
          {
            prodNumber = deptProdsNumber;
          }
    
        }
           //alert(lastProdId);
           //alert(prodNumber);
 
      var BeginObjId = "d" + deptNumber + "p" + prodNumber ;
      document.getElementById("prodDesc").innerHTML = document.getElementById(BeginObjId + "productdescription").value;
      document.getElementById("imgProduct").src = document.getElementById(BeginObjId + "prodImg").value;
      document.getElementById("imgProduct").alt = document.getElementById(BeginObjId + "productname").value;
      document.getElementById("imgProduct").title = document.getElementById(BeginObjId + "productname").value;
      


       fadeIn('imgProduct',1);

       var btn = document.getElementById("btnGoToProduct");
       btn.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById(BeginObjId + "pk_prod_id").value; };


        var pImg = document.getElementById("imgProduct");
       pImg.onclick = function() { window.location.href='product.asp?pc=' + document.getElementById(BeginObjId + "pk_prod_id").value; };



      try{
         document.getElementById("imgProductCompLogo").src = document.getElementById(BeginObjId + "prodCompImg").value.replace(" ","");
         document.getElementById("imgProductCompLogo").alt = document.getElementById(BeginObjId + "manufacturedescription").value;
         document.getElementById("imgProductCompLogo").title = document.getElementById(BeginObjId + "manufacturedescription").value;
        fadeIn('imgProductCompLogo',1);
        }
      catch(ex){document.getElementById("imgProductCompLogo").src = '';document.getElementById("imgProductCompLogo").style.display= 'none';}
  


    try
     {
     var p = "מחיר: ";
     var imgSaleIcon = "";
     var imgSaleIconAlt = "";
     var price = "";
        if(document.getElementById(BeginObjId + "sale_status").value == 1 && document.getElementById(BeginObjId + "sale_quantity").value > 0)
        {
           p = "מחיר: ";
           imgSaleIcon = "gr_sale_s.jpg";
           imgSaleIconAlt = gSale;
           price = document.getElementById(BeginObjId + "prodTargetPrice").value  ;
        }
        else
        {
         if(document.getElementById(BeginObjId + "isPersonalSale").value == "True")
            {
             p = "הצעות מ: ";
             imgSaleIcon = "prt_sale_s.jpg";
             imgSaleIconAlt = pSale;
             price = document.getElementById(BeginObjId + "prodPrice").value;
            }
            else
            {
              imgSaleIcon = "reg_sale_s.jpg";
              imgSaleIconAlt = rSale;
              price = document.getElementById(BeginObjId + "prodPrice").value;
            }
        }

      document.getElementById("imgSaleTypeIcon").src = "shops/" + supplier_id + "/images/" + imgSaleIcon;
      document.getElementById("imgSaleTypeIcon").alt = imgSaleIconAlt;
      document.getElementById("imgSaleTypeIcon").title = imgSaleIconAlt;

    }
    catch(ex){}



        $("#prodPayments").text($("#" + BeginObjId + "maxpayments").val());
        $("#prodName").html("<a class='a_link_xl' href='product.asp?pc=" + $("#" + BeginObjId + "pk_prod_id").val() + "'>" + $("#" + BeginObjId + "productname").val() + "</a>");
      
if($("#" + BeginObjId + "self_ship_price").val() != "0")
    $("#prodShip").text($("#" + BeginObjId + "self_ship_price").val() + ".00 ₪ ");
else
    $("#prodShip").text("חינם");

  


        $("#prodPrice").text(p + price);


      document.getElementById("spn" + lastSpnId).style.color = "#004B9C";
      document.getElementById("spn" + prodNumber).style.color = "#A3A5A4";
      

      
      lastProdId = prodNumber;
      lastSpnId = prodNumber;
      }
      catch(ex)
      {
           // alert(ex.message);
      }
   }
}



function isdigit()
{
       
      	     if ((window.event.keyCode>47 && window.event.keyCode<58) || window.event.keyCode==46 || window.event.keyCode==45)
    	      {
    	      return true;
    	     }
    	     else
    	     {
             return false;
             }
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


 function LegalTz(num) {


        var tot = 0;
        var tz = new String(num);
        for (i=0; i<8; i++)
            {
                x = (((i%2)+1)*tz.charAt(i));
                if (x > 9) 
                    {
                    x =x.toString();
                    x=parseInt(x.charAt(0))+parseInt(x.charAt(1))
                    }
            tot += x;
            }
        
    if ((tot+parseInt(tz.charAt(8)))%10 == 0) {
        return true;
    } else {

        return false;
    }
}

function onCustomerClub()
{
  try
  {

        var username =   document.getElementById("username").value;
	var firstname  = document.getElementById("firstname").value;
	var lastname   = document.getElementById("lastname").value;
	var id_number  = document.getElementById("identification_num").value;
	var address    = document.getElementById("address").value;
	var fk_city_id = document.getElementById("fk_city_id").value;
	var zipcode    = document.getElementById("zipcode").value;
	var phone      = document.getElementById("phone").value;
	var e_mail     = document.getElementById("e_mail").value;
	var password   = document.getElementById("password").value;
	var password2   = document.getElementById("password2").value;
	
	var vDay   = document.getElementById("day").value;
	var vMonth   = document.getElementById("month").value;
	var vYear   = document.getElementById("year").value;


      


			
	if (firstname == "")
	{
		alert("שם פרטי הוא שדה חובה");
		document.getElementById("firstname").focus();
		document.getElementById("firstname").style.borderColor="#ff0000";
		return;
	}
	if (lastname == "")
	{
		alert("שם משפחה הוא שדה חובה");
		document.getElementById("lastname").focus();
		document.getElementById("lastname").style.borderColor="#ff0000";
		return;
	} 
	if (id_number == "")
	{
		alert("תעודת זהות הוא שדה חובה");
		document.getElementById("identification_num").focus();
		document.getElementById("identification_num").style.borderColor="#ff0000";
		return;
	}

  if(!LegalTz(id_number))
   {
       alert("תעודת זהות לא תקינה");
       document.getElementById("identification_num").focus();
    
return;
   }

     try
       {
           if(!CheckValidID(id_number) || id_number == "000000000" || id_number.length > 9)
           {
             alert("תעודת זהות לא תקינה");
             return false;
           }
         
       }catch(e){};



  if(vDay.length > 0)
        {
          if(IsNumeric(vDay) == false)
          {
                           alert("יום לא תקין");
                             document.getElementById("day").focus();
                             document.getElementById("day").style.borderColor="#ff0000";
		return;
          }
        }
       else
       {
          alert("תאריך לידה הוא שדה חובה - נא הזן יום");
          document.getElementById("day").style.borderColor="#ff0000";
          document.getElementById("day").focus();
         return;
      }

        if(vMonth.length > 0)
        {
          if(IsNumeric(vMonth) == false)
          {
                           alert("חודש לא תקין");
                             vMonth.focus();
		return;
          }
        }
      else
      {
        alert("תאריך לידה הוא שדה חובה - נא הזן חודש");
        document.getElementById("month").style.borderColor="#ff0000";
          document.getElementById("month").focus();
         return;
      }


   if(vYear.length > 0)
        {
             if(IsNumeric(vYear) == false)
             {
                            alert("שנה לא תקינה");
                            document.getElementById("year").style.borderColor="#ff0000";
                            document.getElementById("year").focus();
                            return;
             }
             else
             {

                   if(vYear.length != 4 )
                     {
                             alert("שנה לא תקינה, יש להזין שנה ב 4 ספרות");
                             document.getElementById("year").style.borderColor="#ff0000";
                             document.getElementById("year").focus();
                             return;
                    }
            }
       
        }
      else
      {
          alert("תאריך לידה הוא שדה חובה - נא הזן שנה");
          document.getElementById("year").style.borderColor="#ff0000";
          document.getElementById("year").focus();
          return;
      }



    




	if (address == "")
	{
		alert("כתובת הוא שדה חובה");
		document.getElementById("address").focus();
		document.getElementById("address").borderColor="#ff0000";
		return;
	} 
	if (fk_city_id == "")
	{
		alert("עיר הוא שדה חובה");
		document.getElementById("fk_city_id").focus();
		document.getElementById("fk_city_id").style.borderColor="#ff0000";
		return;
	} 
	if (zipcode == "")
	{
		alert("מיקוד הוא שדה חובה");
		document.getElementById("zipcode").focus();
		document.getElementById("zipcode").style.borderColor="#ff0000";
		return;
	}
        else
        {
          if(!IsNumeric(zipcode))
          {
             alert("שדה מיקוד חייב להכיל ספרות בלבד");
             document.getElementById("zipcode").focus();
	     document.getElementById("zipcode").style.borderColor="#ff0000";
	     return;
          }
        }
	if (phone == "")
	{
		alert("טלפון הוא שדה חובה");
		document.getElementById("phone").focus();
		document.getElementById("phone").style.borderColor="#ff0000";
		return;
	} 
              else
               {
                 if(phone.length < 9)
                     {
                         alert("מספר לא תקין");
                         document.getElementById("phone").focus();
	                 document.getElementById("phone").style.borderColor="#ff0000";
	         return;
                     }
               }
	if (e_mail == "")
	{
		alert("דואר אלקטרוני הוא שדה חובה");
		document.getElementById("e_mail").focus();
		document.getElementById("e_mail").style.borderColor="#ff0000";
		return;
	}
              else
               {
                     var at = document.getElementById("e_mail").value.indexOf("@");
                     var p = document.getElementById("e_mail").value.indexOf(".");
                     
                     if(at > 0 && p > 0)
                     {
                     }
                     else
                     {
                        alert("פורמט לא תקין");
                        document.getElementById("e_mail").focus();
                       return ;
                     }  
               }
	if (password == "")
	{
		alert("סיסמא הוא שדה חובה");
		document.getElementById("password").focus();
		document.getElementById("password").style.borderColor="#ff0000";
		return;
	} 
            else
               {
                 if(password.length < 6)
                     {
                           alert("סיסמא חייבת להיות בעלת 6 תווים לפחות");
                           document.getElementById("password").focus();
		document.getElementById("password").style.borderColor="#ff0000";
		return;
                     }
               }


	if (password != password2)
	{
		alert("סיסמא אינה זהה לשדה אימות סיסמא");
		document.getElementById("password").focus();
		document.getElementById("password").style.borderColor="#ff0000";  
		return;
	} 
	
	
	if (username == "")
	{
		alert("שם משתמש הוא שדה חובה");
		document.getElementById("username").focus();
		document.getElementById("username").style.borderColor="#ff0000";
		return;
	} 
        else
        {
              if(username.length < 6)
                {
                    alert("שם משתמש חייב להיות בעלת 6 תווים לפחות");
                    document.getElementById("username").focus();
		    document.getElementById("username").style.borderColor="#ff0000";
		    return;
                }
                else
                {
                  if(checkIfUserNameAvailable(username) == 0)
                  {
                    alert("שם משתמש קיים במערכת - נא בחר שם משתמש שונה");
                    document.getElementById("username").focus();
		    document.getElementById("username").style.borderColor="#ff0000";
		    return;
                  }
                }
       }
               



          


	document.frmContact.submit();
	
  }
  catch(ex)
  {
     //alert(ex.message);
  }
}




function onCustomerClubVip()
{
  

  	var firstname  = document.getElementById("firstname").value;
	var lastname   = document.getElementById("lastname").value;
	var e_mail     = document.getElementById("e_mail").value;
	

	if (firstname == "")
	{
		alert("שם פרטי הוא שדה חובה");
		document.getElementById("firstname").focus();
		document.getElementById("firstname").style.borderColor="#ff0000";
		return;
	} 
	if (lastname == "")
	{
		alert("שם משפחה הוא שדה חובה");
		document.getElementById("lastname").focus();
		document.getElementById("lastname").style.borderColor="#ff0000";
		return;
	} 

	
	if (e_mail == "")
	{
		alert("דואר אלקטרוני הוא שדה חובה");
		document.getElementById("e_mail").focus();
		document.getElementById("e_mail").style.borderColor="#ff0000";
		return;
	} 
              else
               {
                     var at = document.getElementById("e_mail").value.indexOf("@");
                     var p = document.getElementById("e_mail").value.indexOf(".");
                     
                     if(at > 0 && p > 0 && p > at)
                     {
                     }
                     else
                     {
                        alert("פורמט לא תקין");
                        document.getElementById("e_mail").focus();
                       return ;
                     }  
               }
	
	document.frmContact.submit();
}

function onContactUs()
{
	var firstname  = document.getElementById("firstname").value;
	var phone   = document.getElementById("phone").value;
	var e_mail     = document.getElementById("e_mail").value;



	
	if (firstname == "")
	{
		alert("שם פרטי הוא שדה חובה");
		document.getElementById("firstname").focus();
		document.getElementById("firstname").style.borderColor="#ff0000";  //background="#EFD000";
		return;
	} 
	if (phone == "")
	{
		alert("טלפון הוא שדה חובה");
		document.getElementById("phone").focus();
		document.getElementById("phone").style.borderColor="#ff0000";
		return;
	} 
	if (e_mail == "")
	{
		alert("דואר אלקטרוני הוא שדה חובה");
		document.getElementById("e_mail").focus();
		document.getElementById("e_mail").style.borderColor="#ff0000";
		return;
	} 
	
	document.frmContact.submit();
}

function window_onload() {
	if (document.all.txtRetMsg.value != "")
	{ 
		alert(document.all.txtRetMsg.value)
		document.all.txtRetMsg.value = ""
	}
}

function sStop()
{
	scrollerS.scrollAmount=0
}
function sStart()
{
	scrollerS.scrollAmount=1
}
function ShowLargePic(vSrc)
{
	var vS = vSrc.src
	vS = vS.replace("/s/s","/s");
	document.getElementById("LargeImage").src =vS;
}
function OpenDept(vObj)
{
	var x=vObj.value.split(";");
	//var b ="shopDepartment.asp?sc="+x[0]+"&id="+x[1]+"f&id="+x[2];
	window.location.href = "shopDepartment.asp?sc="+x[0]+"&id="+x[1]+"&fid="+x[2]+"&sid="+x[2]+"&top=1&items=0";
}

var sumOfAccompProdsPrice = 0;
function SetAccompProds(vObj)
{        // alert(vObj.value);
    var oRadio = document.product_details_form.elements[vObj.name];
        // alert(3);
       for(var i = 0; i < oRadio.length; i++) 
       {



         if(oRadio[i].checked)
         {

           if(oRadio[i].value != 0)
           {
               var AccompProds = document.getElementById("AccompProds").value;

               if(AccompProds.indexOf(oRadio[i].value + ",") == -1)
               {
                  if(document.getElementById("AccompPrice" + oRadio[i].value) != null)
                  {
                     sumOfAccompProdsPrice += parseInt(document.getElementById(("AccompPrice" + oRadio[i].value)).value);
                  }
                  
                 AccompProds = AccompProds + oRadio[i].value + ",";
                 document.getElementById("AccompProds").value = AccompProds;
               }
    

           }
         }
         else
         {
           if(oRadio[i].value != 0)
           {
               var AccompProds = document.getElementById("AccompProds").value;
               
               if(AccompProds.indexOf(oRadio[i].value + ",") != -1)
               {
                  if(document.getElementById("AccompPrice" + oRadio[i].value) != null)
                  {
                     sumOfAccompProdsPrice = (sumOfAccompProdsPrice - parseInt(document.getElementById("AccompPrice" + oRadio[i].value).value));
                  }
               }
    
               AccompProds =  AccompProds.replace(oRadio[i].value + "," , "");
               document.getElementById("AccompProds").value = AccompProds;
           }
         }
       }

       $("#divSumPriceOfAccompProds").html('סה"כ מחיר לתוספות שנבחרו :  ' + sumOfAccompProdsPrice + ' ש"ח');
  /*if(vObj.checked)
  {
     var AccompProds = document.getElementById("AccompProds").value;
     AccompProds +=  vObj.value + ",";
     document.getElementById("AccompProds").value = AccompProds;
  }
  else
  {
     var AccompProds = document.getElementById("AccompProds").value;
     AccompProds =  AccompProds.replace(vObj.value + "," , "");
     document.getElementById("AccompProds").value = AccompProds;
  }*/
}

function SetAccompProdsOffer(vObj)
{
    var oRadio = document.offer_form.elements[vObj.name];

       for(var i = 0; i < oRadio.length; i++) 
       {
         if(oRadio[i].checked)
         {
           if(oRadio[i].value != 0)
           {
               var AccompProds = document.getElementById("AccompProds").value;
               if(AccompProds.indexOf(oRadio[i].value + ",") == -1)
               {
                 AccompProds = AccompProds + oRadio[i].value + ",";
                 document.getElementById("AccompProds").value = AccompProds;
               }
           }
         }
         else
         {
           if(oRadio[i].value != 0)
           {
               var AccompProds = document.getElementById("AccompProds").value;
               AccompProds =  AccompProds.replace(oRadio[i].value + "," , "");
               document.getElementById("AccompProds").value = AccompProds;
           }
         }
       }
       
        //alert(AccompProds);
}
function GoToPeronalSale(vObj)
{
    var AccompProdsParams = "";
    var AccompProds = document.getElementById("AccompProds").value;
    if (AccompProds != "")
    {
       if(AccompProds.substr((AccompProds.length-1),1) == ",")
       {
          AccompProds =  AccompProds.substr(0 ,(AccompProds.length-1));
       }
       AccompProdsParams = "&accomp="  + AccompProds;
    }
  

  window.document.location.href = "https://www.traklin.co.il/shopOffer.asp?pc=" + vObj + AccompProdsParams;
}


function showvideo()
{
   try {
         document.getElementById("trfullspecifications").style.display = "none";
         document.getElementById("tdfullspecifications").className = "tabOff";
       }catch(ex){}

    try{
         document.getElementById("trOperatingInstructions").style.display = "none";
         document.getElementById("tdOperatingInstructions").className = "tabOff";
      }catch(ex){}

   try{
      document.getElementById("tdvideo").className = "tabOn";
      document.getElementById("trvideo").style.display = "inline";
   }
   catch(ex){}
   

}
function showOperatingInstructions()
{
   try {
          document.getElementById("trfullspecifications").style.display = "none";
          document.getElementById("tdfullspecifications").className = "tabOff";
       } catch(ex){}

   try {
         document.getElementById("tdvideo").className = "tabOff";
         document.getElementById("trvideo").style.display = "none";
       } catch(ex){}

   try{
        document.getElementById("tdOperatingInstructions").className = "tabOn";
        document.getElementById("trOperatingInstructions").style.display = "inline";
      }catch(ex){}
}
function hidevideo()
{
   try {
          document.getElementById("trfullspecifications").style.display = "inline";
          document.getElementById("tdfullspecifications").className = "tabOn";
        }catch(ex){}

   try {
          document.getElementById("tdvideo").className = "tabOff";
          document.getElementById("trvideo").style.display = "none";
       }catch(ex){}

   try {
         document.getElementById("tdOperatingInstructions").className = "tabOff";
         document.getElementById("trOperatingInstructions").style.display = "none";
      }catch(ex){}
}

function searchManufacturer(manufacturer)
{
     try {
           var m = "";
           if(document.all)
           {
              m = manufacturer.innerText;
           }
           else
           {
              m = manufacturer.textContent;
           }

          document.getElementById("txtSearch").value= m;
          document.getElementById("frm_search").action = 'shopsearchresult.asp?supplierid=' + supplier_id + '&manufacturer=' + m;
          //document.getElementById("btnSearch").click();

          window.location.href = document.getElementById("frm_search").action
         }catch(ex){}
}
function searchByDeptFilter(deptId,searchVal)
{
     try {
           document.getElementById("txtSearch").value= searchVal;
           //document.getElementById("frm_search").action = 'shopsearchresult.asp?supplierid=1122&deptid=' + deptId;
           

           var sURL = window.document.URL.toString();
           var loc_did = sURL.indexOf("deptid=");
           


           if(loc_did > -1)
           {
             sURL = sURL.substring(0,(loc_did - 1));
           }


           loc_did = sURL.indexOf("?");

           if(loc_did > -1)
           {
              sURL = sURL + '&deptid=' + deptId;
           }
           else
           {
             sURL = sURL + '?deptid=' + deptId;
           }
           document.getElementById("frm_search").action = sURL;
           document.getElementById("frm_search").submit();

         }catch(ex){}
}

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}


function setEmpty(val,obj)
{
  if(obj.value ==  val)
   obj.value = "";
} 



function goToParent(dept_id,p_dept)
{
      var page = "";
      switch(dept_id)
      {
        case 2212:
        page = "%D7%98%D7%9C%D7%95%D7%99%D7%96%D7%99%D7%95%D7%AA_%D7%95%D7%9E%D7%A7%D7%A8%D7%A0%D7%99%D7%9D.html";
        break;
        case 2055:
        page = "%D7%9E%D7%95%D7%A6%D7%A8%D7%99_%D7%97%D7%A9%D7%9E%D7%9C_%D7%A7%D7%98%D7%A0%D7%99%D7%9D.html";
        break;
      default:
        page = "departmentpage.asp?sc=1122&id=" + p_dept + "&fid=" + dept_id;
      }

      window.location.href = page;
}


function CheckValidID(VID){
    var iIDLength = VID.length,
        i,
        iID = VID;
    if(iIDLength<9){
        for(i=0;i<9-iIDLength;i++){
            iID = "0" + iID;
        }
        iIDLength = 9;
    }

    var iCount = 0,
        iCurrent,
        iTemp;

    for(i=2;i<iIDLength+2;i++){
        iTemp = iID.substr(i-2,1)*1;
        if(iTemp != 0){
            iCurrent=((i%2)+1)*iTemp;
            iCount+=iCurrent>9?1+iCurrent%10:iCurrent;
        }
    }
    //return(iCount%10===0);
    if(iCount%10!=0  || iID=="111111118" || iIDLength<6)
    {
      return false;
    }
    else
    {
      return true;
    }
}

function getSearch(obj,txtSearch)
{
    obj.action = "shopsearchresult.asp?val=" + document.getElementById(txtSearch).value;
    obj.submit();
}
function nofollow(n) 
{
  n = n.replace(/!/, "http://www.");
  document.location.href = n;
}
/*common js :*/
function GetBanner2(tdID,bSc,bDp,bLc,bWidth,bHeight)
{       
     var xmlData = ffLoadXMLBrowser("<content>Banner<banners><banner sc='"+bSc+"' dp='"+bDp+"' lc='"+bLc+"'/></banners></content>");
               var x= xmlData.getElementsByTagName("banners");
               var el = x[0];

                var httpOb = GetHttp(xmlData);

                 if(httpOb.status==200)
                 {    
                   var obj = unescape(httpOb.responseText)
                   if(obj!=null && obj!="")
                   {
                    if(obj.indexOf('swf')>-1)
                    {
                      if(obj.indexOf('.')>-1)
                       $("#" + tdID).html("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'  width='"+bWidth+"' height='"+bHeight+"' id='myflash' align='middle'><param name='wmode' value='transparent'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='"+obj.split(";")[0]+"' /><param name='quality' value='high' /><embed src='"+obj.split(";")[0]+"' quality='high' wmode='transparent' width='"+bWidth+"' height='"+bHeight+"' name='mymovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");
                    }
                    else
                    {
                      if(obj.indexOf('.')>-1)
                       $("#" + tdID).html("<img vspace='0' hspace='0' alt='' id='img" + tdID + "' src='" + obj.split(";")[0] + "' style='cursor:pointer' onclick=\"javascript:BannerAim('" +  obj.split(";")[1] + "');\" alt='" + obj.split(";")[2] + "'  width='" + bWidth + "' height='" + bHeight + "' ></img>");
                    }
                   }
                 }
}
  function SelectSingleNode(xmlDoc, elementPath){
    if (document.implementation && document.implementation.createDocument)      
    {
      var nodes=xmlDoc.evaluate(elementPath, xmlDoc, null, XPathResult.ANY_TYPE, null);
      var results=nodes.iterateNext();
      return results;
       }   
}
function ffLoadXMLBrowser(strXML){ 
        if(document.implementation && document.implementation.createDocument) 
        {
            if(navigator.appVersion.indexOf('MSIE 9.0;') > -1)
            {
                // IE 9
              xmlDocum = new ActiveXObject("Microsoft.XMLDOM");
              xmlDocum.async=false;
              xmlDocum.loadXML( strXML);
            }
            else
            {
              // MOZILLA or other Browser
              xmlParser = new DOMParser();
              xmlDocum = xmlParser.parseFromString( strXML, 'text/xml');
              xmlSerializer = new XMLSerializer();
            }
       }
       else if(window.ActiveXObject) 
       {
            // IE
            xmlDocum = new ActiveXObject("Microsoft.XMLDOM");
            xmlDocum.async=false;
            xmlDocum.loadXML( strXML);
            

        }
        return xmlDocum;
    }
function BannerAim(vLink)
{
 if(vLink!="")
 {
   if(vLink.indexOf("shop")!=-1 || vLink.indexOf("content")!=-1 || vLink.indexOf("product")!=-1)
   {
     window.location.href = vLink;
   }
   else
   {
      window.open(vLink);
   }
 }
}
function GetHttp(XmlSource,vHttps)
{

    var oXMLServer = "http://" + window.location.hostname + "/UpdateXml.asp";
    if(window.location.href.indexOf("https")!=-1)
    {
      oXMLServer = "https://" + window.location.hostname + "/UpdateXml.asp";
    }
    var HttpRequest;
    
    
    if (window.XMLHttpRequest)
    {      
          // If IE7, Mozilla, Safari, etc: Use native object
          HttpRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
           // ...otherwise, use the ActiveX control for IE5.x and IE6
           HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }

    HttpRequest.open("POST",oXMLServer,false);
    HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    HttpRequest.send(XmlSource);
    return HttpRequest;
}



function ResetForm(cForm)
{
	var eLm = new Object();

	for(i=0;i<cForm.elements.length;i++)
	{
	  eLm = cForm.elements(i);
	  if (eLm.tagName.toUpperCase()=="INPUT")
	  {
	 		if (eLm.type.toUpperCase()=="TEXT")
				 eLm.value = "";
	  }
	  else
	  {
				if (eLm.tagName.toUpperCase()=="SELECT")
					eLm.selectedIndex = 0;
	  }
	}  
}
function GetNBanner(tdID,vId,vName,Target,wWidth,wHeight,AltText,bLink,bWidth,bHeight)
{
  if(vName.indexOf('Video')>-1)
  {
      writeNVideo(tdID,vId,bLink,wWidth,wHeight)
  }
  if(vName.indexOf('swf')>-1)
  {
      writeNFlash(tdID,vId,vName,bWidth,bHeight);
  }
  else
  {
      writeNImage(tdID,vId,vName,bWidth,bHeight,AltText,Target,bLink,wWidth,wHeight);
  }
}
function writeNFlash(tdID,vId,vName,bWidth,bHeight,AltText,Target,bLink,wWidth,wHeight)
{
    var tdObj;
    tdObj = "<a href=\"javascript:SetTheyClickOnMe('" + vId + "');\" "
    tdObj += " onclick=\"javascript:SetTheyClickOnMe('" + vId + "');\" >"
    tdObj += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' "
    tdObj += " width='" + bWidth +"' "
    tdObj += " height='" + bHeight +"' "
    tdObj += " id='myflash' align='middle'> "
    tdObj += "<param name='allowScriptAccess' value='sameDomain' />"
    tdObj += "<param name='movie' value='" + vName + "' />"
    tdObj += "<param name='quality' value='high' />"
    tdObj += "<embed src='" + vName + "' quality='high' width='" + bWidth + "' height='" + bHeight + "' name='mymovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
    tdObj += "</object>";
    tdObj += "</a>";
    document.getElementById(tdID).innerHTML = tdObj;
    //document.getElementById(id).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+fWidth+"' height='"+fHeight+"' id='myflash' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='"+fName+"' /><param name='quality' value='high' /><embed src='"+fName+"' quality='high' width='"+fWidth+"' height='"+fHeight+"' name='mymovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
}
function writeNImage(tdID,vId,vName,bWidth,bHeight,AltText,Target,bLink,wWidth,wHeight)
{
    var tdObj;
    if(bLink!="" && bLink!=null)
    {
        tdObj = "<a "

        tdObj += " href='" + bLink + "' "
        tdObj += " target='" + Target + "' "
        if(Target=="_blank")
        {
         tdObj += " onclick=\"window.open('" + bLink +"','','menubar=0,resizable=1,location=1,status=0,scrollbars=1,width=" + wWidth + ",height=" + wHeight+ "');return false; \" "
        }
        tdObj += "> "

        tdObj += "<img onerror=\"this.style.display='none'\" "
        tdObj += " id='img" + vId + "' "
        tdObj += " alt='" + AltText + "' "
        tdObj += " width='" + bWidth +"' "
        tdObj += " height='" + bHeight +"' "
        tdObj += " src='" + vName + "' "
        tdObj += " onclick=\"javascript:SetTheyClickOnMe('" + vId + "');\" >"
        tdObj += "</img>"

        tdObj += "</a>"
    }
    else
    {
        tdObj = "<img onerror=\"this.style.display='none'\" "
        tdObj += " id='img" + vId + "' "
        tdObj += " alt='" + AltText + "' "
        tdObj += " width='" + bWidth +"' "
        tdObj += " height='" + bHeight +"' "
        tdObj += " src='" + vName + "' "
        tdObj += " onclick=\"javascript:SetTheyClickOnMe('" + vId + "');return false;\" >"
        tdObj += "</img>"
    }
    document.getElementById(tdID).innerHTML = tdObj;
}
function writeNVideo(tdID,vId,bLink,wWidth,wHeight)
{
    var tdObj;
    //tdObj = "<a href=\"javascript:SetTheyClickOnMe('" + vId + "');\" "
    //tdObj += " onclick=\"javascript:SetTheyClickOnMe('" + vId + "');\" >"
    var x;
    //alert(bLink);
    x= bLink.replace("&amp;","#");
    alert(x);
    tdObj = "<iframe id=\"ifrm" + vId + "\" "
    tdObj += " width=\"" + wWidth +"\" "
    tdObj += " height=\"" + wHeight +"\" "
    tdObj += " src=\"" + "http://www.ecomtrade.co.il" + "\" "
    tdObj += " frameborder=\"0\" scrollbars=\"no\"  >Your browser doesn't support frames."
    tdObj += "</iframe>";
    //tdObj += "</a>";
    document.getElementById(tdID).innerHTML = tdObj;
    //alert(document.getElementById(tdID).innerHTML)
}

function SetTheyClickOnMe(vID)
{
   var vdata = "<content>BannerClicks<banners><banner id='" + vID + "'/></banners></content>";
   var olXMLsource = new ActiveXObject("Microsoft.XMLDOM");
   olXMLsource.async = false;
   olXMLsource.loadXML(vdata);
   var httpOb = GetHttp(olXMLsource);
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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 '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function SetDataFromCockie(fName,cName)
{
   document.getElementById(fName).value = readCookie(cName);
}


function joinToNewsletter(email,supplierId,defVal)
{    
  try
  {
   if(email.value == "" || email.value == defVal)
   {
     alert("נא הזן כתובת מייל");
     email.focus();
     return false;
   }
   else
   {
           var at = email.value.indexOf("@");
           var p = email.value.indexOf(".");
                     
                     if(at > 0 && p > 0 && p > at){}
                     else
                     {
                        alert("פורמט מייל לא תקין");
                        email.focus();
                        return ;
                     }
   }


       var vdata = "<content>join to newsletter<prods><prod email='" + email.value + "' supplierid='" + supplierId + "'  /></prods></content>";

       var olXMLsource = ffLoadXMLBrowser(vdata)

       //Open http to send data to server
       var httpOb = GetHttp(olXMLsource);

       if(httpOb.status==200)
       {

          if(httpOb.getResponseHeader('RetVal') == 1)
          {
             alert("הצטרפת בהצלחה למועדון המנויים");

          }
          else
          {
            if(httpOb.getResponseHeader('RetVal') == 2)
            {
               alert("מייל קיים במערכת");
            }
            else
            {
                alert("שגיאה");
            }

          }
       }
       else
       {
         
          return "99";
       }
  }
  catch(ex)
  {
   alert(ex.message); 
  }

}

function sendPasswordToUserByEmail(userName)
{    
  try
  {
   if(userName == "")
   {
     alert("שם משתמש חסר");
     document.getElementById("fUserName").focus();
     return false;
   }


       var vdata = "<content>send password to user by email<prods><prod userName='" + userName + "'  /></prods></content>";
       var olXMLsource = ffLoadXMLBrowser(vdata)

       //Open http to send data to server
       var httpOb = GetHttp(olXMLsource);
         
       if(httpOb.status==200)
       {
          if(httpOb.getResponseHeader('RetVal') == 1)
          {
             alert("סיסמתך נשלחה לכתובה הדואר האלקטרוני איתה נרשמת לאתר");

          }
          else
          {
             alert("שגיאה");
          }
       }
       else
       {
          return "99";
       }
  }
  catch(ex)
  {
   alert(ex.message); 
  }

}
function LogOutUser()
{
   
   var vdata = "<content>log out<prods><prod/></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //var oXMLServer = "http://www.traklin.co.il/UpdateXml.asp";
   var oXMLServer = "UpdateXml.asp";
        var HttpRequest;



        if (window.XMLHttpRequest)
        { HttpRequest = new XMLHttpRequest();}
        else if (window.ActiveXObject)
        { HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}


//alert("LogOut");
	
	
         HttpRequest.open("POST",oXMLServer,false);
	



        HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        HttpRequest.send(olXMLsource);



       //var httpOb = GetHttp(olXMLsource);
       
       var httpOb = HttpRequest;

   if(httpOb.status==200)
   {
     window.location.href = window.location.href;
   }
   else
   {
      alert("Error");
   }
}

function GetShopingCartCount(sid)
{

   var vdata = "<content>Get Shoping Cart Count<prods><prod sid='" + sid + "'/></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   var oXMLServer = "http://www.traklin.co.il/UpdateXml.asp";
        var HttpRequest;
        if (window.XMLHttpRequest)
        { HttpRequest = new XMLHttpRequest();}
        else if (window.ActiveXObject)
        { HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
        HttpRequest.open("POST",oXMLServer,false);
        HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        HttpRequest.send(olXMLsource);
       //var httpOb = GetHttp(olXMLsource);
       
       var httpOb = HttpRequest;

   if(httpOb.status==200)
   {
     $("#cartProdsCount").text(httpOb.getResponseHeader('RetVal'));
     //return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      $("#cartProdsCount").text(httpOb.getResponseHeader('RetVal'));
     //return "99";
   }

}


function UpdateShopingCartShipment(prod_id,gathering_from_store)
{
   var vdata = "<content>Update Shoping Cart Shipment<prods><prod prod_id='" + prod_id + "' gathering_from_store='" + gathering_from_store + "'/></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)
   var oXMLServer = "http://www.traklin.co.il/UpdateXml.asp";
        var HttpRequest;
        if (window.XMLHttpRequest)
        { HttpRequest = new XMLHttpRequest();}
        else if (window.ActiveXObject)
        { HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
        HttpRequest.open("POST",oXMLServer,false);
        HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        HttpRequest.send(olXMLsource);

       var httpOb = HttpRequest;

        if(httpOb.status==200)
        {
           window.location.href = "http://www.traklin.co.il/shopingcart.asp?pc=" + prod_id;
        }
}



function LogInUser(userName,Password,isSubmit,isPeronalSale,prodId)
{

   if(userName.value == "")
   {
     alert("שם משתמש חסר");
     userName.focus();
     return false;
   }
   if(Password.value == "")
   {
     alert("סיסמא חסרה");
     Password.focus();
     return false;
   }
    
       var vdata = "<content>check user login<prods><prod userName='" + userName.value + "' Password='" + Password.value + "' /></prods></content>";
 

       var olXMLsource = ffLoadXMLBrowser(vdata)

       var oXMLServer = "http://www.traklin.co.il/UpdateXml.asp";
        var HttpRequest;
        if (window.XMLHttpRequest)
        { HttpRequest = new XMLHttpRequest();}
        else if (window.ActiveXObject)
        { HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
        HttpRequest.open("POST",oXMLServer,false);
        HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        HttpRequest.send(olXMLsource);
       //var httpOb = GetHttp(olXMLsource);
       
       var httpOb = HttpRequest;
    
       if(httpOb.status==200)
       {
          if(httpOb.getResponseHeader('RetVal') == 1)
          {
              
              if(isSubmit)
               {
                 if(isPeronalSale == 1)
                 {
                   GoToPeronalSale(prodId);
                 }
                 else
                 {
                    document.product_details_form.submit();
                 }

               }
               else
               {
                    if(prodId != 0)
                    {



			var vdata = "<content>get customer choose price<prods><prod prodId='" + prodId + "'  /></prods></content>";
       			var olXMLsource = ffLoadXMLBrowser(vdata)

        		var oXMLServer = "http://www.traklin.co.il/UpdateXmlV.asp";
        		var HttpRequest;

        		if (window.XMLHttpRequest)
        		{ HttpRequest = new XMLHttpRequest();}
        		else if (window.ActiveXObject)
        		{ 
			HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
       		 	HttpRequest.open("POST",oXMLServer,false);
       		 	HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        		HttpRequest.send(olXMLsource);

			var httpOb = HttpRequest;



			if(httpOb.status==200)
         			{
			var customerChoosePrice = httpOb.getResponseHeader('RetVal');
			var status = httpOb.getResponseHeader('RetVal2');

				
				    if(customerChoosePrice  != "-1") 
					{ 


	    				  if(customerChoosePrice  == "True")
          					{ 

							if(status == 1)
							{
							  window.location.href = "https://www.traklin.co.il/shopOffer.asp?pc=" + prodId;  
							}

							else
							{
							window.location.href = "http://www.traklin.co.il/product.asp?pc=" + prodId;
							}
						}
					  else  
						{
							
							  window.location.href =   "http://www.traklin.co.il/product.asp?pc=" + prodId;
							

							
						}
					}
				     else
					{
						
					}
				  
				  
	 			}

			 else
       				{
          			  return "99";
       				}






                       //window.location.href = "http://www.traklin.co.il/product.asp?pc=" + prodId;
		       //window.location.href = "https://www.traklin.co.il/shopOffer.asp?pc=" + prodId;
                    }
                    else
                    {

                            document.getElementById("divUserLogIn").style.display = 'none';
                            if(document.getElementById("divUserLogIn2"))
                            {
                              document.getElementById("divUserLogIn2").style.display = 'none';
                            }
                            document.getElementById("divUserLogInMsg").style.display = '';
        
                            if(document.getElementById("divUserLogInMsg2"))
                            {
                              document.getElementById("divUserLogInMsg2").style.display = '';
                            }
                            document.getElementById("spnDisconnect").style.display = '';
                            document.getElementById("spnConnect").style.display = 'none';
                            
              
                             if(document.all)
                             {
                               document.getElementById("spnLogerName").innerText = userName.value;
                               if(document.getElementById("spnLogerName2"))
                               {
                                 document.getElementById("spnLogerName2").innerText = userName.value;
                               }
                               document.getElementById("spnUserName").innerText = userName.value;
                               
              
                             }
                             else
                             {
                              document.getElementById("spnLogerName").textContent = userName.value;
                              if(document.getElementById("spnLogerName2"))
                               {
                                 document.getElementById("spnLogerName2").textContent = userName.value;
                               }
                              document.getElementById("spnUserName").textContent = userName.value;
                             }
                    }
               }

          }
          else
          {
             alert("אי התאמה בשם משתמש או סיסמא נא נסה שנית");
          }
       }
       else
       {

          return "99";
       }

}


function checkIfIdentityInBlacklist(supplierId,identity)
{
    if(identity == "")
    {
     identity = -1;
    }
   var vdata = "<content>check if identity in blacklist<prods><prod supplierId='" + supplierId + "' identity='" + identity + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);

   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}
function checkIfUserNameAvailable(UserName)
{

   var vdata = "<content>check If UserName Available<prods><prod UserName='" + UserName + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);

   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}
function checkIfProdIsBlockedForCustomer(Prod,identity,card)
{
  try
  {
      if(identity.charAt(0) == 0)
      {
        identity =  identity.substring(1, identity.length );
      }
  

      if(identity == "")
      {
       identity = -1;
      }
     var vdata = "<content>check if prod is blocked for customer<prods><prod prodid='" + Prod + "' identity='" + identity + "' card='" + card + "' /></prods></content>";
     var olXMLsource = ffLoadXMLBrowser(vdata)
  
     //Open http to send data to server
     var httpOb = GetHttp(olXMLsource);

     if(httpOb.status==200)
     {
       return httpOb.getResponseHeader('RetVal');
     }
     else
     {
        return "99";
     }
  }catch(ex){}
}


function updateProductsCart(pid,isChecked)
{
   var vdata = "<content>update products cart<prods><prod pid='" + pid + "' ischecked='" + isChecked + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);



   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}

function CheckIfUserExists(username,password)
{
   var vdata = "<content>Check If User Exists<prods><prod username='" + username + "' password='" + password + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);



   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}



function updateProductsCartQuantity(pid)
{
   var vdata = "<content>update products cart quantity<prods><prod pid='" + pid + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);
        
   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}
function getProductsCartQuantity()
{
   var vdata = "<content>get products cart quantity<prods><prod/></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata)

   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);
        
   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}
function SendEmailPersent(vSup,vPid,vName,vPhone,vMobile,vPrice,vEmail,PrCode,ident,user_name_login)
{
   var vdata = "<content>send product price<prods><prod pid='" + vPid + "' nm='" + vName + "' ph='" + vPhone + "' mb='" + vMobile + "' pr='" + vPrice + "' em='" + vEmail + "' sup='" + vSup + "' prcode='"+PrCode+"' ident='"+ident+"' unl='"+user_name_login+"' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata);
   olXMLsource.async = false;
   var httpOb = GetHttp(olXMLsource);
}
function CheckProdPriceNew(vProd,vPrice,vRet)
{
   var vdata = "<content>check product price new<prods><prod pid='" + vProd + "' pps='" + vPrice + "' ret='" + vRet + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata);
   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);


   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "99";
   }
}
function GetProdPrice(vProd,vPrice)
{
   var vdata = "<content>get product price<prods><prod pid='" + vProd + "' pps='" + vPrice + "' /></prods></content>";
   var olXMLsource = ffLoadXMLBrowser(vdata);
   //Open http to send data to server
   var httpOb = GetHttp(olXMLsource);

   if(httpOb.status==200)
   {
     return httpOb.getResponseHeader('RetVal');
   }
   else
   {
      return "0";
   }
}

function checkImageState()
{

   if(document.getElementById("imgLarge").style.display=="none")
   {
      document.getElementById("btnLarge").style.display="none";
   }
   else
   {
     try
     {
       if(document.getElementById("btnLarge").style.display!='none')
       {
         document.getElementById("btnLarge").style.top = parseInt(document.getElementById("btnLarge").style.top) + document.getElementById("imgLarge").offsetTop + document.getElementById("imgLarge").offsetHeight
         document.getElementById("btnLarge").style.display="inline";
       }
     }
     catch(e){}
   }
}
function ChangeAccomp(vSel)
{
	var Arr = vSel.value.split(":");
	var tbl = document.all["tblAccomp"].rows.length;
	if(tbl==3)
		ChangeAccompById(vSel,document.all["chk_accomp_prod"],document.all["accompPrice"],document.all["tdaccompImg"],document.all["tdaccompHref"],document.all["sel_accomp_prod_qty"],document.all["inpCompQty"])
	else
	{
		var i=0;
		for(;i<tbl-2;i++)
		{
			if(Arr[0]==document.all["inpComp"][i].value)
			{
				break;
			}
		}
		ChangeAccompById(vSel,document.all["chk_accomp_prod"][i],document.all["accompPrice"][i],document.all["tdaccompImg"][i],document.all["tdaccompHref"][i],document.all["sel_accomp_prod_qty"][i],document.all["inpCompQty"][i])
	}
}


function SetData()
{
   try
   {
	var tbl = document.all["tblAccomp"].rows.length;
	if(tbl==3)
	{
		if(!document.all["chk_accomp_prod"].checked)
		{
			document.all["sel_accomp_prod_qty"].text = "-1";
			document.all["inpCompQty"].value = "";
		}
	}
	else
	{
		var i=0;
		for(;i<tbl-2;i++)
		{
			if(!document.all["chk_accomp_prod"][i].checked)
			{
				document.all["sel_accomp_prod_qty"][i].value = "-1";
				document.all["inpCompQty"][i].value = "";
			}
		}
	}
   }
   catch(e){};
   return true;
}
function ClearForm(cForm)
{
	var eLm = new Object()
	
	for(i=0;i<cForm.elements.length;i++)
	{
	  eLm = cForm.elements(i)
	  switch(eLm.tagName.toUpperCase()) 
	  {
	    case "INPUT":
    	    if (eLm.type.toUpperCase()=="TEXT")
    	    {
				 eLm.value = "";
			}	 
    	    else if (eLm.type.toUpperCase()=="CHECKBOX")
    	    {
				 eLm.checked = false;
			}
	    break;
	    case "SELECT":
			eLm.selectedIndex = 0
	    break;
	    case "TEXTAREA":
			eLm.value = "";
	    break;
	 }                               
	}
}  


function setMenuOn(obj)
{

     $("#tdr_" + obj).addClass("td_dept_top_r");
     $("#tdl_" + obj).addClass("td_dept_top_l");
     $("#tdm_" + obj).addClass("td_dept_top_m");

}
function setMenuOut(obj)
{
   $("#tdr_" + obj).removeClass("td_dept_top_r");
   $("#tdl_" + obj).removeClass("td_dept_top_l");
   $("#tdm_" + obj).removeClass("td_dept_top_m");
}
