// JavaScript Document


function view(url){
	
	window.open(url,'pop','height=400,width=500,scrollbars=1,toolbars=false');
	
}

function setCookie(name, value) {
 
	Set_Cookie(name, value, 30, '/', '', '' );
}

function getCookie(name) {
	return Get_Cookie(name);
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function XMLHTTP(url)
{
	this.url = url;
	this.headers = new Array();
	this.async = true;
	this.method = "POST";
	this.req = null;
	this.debug_flag = false;
	this.deb_str = '';		// debug string for application debugging
	
	this.active = false;
	return this;
}

XMLHTTP.prototype.debug = function(str)
{
	if(this.debug_flag){
		document.write( str + "<br>" );
	}
}



// xmlhttp wrapper method
/**
*@param string			methodName this is the FSService method you want to call on the engine
*@param mixed 			arguments passed as an array that contain the options you're passing to the methodName
*@responseHandler string	the name of the javascript function you want to handle the response back from the server
*@useSOAP bool			whether to use a SOAP request or to use regular POST/GET request
*/
XMLHTTP.prototype.call = function(arguments, responseHandler)
{

	this.request = arguments;
	
	// moz XMLHTTPRequest object
	if (window.XMLHttpRequest)
	{
		this.req = new XMLHttpRequest();
		this.deb_str += "Mozilla Version of XMLHTTPRequest\r\n";
	}
	// IE/Windows ActiveX version
	else if (window.ActiveXObject)
	{
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		this.deb_str += "Microsoft Version of XMLHTTPRequest\r\n";
	}
	// set response handler
	this.req.onreadystatechange = responseHandler;
	
	// open connection
	this.req.open(this.method, this.url, this.async);
    
  	// set headers
	if(this.headers.length > 0)
	{
		for(var i in this.headers)
		{
			this.req.setRequestHeader( i, this.headers[i]);
		}
	}
	
	 this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
	
	// send request
	if(this.method == 'POST')
	{
		this.req.send(arguments);
	}
	else 
	{
		this.req.send(null);
	}
	
	if(this.async == false)
	{
		return this.req.responseXML;
	}
	
	return true;
}

// DEBUG METHOD
XMLHTTP.prototype.debugTransaction = function()
{
	var req = document.getElementById("request");
	if(req) {
		req.value = this.request;
	} 
	var resp = document.getElementById("response");
	if(resp) {
		resp.value = this.req.responseText;
	}
	var deb = document.getElementById("debug");
	if(deb) {
		deb.value = this.deb_str;
	}
}


		