/* This file is based on Macromedia's JavaScriptFlashGateway.js - it is an exact
   copy of this file, with a small omnidate.com-specific addition at the end of
   the file. */
   
/*
Macromedia(r) Flash(r) JavaScript Integration Kit License


Copyright (c) 2005 Macromedia, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment:

"This product includes software developed by Macromedia, Inc.
(http://www.macromedia.com)."

Alternately, this acknowledgment may appear in the software itself, if and
wherever such third-party acknowledgments normally appear.

4. The name Macromedia must not be used to endorse or promote products derived
from this software without prior written permission. For written permission,
please contact devrelations@macromedia.com.

5. Products derived from this software may not be called "Macromedia" or
"Macromedia Flash", nor may "Macromedia" or "Macromedia Flash" appear in their
name.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

--

This code is part of the Flash / JavaScript Integration Kit:
http://www.macromedia.com/go/flashjavascript/

Created by:

Christian Cantrell
http://weblogs.macromedia.com/cantrell/
mailto:cantrell@macromedia.com

Mike Chambers
http://weblogs.macromedia.com/mesh/
mailto:mesh@macromedia.com

Macromedia

Modified by Media Semantics, Inc. (MSI) as marked to add setWMode(), setBase().
*/

/**
 * Create a new Exception object.
 * name: The name of the exception.
 * message: The exception message.
 */
function Exception(name, message)
{
    if (name)
        this.name = name;
    if (message)
        this.message = message;
}

/**
 * Set the name of the exception. 
 */
Exception.prototype.setName = function(name)
{
    this.name = name;
}

/**
 * Get the exception's name. 
 */
Exception.prototype.getName = function()
{
    return this.name;
}

/**
 * Set a message on the exception. 
 */
Exception.prototype.setMessage = function(msg)
{
    this.message = msg;
}

/**
 * Get the exception message. 
 */
Exception.prototype.getMessage = function()
{
    return this.message;
}

/**
 * Generates a browser-specific Flash tag. Create a new instance, set whatever
 * properties you need, then call either toString() to get the tag as a string, or
 * call write() to write the tag out.
 */

/**
 * Creates a new instance of the FlashTag.
 * src: The path to the SWF file.
 * width: The width of your Flash content.
 * height: the height of your Flash content.
 */
function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.style     = null;
    this.bgcolor   = 'ffffff';
	this.flashVars = null;
    this.wmode     = null; // MSI
    this.base      = null; // MSI
    this.allowscriptaccess      = null; // MSI
}

/**
 * Sets the Flash version used in the Flash tag.
 */
FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}

/**
 * Sets the ID used in the Flash tag.
 */
FlashTag.prototype.setId = function(id)
{
    this.id = id;
}


/**
 * Sets the ID used in the Flash tag.
 */
FlashTag.prototype.setStyle = function(style)
{
    this.style = style;
}

/**
 * Sets the background color used in the Flash tag.
 */
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}



/**
 * Sets any variables to be passed into the Flash content. 
 */
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

// Begin MSI

/**
 * Sets wmode
 */
FlashTag.prototype.setWmode = function(wm)
{
    this.wmode = wm;
}

/**
 * Sets base
 */
FlashTag.prototype.setBase = function(b)
{
    this.base = b;
}

/**
 * Sets allowscriptaccess
 */
FlashTag.prototype.setAllowScriptAccess = function(b)
{
    this.allowscriptaccess = b;
}

// End MSI

/**
 * Get the Flash tag as a string. 
 */
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        if (this.style != null)
        {
            flashTag += 'style="'+this.style+'" ';
		}
		flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if (this.flashVars != null)
        {
			//alert(this.flashVars);
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        // Begin MSI
        if (this.wmode != null)
        {
            flashTag += '<param name="wmode" value="'+this.wmode+'"/>';
        }
        if (this.base != null)
        {
            flashTag += '<param name="base" value="'+this.base+'"/>';
        }
        if (this.allowscriptaccess != null)
        {
            flashTag += '<param name="allowscriptaccess" value="'+this.allowscriptaccess+'"/>';
        }
        // End MSI
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
 		//alert(this.flashVars);
           flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.style != null)
        {
            flashTag += 'style="'+this.style+'" ';
		}
      // Begin MSI
        if (this.wmode != null)
        {
            flashTag += 'wmode="'+this.wmode+'" ';
        }
        if (this.base != null)
        {
            flashTag += 'base="'+this.base+'" ';
        }
        if (this.allowscriptaccess != null)
        {
            flashTag += 'allowscriptaccess="'+this.allowscriptaccess+'" ';
        }
        // End MSI
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}

/**
 * Write the Flash tag out. Pass in a reference to the document to write to. 
 */
FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}

/**
 * The FlashSerializer serializes JavaScript variables of types object, array, string,
 * number, date, boolean, null or undefined into XML. 
 */

/**
 * Create a new instance of the FlashSerializer.
 * useCdata: Whether strings should be treated as character data. If false, strings are simply XML encoded.
 */
function FlashSerializer(useCdata)
{
    this.useCdata = useCdata;
}

/**
 * Serialize an array into a format that can be deserialized in Flash. Supported data types are object,
 * array, string, number, date, boolean, null, and undefined. Returns a string of serialized data.
 */
FlashSerializer.prototype.serialize = function(args)
{
    var qs = new String();

    for (var i = 0; i < args.length; ++i)
    {
        switch(typeof(args[i]))
        {
            case 'undefined':
                qs += 't'+(i)+'=undf';
                break;
            case 'string':
                qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]);
                break;
            case 'number':
                qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]);
                break;
            case 'boolean':
                qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]);
                break;
            case 'object':
                if (args[i] == null)
                {
                    qs += 't'+(i)+'=null';
                }
                else if (args[i] instanceof Date)
                {
                    qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime());
                }
                else // array or object
                {
                    try
                    {
                        qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i]));
                    }
                    catch (exception)
                    {
                        throw new Exception("FlashSerializationException",
                                            "The following error occurred during complex object serialization: " + exception.getMessage());
                    }
                }
                break;
            default:
                throw new Exception("FlashSerializationException",
                                    "You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined.");
        }

        if (i != (args.length - 1))
        {
            qs += '&';
        }
    }

    return qs;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeXML = function(obj)
{
    var doc = new Object();
    doc.xml = '<fp>'; 
    this._serializeNode(obj, doc, null);
    doc.xml += '</fp>'; 
    return doc.xml;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeNode = function(obj, doc, name)
{
    switch(typeof(obj))
    {
        case 'undefined':
            doc.xml += '<undf'+this._addName(name)+'/>';
            break;
        case 'string':
            doc.xml += '<str'+this._addName(name)+'>'+this._escapeXml(obj)+'</str>';
            break;
        case 'number':
            doc.xml += '<num'+this._addName(name)+'>'+obj+'</num>';
            break;
        case 'boolean':
            doc.xml += '<bool'+this._addName(name)+' val="'+obj+'"/>';
            break;
        case 'object':
            if (obj == null)
            {
                doc.xml += '<null'+this._addName(name)+'/>';
            }
            else if (obj instanceof Date)
            {
                doc.xml += '<date'+this._addName(name)+'>'+obj.getTime()+'</date>';
            }
            else if (obj instanceof Array)
            {
                doc.xml += '<array'+this._addName(name)+'>';
                for (var i = 0; i < obj.length; ++i)
                {
                    this._serializeNode(obj[i], doc, null);
                }
                doc.xml += '</array>';
            }
            else
            {
                doc.xml += '<obj'+this._addName(name)+'>';
                for (var n in obj)
                {
                    if (typeof(obj[n]) == 'function')
                        continue;
                    this._serializeNode(obj[n], doc, n);
                }
                doc.xml += '</obj>';
            }
            break;
        default:
            throw new Exception("FlashSerializationException",
                                "You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined");
            break;
    }
}

/**
 * Private
 */
FlashSerializer.prototype._addName= function(name)
{
    if (name != null)
    {
        return ' name="'+name+'"';
    }
    return '';
}

/**
 * Private
 */
FlashSerializer.prototype._escapeXml = function(str)
{
    if (this.useCdata)
        return '<![CDATA['+str+']]>';
    else
        return str.replace(/&/g,'&amp;').replace(/</g,'&lt;');
}

/**
 * The FlashProxy object is what proxies function calls between JavaScript and Flash.
 * It handles all argument serialization issues.
 */

/**
 * Instantiates a new FlashProxy object. Pass in a uniqueID and the name (including the path)
 * of the Flash proxy SWF. The ID is the same ID that needs to be passed into your Flash content as lcId.
 */
function FlashProxy(uid, proxySwfName)
{
    this.uid = uid;
    this.proxySwfName = proxySwfName;
    this.flashSerializer = new FlashSerializer(false);
}

/**
 * Call a function in your Flash content.  Arguments should be:
 * 1. ActionScript function name to call,
 * 2. any number of additional arguments of type object,
 *    array, string, number, boolean, date, null, or undefined. 
 */
FlashProxy.prototype.call = function()
{
    if (arguments.length == 0)
    {
        throw new Exception("Flash Proxy Exception",
                            "The first argument should be the function name followed by any number of additional arguments.");
    }

    var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]);

    if (arguments.length > 1)
    {
        var justArgs = new Array();
        for (var i = 1; i < arguments.length; ++i)
        {
            justArgs.push(arguments[i]);
        }
        qs += ('&' + this.flashSerializer.serialize(justArgs));
    }
	//qs += '&s=1';
	//alert(qs);

    var divName = '_flash_proxy_' + this.uid;
    if(!document.getElementById(divName))
    {
        var newTarget = document.createElement("div");
        newTarget.id = divName;
        document.body.appendChild(newTarget);
    }
    var target = document.getElementById(divName);
    var ft = new FlashTag(this.proxySwfName, 1, 1);
    ft.setVersion('6,0,65,0');
    ft.setFlashvars(qs);
	ft.setId('tempObj');
	target.innerHTML = ft.toString();
}

