﻿// JScript File

function vis_dommerkort(id_nr,utstilling_nokkel,id_utst,type)
{
 if(type == 'vanlig')
   window.open('dommer_kort_vanlig.aspx?id=' + id_nr + '&iduts=' + utstilling_nokkel + '&idutsdyr=' + id_utst + '&dato=' + Date(),'_blank');
 else if(type == 'npa')
     window.open('dommer_kort_unghest.aspx?type=npa&id=' + id_nr + '&iduts=' + utstilling_nokkel + '&idutsdyr=' + id_utst + '&dato=' + Date(),'_blank');
 else if(type == 'ung')
     window.open('dommer_kort_unghest.aspx?type=unghest&id=' + id_nr + '&iduts=' + utstilling_nokkel + '&idutsdyr=' + id_utst + '&dato=' + Date(),'_blank');

}

function vis_dommerkort_pdf(id_utst)
{
   window.open('http://www.ponniavl.no/File/dommerkort/' + id_utst + '.pdf?dato=' + Date(),'_blank');
}

var xmlhttp

function showHint(rek_id)
{
if (rek_id.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="salg_kjop.aspx";
if(rek_id == '0')
{
  url=url+"?antall=0&str=0&rek_id=0&farge=0";
}
else
{

  if(document.getElementById("antall_" + rek_id).value == "")
  {
    alert('Antall må fylles ut.');
    return;
  }
  if(document.getElementById("str_" + rek_id))
  {
    if(document.getElementById("str_" + rek_id).value == "")
    {
      alert('Størrelse må velges.');
      return;
    }
  }
  
  if(document.getElementById("farge_" + rek_id))
  {
    if(document.getElementById("farge_" + rek_id).value == "")
    {
      alert('Farge må velges.');
      return;
    }
  }
    
  url=url+"?antall="+ document.getElementById("antall_" + rek_id).value;
  if(document.getElementById("str_" + rek_id))
    url=url+"&str="+ document.getElementById("str_" + rek_id).value;
  else  
    url=url+"&str=0";
  if(document.getElementById("farge_" + rek_id))
    url=url+"&farge="+ document.getElementById("farge_" + rek_id).value;
  else  
    url=url+"&farge=0";
    
  url=url+"&rek_id="+ rek_id;
}
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;

xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
  if (xmlhttp.readyState==4)
  {
      sRet = xmlhttp.responseText;
      arrRet = sRet.split('|');
      if(arrRet[2] == '0')
      {
        document.getElementById("ant_artikler").innerHTML= "0";
        document.getElementById("tot_pris").innerHTML= "0.-";
        
        for(i=0;i < 15;i++)
        {
           if(document.getElementById("status_" + i))
             document.getElementById("status_" + i).innerHTML = '';
        }
        return;
      }
  
      document.getElementById("ant_artikler").innerHTML= arrRet[0];
      document.getElementById("tot_pris").innerHTML= arrRet[1] + ".-";
  
      if(document.getElementById("str_" + arrRet[2]))
        document.getElementById("str_" + arrRet[2]).value = "";
      if(document.getElementById("farge_" + arrRet[2]))
        document.getElementById("farge_" + arrRet[2]).value = "";        

      if(document.getElementById("antall_" + arrRet[2]))
        document.getElementById("antall_" + arrRet[2]).value = "";

      if(arrRet[2])
      {
        document.getElementById("status_" + arrRet[2]).innerHTML = '<b>Er lagt til i handlevogna.</b>';
        getSleeping(arrRet[2]);
      }
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function getSleeping(rek_id)
{
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null)
  {
    alert ("Your browser does not support XMLHTTP!");
    return;
  }
  var url="sleeping.aspx";
  url=url+"?id=" + rek_id;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateSleeping;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function stateSleeping()
{
  if (xmlhttp.readyState==4)
  {
    document.getElementById("status_" + xmlhttp.responseText).innerHTML = '';
  }
}

function setSearcWaitHorePro()
{
  document.getElementById("ctl00_hoved_NprosSearch").innerHTML = '' + 
           '<table align="center" style="padding-top:50px;padding-bottom:50px">' +
             '<tr>' + 
               '<td align="center"><img src="/grafikk/spinner_white.gif" border="0"/><br /><br /><b><i>Henter sportsresultater fra HorsePro...</b></i></td>' +
             '</tr>'  +
           '</table>';
}



