/* 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 YourGraphicServer = "64.34.169.15";

var YourDate = "";
var YourDateId = "";
var YourDateName = "";
var YourDateGender = "";
var YourDateGraphicServer = "64.34.169.15";


var Omni_Table = "";
var StorylineFile = "";
var Omni_premium = "";
var Omni_premiumpop = false;
var Omni_premiumxml = "";
var Omni_userxml = ""
var DateStatus = "";
var Omni_avatars = "";
var Omni_survey = "";
var Omni_verb = "";

var Omni_ChatServer = "";
var Omni_ShowDate = "";
var Omni_profiletype = "userid";
var Omni_movetype = "window.location.href";
var Omni_sound = "true";

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_PFServer = "98.175.249.86";

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 Button04 = new Object;
Button04.offline = Omni_Server + "images/btn04-offline.gif";
Button04.online = Omni_Server + "images/btn04-online.gif";
Button04.inactive = Omni_Server + "images/btn04-inactive.gif";
Button04.dating = Omni_Server + "images/btn04-dating.gif";
Button04.info = Omni_Server + "images/info02.gif";
Button04.height = "28";
Button04.width = "170";
Button04.iheight = "25";
Button04.iwidth = "20";

var Button05 = new Object;
Button05.offline = Omni_Server + "images/btn05-offline.gif";
Button05.online = Omni_Server + "images/btn05-online.gif";
Button05.inactive = Omni_Server + "images/btn05-inactive.gif";
Button05.dating = Omni_Server + "images/btn05-dating.gif";
Button05.info = Omni_Server + "images/info02.gif";
Button05.height = "25";
Button05.width = "160";
Button05.iheight = "25";
Button05.iwidth = "20";

var Button06 = new Object;
Button06.offline = Omni_Server + "images/btn06-offline.gif";
Button06.online = Omni_Server + "images/btn06-online.gif";
Button06.inactive = Omni_Server + "images/btn06-inactive.gif";
Button06.dating = Omni_Server + "images/btn06-dating.gif";
Button06.info = Omni_Server + "images/info02.gif";
Button06.height = "30";
Button06.width = "90";
Button06.iheight = "25";
Button06.iwidth = "20";





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";


var ButtonTW01 = new Object;
ButtonTW01.offline = Omni_Server + "images/od-offline.gif";
ButtonTW01.online = Omni_Server + "images/od-online.gif";
ButtonTW01.inactive = Omni_Server + "images/od-online2.gif";
ButtonTW01.dating = Omni_Server + "images/od-dating.gif";
ButtonTW01.info = "";
ButtonTW01.height = "18";
ButtonTW01.width = "65";
ButtonTW01.iheight = "0";
ButtonTW01.iwidth = "0";


// Add to master array
var uiDefaults = new Object;
uiDefaults['Button01'] = Button01;
uiDefaults['Button02'] = Button02;
uiDefaults['Button03'] = Button03;
uiDefaults['Button04'] = Button04;
uiDefaults['Button05'] = Button05;
uiDefaults['Button06'] = Button06;
uiDefaults['ButtonSTB01'] = ButtonSTB01;
uiDefaults['ButtonSTB02'] = ButtonSTB02;
uiDefaults['AFui01'] = AFui01;
uiDefaults['AFui02'] = AFui02;
uiDefaults['ButtonTW01'] = ButtonTW01;

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);
	}
	);


}

var ajaxCount = 0;
var AjaxSuccessDefined = false;

var Omni_JobID = "";

// 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" || Omni_dbid == "TW")
			//{
				// 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 (_this.JobID) // Job in progress
		{
			Omni_JobID = _this.JobID;
			var OmniJobFile = "CheckJobJSON.asp";
			var OmniJobServer = YourGraphicServer;
			
			if (Omni_JobID.substr(0,3) == "FRQ")
			{
				OmniJobFile = "CheckPhotoFitJSON.asp";
				OmniJobServer = Omni_PFServer;
			}

			var jobcheckStr = "http://" + OmniJobServer + "/PhotoFit/"+OmniJobFile+"?id=" + Omni_JobID + "&jsonp=?";

			if (Omni_Debugging) Omni_data += "<br />JOB CALL:" + jobcheckStr + "<br /><br />";
			jQuery("#containerX").html(Omni_data);

			var XmlHttpRequest = jQuery.getJSON(jobcheckStr, 
				function(p)
				{
					if (Omni_Debugging) Omni_data += "<br />JOB RETURN:" + p.RetCode + "<br /><br />";
					jQuery("#containerX").html(Omni_data);

					//if (p.RetCode == "ERROR" || p.RetCode == "COMPLETE")
					//{
					if (p.RetCode != "INCOMPLETE")
						MoreInfo();
					//}
				}
			);
		}
		else
			Omni_JobID = "";



		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 && !PremiumShowing)
		{
			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();
				}

			}
			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 if (_this.InvitationStatus != null && PremiumShowing)
		{
			Omni_Frequency = 2;
		}
		else
		{	// Here we know we're just idle

			if (AreWeOnADate)
			{
				dating = "";
				AreWeOnADate = false;

				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 />DATE IS OVER, CLEAR OUT<br /><br />";
			}


			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()
{
	var flashVarStr = "lcId=" + Omni_lcId+"_"+Omni_Unique + "&userid="+Omni_userid+"&username="+username+"&gender="+gender+"&avatar="+You+"&GraphicServer="+YourGraphicServer;

	// PhotoFit
	if (Omni_avatars == "2" || Omni_avatars == "3")
	{
		var tag = new FlashTag(Omni_Server+'InfoBox2.swf', 575, 455, "8,0,0,0");
		flashVarStr += "&CustomServer=64.34.169.15&PhotoFitServer=" + Omni_PFServer;
	}
	else
	{
		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");


	if (Omni_dbid != "")
	{
		flashVarStr += "&DbId=" + Omni_dbid;
	}
	if (arguments[0] != null)
	{
		flashVarStr += "&tab=" + arguments[0];
	}
	if (Omni_JobID != "")
	{
		flashVarStr += "&JobID=" + Omni_JobID;
	}
	if (Omni_avatars != "")
	{
		flashVarStr += "&phase=" + Omni_avatars;
	}
	if (Omni_verb != "")
	{
		flashVarStr += "&verb=" + Omni_verb;
	}
	


	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 > ";

		//HideRegisterBox();

		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);
}





var PremiumShowing = false;

function ShowRegisterBox()
{
	if (!BannerShowing)
	{
		if (Omni_Debugging) Omni_data += "<br />ShowRegisterBox() > ";
		PremiumShowing = true;

		if(document.layers)	   //NN4+
		{
			document.layers['OmniFloatingLayerRegister'+Omni_verb].visibility = "show";
			document.layers['OmniFloatingLayerRegister'+Omni_verb].display = "block";
		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
			var obj = document.getElementById('OmniFloatingLayerRegister'+Omni_verb);
			obj.style.visibility = "visible";
			obj.style.display = "block";
		}
		else if(document.all)	// IE 4
		{
			document.all['OmniFloatingLayerRegister'+Omni_verb].style.visibility = "show";
			document.all['OmniFloatingLayerRegister'+Omni_verb].style.display = "block";
		}

		jQuery("#containerX").html(Omni_data);
	}
}
function HideRegisterBox()
{
	if (Omni_Debugging) Omni_data += "<br />HideRegisterBox() > ";
	PremiumShowing = false;

	if(document.layers)	   //NN4+
	{
		document.layers['OmniFloatingLayerRegister'+Omni_verb].visibility = "hide";
		document.layers['OmniFloatingLayerRegister'+Omni_verb].display = "none";
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById('OmniFloatingLayerRegister'+Omni_verb);
		obj.style.visibility = "hidden";
		obj.style.display = "none";
	}
	else if(document.all)	// IE 4
	{
		document.all['OmniFloatingLayerRegister'+Omni_verb].style.visibility = "hidden";
		document.all['OmniFloatingLayerRegister'+Omni_verb].style.display = "none";
	}

	jQuery("#containerX").html(Omni_data);
}



function YesRegisterPremium()
{
	var premiumStr = "http://" + g_Omnidate_Server + "/od/LogGenericUserAction.aspx?userid=" + Omni_userid + "&action=1";
	if (Omni_dbid != "")
		premiumStr += '&dbid=' + Omni_dbid;
	premiumStr += "&jsonp=?";
	
	jQuery.getJSON( premiumStr, 
		function(p)
		{
		} 
	);

	if (Omni_premiumpop || Omni_ShowDate != "")
	{
		Omni_PremiumPopup();
		HideRegisterBox();
	}
	else
		Omni_MoveTo(Omni_premium, Omni_movetype);
}

function NoRegisterPremium()
{
	var premiumStr = "http://" + g_Omnidate_Server + "/od/LogGenericUserAction.aspx?userid=" + Omni_userid + "&action=2";
	if (Omni_dbid != "")
		premiumStr += '&dbid=' + Omni_dbid;
	premiumStr += "&jsonp=?";
	
	jQuery.getJSON( premiumStr, 
		function(p)
		{
		}
	);

	HideRegisterBox();
}





function Omni_PremiumPopup()
{
	var WindowConfig = 'status=no, toolbar=no, location=no, directories=no, menubar=no, scrollbars=yes';

	if (navigator.appName.indexOf("Microsoft") >= 0)
	{
		WindowConfig += ',left=150,top=20,width=650,height=600';
	}
	else
	{
		WindowConfig += ',screenX=150,screenY=20,width=650,height=600';
	}

	window.open(Omni_premium, 'omniregister', WindowConfig);
}




/***************************************************************************************************************
************	Request Date
***************************************************************************************************************/
function OnDate(useridIn)
{
	if (Omni_Debugging) Omni_data += "OnDate Pressed, BannerShowing = " + BannerShowing + "<br />";
	jQuery("#containerX").html(Omni_data);
	
	if (!BannerShowing && (useridIn != Omni_userid))
	{
		if (Omni_premium == "")
		{
			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=?";


			if (Omni_Debugging) Omni_data += requestStr + "<br />";
			jQuery("#containerX").html(Omni_data);


			// Call request.php and parse the return xml using OnRequestComplete.
			jQuery.getJSON(requestStr, 
			function(p)
			{
				if (Omni_Debugging) Omni_data += "RETURN:" + p.Status + "<br />";
				jQuery("#containerX").html(Omni_data);
				OnRequestComplete(p);
			}
			);
		}
		else
		{
			ShowRegisterBox();
		}
	}
	else
	{
		if (Omni_Debugging) Omni_data += "OnDate() > Invalid Button!<br />";
		jQuery("#containerX").html(Omni_data);
	}
}

 