/*
function removeElement(divNum) {
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
*/

/**
 * This is the function that proxies function calls from Flash to JavaScript.
 * It is called implicitly.
 */
FlashProxy.callJS = function()
{
    var functionToCall = eval(arguments[0]);
    var argArray = new Array();
    for (var i = 1; i < arguments.length; ++i)
    {
        argArray.push(arguments[i]);
    }
    functionToCall.apply(functionToCall, argArray);
}





/***************************************************************************************************************
************	OmniDate Include
***************************************************************************************************************/
jQuery.noConflict();
var Omni_BannerProxy;
var Omni_AppProxy;
var Omni_lcId = new Date().getTime();
var Omni_Unique = 1;

var Omni_data = "";

var Omni_DefaultFreq = 10;
var Omni_Frequency = Omni_DefaultFreq;
var PingInterval = 0;
var Omni_ArStatus = [];
var Omni_Unique = 0;

var Omni_userid = "";
var username = "";
var gender = "";
var Omni_dbid = "";
var siteCode = "";
var dating = "";


var You = "";
var YourId = "";
var YourName = "";
var YourGender = "";

var YourDate = "";
var YourDateId = "";
var YourDateName = "";
var YourDateGender = "";


var Omni_Table = "";
var StorylineFile = "";
var RedirectLink = "";
var Omni_userxml = ""
var DateStatus = "";
var Omni_ChatServer = "";
var Omni_ShowDate = "";
var Omni_profiletype = "userid";

var LoadStarted = false;
var InviteOverShowing = false;
var DateHasBeenRequested = false;
var TimeRemaining = "";
var BannerShowing = false;
var AreWeOnADate = false

var g_Omnidate_Server = '64.34.162.224';
var Omni_Server = "http://www.omnidate.net/";
var Omni_landing = "";
var Omni_bannerStyle = "";
var bannerExists = false;
var Omni_profile = "";
var IgnorePingReturn = false;
var InviteInProgress = false;
var UserInfoSetOnPing = false;
var Omni_Debugging = true;


/***************************************************************************************************************
************	Button UI Default Values
***************************************************************************************************************/
var Button01 = new Object;
Button01.offline = Omni_Server + "images/od-offline.gif";
Button01.online = Omni_Server + "images/od-online.gif";
Button01.inactive = Omni_Server + "images/od-online2.gif";
Button01.dating = Omni_Server + "images/od-dating.gif";
Button01.info = Omni_Server + "images/info01.png";
Button01.height = "18";
Button01.width = "65";
Button01.iheight = "18";
Button01.iwidth = "18";

var Button02 = new Object;
Button02.offline = Omni_Server + "images/od2-offline.gif";
Button02.online = Omni_Server + "images/od2-online.gif";
Button02.inactive = Omni_Server + "images/od2-online2.gif";
Button02.dating = Omni_Server + "images/od2-dating.gif";
Button02.info = Omni_Server + "images/od2-info.gif";
Button02.iposition = "bottom";
Button02.height = "37";
Button02.width = "41";
Button02.iheight = "12";
Button02.iwidth = "41";

var Button03 = new Object;
Button03.offline = Omni_Server + "images/pq-offline.gif";
Button03.online = Omni_Server + "images/pq-online.gif";
Button03.inactive = Omni_Server + "images/pq-inactive.gif";
Button03.dating = Omni_Server + "images/pq-dating.gif";
Button03.info = Omni_Server + "images/info01.png";
Button03.height = "18";
Button03.width = "84";
Button03.iheight = "18";
Button03.iwidth = "18";

var ButtonSTB01 = new Object;
ButtonSTB01.offline = Omni_Server + "images/stb1-offline.gif";
ButtonSTB01.online = Omni_Server + "images/stb1-online.gif";
ButtonSTB01.inactive = Omni_Server + "images/stb1-inactive.gif";
ButtonSTB01.dating = Omni_Server + "images/stb1-dating.gif";
ButtonSTB01.info = Omni_Server + "images/info01.png";
ButtonSTB01.height = "18";
ButtonSTB01.width = "135";
ButtonSTB01.iheight = "18";
ButtonSTB01.iwidth = "18";

var ButtonSTB02 = new Object;
ButtonSTB02.offline = Omni_Server + "images/stb2-inactive.gif";
ButtonSTB02.online = Omni_Server + "images/stb2-online.gif";
ButtonSTB02.inactive = Omni_Server + "images/stb2-inactive.gif";
ButtonSTB02.dating = Omni_Server + "images/stb2-dating.gif";
ButtonSTB02.info = Omni_Server + "images/stb2-info.gif";
ButtonSTB02.height = "20";
ButtonSTB02.width = "62";
ButtonSTB02.iheight = "20";
ButtonSTB02.iwidth = "20";

var AFui01 = new Object;
AFui01.offline = Omni_Server + "images/af-offline.gif";
AFui01.online = Omni_Server + "images/af-online.gif";
AFui01.inactive = Omni_Server + "images/af-inactive.gif";
AFui01.dating = Omni_Server + "images/af-dating.gif";
AFui01.info = Omni_Server + "images/info01.png";
AFui01.height = "18";
AFui01.width = "65";
AFui01.iheight = "18";
AFui01.iwidth = "18";

var AFui02 = new Object;
AFui02.offline = Omni_Server + "images/af-offline2.gif";
AFui02.online = Omni_Server + "images/af-online2.gif";
AFui02.inactive = Omni_Server + "images/af-inactive2.gif";
AFui02.dating = Omni_Server + "images/af-dating2.gif";
AFui02.info = Omni_Server + "images/info01.png";
AFui02.height = "29";
AFui02.width = "129";
AFui02.iheight = "18";
AFui02.iwidth = "18";

// Add to master array
var uiDefaults = new Object;
uiDefaults['Button01'] = Button01;
uiDefaults['Button02'] = Button02;
uiDefaults['Button03'] = Button03;
uiDefaults['ButtonSTB01'] = ButtonSTB01;
uiDefaults['ButtonSTB02'] = ButtonSTB02;
uiDefaults['AFui01'] = AFui01;
uiDefaults['AFui02'] = AFui02;

var uiObj;
var btnUiAr = new Object;




var Hover01 = new Object;
Hover01.offline = "Unavailable for a Virtual Date. Message Them Now to Schedule a Date.";
Hover01.online = "Invite This User on a Virtual Date Now!";
Hover01.inactive = "You cannot Invite this User right now.";
Hover01.dating = "This User is on a Virtual Date.";
Hover01.info = "View More Info / Select Your Virtual Character";

// Add to master array
var omniHoverAr = new Object;
omniHoverAr['Hover01'] = Hover01;

var btnTextObj;
var btnHoverAr = new Object;







function OmniTime()
{
	var d = new Date();
	var time = ((d.getHours() < 10) ? ("0"+d.getHours()) : d.getHours()) + ":";
	time += ((d.getMinutes() < 10) ? ("0"+d.getMinutes()) : d.getMinutes()) + ":";
	time += ((d.getSeconds() < 10) ? ("0"+d.getSeconds()) : d.getSeconds()) + ".";
	if (d.getMilliseconds() < 10)
		time += "00" + d.getMilliseconds();
	else if (d.getMilliseconds() < 100)
		time += "0" + d.getMilliseconds();
	else
		time += d.getMilliseconds();

	return "[" + time + "] ";
}

function StopStartTrace()
{
	if (Omni_Debugging) Omni_Debugging = false;
	else Omni_Debugging = true;
}

/***************************************************************************************************************
************	Registration and Broadcasting
***************************************************************************************************************/
var SendingPing = false;

// Pinging function
function Send()
{
	if (SendingPing)
		return;
	SendingPing = true;



	Omni_data = "";
	if (PingInterval != 0)
	{
		clearInterval(PingInterval);
		PingInterval = 0;
	}


	// Accumulate a string of the active users (defined by the number of dynamic buttons)
	var interests = "";
	for (i = 0; i < Omni_ArStatus.length; i++)
	{
		interests += Omni_ArStatus[i] + (i < Omni_ArStatus.length-1 ? "," : "");
	}

	//registerStr = Omni_Server + "_register.php?dbid=" + dbid + "&domain=www.omnidate&user=" + Omni_userid + "&interests=" + interests + "&username=" + username + "&gender=" + gender;
	var registerStr = "http://" + g_Omnidate_Server + "/od/GetStatus.aspx?userid=" + Omni_userid;


	if (dating != "")
	{	// dating
		
		//Omni_Frequency = Omni_DefaultFreq * 2; // Removed temp
		registerStr += "&isdating=true";
	}
	else
	{	// not dating
		//Omni_Frequency = Omni_DefaultFreq; // Removed temp

		// show interests only when not dating
		if (interests != "")
		{
			registerStr += '&interests=' + interests;
		}
	}

	if (Omni_dbid != "")
	{
		registerStr += '&dbid=' + Omni_dbid;
	}
	if (Omni_lcId != "")
	{
		registerStr += '&browser=' + Omni_lcId;
	}
	if (Omni_ShowDate != "")
	{
		registerStr += '&showdate=false';
	}



	// Construct list of user ids you are interested in. Each user id is taken from a button in the class omnidate_button
	if (!UserInfoSetOnPing)
	{
		registerStr += '&username=' + username;
		if (gender=='male') registerStr += '&gender=m';
		else if (gender=='female') registerStr += '&gender=f';
	}

	registerStr += "&jsonp=?";




	// Call register.php and parse the return xml using OnSendComplete.
	var XmlHttpRequest = jQuery.getJSON(registerStr, 
	function(p)
	{
		if (Omni_Debugging) Omni_data += "<br />" + OmniTime() + registerStr + "<br />";		
		jQuery("#containerX").html(Omni_data);
		OnSendComplete(p);
	}
	);


/*
	if (Omni_Debugging) Omni_data += "XmlHttpRequest : " + XmlHttpRequest + "<br />";		

	// If the request is still running, abort it.
	if (XmlHttpRequest) {
		if (Omni_Debugging) Omni_data += "About Request: " + XmlHttpRequest + "<br />";		
		req.abort();
		jQuery("#containerX").html(Omni_data);
	}
*/




/*
	jQuery.ajaxComplete(
	function(event,request, settings)
	{
		alert("Request Complete.");
	}
	);*/
}

