// ***** http://reading.udn.com/lib/ncl/ *****
function getbook(bid)
{
	window.open("http://192.192.58.90/ebook/"+bid+".pdf");	
}

function gobook(bid)
{
	window.open("http://reading.udn.com/reading/book.do?id="+bid, "bookinfo");
}

function goLibBook(mcate,tid)
{
	window.open("book.jsp?mcate="+mcate+"&tid="+tid, "mainFrame");
}

runtimeVersion = "2.0.0";
function GoReader(tid)
{
	var gourl = "";
		//gourl = "/lib_reader/UDN.Book.Lib.application?T_ID="+tid;
		gourl = "http://reading.udn.com/lib_reader/UDN.Book.Lib.application?T_ID="+tid;

  if (HasRuntimeVersion(runtimeVersion))
  {
    //window.navigate(gourl);
	window.location=gourl; 
  }
  else
  {
  	alert("您尚未升級至.NET Framework2.0，請在按下確定後開始安裝程式。");
	//window.navigate("/lib_reader/setup.exe");
  	//window.navigate(gourl);
	//window.location="/lib_reader/setup.exe"; 
	window.location="http://reading.udn.com/lib_reader/setup.exe"; 
	//window.location=gourl; 
	}
}

function GoReaderShelf(tid)
{
	var gourl = "";
		//gourl = "/lib_reader/UDN.Book.Lib.application?T_ID="+tid+"&sort=s";
		gourl = "http://reading.udn.com/lib_reader/UDN.Book.Lib.application?T_ID="+tid+"&sort=s";

  if (HasRuntimeVersion(runtimeVersion))
  {
    //window.navigate(gourl);
	window.location=gourl; 
  }
  else
  {
  	alert("您尚未升級至.NET Framework2.0，請在按下確定後開始安裝程式。");
	//window.navigate("/lib_reader/setup.exe");
  	//window.navigate(gourl);
	//window.location="/lib_reader/setup.exe"; 
	window.location="http://reading.udn.com/lib_reader/setup.exe"; 
	//window.location=gourl; 
	}
}

function HasRuntimeVersion(v)
{
  var va = GetVersion(v);
  var i;
  var a = navigator.userAgent.match(/\.NET CLR [0-9.]+/g);
  if (a != null)
    for (i = 0; i < a.length; ++i)
      if (CompareVersions(va, GetVersion(a[i])) <= 0)
		return true;
  return false;
}
function GetVersion(v)
{
  var a = v.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
    return a.slice(1);
}
function CompareVersions(v1, v2)
{
  for (i = 0; i < v1.length; ++i)
  {
    var n1 = new Number(v1[i]);
    var n2 = new Number(v2[i]);
    if (n1 < n2)
      return -1;
    if (n1 > n2)
      return 1;
  }
  return 0;
}

function GoReader8(tid)
{
	var gourl = "";
		//gourl = "/lib_reader/forAcrobat8/UDN.Book.Lib.application?T_ID="+tid;
		gourl = "http://reading.udn.com/lib_reader/forAcrobat8/UDN.Book.Lib.application?T_ID="+tid;

  if (HasRuntimeVersion(runtimeVersion))
  {
    //window.navigate(gourl);
	window.location=gourl; 
  }
  else
  {
  	alert("您尚未升級至.NET Framework2.0，請在按下確定後開始安裝程式。");
	//window.navigate("/lib_reader/setup.exe");
  	//window.navigate(gourl);
	//window.location="/lib_reader/forAcrobat8/setup.exe"; 
	window.location="http://reading.udn.com/lib_reader/forAcrobat8/setup.exe"; 
	window.location=gourl; 
	}
}