function OnRequestComplete(_this)
{
	if (Omni_Debugging) Omni_data += _this + "-OnRequestComplete(Success="+_this.Status+")<br />";
	jQuery("#containerX").html(Omni_data);

	/*
	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.imageM = Omni_Server+"images/Avatar01.png";
Avatar01.imageF = Omni_Server+"images/Avatar02.png";
Avatar01.text = "Select Your Virtual Character";
Avatar01.height = "76";
Avatar01.width = "160";

/*
var Avatar02 = new Object;
Avatar02.image = Omni_Server+"images/Avatar02.png";
Avatar02.image2 = Omni_Server+"images/Avatar02.png";
Avatar02.text = "Select Your Virtual Character";
Avatar02.height = "76";
Avatar02.width = "160";
*/

// Add to master array
var omniAvatarAr = new Object;  // Contains all the presets
omniAvatarAr['Avatar01'] = Avatar01;
//omniAvatarAr['Avatar02'] = Avatar02;
var avatarObj; // our current


function Omni_Avatar()
{
	var avtcontainer = "";
	var avtreturn = "";
	var AvatarGender = "male";

	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 "gender":
				AvatarGender = arguments[i+1];
				break;
			case "container":
				avtcontainer = arguments[i+1];
				break;
			case "return":
				avtreturn = arguments[i+1];
				break;
			default:
		}
	}

	if (avatarObj == null || avatarObj == undefined)
	{
		avatarObj = Avatar01;
	}

	if (AvatarGender == "female")
		avatarObj['image'] = avatarObj['imageF'];
	else
		avatarObj['image'] = avatarObj['imageM'];


	Omni_Unique++;

	var printOmniAvatar = '<input type="button" id="Avatar' + Omni_Unique + '" name="Avatar' + Omni_Unique + '" onclick="MoreInfo(\'2\');" '
		+ '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);
	}
	);
}