var ajaxCount = 0;
var AjaxSuccessDefined = false;



// Parse the return XML
function OnSendComplete(_this)
{
	SendingPing = false;

	if (Omni_Debugging) Omni_data += "OnSendComplete <br />";
	Omni_Frequency = Omni_DefaultFreq;

	if (!IgnorePingReturn)
	{

		if (Omni_Debugging) Omni_data += "RETURN: ";
		if (Omni_Debugging) Omni_data += "InvitationStatus: "+_this.InvitationStatus+", ";
		if (Omni_Debugging) Omni_data += "RetCode: "+_this.RetCode+"<br />";
		
		if (_this.RetCode == "SUCCESS") // Stop setting username, gender, etc
		{
			UserInfoSetOnPing = true;
		}
		if (_this.Avatar) // Stop setting username, gender, etc
		{
			You = _this.Avatar;

			if (Omni_dbid == "OD")
			{
				// Remap Males
				if (You == "James")
					SetAvatar("cauc_m2");
				else if (You == "Jim")
					SetAvatar("cauc_m6");
				else if (You == "John")
					SetAvatar("cauc_m5");
				else if (You == "Josh")
					SetAvatar("cauc_m8");
				else if (You == "Jeff")
					SetAvatar("asian_m4");
				else if (You == "Jamal")
					SetAvatar("afric_m1");

				// Remap Females
				else if (You == "Jessi")
					SetAvatar("cauc_w10");
				else if (You == "Jenny")
					SetAvatar("cauc_w1");
				else if (You == "Jane")
					SetAvatar("cauc_w12");
				else if (You == "Jill")
					SetAvatar("cauc_w2");
				else if (You == "Julie")
					SetAvatar("asian_w1");
				else if (You == "Jada")
					SetAvatar("afric_w8");
			}
		}



		if (Omni_Debugging) Omni_data += "MembersStatus: => ";
		var ResultOnline = "";

		var firstreturned = true;
		for ( var i in _this.MembersStatus )
		{	
			if (!firstreturned) ResultOnline += ",";
			ResultOnline += i+"="+_this.MembersStatus[i];
			firstreturned = false;
		}
		if (Omni_Debugging) Omni_data += "ResultOnline:" + ResultOnline + "<br />";
		jQuery("#containerX").html(Omni_data);




		var buttonCode = "";
		var messageIn = "";
		var removeInvite = "";
		var showBanner = "";
		var inviteStatus = "";
		var TimeRem = "";

		DateStatus = "";

		if (_this.InvitationStatus != null)
		{
			var InviteStatus = _this.InvitationStatus;
			var ResultStatus = InviteStatus.Status;
			//WaitingForResponse
			//Invited
			//Dating
			//ExpiredAck
			//DeclinedAck
			//CanceledAck

			//TimedOutAck
			//DatingFinishedAck
			//DatingTimedOutAck
			if (Omni_Debugging) Omni_data += "Status: " +ResultStatus+ "<br />";
			jQuery("#containerX").html(Omni_data);


			var ResultInviter = InviteStatus.InviterID;
			var ResultInvitee = InviteStatus.InviteeID;
			var ResultTime = TimeRemaining = InviteStatus.TimeToExpiry;
			if (Omni_Debugging) Omni_data += "ResultInviter/ResultInvitee/ResultTime: " +ResultInviter+"/"+ResultInvitee+"/"+ResultTime+ "<br />";
			jQuery("#containerX").html(Omni_data);


			var MyDatesInfo = _this.InvitationStatus.UserInfo;				if (Omni_Debugging) Omni_data += "MyDatesInfo: " +MyDatesInfo+ "<br />"; jQuery("#containerX").html(Omni_data);
				var ResultDateId = YourDateId = MyDatesInfo.UserID;			if (Omni_Debugging) Omni_data += "ResultDateId: " +ResultDateId+ "<br />"; jQuery("#containerX").html(Omni_data);
				var ResultReqName = YourDateName = MyDatesInfo.UserName;	if (Omni_Debugging) Omni_data += "ResultReqName: " +ResultReqName+ "<br />"; jQuery("#containerX").html(Omni_data);
				var ResultGender = YourDateGender = MyDatesInfo.Gender;						if (Omni_Debugging) Omni_data += "ResultGender: " +ResultGender+ "<br />"; jQuery("#containerX").html(Omni_data);
				var ResultChar = YourDate = MyDatesInfo.Avatar;				if (Omni_Debugging) Omni_data += "ResultChar: " +ResultChar+ "<br />"; jQuery("#containerX").html(Omni_data);
			if (Omni_Debugging) Omni_data += "MyDatesInfo/ResultDateId/ResultReqName/ResultGender/ResultChar: " +MyDatesInfo+"/"+ResultInvitee+"/"+ResultReqName+"/"+ResultGender+"/"+ResultChar+ "<br />";
			jQuery("#containerX").html(Omni_data);


			var MyTableInfo = _this.InvitationStatus.DateInfo;
				var ResultTable = Omni_Table = MyTableInfo.TableNum;
				var ResultVenue = StorylineFile = MyTableInfo.Venue;
				var ResultChatServer = Omni_ChatServer = MyTableInfo.CS;
			if (Omni_Debugging) Omni_data += "MyTableInfo/ResultTable/ResultVenue: " +MyTableInfo+"/"+ResultTable+"/"+ResultVenue+ "<br />";
			jQuery("#containerX").html(Omni_data);



			/* Banner Messages
			MessageAr["1"] = "You missed an invitation"; // from _____.
			MessageAr["2"] = "Your request has expired.";
			MessageAr["3"] = "You are currently dating.";
			MessageAr["4"] = "Taking you to the date...";
			MessageAr["5"] = "declined your invitation."; // _____ declined...
			MessageAr["6"] = "Error detected.";
			MessageAr["7"] = "has cancelled a date requst.";  // _____ has cancelled...
			MessageAr["8"] = "You missed an invitation"; // from _____.
			MessageAr["9"] = "no longer available."; // _____ no longer...
			MessageAr["10"] = "That user is no longer available.";
			*/

			if (ResultStatus == "WaitingForResponse")
			{
				// This state applies to the inviter only. The user has invited someone on a date and is awaiting an answer. This user can terminate the request by cancelling the invitation.
				ResultOnline = ReturnOffline(ResultOnline);

				if (!LoadStarted) { /*StartLoading();*/ LoadStarted = true; }

				buttonCode = ""; 
				messageIn = "";
				removeInvite = "";
				inviteStatus = "2";
				showBanner = "1";

				// Speed up the Frequency while we wait for the accept
				Omni_Frequency = 2;
			}
			else if (ResultStatus == "Invited")
			{
				// This state applies to the invitee only. The user has been invited on a date and is expected to accept or decline the invitation.
				ResultOnline = ReturnOffline(ResultOnline);

				if (!LoadStarted) { /*StartLoading();*/ LoadStarted = true; }

				buttonCode = ""; 
				messageIn = "";
				removeInvite = "";
				inviteStatus = "1";
				showBanner = "1";

				if (Omni_ShowDate == "")
				{
					// Speed up the Frequency for the page getting the invites ONLY for the ShowDate page
					Omni_Frequency = 2;
				}
			}
			else if (ResultStatus == "Dating")
			{
				// The invitation has been accepted and the user is now dating. While in this state, a user must ping the server letting it know that he is dating.
				buttonCode = "0";
				messageIn = "3";
				removeInvite = "0";
				inviteStatus = "";
				showBanner = "0";

				if (Omni_ShowDate == "")
				{
					TakeMeOnTheDate();
				}


				// Do we need this? Or an Inactive?
				//buttonStatus = ReturnOffline(ResultOnline);
			}
			else if (ResultStatus == "ExpiredAck" && ResultInviter == Omni_userid)
			{
				// A invitation request expired before a response. The user must acknowledge to complete the date.
				buttonCode = "1"; 
				messageIn = "2";
				removeInvite = "0";
				inviteStatus = "";
				showBanner = "1";
			}
			else if (ResultStatus == "ExpiredAck" && ResultInvitee == Omni_userid)
			{
				// A invitation request expired before a response. The user must acknowledge to complete the date.
				buttonCode = "1"; 
				messageIn = "1";
				removeInvite = "1";
				inviteStatus = "";
				showBanner = "1";
			}
			else if (ResultStatus == "DeclinedAck")
			{
				// This state applies to the inviter only. The invitee has declined your request. The user must acknowledge to complete the date.
				buttonCode = "1";
				messageIn = "5";
				removeInvite = "0";
				inviteStatus = "";
				showBanner = "1";
			}
			else if (ResultStatus == "CanceledAck")
			{
				// This state applies to the invitee only. The inviter has canceled the request while waiting for a response. The user must acknowledge to complete the date.
				buttonCode = "1";
				messageIn = "7";
				removeInvite = "1";
				showBanner = "1";
				inviteStatus = "";
			}

			else if (ResultStatus == "TimedOutAck")
			{
				// Acknowledge Timed Out - The other user has become offline while in the negotiation phase of the  invitation. The user must acknowledge to complete the date.
				buttonCode = "1";
				messageIn = "9";
				removeInvite = "0";
				inviteStatus = "";
				showBanner = "1";
			}
			else if (ResultStatus == "DatingFinishedAck" && Omni_ShowDate == "")
			{
				// Acknowledge End Date - The other user has ended the date. The user must acknowledge to complete the date.
				DateStatus = "DatingFinishedAck";
				if (AreWeOnADate)
					CallFinished();
				TakeMeOnTheDate();
			}
			else if (ResultStatus == "DatingTimedOutAck" && Omni_ShowDate == "")
			{
				// Acknowledge Dating Timed Out - The other user has stopped sending "I am Dating" pings. The user must acknowledge to exit the date.
				DateStatus = "DatingTimedOutAck";
				if (AreWeOnADate)
					CallTimeout();
				TakeMeOnTheDate();
			}

			else // SOME OTHER CASE => BROKEN!
			{
				if (Omni_Debugging) Omni_data += "OnSendComplete---->ERROR!<br />";
				buttonCode = "1";
				messageIn = "6";
				removeInvite = "0";
				inviteStatus = "";
				showBanner = "0";
			}

		}
		else
		{
			DateHasBeenRequested = false;
			buttonCode = "0"; 
			messageIn = "";
			removeInvite = "0";
			inviteStatus = "";
			showBanner = "0";
		}

		jQuery("#containerX").html(Omni_data);

		// Broadcast the online status of the buttons + communicate with the banner
		BroadcastStatus(buttonCode, messageIn, removeInvite, showBanner, inviteStatus, YourDateName, YourDateId, You, YourDate, TimeRemaining, ResultOnline);
	}

	// Define the next ping interval
	if (PingInterval == 0)
	{
		PingInterval = setInterval( "Send()", Omni_Frequency * 1000 );
	}
}

