﻿var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function CountStock()
{
//countstock.aspx?WoodSpecies=&type=&Size=&m2=&ItemNr=&Grades=
    var WoodSpecies ='';
    var Type ='';
    var Size ='';
    var Grades ='';
    var Stock ='';
    
    var ItemNr = document.getElementById("ctl00_LeftMenu_ItemNr").value;
    
    if (document.getElementById("ctl00_LeftMenu_WoodSpecies").selectedIndex > 0)
        WoodSpecies = document.getElementById("ctl00_LeftMenu_WoodSpecies").options[document.getElementById("ctl00_LeftMenu_WoodSpecies").selectedIndex].value;
    
    if (document.getElementById("ctl00_LeftMenu_Type").selectedIndex > 0)
        Type = document.getElementById("ctl00_LeftMenu_Type").options[document.getElementById("ctl00_LeftMenu_Type").selectedIndex].value;
    
    if (document.getElementById("ctl00_LeftMenu_Size").selectedIndex > 0)
        Size = document.getElementById("ctl00_LeftMenu_Size").options[document.getElementById("ctl00_LeftMenu_Size").selectedIndex].value;
    
    if (document.getElementById("ctl00_LeftMenu_Grades").selectedIndex > 0)
        Grades = document.getElementById("ctl00_LeftMenu_Grades").options[document.getElementById("ctl00_LeftMenu_Grades").selectedIndex].value;
    
    if (document.getElementById("ctl00_LeftMenu_Stock").selectedIndex > 0)
        Stock = document.getElementById("ctl00_LeftMenu_Stock").options[document.getElementById("ctl00_LeftMenu_Stock").selectedIndex].value;
    
    
    
    
    var URL_ = "countstock.aspx?WoodSpecies=" + WoodSpecies + "&Type=" + Type + "&Size=" + Size + "&Grades=" + Grades + "&ItemNr=" + ItemNr + "&Stock=" + Stock  ;
       URL_ = encodeURI(URL_);
   // prompt("", URL_); 
     xmlhttp.open("GET", URL_ ,true);
     xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
       if (xmlhttp.status!=404) {
        document.getElementById("SearchResult").innerHTML = xmlhttp.responseText;
        if (xmlhttp.responseText == 0)
            document.getElementById("ctl00_LeftMenu_SearchStock").disabled = true;
        else
            document.getElementById("ctl00_LeftMenu_SearchStock").disabled = false;
       }
      }
     }
     xmlhttp.send(null);
}


function ShowItem(Page_, Parameters_)
{

    var Top = '';
    Top += '<table border=\"0\" width=\"547px\" height=\"520px\" style=\"border:solid 1px #999999; background-color:#f3f3f3;\">';
    Top += '<tr>';
    Top += '<td style=\"height:15px;\" colspan=\"3\" align=\"right\"><img src=\"/images/blank.gif\" height=\"15\" alt=\"\"/><span onclick=\"HideHover()\"><img src=\"/images/close.png\" border=\"0\"/></span></td>';
    Top += '</tr>';
    Top += '<tr>';
    Top += '<td><img src=\"/images/blank.gif\" height=\"15\" alt=\"\" width=\"24\"/></td>';
    Top += '<td>';
    Top += '<table border=\"0\" style=\"height:400px; width:490px; border:solid 1px #BBBBBB; background-color:#FFFFFF;\">';
    Top += '<tr>';
    Top += '<td style=\"height:15px;\" colspan=\"3\"><img src=\"/images/blank.gif\" height=\"15\" alt=\"\"/></td>';
    Top += '</tr>';
    Top += '<tr>';
    Top += '<td align=\"center\">';

    var Bottom = '';
    Bottom += '</td>';
    Bottom += '</tr>';
    Bottom += '<tr>';
    Bottom += '<td style=\"height:15px;\" colspan=\"3\"><img src=\"/images/blank.gif\" height=\"15\" alt=""/></td>';
    Bottom += '</tr>';
    Bottom += '</table>';
    Bottom += '</td>';
    Bottom += '<td><img src="/images/blank.gif" height="15" alt="" width="24"/></td>';
    Bottom += '</tr>';
    Bottom += '<tr>';
    Bottom += '<td style="height:15px;" colspan="3"><img src="/images/blank.gif" height="15" alt=""/></td>';
    Bottom += '</tr>';
    Bottom += '</table>';
    

  var URL_ = Page_  +  Parameters_;;
    URL_ = encodeURI(URL_);
   //prompt("", URL_); 
     xmlhttp.open("GET", URL_ ,true);
     xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
       if (xmlhttp.status!=404) {
     //  alert(xmlhttp.responseText)
            document.getElementById("HoverImage").style.visibility = "visible";
            document.getElementById("HoverImage").innerHTML = Top + xmlhttp.responseText +  Bottom;
            document.getElementById("HoverImage").style.top = 237;//(990/2) - 240;
            document.getElementById("HoverImage").style.left = 220; //(990/2) -270;
            document.getElementById("HoverImage").style.position = 'absolute';
        
       }
      }
     }
     xmlhttp.send(null);


}

 function HideHover()
{
    document.getElementById("HoverImage").style.visibility = 'hidden';
}


function addToFavorite(Page_, Parameters_, ID_)
{
   
  var URL_ = Page_  +  Parameters_;;
    URL_ = encodeURI(URL_);
   //prompt("", URL_); 
     xmlhttp.open("GET", URL_ ,true);
     xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
       if (xmlhttp.status!=404) {
        alert(xmlhttp.responseText);
        
   //      document.getElementById(ID_).style.visibility = 'hidden';
       }
      }
     }
     xmlhttp.send(null);
    PostBack();

}

function GetPage(Page_,Parameters_,  Id_, Top_, Left_, Position_)
{

    if (document.getElementById(Id_).style.display == "none")
    {
    var URL_ = Page_  +  Parameters_;
    URL_ = encodeURI(URL_);
   //prompt("", URL_); 
     xmlhttp.open("GET", URL_ ,true);
     xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
       if (xmlhttp.status!=404) {
     //  alert(xmlhttp.responseText)
            document.getElementById(Id_).style.display = "block";
            document.getElementById(Id_).innerHTML = xmlhttp.responseText;
            document.getElementById(Id_).style.top = Top_;//(990/2) - 240;
            document.getElementById(Id_).style.left = Left_; //(990/2) -270;
            document.getElementById(Id_).style.position = Position_;
            document.getElementById(Id_).style.zIndex  = '10';
       }
      }
     }
     xmlhttp.send(null);
    }
    else
        document.getElementById(Id_).style.display = "none";
    
    
}