function SetJobId(JobIn)
{
	Omni_JobID = JobIn;

	var jobStr = "http://" + g_Omnidate_Server + "/od/SetJobID.aspx?userid=" + Omni_userid + "&jobid=" + JobIn;
	if (Omni_dbid != "")
	{
		jobStr += '&dbid=' + Omni_dbid;
	}
	jobStr += "&jsonp=?";


	if (Omni_Debugging) Omni_data += "SetJobId("+jobStr+")<br />";
	jQuery("#containerX").html(Omni_data);

	jQuery.getJSON(jobStr, 
		function(p)
		{
			// Do nothing
		}
	);
}


function Omni_ShowAvatar()
{
	MoreInfo('2');
}

/***************************************************************************************************************
************	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";

var BannerNF = new Object;
BannerNF.source = Omni_Server+'OmniBannerNF.swf';
BannerNF.height = "150";
BannerNF.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['BannerNF'] = BannerNF;


/*
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+"&SoundStart="+Omni_sound;

	YourDateGraphicServer = (YourDate.substr(0,4) == "User") ? YourDateGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net
	YourGraphicServer = (You.substr(0,4) == "User") ? YourGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net;

	flashVars += "&YourDateGraphicServer=" + YourDateGraphicServer;
	flashVars += "&YourGraphicServer=" + YourGraphicServer;


	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 == "")
	{
		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();
		HideRegisterBox();
	}
}


function onEndNotify()
{
	if (Omni_Debugging) Omni_data += "onEndNotify()<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)
	{
		OnEndNotifyComplete(p);
		if (Omni_Debugging) Omni_data += cancelStr + "<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);
}
function OnEndNotifyComplete()
{
	if (Omni_Debugging) Omni_data += "OnEndNotifyComplete()<br />";

	if (Omni_premium !== "")
		ShowRegisterBox();
	else if (Omni_dbid == "OD" || Omni_dbid == "")
	{
		PDF_launch('04D70E8C588FAAAB');
	}
	else if (Omni_dbid == "IS")
	{
		GoToProfile (_omniuserid, _omniusername);
	}
}


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);

		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.DateStatus = DateStatus;
	dateObj.YourDateGraphicServer = (YourDate.substr(0,4) == "User") ? YourDateGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net
	dateObj.YourGraphicServer = (You.substr(0,4) == "User") ? YourGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net;
	dateObj.SoundStart = Omni_sound;
	dateObj.LoggingServer = g_Omnidate_Server;
	dateObj.Verb = Omni_verb;

	if (Omni_userxml != "")
	{
		if (Omni_profiletype == "username")		
			dateObj.ProfileURL = encodeURIComponent(Omni_userxml + YourDateName);
		else
			dateObj.ProfileURL = encodeURIComponent(Omni_userxml + YourDateId);
	}

	if (Omni_survey != "")
	{
		dateObj.Survey = "true";
	}

	// 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"); 
	if (Omni_dbid == "OD" || Omni_dbid == "TEST")
		var tag = new FlashTag("http://www.omnidate.net/OmniDate_5.swf", "820", "550", "8,0,0,0");
	else
		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 FilterValues(WinParam, DocParam, BodyParam)
{
		var FilterResult = WinParam ? WinParam : 0;
		if (DocParam && (!FilterResult || (FilterResult > DocParam))) FilterResult = DocParam;
		return BodyParam && (!FilterResult || (FilterResult > BodyParam)) ? BodyParam : FilterResult;
}
function GetClientAreaWidth()
{
	return FilterValues (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function GetClientAreaHeight()
{
	return FilterValues (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}



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 clientHeight = GetClientAreaHeight();
		var clientWidth = GetClientAreaWidth();
		var obj = document.getElementById('OmniFloatingLayerModal');
		obj.style.visibility = ShowOnScreen ? "visible" : "hidden";
		obj.style.display = ShowOnScreen ? "block" : "none";
		obj.style.width = Math.max(document.body.scrollWidth, clientWidth) +'px';
		obj.style.height = Math.max(document.body.scrollHeight, clientHeight) + 'px';
	}
	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, null);
}

function EndTheDate(redirect, _omniuserid, _omniusername)
{
	dating = "";
	AreWeOnADate = false;

	if (Omni_Debugging) Omni_data += "EndTheDate("+redirect+")<br />";
	jQuery("#containerX").html(Omni_data);

	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 />";

		onEndNotify();
		// This is the same as OnEndDate, except without redirection
		
	}
	else if (redirect == "2")
	{
		//Send();
		OnEndDate(_omniuserid, _omniusername);
	}
}

function OnEndDate(_omniuserid, _omniusername)
{
	if (Omni_Debugging) Omni_data += "onEndDate("+_omniuserid+","+_omniusername+")<br />";
	jQuery("#containerX").html(Omni_data);

	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);
		if (Omni_premium !== "")
			Omni_MoveTo(Omni_premium, Omni_movetype);
		else
			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")
		Omni_MoveTo(Omni_profile + _omniusername, Omni_movetype);
	else
		Omni_MoveTo(Omni_profile + _omniuserid, Omni_movetype);
}


var TakingSurvey = "";
function CallSurvey(DateNumber)
{
	if (Omni_survey != "" && DateNumber != TakingSurvey)
	{
		TakingSurvey = DateNumber;
		var WindowConfig = 'status=no, toolbar=no, location=no, directories=no, menubar=no, scrollbars=yes';

		if (navigator.appName.indexOf("Microsoft") >= 0)
			WindowConfig += ',left=150,top=20,width=550,height=375';
		else
			WindowConfig += ',screenX=150,screenY=20,width=550,height=375';

		window.open(Omni_survey+Omni_userid,'surveyWindow','location=0,status=0,scrollbars=1,width=550,height=375');
	}
}


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
***************************************************************************************************************/