function ReturnOffline (OnlineString)
{
	InactiveAll();
	return OnlineString;
}

// Interface between the controller and banner/buttons.
function BroadcastStatus(buttonCode, messageIn, removeInvite, showBanner, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem, online)
{
	var outString = buttonCode + "/" + messageIn + "/" + removeInvite + "/" + showBanner + "/" + inviteStatus + "/" + DateName + "/" + DateId + "/" + YourChar + "/" + DateChar + "/" + TimeRem + "/" + online;
	Omni_data += "BroadcastStatus(" + outString + ")<br />";
	updateStatus(outString);
}

function updateStatus(statusString)
{
	var splitStatus = statusString.split("/");

	var buttonCode = splitStatus[0];
	var messageIn = splitStatus[1];
	var removeInvite = splitStatus[2];
	var showBanner = splitStatus[3];
	var inviteStatus = splitStatus[4];
	var DateName = splitStatus[5];
	var DateId = splitStatus[6];
	var YourChar = splitStatus[7];
	var DateChar = splitStatus[8];
	var TimeRem = splitStatus[9];
	var s = splitStatus[10];

	if (showBanner == "0")
	{
		if (bannerExists)
 			changeUI(buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem);
		OmniDate_HideBanner();
	}
	else if (showBanner == "1")
	{
		OmniDate_ShowBannerAndChangeUI(buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem);
	}

	// 0,1,0,1,1,0
	// kam=1,billy=1,paco=2, etc
	if (s != "")
	{
		var onlineusers = Array();
		var temponlineusers = s.split(",")
		
		// [0]=>kam=1,[1]=>billy=1,[2]=>paco=2, etc
		for (var i = 0; i < temponlineusers.length; i++)
		{
			var oneonlineuser = temponlineusers[i].split("=");
			onlineusers[oneonlineuser[0]] = oneonlineuser[1];
		}

		if (Omni_Debugging) Omni_data += "updateStatus("+s+"): ";

		// [kam]=>1,[billy]=>1,[paco]=>2, etc
		for (var j = 0; j < Omni_ArStatus.length; j++)
		{
			if (typeof(onlineusers[Omni_ArStatus[j]]) != "undefined")
			{
				updateButton(Omni_ArStatus[j], onlineusers[Omni_ArStatus[j]]);
				if (Omni_Debugging) Omni_data += Omni_ArStatus[j]+"="+onlineusers[Omni_ArStatus[j]]+", ";
			}
			else
			{
				updateButton(Omni_ArStatus[j], '0');
				if (Omni_Debugging) Omni_data += Omni_ArStatus[j]+"=0, ";
			}
		}
		if (Omni_Debugging) Omni_data += "<br />";

		jQuery("#containerX").html(Omni_data);

	}
}

// Update the button text and enable/disable
function updateButton(buttonid, status)
{

	var Status = "";
	var Disabled = true;

	if (status == "0")
	{
		Status = "Offline";
		if (typeof(btnUiAr[buttonid]['offline']) != "undefined")
			swapImage(buttonid, btnUiAr[buttonid]['offline'], 'offline');
	}
	else if (status == "1")
	{
		Status = "Date Me";
		if (!BannerShowing)
		{
			Disabled = false;
			if (typeof(btnUiAr[buttonid]['online']) != "undefined")
				swapImage(buttonid, btnUiAr[buttonid]['online'], 'online');
		}
		else
		{
			if (typeof(btnUiAr[buttonid]['inactive']) != "undefined")
				swapImage(buttonid, btnUiAr[buttonid]['inactive'], 'inactive');
		}
	}
	else if (status == "2")
	{	
		Status = "Dating";
		if (typeof(btnUiAr[buttonid]['dating']) != "undefined")
			swapImage(buttonid, btnUiAr[buttonid]['dating'], 'dating');
	}

	if(document.layers)	   //NN4+
	{
		document.layers[buttonid].cursor = (Disabled) ? "default" : "pointer";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById(buttonid);
		obj.style.cursor = (Disabled) ? "default" : "pointer";
	}
	else if(document.all)	// IE 4
	{
		document.all[buttonid].style.cursor = (Disabled) ? "default" : "pointer";
	}


	//document.getElementById(buttonid).value = Status;
	document.getElementById(buttonid).disabled = Disabled;
}




/***************************************************************************************************************
************	Button Functions
***************************************************************************************************************/
function Omni_Button()
{
	var btnUserId = "";
	var btncontainer = "";
	var btnreturn = "";
	var Omni_CustomButton = false;
	var Omni_CustomHover = false;

	uiObj = new Object();
	btnTextObj = new Object();

	for (var i=0; i < arguments.length; i=i+2)
	{
		var currArg = arguments[i].toLowerCase();

		switch (currArg){	
			case "user":
			case "userid":
				btnUserId = arguments[i+1];
				break;
			case "style":
			case "uiobj":
				Omni_CustomButton = true;
				if (typeof(uiDefaults[arguments[i+1]]) == "undefined")
				{
					//alert(arguments[i+1]['online']);

					// Check if it's an object and check if it has all the right parameters
						uiDefaults["custom"] = arguments[i+1];
						uiObj = uiDefaults["custom"];

					//If not an object
						//var btn = arguments[i+1];
						//uiObj = Button01; 
				}
				else
					uiObj = uiDefaults[arguments[i+1]];
				break;
			case "hover":
				Omni_CustomHover = true;
				if (typeof(omniHoverAr[arguments[i+1]]) == "undefined")
				{
					// Check if it's an object and check if it has all the right parameters
						omniHoverAr["custom"] = arguments[i+1];
						btnTextObj = omniHoverAr["custom"];
					//If not an object
						//btnTextObj = Hover01; 
				}
				else
					btnTextObj = omniHoverAr[arguments[i+1]];
				break;
			case "container":
				btncontainer = arguments[i+1];
				break;
			case "return":
				btnreturn = arguments[i+1];
				break;
			default:
		}
	}

	// If we defined a username create the button
	if (btnUserId != "")
	{
		Omni_ArStatus[Omni_ArStatus.length] = btnUserId; // thereby increasing length by 1
		// If we didn't specify ANY definition, use a default
		//if (typeof(window['uiObj']) == "undefined") {
		if (!Omni_CustomButton) {
			uiObj = new Object();
			uiObj = uiDefaults['Button01'];
		}
		// Check each specific image, if there is one missing, set a default
		else
		{
			if (typeof(uiObj['offline']) == "undefined")
				uiObj['offline'] = Button01['offline'];
			if (typeof(uiObj['online']) == "undefined")
				uiObj['online'] = Button01['online'];
			if (typeof(uiObj['inactive']) == "undefined")
				uiObj['inactive'] = Button01['inactive'];
			if (typeof(uiObj['dating']) == "undefined")
				uiObj['dating'] = Button01['dating'];
			if (typeof(uiObj['info']) == "undefined")
			{
				uiObj['info'] = Button01['info'];
				uiObj['iheight'] = Button01['iheight'];
				uiObj['iwidth'] = Button01['iwidth'];
			}
			if (typeof(uiObj['height']) == "undefined")
				uiObj['height'] = Button01['height'];
			if (typeof(uiObj['width']) == "undefined")
				uiObj['width'] = Button01['width'];
		}

		// Add the UI obj to the array
		btnUiAr[btnUserId] = uiObj;



		// If we didn't specify ANY definition, use a default
//		if (typeof(window['btnTextObj']) == "undefined") {
		if (!Omni_CustomHover) {
			btnTextObj = new Object();
			btnTextObj = omniHoverAr['Hover01'];
		}
		else
		{
			if (typeof(btnTextObj['offline']) == "undefined")
				btnTextObj['offline'] = Hover01['offline'];
			if (typeof(btnTextObj['online']) == "undefined")
				btnTextObj['online'] = Hover01['online'];
			if (typeof(btnTextObj['inactive']) == "undefined")
				btnTextObj['inactive'] = btnTextObj['online']; // default to online
			if (typeof(btnTextObj['dating']) == "undefined")
				btnTextObj['dating'] = Hover01['dating'];
			if (typeof(btnTextObj['info']) == "undefined")
				btnTextObj['info'] = Hover01['info'];
		}

		// Add the UI obj to the array
		btnHoverAr[btnUserId] = btnTextObj;





		var printOmniButton = ''
		if (uiObj['iposition'] == 'bottom') { printOmniButton += '<span style="float:none;"><div>'; }
		var inviteButton = '<input type="button" id="' + btnUserId + '" name="' + btnUserId + '" onclick="OnDate(\''+btnUserId+'\');" '
			+ 'value="" disabled="true" style="height:'+uiObj['height']+'px;width:'+uiObj['width']+'px;background:url(\'' + uiObj['offline'] + '\');border:0px;" title="' + btnTextObj['offline'] + '" />';
		printOmniButton += inviteButton;
		if (uiObj['iposition'] == 'bottom') { printOmniButton += '</div><div>'; }
		// if not button off
		var infoButton = '<input type="button" id="' + btnUserId + 'Info" name="' + btnUserId + 'Info" onclick="MoreInfo();" '
			+' value="" style="cursor:pointer;height:'+uiObj['iheight']+'px;width:'+uiObj['iwidth']+'px;background:url(\'' + uiObj['info'] + '\');border:0px;" title="' + btnTextObj['info'] + '" />';
		printOmniButton += infoButton;
		if (uiObj['iposition'] == 'bottom') { printOmniButton += '</div></span>'; }
		
		//printOmniButton = inviteButton + infoButton;


		if (btncontainer != "")
			document.getElementById(btncontainer).innerHTML += printOmniButton;
		else if (btnreturn != "")
			return printOmniButton;
		else
			document.write(printOmniButton);
	}
}

