// Ajax Control
Function diggajax (){
VaR xhrobj = NULL;
If (window. XMLHttpRequest ){
Xhrobj = new XMLHttpRequest ();
}
Else if (window. activexobject ){
Try {
Xhrobj = new activexobject ("Microsoft. XMLHTTP ");
}
Catch (E1)
{
Try {
Xhrobj = new activexobject ("msxml2.xmlhttp ");
}
Catch (E2 ){
Try {
Xhrobj = new activexobject ("msxml3.xmlhttp ");
}
Catch (E3 ){
Alert ("failed to Create Ajax:" + E3)
}
}
}
}
Else
{
Alert ("Unrecognized browsers ");
}
Return xhrobj;
}
VaR loader = new diggajax;
Function ajaxloadpage (URL, request, method, fun)
{
Method = method. touppercase ();
If (Method = 'get ')
{
URLs = URL. Split ("? ");
If (URLs [1] = ''| typeof URLs [1] = 'undefined ')
{
Url = URLs [0] + "? "+ Request;
}
Else
{
Url = URLs [0] + "? "+ URLs [1] +" & "+ request;
}
Request = NULL;
}
Loader. Open (method, URL, true );
If (Method = "Post ")
{
Loader. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
}
Loader. onreadystatechange = function (){
Eval (fun + '()');
}
Loader. Send (request );
}
Function callbacks ()
{
If (loader. readystate = 4)
{
VaR S = loader. responsetext;
Switch (s)
{
Case "Err ":
Alert ('digg error! ');
Break;
Case "over ":
Alert ('you have already recommended it! ');
Break;
Case "nologin ":
Alert ('You have not logged on yet, not recommended! ');
Break;
Default:
VaR Sarr = S. Split ('| ');
Eval ("document. All. s" + Sarr [0]). innerhtml = Sarr [1];
Eval ("document. All. d" + Sarr [0]). innerhtml = "thanks ";
}
}
}
// Digg
Function Digg (channelid, infoid, installdir)
{
Ajaxloadpage (installdir + 'plus/Digg. asp ', 'Action = hits & channelid =' + channelid + '& infoid =' + infoid, 'post', 'callbacks ');
}
Function show_digg (channelid, infoid, installdir)
{
VaR xhr = new diggajax ();
Xhr. Open ("get", installdir + "Plus/Digg. asp? Channelid = "+ channelid +" & infoid = "+ infoid +" & Action = show ", true );
Xhr. onreadystatechange = function (){
If (xhr. readystate = 1)
{
Eval ("document. All. s" + infoid). innerhtml = " ";
}
Else if (xhr. readystate = 2 | xhr. readystate = 3)
{
Eval ("document. All. s" + infoid). innerhtml = " ";
}
Else if (xhr. readystate = 4)
{
If (xhr. Status = 200)
{
VaR r = xhr. responsetext
VaR rarr = R. Split ('| ');
Eval ("document. All. s" + infoid). innerhtml = rarr [1];
}
}
}
Xhr. Send (null );
}