/*
var Omni_maintext =		"		You must be a <em>Premium Account Holder</em> to invite someone on a Virtual Date." +
						"		Click <a href='javascript:YesRegisterPremium();'>\"Yes, Please\"</a> to find out more about the benefits of being Premium.";
var Omni_subtext =		"<div style='padding-top:7px; font-size:11px;'>Click <a href='javascript:MoreInfo(\"1\")'>here</a> to read more about Virtual Dating.</div>";
var Omni_question =		"<div style='padding-top:7px;'><em>Would you like to register?</em></div>";
var Omni_buttonyes =	"Yes, Please";
var Omni_buttonno =		"Maybe Later";
*/


var Omni_maintext =		"		Please upgrade your account to invite someone on a <a href='javascript:MoreInfo(\"1\")'>virtual date</a> now.<br />" +
						"		<img src='http://www.omnidate.net/images/screen2a.jpg' /><img src='http://www.omnidate.net/images/asseenon.gif' />";
var Omni_subtext =		"<div style='padding-top:7px; font-size:11px;'><a href='javascript:MoreInfo(\"2\")'>Choose your virtual character now</a></div>";
var Omni_question =		"";
var Omni_buttonyes =	"Okay";
var Omni_buttonno =		"Maybe Later";

/*
var Omni_maintext =		"";
var Omni_subtext =		"";
var Omni_question =		"";
var Omni_buttonyes =	"";
var Omni_buttonno =		"";


var Omni_maintext =		"		Please upgrade your account to invite someone on a <a href='javascript:MoreInfo(\"1\")'>virtual date</a> now.<br />" +
						"		<img src='http://www.omnidate.net/images/screen2a.jpg' width='105' height='70' /><img src='http://www.omnidate.net/images/asseenon.gif' width='133' height='70' style='padding-left:10px;' />";
var Omni_subtext =		"<div style='padding-top:7px; font-size:11px;'><a href='javascript:MoreInfo(\"2\")'>Choose your virtual character now</a></div>";
var Omni_question =		"<div style='padding-top:7px;'><em>Would you like to register?</em></div>";
var Omni_buttonyes =	"Yes, Please";
var Omni_buttonno =		"Maybe Later";
*/


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);

	var strPopUpElement5 = "<div id='OmniFloatingLayerRegisterOuter"+Omni_verb+"'><div id='OmniFloatingLayerRegister"+Omni_verb+"' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement5);
	if (Omni_premiumxml != "")
	{
		GetPremiumHTML();
	}
	else
	{
		SetPremiumHTML();
	}


	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";
            }
            var ele5 = document.getElementById("OmniFloatingLayerRegister"+Omni_verb);
            if (ele5) {
                ele5.className = "OmniPopUpHack";
            }
        }
    }

}




