﻿// JScript File

function InvokeProfileAdd()
{
    InitXmlHttp();
    xmlhttp.onreadystatechange= XMLHttpRequestCompleted;
    xmlhttp.open("GET", "" + "Profiles.ashx", true );
    xmlhttp.send(null);
}

function InitXmlHttp() {
    // Attempt to initialize xmlhttp object
    try
    {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
        // Try to use different activex object
        try
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
            xmlhttp = false;
        }
    }
    
    // If not initialized, create XMLHttpRequest object
    if (!xmlhttp && typeof XMLHttpRequest!='undefined')
      {     
            xmlhttp = new XMLHttpRequest();
      }
      // Define function call for when Request obj state has changed
      xmlhttp.onreadystatechange=XMLHttpRequestCompleted;
}

function XMLHttpRequestCompleted()
{
        if (xmlhttp.readyState==4)
    {
        try
        {
            alert(xmlhttp.responseText);
            window.parent.handleResponse();
        }
        catch (e)
        {
        }
    }
}

function StringBuffer() { 
   this.buffer = []; 
 } 

 StringBuffer.prototype.append = function append(string) { 
   this.buffer.push(string); 
   return this; 
 }; 

 StringBuffer.prototype.toString = function toString() { 
   return this.buffer.join(""); 
 }; 


function AddToFavorite(siteID, adminID, userID, accID, dataID, email, title)
{
	//InitXmlHttp();
  //xmlhttp.onreadystatechange= XMLHttpRequestCompleted;
    
  var buf = new StringBuffer();
	buf.append("/aspx/Profiles.ashx");
	buf.append("?SiteID=" + siteID);
	buf.append("&AdminID=" + adminID);
	buf.append("&UserID=" + userID);
	buf.append("&AccountID=" + accID);
	buf.append("&DataID=" + dataID);
	buf.append("&Title=" + title);
	buf.append("&Email=" + email);
	buf.append("&Action=Add");
    
  //xmlhttp.open("GET", buf.toString(), true );
  //xmlhttp.send(null);
  
  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;
		}
	}
	xmlhttp.open("GET", buf.toString(),true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
	alert(xmlhttp.responseText)
	window.parent.handleResponse()
	}
	}
	xmlhttp.send(null)  
}


function AddToPDFItemList(dataID, template, title)
{
  //alert("dataID = " + dataID + "\ntemplate = " + template + "\ntitle = " + title);
        
  var buf = new StringBuffer();
	buf.append("AddAsPDFItem.asp");
	buf.append("?DataID=" + dataID);
	buf.append("&Title=" + title);
	buf.append("&Template=" + template);
	  
  var xmlhttp=false;
	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;
		}
	}
	xmlhttp.open("GET", buf.toString(),true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
	alert(xmlhttp.responseText)
	}
	}
	xmlhttp.send(null)        
}