function swapImage (imgName, imgSrc, statusType)
{
	if(document.layers)	   //NN4+
	{
		document.layers[imgName].background = "url('"+imgSrc+"')";
		document.layers[imgName].height = btnUiAr[imgName]['height'] + "px";
		document.layers[imgName].width = btnUiAr[imgName]['width'] + "px";
		document.layers[imgName].title = btnHoverAr[imgName][statusType];
		document.layers[imgName].disabled = (statusType == "online") ? false : true;
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById(imgName);
		obj.style.background = "url('"+imgSrc+"')";
		obj.style.height = btnUiAr[imgName]['height'] + "px";
		obj.style.width = btnUiAr[imgName]['width'] + "px";
		obj.title = btnHoverAr[imgName][statusType];
		obj.disabled = (statusType == "online") ? false : true;
	}
	else if(document.all)	// IE 4
	{
		document.all[imgName].style.background = "url('"+imgSrc+"')";
		document.all[imgName].style.height = btnUiAr[imgName]['height'] + "px";
		document.all[imgName].style.width = btnUiAr[imgName]['width'] + "px";
		document.all[imgName].title = btnHoverAr[imgName][statusType];
		document.all[imgName].disabled = (statusType == "online") ? false : true;
	}
}

function InactiveAll()
{
	if (Omni_Debugging) Omni_data += "InactiveAll()<br />";
	for (i = 0; i < Omni_ArStatus.length; i++)
	{
		document.getElementById(Omni_ArStatus[i]).disabled = true;
	}
}




// The MoreInfo
function MoreInfo()
{
	// Do we want to disable this function until we get a return from the OnSendComplete? 
	// Else we could set bad characters possibly if there is enough of a delay

	// PhotoFit
	if (Omni_dbid == "OD" || UnlimitedAccess)
		var tag = new FlashTag(Omni_Server+'InfoBox_1.swf', 480, 320, "8,0,0,0");
	else
		var tag = new FlashTag(Omni_Server+'OmniInfoBox2.swf', 480, 320, "8,0,0,0");


	var flashVarStr = "lcId=" + Omni_lcId+"_"+Omni_Unique + "&userid="+Omni_userid+"&username="+username+"&gender="+gender+"&AvatarIn="+You;
	if (Omni_dbid != "")
	{
		flashVarStr += "&DbId=" + Omni_dbid;
	}
	if (Omni_Debugging) Omni_data += "<br />HERE IT IS: " + flashVarStr + "<br />";
	jQuery("#containerX").html(Omni_data);

	tag.setFlashvars(flashVarStr);
	tag.setAllowScriptAccess("always");
	tag.setWmode("transparent");
	tag.setId("InfoBox");
	Omni_Unique++;

	var target = document.getElementById('OmniFloatingLayerInfo');
	target.innerHTML = tag.toString();

	if (BannerShowing == false)
	{
		if (Omni_Debugging) Omni_data += "<br />!BannerShowing > ";

		if(document.layers)	  //NN4+
		{
			document.layers['OmniFloatingLayerInfo'].visibility = "show";
			document.layers['OmniFloatingLayerInfo'].display = "block";
			if (Omni_Debugging) Omni_data += "Type 1<br />";
		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
			var obj = document.getElementById('OmniFloatingLayerInfo');
			obj.style.visibility = "visible";
			obj.style.display = "block";
			//document.getElementById('InfoBox').focus();
			if (Omni_Debugging) Omni_data += "Type 2<br />";
		}
		else if(document.all)	// IE 4
		{
			document.all['OmniFloatingLayerInfo'].style.visibility = "visible";
			document.all['OmniFloatingLayerInfo'].style.display = "block";
			if (Omni_Debugging) Omni_data += "Type 3<br />";
		}

		jQuery("#containerX").html(Omni_data);
	}
}

function HideInfo()
{
	if (Omni_Debugging) Omni_data += "<br />HideInfo() > ";

	if(document.layers)	   //NN4+
	{
		document.layers['OmniFloatingLayerInfo'].visibility = "hide";
		document.layers['OmniFloatingLayerInfo'].display = "none";
		if (Omni_Debugging) Omni_data += "Type 1<br />";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById('OmniFloatingLayerInfo');
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		if (Omni_Debugging) Omni_data += "Type 2<br />";
	}
	else if(document.all)	// IE 4
	{
		document.all['OmniFloatingLayerInfo'].style.visibility = "hidden";
		document.all['OmniFloatingLayerInfo'].style.display = "none";
		if (Omni_Debugging) Omni_data += "Type 3<br />";
	}

	jQuery("#containerX").html(Omni_data);
}


/***************************************************************************************************************
************	Request Date
***************************************************************************************************************/
function OnDate(useridIn)
{
	if (Omni_Debugging) Omni_data += "OnDate Pressed, BannerShowing = " + BannerShowing + "<br />";
	
	if (!BannerShowing && useridIn != Omni_userid)
	{
		var Omni_action = "invite";
		BannerShowing = true;

		InactiveAll();
		//requestStr = Omni_Server + "_requestdate.php?dbid=" + dbid + "&user="+Omni_userid+"&requests="+userid +"&invite=true" + "&jsonp=?";	
		var requestStr = "http://" + g_Omnidate_Server + "/od/DoAction.aspx?userid=" + Omni_userid + "&action=" + Omni_action + "&userid2=" + useridIn;
		if (Omni_dbid != "")
		{
			requestStr += '&dbid=' + Omni_dbid;
		}
		if (Omni_lcId != "")
		{
			requestStr += '&browser=' + Omni_lcId;
		}
		if (Omni_ShowDate != "")
		{
			requestStr += '&showdate=false';
		}
		requestStr += "&jsonp=?";


		// Call request.php and parse the return xml using OnRequestComplete.
		jQuery.getJSON(requestStr, 
		function(p)
		{
			OnRequestComplete(p);
			if (Omni_Debugging) Omni_data += requestStr + "<br />";
			jQuery("#containerX").html(Omni_data);
		}
		);
	}
}

 




function OnRequestComplete(_this)
{
	if (Omni_Debugging) Omni_data += _this + "-OnRequestComplete(Success="+_this.Status+")<br />";

	/*
	o	" SUCCESS" - successful
	o	" INVALID_USERID" - error, invalid user id. i.e. if left out
	o	" CANNOT_INVITE_SELF" - error, tried to invite self
	o	" INVALID_OPERATION" - error, the current state does not support this action
	o	" INVITEE_NOT_AVAILABLE" - error, tried to invite someone who is not available.
	o	"ERROR" - general error.
	*/
	/* Banner Messages
	MessageAr["1"] = "You missed an invitation"; // from _____.
	MessageAr["2"] = "Your request has expired.";
	MessageAr["3"] = "You are currently dating.";
	MessageAr["4"] = "Taking you to the date...";
	MessageAr["5"] = "declined your invitation."; // _____ declined...
	MessageAr["6"] = "Error detected.";
	MessageAr["7"] = "has cancelled a date requst.";  // _____ has cancelled...
	MessageAr["8"] = "You missed an invitation"; // from _____.
	MessageAr["9"] = "is no longer available."; // _____ no longer...
	MessageAr["10"] = "That user is no longer available.";
	*/

	if (_this.Status == "ERROR")
	{
		BroadcastStatus("1", "6", "1", "", "", "", "", "", "", "", "");
	}
	else if (_this.Status != "SUCCESS")
	{
		BroadcastStatus("1", "10", "1", "", "", "", "", "", "", "", "");
	}


	Send();
}




/***************************************************************************************************************
************	Avatar Selector
***************************************************************************************************************/
var Avatar01 = new Object;
Avatar01.image = Omni_Server+"images/Avatar01.png";
Avatar01.text = "Select Your Virtual Character";
Avatar01.height = "76";
Avatar01.width = "160";

// Add to master array
var omniAvatarAr = new Object;  // Contains all the presets
omniAvatarAr['Avatar01'] = Avatar01;
var avatarObj; // our current


function Omni_Avatar()
{
	var avtcontainer = "";
	var avtreturn = "";
	avatarObj = Avatar01;

	for (var i=0; i < arguments.length; i=i+2)
	{
		var currArg = arguments[i].toLowerCase();

		switch (currArg){	
			case "style":
				avatarObj = new Object();			
				if (typeof(omniAvatarAr[arguments[i+1]]) == "undefined")
					avatarObj = Avatar01;
				else
					avatarObj = omniAvatarAr[arguments[i+1]];
				break;
			case "container":
				avtcontainer = arguments[i+1];
				break;
			case "return":
				avtreturn = arguments[i+1];
				break;
			default:
		}
	}


	Omni_Unique++;

	var printOmniAvatar = '<input type="button" id="Avatar' + Omni_Unique + '" name="Avatar' + Omni_Unique + '" onclick="MoreInfo();" '
		+ 'value="" style="cursor:pointer;height:'+avatarObj['height']+'px;width:'+avatarObj['width']+'px;background:url(\'' + avatarObj['image'] + '\');border:0px;" title="' + avatarObj['text'] + '" />';

	if (avtcontainer != "")
		document.getElementById(avtcontainer).innerHTML += printOmniAvatar;
	else if (avtreturn != "")
		return printOmniAvatar;
	else
		document.write(printOmniAvatar);
}