function GetPremiumHTML()
{
	jQuery(document).ready(function(){
		jQuery.ajax
		(
			{
				url: Omni_premiumxml,
				dataType: "xml",
				success: Omni_SetDataXML,
				error: Omni_SetDataError
			}
		);
	});
}

function Omni_SetDataError(xhr, reason, ex) 
{ 
	SetPremiumHTML();
}


function Omni_SetDataXML(xml)
{
	var maintext = jQuery(xml).find("maintext").text();
		if (maintext != "" && maintext != null) Omni_maintext = maintext;
	var subtext = jQuery(xml).find("subtext").text();
		if (subtext != null) Omni_subtext = subtext;
	var question = jQuery(xml).find("question").text();
		if (question != null) Omni_question = question;
	var buttonyes = jQuery(xml).find("button-yes").text();
		if (buttonyes != "" && buttonyes != null) Omni_buttonyes = buttonyes;
	var buttonno = jQuery(xml).find("button-no").text();
		if (buttonno != "" && buttonno != null) Omni_buttonno = buttonno;

	if (Omni_subtext != "")
		Omni_subtext = "<div style='padding-top:7px; font-size:11px;'>"+Omni_subtext+"</div>";
	if (Omni_question != "")
		Omni_question = "<div style='padding-top:7px;'><em>"+Omni_question+"</em></div>";

	SetPremiumHTML();
}

