﻿var xmlHttp

function showKakelList(ProdCatID, PageIndex, Format, Feeling, FreeText, sortimentlink)
{
    if (ProdCatID.length==0)
    { 
      document.getElementById("big_box_sortiment2").innerHTML= "";
      return;
    }
      
    //document.getElementById("spnList").innerHTML="<div align=center><img src='/img/ajax-loader.gif' border=0 alt='Loading...'></div>";  
    document.getElementById("big_box_sortiment2").innerHTML="<div align=center><img src='/img/ajax-loader.gif' border=0 alt=''></div>";  
    xmlHttp=GetXmlHttpObject4();
    
    if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    }
    
    SetSession(Format, FreeText);
 
    var url="/LoadKakelList.asp";
    url=url+"?ProductType=" + ProdCatID +"&PageIndex="+ PageIndex +"&Format="+ Format +"&Feeling="+ Feeling +"&FreeText="+ FreeText+ "&sortimentlink=" + sortimentlink;
    xmlHttp.onreadystatechange=stateChanged4;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function SetSession(Format, FreeText)
{
    var url = "/SetSession.asp?FreeText=" + FreeText + "&Format=" + Format

    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            //alert(xmlhttp.responseText);
//            document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
    }
    
    xmlhttp.open("POST",url,true);
    xmlhttp.send();
}


function stateChanged4() 
{ 
    if (xmlHttp.readyState==4)
    { 
        document.getElementById("big_box_sortiment2").innerHTML=xmlHttp.responseText;
        
        // För produktsöken
        $("#txtSearch").keypress(function(e) {
            if(e.which == 13){
                $("#btnSend").click();
            }
        });
    }
}

function GetXmlHttpObject4()
{
    var xmlHttp=null;
    try
      {
          // Firefox, Opera 8.0+, Safari
          xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
}