function SetAvatar(AvatarIn)
{
	var charStr = "http://" + g_Omnidate_Server + "/od/SetAvatar.aspx?userid=" + Omni_userid + "&avatar=" + AvatarIn;
	if (Omni_dbid != "")
	{
		charStr += '&dbid=' + Omni_dbid;
	}
	if (Omni_lcId != "")
	{
		charStr += '&browser=' + Omni_lcId;
	}
	if (Omni_ShowDate != "")
	{
		charStr += '&showdate=false';
	}
	charStr += "&jsonp=?";

	// Call request.php and parse the return xml using OnRequestComplete.
	jQuery.getJSON(charStr, 
	function(p)
	{
		You = AvatarIn;
		if (Omni_Debugging) Omni_data += "SetAvatar("+AvatarIn+")<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);

}


/***************************************************************************************************************
************	Banner Functions
***************************************************************************************************************/
var Banner00 = new Object;
Banner00.source = "";
Banner00.height = "150";
Banner00.width = "300";


// Uses UserID Link
var Banner01 = new Object;
Banner01.source = Omni_Server+'OmniBanner01.swf';
Banner01.height = "150";
Banner01.width = "300";

/*
var Banner02 = new Object;
Banner02.source = Omni_Server+'OmniBanner02.swf';
Banner02.height = "150";
Banner02.width = "300";
*/

var BannerSTB = new Object;
BannerSTB.source = Omni_Server+'OmniBannerSTB.swf';
BannerSTB.height = "150";
BannerSTB.width = "300";


/*
// Uses UserName Link
var Banner02 = new Object;
Banner02.source = Omni_Server+'OmniBanner2.swf';
Banner02.height = "150";
Banner02.width = "300";

var Skipthebar01 = new Object;
Skipthebar01.source = Omni_Server+'OmniBannerSTB1.swf';
Skipthebar01.height = "150";
Skipthebar01.width = "300";

var Anotherfriend01 = new Object;
Anotherfriend01.source = Omni_Server+'OmniBannerAF.swf';
Anotherfriend01.height = "150";
Anotherfriend01.width = "300";

var Banner03 = new Object;
Banner03.source = Omni_Server+'OmniBanner3.swf';
Banner03.height = "150";
Banner03.width = "300";
*/


var BannerObj = new Object;
BannerObj['Banner00'] = Banner00;
BannerObj['Banner01'] = Banner01;
BannerObj['BannerSTB'] = BannerSTB;

/*
BannerObj['Banner02'] = Banner02;
BannerObj['Banner03'] = Banner03;
BannerObj['Skipthebar01'] = Skipthebar01;
BannerObj['Anotherfriend01'] = Anotherfriend01;
*/
var bnrObj;

function omnidateBanner(variables)
{
	var flashVars = "lcId=" + Omni_lcId+"_"+Omni_Unique+"&"+variables;

	Omni_BannerProxy = new FlashProxy(Omni_lcId+"_"+Omni_Unique, Omni_Server+"JavaScriptFlashGateway.swf"); 
	var tag = new FlashTag(bnrObj.source, bnrObj.width, bnrObj.height, "8,0,0,0");
	tag.setFlashvars(flashVars);
	tag.setAllowScriptAccess("always");
	tag.setId("OmniBanner");

	Omni_Unique++;
	return tag.toString();
}

function BannerStyle(bannerStyleIn)
{
	if (bannerStyleIn == "")
	{
/*		if (Omni_dbid == "OD")
			siteCode = "3";
		else if (Omni_dbid == "IS")
			siteCode = "3";
		else if (Omni_dbid == "datecouk")
			siteCode = "DCU";
		else if (Omni_dbid == "anotherfriend")
			siteCode = "AF";
		else if (Omni_dbid == "personalquest")
			siteCode = "PQ";
		else if (Omni_dbid == "skipthebar")
			siteCode = "STB";
		else if (Omni_dbid == "uhooo")
			siteCode = "UH";
		else
			siteCode = "3";
*/			
		siteCode = "01";

		Banner00.source = Omni_Server+'OmniBanner'+siteCode+'.swf';
		BannerObj['Banner00'] = Banner00;
		bnrObj = BannerObj['Banner00'];
	}
	else
	{
		if (typeof(BannerObj[bannerStyleIn]) == "undefined")
			bnrObj = BannerObj['Banner01'];
		else
			bnrObj = BannerObj[bannerStyleIn];
	}
	if (Omni_Debugging) Omni_data += "BANNER="+bnrObj.source+"<br />";
}

function changeUI(buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem)
{
	if (Omni_Debugging) Omni_data += "Omni_BannerProxy.call('ChangeUI', "+buttonCode+", "+messageIn+", "+removeInvite+", "+inviteStatus+", "+DateName+", "+DateId+", "+YourChar+", "+DateChar+", "+TimeRem+");<br />";
	Omni_BannerProxy.call('ChangeUI', buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem);
}

function OmniDate_ShowBannerAndChangeUI(buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem)
{
	if (!bannerExists)
	{
		OmniDate_VisibleBanner('OmniFloatingLayer', 1);
		var target = document.getElementById('OmniFloatingLayer');

		var BannerVars = 'buttonCode=' + buttonCode + '&messageIn=' + messageIn + '&removeInvite=' + removeInvite + '&inviteStatus=' + inviteStatus + '&DateName=' + DateName + '&DateId=' + DateId + '&You=' + YourChar + '&YourDate=' + DateChar + '&TimeRem=' + TimeRem + '&profile=' + Omni_profile;
		if (Omni_dbid != "")
		{
			BannerVars += '&DbId=' + Omni_dbid;
		}
		target.innerHTML = omnidateBanner(BannerVars);

		bannerExists = true;
	}
	else
	{
		OmniDate_VisibleBanner('OmniFloatingLayer', 1);
 		changeUI(buttonCode, messageIn, removeInvite, inviteStatus, DateName, DateId, YourChar, DateChar, TimeRem);
	}
}

function OmniDate_HideBanner()
{
	OmniDate_VisibleBanner('OmniFloatingLayer', 0);
	var target = document.getElementById('OmniFloatingLayer');
	target.innerHTML = "";
	bannerExists = false;
}

function OmniDate_VisibleBanner(OmniLayer, ShowOnScreen)
{
	// Banner starts "visible=true" and off the page at -750px (see CSS)
	// This function hides the banner "visible=false" and moves it to the center of the page.
	BannerShowing = false;

	if(document.layers)	   //NN4+
	{
	   document.layers[OmniLayer].visibility = ShowOnScreen ? "show" : "hide";
	   document.layers[OmniLayer].display = ShowOnScreen ? "block" : "none";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById(OmniLayer);
		obj.style.visibility = ShowOnScreen ? "visible" : "hidden";
		obj.style.display = ShowOnScreen ? "block" : "none";
	}
	else if(document.all)	// IE 4
	{
		document.all[OmniLayer].style.visibility = ShowOnScreen ? "visible" : "hidden";
		document.all[OmniLayer].style.display = ShowOnScreen ? "block" : "none";
	}

	if (ShowOnScreen) {
		BannerShowing = true;
		InactiveAll();
		HideInfo();
	}
}

function onCancelClick()
{
	if (Omni_Debugging) Omni_data += "onCancelClick()<br />";
	OmniDate_HideBanner();
	
	//var cancelStr = Omni_Server + "_canceldate.php?dbid=" + dbid + "&user="+Omni_userid + "&jsonp=?";
	var cancelStr = "http://" + g_Omnidate_Server + "/od/DoAction.aspx?userid=" + Omni_userid + "&action=exitnow";
	if (Omni_dbid != "")
	{
		cancelStr += '&dbid=' + Omni_dbid;
	}
	if (Omni_lcId != "")
	{
		cancelStr += '&browser=' + Omni_lcId;
	}
	if (Omni_ShowDate != "")
	{
		cancelStr += '&showdate=false';
	}
	cancelStr += "&jsonp=?";


	jQuery.getJSON(cancelStr, 
	function(p)
	{
		OnCancelComplete(p);
		if (Omni_Debugging) Omni_data += cancelStr + "<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);
}
function OnCancelComplete(_this)
{
	if (Omni_Debugging) Omni_data += "OnCancelComplete()<br />";
	Send();
}

function onOkayClick()
{
	if (Omni_Debugging) Omni_data += "onOkayClick()<br />";
	OmniDate_HideBanner();

	//var clearStr = Omni_Server + "_clearrequest.php?dbid=" + dbid + "&user="+Omni_userid + "&jsonp=?";
	var clearStr = "http://" + g_Omnidate_Server + "/od/DoAction.aspx?userid=" + Omni_userid + "&action=exitnow";
	if (Omni_dbid != "")
	{
		clearStr += '&dbid=' + Omni_dbid;
	}
	if (Omni_lcId != "")
	{
		clearStr += '&browser=' + Omni_lcId;
	}
	if (Omni_ShowDate != "")
	{
		clearStr += '&showdate=false';
	}
	clearStr += "&jsonp=?";

	
	jQuery.getJSON(clearStr, 
	function(p)
	{
		OnOkayComplete(p);
		if (Omni_Debugging) Omni_data += clearStr + "<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);
}
function OnOkayComplete(_this)
{
	if (Omni_Debugging) Omni_data += "OnOkayComplete()<br />";
	Send();
}

/***************************************************************************************************************
************	Accept/Decline Dates
***************************************************************************************************************/
function acceptOrDecline(acceptdecline)
{
	var doAction = "";
	var acceptdeclineStr = "";

	if (acceptdecline == "false")
	{
		doAction = "exitnow";
		OmniDate_HideBanner();
	}
	else if (acceptdecline == "true")
	{
		doAction = "accept";
		InactiveAll();
		if (Omni_ShowDate == "")
		{
			Omni_Modal(true);
		}
	}


	//var acceptdeclineStr = Omni_Server + "_acceptdate.php?dbid=" + dbid + "&user=" + Omni_userid + "&accept=" + acceptdecline + "&jsonp=?";
	if (doAction != "") {
		acceptdeclineStr = "http://" + g_Omnidate_Server + "/od/DoAction.aspx?userid=" + Omni_userid + "&action=" + doAction;
		if (Omni_dbid != "")
		{
			acceptdeclineStr += '&dbid=' + Omni_dbid;
		}
		if (Omni_lcId != "")
		{
			acceptdeclineStr += '&browser=' + Omni_lcId;
		}
		if (Omni_ShowDate != "")
		{
			acceptdeclineStr += '&showdate=false';
		}
		acceptdeclineStr += "&jsonp=?";
	}

	jQuery.getJSON(acceptdeclineStr, 
	function(p)
	{
		if (acceptdecline == "true")
			OnAcceptComplete(p);
		else if (acceptdecline == "false")
			OnDeclineComplete(p);

		if (Omni_Debugging) Omni_data += acceptdeclineStr + "<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);
}


function OnAcceptComplete(_this)
{
	if (Omni_Debugging) Omni_data += "OnAcceptComplete(Success="+_this.Status+")<br />";
	if (_this.Status == "SUCCESS" && Omni_ShowDate == "")
	{
		TakeMeOnTheDate();
	}
	else
	{
		// Woops, there was an error.
		BroadcastStatus("1", "6", "1", "0", "", "", "", "", "", "", "");
	}
}
function OnDeclineComplete(_this)
{
	if (Omni_Debugging) Omni_data += "OnDeclineComplete(Success="+_this.Status+")<br />";
	BroadcastStatus("0", "", "1", "0", "", "", "", "", "", "", "")
	Send();
}




/***************************************************************************************************************
************	Go On The Date
***************************************************************************************************************/
function TakeMeOnTheDate()
{

	if (!AreWeOnADate) // This is NO window open
	{

		AreWeOnADate = true;
		IgnorePingReturn = true;

		OmniDate_HideBanner();
		Omni_Modal(true);

		if (Omni_Debugging) Omni_data += "TakeMeOnTheDate()<br />";
		jQuery("#containerX").html(Omni_data);


		var profileurl = "";
		if (Omni_userxml != "")
			profileurl = Omni_userxml + YourDateId;

		if (profileurl != "")
		{
			var getprofileStr = "http://" + g_Omnidate_Server + "/od/GetUserProfile.aspx?userid=" + Omni_userid + "&url=" + profileurl;
			if (Omni_dbid != "")
			{
				getprofileStr += '&dbid=' + Omni_dbid;
			}
			if (Omni_lcId != "")
			{
				getprofileStr += '&browser=' + Omni_lcId;
			}
			if (Omni_ShowDate != "")
			{
				getprofileStr += '&showdate=false';
			}
			getprofileStr += "&jsonp=?";

			jQuery.getJSON(getprofileStr, 
			function(data)
			{
				if (data.RetCode != "SUCCESS")
					TakeMeOnTheDateComplete(null);
				else
					TakeMeOnTheDateComplete(data);

				jQuery("#containerX").html(Omni_data);
			}
			);
		}
		else
		{
			TakeMeOnTheDateComplete(null);
		}

	}
}

function TakeMeOnTheDateComplete(_this) 
{
	if (Omni_Debugging) Omni_data += "TakeMeOnTheDateComplete()<br />";
	jQuery("#containerX").html(Omni_data);

	var LocationString = "";

	var dateObj = new Object();
	dateObj.You = You;
	dateObj.YourDate = YourDate;
	dateObj.Table = Omni_Table;
	dateObj.ChatServer = Omni_ChatServer;
	dateObj.YourId = YourId;
	dateObj.YourName = YourName;
	dateObj.YourGender = YourGender;
	dateObj.YourDateId = YourDateId;
	dateObj.YourDateName = YourDateName;
	dateObj.YourDateGender = YourDateGender;
	dateObj.StorylineFile = StorylineFile;
	dateObj.DbId = Omni_dbid;
	dateObj.RedirectLink = top.location.href;
	dateObj.DateStatus = DateStatus;
	dateObj.YourDateGraphicServer = "www.omnidate.net";
	dateObj.YourGraphicServer = "www.omnidate.net";

	if (_this != null)
	{
		dateObj.profileName = _this.ProfileName;
		dateObj.profileQuote = _this.ProfileQuote;
		dateObj.profileGender = _this.ProfileGender;
		dateObj.profileAge = _this.ProfileAge;
		dateObj.profileLocation = _this.ProfileLocation;
		dateObj.profileProfessional = _this.ProfileProfession;
		dateObj.profilePhoto = _this.ProfilePhoto;
		dateObj.profileAbout = _this.ProfileAbout;
	}


	// Compound the object variables.
	var flashVars = ""; 
	var firstVar = true;
	for (OmniDate_i in dateObj) {
		flashVars += (firstVar) ? "" : "&";
		flashVars += OmniDate_i + "=" + dateObj[OmniDate_i];
		firstVar = false;
	};
	GoToDate(flashVars);


	IgnorePingReturn = false;
}


function GoToDate(OmniDate_variables)
{
	if (Omni_Debugging) Omni_data += "GoToDate()<br />";
	jQuery("#containerX").html(Omni_data);

	dating = true;

	var target = document.getElementById('OmniFloatingLayerDate');


	if (Omni_Debugging) Omni_data += "<br />" + OmniDate_variables + "<br />";



	jQuery("#msgX").html(OmniDate_variables);


	Omni_AppProxy = new FlashProxy(Omni_lcId+"_"+Omni_Unique, Omni_Server+"JavaScriptFlashGateway.swf"); 
	var tag = new FlashTag("http://www.omnidate.net/OmniDate_4.swf", "820", "550", "8,0,0,0");
	tag.setFlashvars("lcId=" + Omni_lcId+"_"+Omni_Unique+"&"+OmniDate_variables);
	tag.setAllowScriptAccess("always");

	// Internet Explorer 6
	var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	if (!IE6)
	{
		// Removed as proven CPU increase issue
		//tag.setWmode("transparent");
	}

	tag.setBgcolor("838383");
	tag.setId("OmniDateMovie1");
	Omni_Unique++;
	target.innerHTML = tag.toString();



	OmniDate_HideBanner();
	if(document.layers)	   //NN4+
	{
	   document.layers['OmniFloatingLayerInfo'].visibility = "hide";
	   document.layers['OmniFloatingLayerInfo'].display = "none";
	   document.layers['OmniFloatingLayerDate'].visibility = "show";
	   document.layers['OmniFloatingLayerDate'].display = "block";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById('OmniFloatingLayerInfo');
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		var obj = document.getElementById('OmniFloatingLayerDate');
		obj.style.visibility = "visible";
		obj.style.display = "block";
	}
	else if(document.all)	// IE 4
	{
		document.all['OmniFloatingLayerInfo'].style.visibility = "hidden";
		document.all['OmniFloatingLayerInfo'].style.display = "none";
		document.all['OmniFloatingLayerDate'].style.visibility = "visible";
		document.all['OmniFloatingLayerDate'].style.display = "block";
	}


	jQuery("#containerX").html(Omni_data);
}

function Omni_Modal(ShowOnScreen) 
{
	if(document.layers)	   //NN4+
	{
	   document.layers['OmniFloatingLayerModal'].visibility = ShowOnScreen ? "show" : "hide";
	   document.layers['OmniFloatingLayerModal'].display = ShowOnScreen ? "block" : "none";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById('OmniFloatingLayerModal');
		obj.style.visibility = ShowOnScreen ? "visible" : "hidden";
		obj.style.display = ShowOnScreen ? "block" : "none";
	}
	else if(document.all)	// IE 4
	{
		document.all['OmniFloatingLayerModal'].style.visibility = ShowOnScreen ? "visible" : "hidden";
		document.all['OmniFloatingLayerModal'].style.display = ShowOnScreen ? "block" : "none";
	}
}

function Quit()
{
	EndTheDate("1", null);
}

function EndTheDate(redirect, _omniuserid, _omniusername)
{
	dating = "";
	AreWeOnADate = false;

	if (redirect == "1" || Omni_dbid == "IS")
	{
		if(document.layers)	   //NN4+
		{
		   document.layers['OmniFloatingLayerDate'].visibility = "hide";
		   document.layers['OmniFloatingLayerDate'].display = "none";
		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
			var obj = document.getElementById('OmniFloatingLayerDate');
			obj.style.visibility = "hidden";
			obj.style.display = "none";
		}
		else if(document.all)	// IE 4
		{
			document.all['OmniFloatingLayerDate'].style.visibility = "hidden";
			document.all['OmniFloatingLayerDate'].style.display = "none";
		}

		Omni_Modal(false);
		var target = document.getElementById('OmniFloatingLayerDate');
		target.innerHTML = "";

		if (Omni_Debugging) Omni_data += "<br /><br />END THE DATE<br /><br />";

		onCancelClick(); // TEMPORARY FIX!!!
		// This is the same as OnEndDate, except without redirection

		if (Omni_dbid == "OD" || Omni_dbid == "")
		{
			PDF_launch('04D70E8C588FAAAB');
		}
		else if (Omni_dbid == "IS")
			GoToProfile (_omniuserid, _omniusername);
	}
	else if (redirect == "2")
	{
		//Send();
		OnEndDate(_omniuserid, _omniusername);
	}
}

function OnEndDate(_omniuserid, _omniusername)
{
	if (Omni_Debugging) Omni_data += "onEndDate("+_omniuserid+")<br />";
	var cancelStr = "http://" + g_Omnidate_Server + "/od/DoAction.aspx?userid=" + Omni_userid + "&action=exitnow";
	if (Omni_dbid != "")
	{
		cancelStr += '&dbid=' + Omni_dbid;
	}
	if (Omni_lcId != "")
	{
		cancelStr += '&browser=' + Omni_lcId;
	}
	if (Omni_ShowDate != "")
	{
		cancelStr += '&showdate=false';
	}
	cancelStr += "&jsonp=?";

	jQuery.getJSON(cancelStr, 
	function(p)
	{
		if (Omni_Debugging) Omni_data += cancelStr + "<br />";
		jQuery("#containerX").html(Omni_data);
		GoToProfile (_omniuserid, _omniusername);
	}
	);
}

function GoToProfile(_omniuserid, _omniusername)
{
	if (Omni_Debugging) Omni_data += "<br />GoToProfile<br /><br />";
	jQuery("#containerX").html(Omni_data);

	if (Omni_dbid == "IS")
		OpenDetailsWindowOD(_omniuserid);
	else if (Omni_profiletype == "username" || Omni_dbid == "PQ")
		top.location.href = Omni_profile + _omniusername;
	else
		top.location.href = Omni_profile + _omniuserid;
}



function CallTimeout()
{
	if (Omni_Debugging) Omni_data += "Omni_AppProxy.call('CallTimeout');<br />";
	Omni_AppProxy.call('CallTimeout');
}
function CallFinished()
{
	if (Omni_Debugging) Omni_data += "Omni_AppProxy.call('CallFinished');<br />";
	Omni_AppProxy.call('CallFinished');
}

function TraceDebug(s)
{
	var target = document.getElementById('OmniDateTraceOutput');
	target.innerHTML += s + "</br>";
}


/***************************************************************************************************************
************	Ajax Solution Functions
***************************************************************************************************************/
function clearContainer(container) {
	document.getElementById(container).innerHTML = '';
}
function clearButtons() {
	Omni_ArStatus = new Array();
}
function refreshButtons() {
	if (Omni_dbid != "")
	{
		Send();
	}
}

/***************************************************************************************************************
************ Use to dynamically write Pop Divs
***************************************************************************************************************/

function OmniWriteDivs()
{
    var strPopUpElement = "<div id='OmniFloatingLayerOuter'><div id='OmniFloatingLayer' style='display: none;'></div></div>";
    var strPopUpWrapper = "<div id='OmniFloatingLayerOuter'></div>";
    if (jQuery("#OmniFloatingLayer").length > 0) // For existing customers who already includes this element. They should remove it though.
    {
        jQuery("#OmniFloatingLayer").wrap(strPopUpWrapper);   
    }
    else {
        jQuery("body").append(strPopUpElement);
    }

	var strPopUpElement2 = "<div id='OmniFloatingLayerInfoOuter'><div id='OmniFloatingLayerInfo' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement2);

	var strPopUpElement3 = "<div id='OmniFloatingLayerDateOuter'><div id='OmniFloatingLayerDate' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement3);

	var strPopUpElement4 = "<div id='OmniFloatingLayerModalOuter'><div id='OmniFloatingLayerModal' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement4);

	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
        if (ieversion < 7 || (ieversion >= 7 && document.compatMode == "BackCompat")) {
            var ele = document.getElementById("OmniFloatingLayer");
            if (ele) {
                ele.className = "OmniPopUpHack";
            }
            var ele2 = document.getElementById("OmniFloatingLayerInfo");
            if (ele2) {
                ele2.className = "OmniPopUpHack";
            }
            var ele3 = document.getElementById("OmniFloatingLayerDate");
            if (ele3) {
                ele3.className = "OmniPopUpHack";
            }
            var ele4 = document.getElementById("OmniFloatingLayerModal");
            if (ele4) {
                ele4.className = "OmniPopUpHack";
            }
        }

    }
}

/***************************************************************************************************************
************	Initialization
***************************************************************************************************************/
var UnlimitedAccess = false;
var UnlimitedUsers = new Array(
	'834ea544-909c-4dd4-9cd3-dcfd167b20a6', // roger@gmail.com
	'f272f6e9-e378-4a6d-8c48-5730368a201e', // ella@gmail.com
	'f968a91b-4924-4c29-8c5f-40c9d551b8de', // jack@gmail.com
	'497c73bb-3c2f-404b-be9e-378af1339457' // julie@gmail.com
	);


function Omni_Initialize()
{
	var argObj = new Object();

	for (var i=0; i < arguments.length; i=i+2)
	{
		var currArg = arguments[i].toLowerCase();

		switch (currArg){	
			case "user":
			case "userid":
				YourId = Omni_userid = arguments[i+1];
				var unlimitedX = 0;
				for (unlimitedX; unlimitedX < UnlimitedUsers.length; unlimitedX++)
				{
					if (UnlimitedUsers[unlimitedX] == Omni_userid)
						UnlimitedAccess = true;
				}
				break;
			case "name":
			case "username":
				YourName = username = arguments[i+1];
				break;
			case "gender":
			case "usergender":
				YourGender = gender = arguments[i+1].toLowerCase();
				break;
			case "account":
				if (arguments[i+1] != "")
					Omni_dbid = arguments[i+1];
				break;
			case "landing":
				Omni_landing = arguments[i+1];
				break;
			case "redirect":
				if (arguments[i+1] == "back")
					RedirectLink = top.location.href;
				else
					RedirectLink = arguments[i+1];
				break;
			case "dating":
				dating = arguments[i+1];
				break;
			case "showdate":
				Omni_ShowDate = arguments[i+1];
				break;
			case "profile":
				Omni_profile = arguments[i+1];
				break;
			case "profiletype":
				Omni_profiletype = arguments[i+1];
				break;
			case "style":
			case "banner":
				Omni_bannerStyle = arguments[i+1];
				break;
			case "userxml":
				Omni_userxml = arguments[i+1];
				break;
			default:
				argObj[arguments[i]] = arguments[i+1];
		}
	}

	BannerStyle(Omni_bannerStyle);
	OmniWriteDivs();

	jQuery("#msgX").ajaxSuccess(function(event, request, settings)
	{
		jQuery("#msgX").html("<b>Number of Successful Ajax Calls:</b> " + ++ajaxCount + " Updated: " + OmniTime());
	});

	Send();
}





/***************************************************************************************************************
************	Ajax Testing
***************************************************************************************************************/

// This is just sample data for lack of a database. 
// Just used JS Object and Multidementional Arrays to house sample data.
function AButton( btnUser, btnName, btnUI ) {
	this.btnUser = btnUser;
	this.btnName = btnName;
	this.btnUI = btnUI;
}

var myPages = new Array();
myPages[0] = new Array();
myPages[0][0] = new AButton ( 'jackie', 'Jackie', 'Button01' );
myPages[0][1] = new AButton ( 'jake', 'Jake', 'Button02' );
myPages[0][2] = new AButton ( 'james', 'James', 'Button02' );

myPages[1] = new Array();
myPages[1][0] = new AButton ( 'jamal', 'Jamal', 'Button02' );
myPages[1][1] = new AButton ( 'jenny', 'Jake', 'Button02' );
myPages[1][2] = new AButton ( 'jackie', 'Jackie', 'Button01' );

myPages[2] = new Array();
myPages[2][0] = new AButton ( 'james', 'James', 'Button01' );
myPages[2][1] = new AButton ( 'jackie', 'Jackie', 'Button01' );
myPages[2][2] = new AButton ( 'jamal', 'Jamal', 'Button01' );

// This code would be executed by the site. 
// I've created this function for quick pagination through the test arrays.
function ChangePage(page)
{
	//Clears the container HTML. This would typically be done by the site on their own
	clearContainer('refresh');
	// Reset the button array.
	clearButtons();

	for (i = 0; i < myPages[page].length; i++)
	{
		// Just for visual effect, print the username beside the button.
		document.getElementById('refresh').innerHTML += " " + myPages[page][i].btnName + ": ";
		// The site would recall the omnidateButton function with the usual parameters.
		// A new parameter "container", specifies where the buttons will be written to (appended).
		//Omni_Button('userid', myPages[page][i].btnUser, 'uiobj', myPages[page][i].btnUI, 'container', 'refresh');
		document.getElementById('refresh').innerHTML += Omni_Button('userid', myPages[page][i].btnUser, 'uiobj', myPages[page][i].btnUI, 'return', 'true');
	}

	// Calls the "Send()" funtion to update the buttons.
	refreshButtons();
}



/*
4.1
- Renamed default buttons

4.2 (<------ Current Version 4)
- Gender modifications (m/f vs male/female)
- Update to date application version 4.1
- Update to pass the dbid to the InfoBox
- New custom mouse over title text (hover boxes)
- Major fixes/overhaul to custom button interface
- Banner system renamed and re-oganized.
- New banners and setup for easy style swapping.
- Separate messaging for anything other than "SUCCESS" on invite.

4.3 (Current on OmniDate.com ONLY)
- remove "inactive" from the custom list, defaulted to "online"
- Default "?" button hover text for custom
- Launch survey for DbId=OD
- Added 'showdate' to Omni_Initialize to prevent dates in certain windows
- Move "Show Profile" functionality to JS, rebuilding the Banner to accomodate

4.4 (In Progress)
- Addition of lcId/browser values passed in JSON
- Addition of browser values passed in

4.5
- Route Jessi/James to new mappings
- complete if/else for objects/strings in Omni_Button (if bad button passed in, default)
- Complete Omni_Avatar
- Photofit version 1.0
- Review "on end date" proceedure. Why does one call "exitnow" other doesnt?

*/