function SetPremiumHTML()
{
	var OmniPremiumWriteHTML = 
			"	<div style='height:160px; width:340px; margin-left:30px; text-align:center;'>" + Omni_maintext +
			"		" + Omni_subtext +
			"		" + Omni_question +
			"	</div>" +
			"	<div style='height:70px; text-align:center;'>" +
			"		<div style='clear:both; padding-bottom:10px;'></div>" +
			"		<div onclick='YesRegisterPremium();' class='OmniRegisterButton' style='margin-left:50px;'>" + Omni_buttonyes + "</div>" +
			"		<div onclick='NoRegisterPremium();' class='OmniRegisterButton' style='margin-left:30px;'>" + Omni_buttonno + "</div>" +
			"	</div>";

	document.getElementById("OmniFloatingLayerRegister"+Omni_verb).innerHTML = OmniPremiumWriteHTML;
}





/***************************************************************************************************************
************	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];
				if (Omni_dbid == "TW" || Omni_dbid == "NF")
					g_Omnidate_Server = "70.33.254.125";
				break;
			case "landing":
				Omni_landing = arguments[i+1];
				break;
			case "premium":
				if (arguments[i+1] != "true" && arguments[i+1] != "")
				{
					Omni_premium = arguments[i+1];
				}
				break;
			/*case "redirect":
				if (arguments[i+1] == "back")
					Omni_premium = top.location.href;
				break;*/
			case "premiumpop":
				if (arguments[i+1] != "true" && arguments[i+1] != "")
				{
					Omni_premium = arguments[i+1];
					Omni_premiumpop = true;
				}
				break;
			case "premiumxml":
				Omni_premiumxml = "http://" + location.host + "/" +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 "sound":
				if (Omni_sound == "true" || Omni_sound == "false")
					Omni_sound = arguments[i+1];
				break;
			case "profiletype":
				Omni_profiletype = arguments[i+1];
				break;
			case "style":
			case "banner":
				Omni_bannerStyle = arguments[i+1];
				break;
			case "avatars":
				Omni_avatars = arguments[i+1];
				break;
			case "verb":
				Omni_verb = arguments[i+1];
				break;
			case "userxml":
				Omni_userxml = arguments[i+1];
				break;
			case "survey":
				Omni_survey = arguments[i+1];
				break;
			default:
				argObj[arguments[i]] = arguments[i+1];
		}
	}

if (Omni_dbid == "OD" && Omni_avatars == "")
	Omni_avatars = "3"; //3
else if (Omni_dbid == "SM" && Omni_avatars == "")
	Omni_avatars = ""; //2
/*
	// Hard Code Testing
	if (Omni_dbid == "IS" && Omni_userid == "446672" && Omni_premium == "")
	{
		Omni_premium = "http://www.isingles.co.uk/asp/omnisubscribetest.asp";
		Omni_premiumpop = true;
	}
*/


	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();
}


function Omni_MoveTo(url, type)
{
	if (type == "window.location.href")
		window.location.href = url;
	else if (type == "window.location")
		window.location = url;
	else if (type == "window.location.pathname")
		window.location.pathname = url;
	else if (type == "top.location.href")
		top.location.href = url;
	else if (type == "self.location")
		self.location = url;
	else if (type == "self.location.href")
		self.location.href = url;
}


/***************************************************************************************************************
************	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();
}



function OmniPrint(inputit)
{
	if (Omni_Debugging) Omni_data += inputit;
	jQuery("#containerX").html(Omni_data);

}