﻿var xmlHttp

function LoadArtDetails(ArtID)
{

    if (ArtID.length==0)
      { 
      document.getElementById("spnArtDetails").innerHTML= "";
      return;
      }
      
    document.getElementById("spnArtDetails").innerHTML="<div align=center><img src='/img/ajax-loader.gif' border=0 alt='' style='margin-top:15px'></div>";  
    xmlHttp=GetXmlHttpObject();
    
    if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    } 
 
    var url="/LoadMyPageArt.asp";
    url=url+"?ArtID=" + ArtID;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    { 
        document.getElementById("spnArtDetails").innerHTML=xmlHttp.responseText;
        
        // Hanterar skicka mina val som e-post inputen
        $("#sendChoicesInEmailInput").focus(function(){
            
            if($("#sendChoicesInEmailInput").val() == "e-postadress"){
                $("#sendChoicesInEmailInput").val("");
            }
        });
        
        $("#sendChoicesInEmailInput").blur(function(){
            if($("#sendChoicesInEmailInput").val() == ""){
                $("#sendChoicesInEmailInput").val("e-postadress");
            }
        });
        
        $("#sendChoicesInEmailInput").keypress(function(e) {
            if(e.which == 13){
                $("#sendChoicesInEmailInputBtn").click();
            }
        });
        
    }
}

function GetXmlHttpObject()
{
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;
}