﻿/* 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
***************************************************************************************************************/

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_lang = "";
var Omni_verb = "";
var Omni_Popup = "";
var Omni_alert = "";
var Omni_appver = "";

var Omni_ChatServer = "";
var Omni_ShowDate = "";
var Omni_profiletype = "userid";
var Omni_movetype = "window.location.href";
var Omni_sound = "true";
var Omni_AppMode = null;

var LoadStarted = false;
var InviteOverShowing = false;
var DateHasBeenRequested = false;
var TimeRemaining = "";
var BannerShowing = false;
var AreWeOnADate = false

var g_Omnidate_Server = '66.135.38.88';
var Omni_Server = "http://www.omnidate.net/";
var Omni_PFServer = "98.175.249.86";
var Omni_landing = "";
var Omni_bannerStyle = "";
var Omni_profile = "";
var IgnorePingReturn = false;
var InviteInProgress = false;
var UserInfoSetOnPing = false;
var Omni_Debugging = false;


/***************************************************************************************************************
************	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 Button07 = new Object;
Button07.offline = Omni_Server + "images/btn07-offline.png";
Button07.online = Omni_Server + "images/btn07-online.png";
Button07.inactive = Omni_Server + "images/btn07-inactive.png";
Button07.dating = Omni_Server + "images/btn07-dating.png";
Button07.info = Omni_Server + "images/info02.gif";
Button07.height = "28";
Button07.width = "86";
Button07.iheight = "25";
Button07.iwidth = "20";

var Button08 = new Object;
Button08.offline = Omni_Server + "images/btn08-offline.png";
Button08.online = Omni_Server + "images/btn08-online.png";
Button08.inactive = Omni_Server + "images/btn08-inactive.png";
Button08.dating = Omni_Server + "images/btn08-dating.png";
Button08.info = Omni_Server + "images/info02.gif";
Button08.height = "28";
Button08.width = "124";
Button08.iheight = "25";
Button08.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";



var ButtonSpark01 = new Object;
ButtonSpark01.offline = Omni_Server + "images/btn-offline.png";
ButtonSpark01.online = Omni_Server + "images/btn-date-me.png";
ButtonSpark01.inactive = Omni_Server + "images/btn-inactive.png";
ButtonSpark01.dating = Omni_Server + "images/btn-dating.png";
ButtonSpark01.info = Omni_Server + "images/info03.png";
ButtonSpark01.height = "16";
ButtonSpark01.width = "78";
ButtonSpark01.iheight = "16";
ButtonSpark01.iwidth = "20";





// 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['Button07'] = Button07;
uiDefaults['Button08'] = Button08;
uiDefaults['ButtonSTB01'] = ButtonSTB01;
uiDefaults['ButtonSTB02'] = ButtonSTB02;
uiDefaults['AFui01'] = AFui01;
uiDefaults['AFui02'] = AFui02;
uiDefaults['ButtonTW01'] = ButtonTW01;
uiDefaults['Spark01'] = ButtonSpark01;

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 showBanner = "";
		var inviteStatus = "";
		var TimeRem = "";
		var ResultStatus = "";

		DateStatus = "";

		if (_this.InvitationStatus != null && !PremiumShowing)
		{
			var InviteStatus = _this.InvitationStatus;
			ResultStatus = InviteStatus.Status;

			if (Omni_Debugging) Omni_data += "Status: " +ResultStatus+ "<br />";
			jQuery("#containerX").html(Omni_data);


			var ResultInviteMsg = InviteStatus.InviteMsg;
			var ResultDeclineMsg = InviteStatus.DeclineMsg;
			var ResultMsg = (ResultInviteMsg == "") ? ResultDeclineMsg : ResultInviteMsg;

			var ResultMode = Omni_AppMode = InviteStatus.Mode;
			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);



			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; }

				showBanner = "1";
				buttonCode = "2";
				messageIn = (ResultMode == "1") ? "1" : "0";
				inviteStatus = "1";
				
				ShowDateAlert(true);

				// Speed up the Frequency while we wait for the accept
				Omni_Frequency = 2;
				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)
			}
			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; }

				showBanner = "1";
				buttonCode = ""; 
				messageIn = "";
				inviteStatus = (ResultMode == "1") ? "3" : "2"; // if chat, return 3, else 2

				if (Omni_ShowDate == "")
				{
					// Speed up the Frequency for the page getting the invites ONLY for the ShowDate page
					Omni_Frequency = 2;
					OmniGetProfile(YourDateId)

				}
			}
			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.
				showBanner = "0";
				buttonCode = "";
				messageIn = "3";
				inviteStatus = "";

				if (Omni_ShowDate == "")
				{
					TakeMeOnTheDate();
				}
				else
				{
					dating = "true";
					AreWeOnADate = true;
				}
			}
			else if (ResultStatus == "ExpiredAck" && ResultInviter == Omni_userid)
			{
				// A invitation request expired before a response. The user must acknowledge to complete the date.
				showBanner = "1";
				buttonCode = "1"; 
				messageIn = "2";
				inviteStatus = "0";
				ShowDateAlert(false);
				
				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)

			}
			else if (ResultStatus == "ExpiredAck" && ResultInvitee == Omni_userid)
			{
				// A invitation request expired before a response. The user must acknowledge to complete the date.
				showBanner = "1";
				buttonCode = "1"; 
				messageIn = "8";
				inviteStatus = "0";
				ShowDateAlert(false);

				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)
			}
			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.
				showBanner = "1";
				buttonCode = "1";
				messageIn = "5";
				inviteStatus = "0";
				ShowDateAlert(false);
				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)
			}
			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.
				showBanner = "1";
				buttonCode = "1";
				messageIn = "7";
				inviteStatus = "0";
				ShowDateAlert(false);
				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)
			}

			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.
				showBanner = "1";
				buttonCode = "1";
				messageIn = "9";
				inviteStatus = "0";
				ShowDateAlert(false);
				if (Omni_ShowDate == "")
					OmniGetProfile(YourDateId)
			}
			else if (ResultStatus == "DatingFinishedAck" && Omni_ShowDate == "")
			{
				// Acknowledge End Date - The other user has ended the date. The user must acknowledge to complete the date.

				if (Omni_Popup == "" || window.self.name == "omnidate")
				{
					//alert("hmmm");
					DateStatus = "DatingFinishedAck";
					if (AreWeOnADate)
						CallFinished();
					TakeMeOnTheDate();
				}
				else if (typeof(omnidateWindow)=="undefined") 
				{
					//alert(typeof(omnidateWindow) + ", " + omnidateWindow.closed);
					ShowDateAlert(true);
//					alert("wow");
				}
				else if (omnidateWindow.closed)
				{
//					alert("holla!" + omnidateWindow.closed);
					ShowDateAlert(false);
					onEndNotify(ResultDateId, ResultReqName); //hard close
				}
			}
			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.

				if (Omni_Popup == "" || window.self.name == "omnidate")
				{
					DateStatus = "DatingTimedOutAck";
					if (AreWeOnADate)
						CallTimeout();
					TakeMeOnTheDate();
				}
				else if (typeof(omnidateWindow)!="undefined" && !omnidateWindow.closed) 
				{
				}
				else
				{
					ShowDateAlert(false);
					onEndNotify(ResultDateId, ResultReqName); //hard close
				}
			}
			else if ((ResultStatus == "DatingFinishedAck" || ResultStatus == "DatingTimedOutAck") && Omni_ShowDate != "")
			{
				// Popup open
				dating = "";
				AreWeOnADate = true;
			}
			else // SOME OTHER CASE => BROKEN!
			{
				if (Omni_Debugging) Omni_data += "OnSendComplete---->ERROR!<br />";
				showBanner = "1";
				buttonCode = "1";
				messageIn = "6";
				inviteStatus = "0";
				ShowDateAlert(false);
			}

		}
		else if (_this.InvitationStatus != null && PremiumShowing)
		{
			ShowDateAlert(false);
			Omni_Frequency = 2;
		}
		else
		{	// Here we know we're just idle
			ShowDateAlert(false);

			if (AreWeOnADate)
			{
				dating = "";
				AreWeOnADate = false;

				OmniDate_ShowHide("OmniFloatingLayerDate", false);
				OmniDate_ShowHide("OmniFloatingLayerChat", false);


				Omni_Modal(false);
				var target = document.getElementById('OmniFloatingLayerDate');
				target.innerHTML = "";
				var target = document.getElementById('OmniFloatingLayerChat');
				target.innerHTML = "";

				if (Omni_Debugging) Omni_data += "<br /><br />DATE IS OVER, CLEAR OUT<br /><br />";
				
				if (window.self.name == "omnidate")
					window.self.close();
			}


			DateHasBeenRequested = false;
			showBanner = "0";
			buttonCode = ""; 
			messageIn = "";
			inviteStatus = "";
			
			OmniInviteIntv = clearTimeout(OmniInviteIntv);
			//OmniInviteIntv = null;

			OmniDate_HideBanner();
			Omni_AppMode = null;


			if (window.self.name == "omnidate")
				window.self.close();
		}

		jQuery("#containerX").html(Omni_data);

		// Broadcast the online status of the buttons + communicate with the banner
		BroadcastStatus(showBanner, buttonCode, messageIn, inviteStatus, YourDateName, YourDateId, ResultMsg, TimeRemaining, ResultStatus, ResultOnline);
	}

	// Define the next ping interval
	if (PingInterval == 0)
	{
		PingInterval = setInterval( "Send()", Omni_Frequency * 1000 );
	}
}

function ReturnOffline (OnlineString)
{
	InactiveAll();
	return OnlineString;
}




var BannerStatusShown = null;
var BannerButtonStatus = null;
var BannerMessageNumber = null;


function BroadcastStatus(showBanner, buttonCode, messageIn, inviteStatus, DateName, DateId, InviteMsg, TimeRem, ResStatus, online)
{

	if (Omni_Debugging) Omni_data += "BroadcastStatus("+showBanner+", "+buttonCode+", "+messageIn+", "+inviteStatus+", "+DateName+", "+DateId+", "+InviteMsg+", "+TimeRem+", "+ResStatus+", "+online+")<br />";
	jQuery("#containerX").html(Omni_data);

	// Broadcast to Banner

	if (showBanner == "1")
	{
		if (!BannerShowing || (inviteStatus != BannerStatusShown))
		{
			if (Omni_Debugging) Omni_data += "BroadcastStatus(1)<br />";jQuery("#containerX").html(Omni_data);
			OmniDate_VisibleBanner('OmniFloatingLayer', true);
			var target = document.getElementById('OmniFloatingLayer');
			target.innerHTML = omnidateBanner(buttonCode, messageIn, inviteStatus, DateName, DateId, TimeRem, InviteMsg);
		}
		else
		{
			if (Omni_Debugging) Omni_data += "BroadcastStatus(2)<br />";jQuery("#containerX").html(Omni_data);
			OmniDate_VisibleBanner('OmniFloatingLayer', true);
 			changeUI(buttonCode, messageIn, inviteStatus, DateName, DateId, TimeRem, InviteMsg);
		}

		OmniDate_ShowHide("OmniFloatingLayerInvite", false);
		BannerStatusShown = inviteStatus;
	}
	else if (showBanner == "0")
	{
		if (Omni_Debugging) Omni_data += "BroadcastStatus(0)<br />";jQuery("#containerX").html(Omni_data);
		if (BannerShowing && ResStatus != "")
			OmniDate_HideBanner();
		BannerStatusShown = 0;
	}


	// Broadcast to Buttons

	// 0,1,0,1,1,0
	// kam=1,billy=1,paco=2, etc
	if (online != "")
	{
		var onlineusers = Array();
		var temponlineusers = online.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 += "Users Online Status ("+online+"): ";

		// [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 numButtonsWithThisName = OmniGetNumButtons(buttonid);

	var btnIndex;
	for (btnIndex=0; btnIndex < numButtonsWithThisName; btnIndex++)
	{
		var btnNum = btnIndex + 1;
		var btnPrintId = buttonid + "_" + btnNum;
		

		if (Omni_Debugging) Omni_data += "AreWeOnADate="+AreWeOnADate+"<br />";
		jQuery("#containerX").html(Omni_data);


		var Status = "";
		var Disabled = true;

		if (status == "0")
		{
			Status = "Offline";
			if (typeof(btnUiAr[btnPrintId]['offline']) != "undefined")
				swapImage(btnPrintId, btnUiAr[btnPrintId]['offline'], 'offline');
		}
		else if (status == "1")
		{
			Status = "Date Me";
			if (!BannerShowing && !AreWeOnADate)
			{
				Disabled = false;
				if (typeof(btnUiAr[btnPrintId]['online']) != "undefined")
					swapImage(btnPrintId, btnUiAr[btnPrintId]['online'], 'online');
			}
			else
			{
				if (typeof(btnUiAr[btnPrintId]['inactive']) != "undefined")
					swapImage(btnPrintId, btnUiAr[btnPrintId]['inactive'], 'inactive');
			}
		}
		else if (status == "2")
		{	
			Status = "Dating";
			if (typeof(btnUiAr[btnPrintId]['dating']) != "undefined")
				swapImage(btnPrintId, btnUiAr[btnPrintId]['dating'], 'dating');
		}

		if(document.layers)	   //NN4+
		{
			document.layers[btnPrintId].cursor = (Disabled) ? "default" : "pointer";
		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
			var obj = document.getElementById(btnPrintId);
			obj.style.cursor = (Disabled) ? "default" : "pointer";
		}
		else if(document.all)	// IE 4
		{
			document.all[btnPrintId].style.cursor = (Disabled) ? "default" : "pointer";
		}

		document.getElementById(btnPrintId).disabled = Disabled;
	}

}




/***************************************************************************************************************
************	Button Functions
***************************************************************************************************************/
function Omni_Button()
{
	var btnUserId = "";
	var btncontainer = "";
	var btnreturn = "";
	var Omni_CustomButton = false;
	var Omni_CustomHover = false;
	var buttonType = "";

	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 "type":
				if (arguments[i+1] == "chat")
					buttonType = "chat";
				else if (arguments[i+1] == "date")
					buttonType = "date";
				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'];
		}


		var numButtonsWithThisName = OmniGetNumButtons(btnUserId);
		var btnPrintId = btnUserId + "_" + numButtonsWithThisName++;
		
		// Add the UI obj to the array
		btnUiAr[btnPrintId] = 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[btnPrintId] = btnTextObj;



		var printOmniButton = ''
		if (uiObj['iposition'] == 'bottom') { printOmniButton += '<span style="float:none;"><div>'; }
		var inviteButton = '<input type="button" id="' + btnPrintId + '" name="' + btnPrintId + '" onclick="OnDate(\''+btnUserId+'\',\''+buttonType+'\');" '
			+ '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

		if (uiObj['info'] != "" && uiObj['info'] != "undefined")
		{
			var infoButton = '<input type="button" id="' + btnPrintId + '_Info" name="' + btnPrintId + '+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 OmniGetNumButtons(_buttonName)
{
	var btnOccurs = 0;
	var btnIndex;
	for (btnIndex=0; btnIndex < Omni_ArStatus.length; btnIndex++)
	{
		if (Omni_ArStatus[btnIndex] == _buttonName)
		{
			btnOccurs++;
		}
	}
	return btnOccurs;
}

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 < btnUiAr.length; i++)
	{
		document.getElementById(btnUiAr[i]).disabled = true;
	}
}

function ActiveAll()
{
	if (Omni_Debugging) Omni_data += "ActiveAll()<br />";
	for (i = 0; i < btnUiAr.length; i++)
	{
		document.getElementById(btnUiAr[i]).disabled = false;
	}
}



// 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 != "")
	{
		var tag = new FlashTag(Omni_Server+'InfoBox_2_1.swf', 575, 455, "8,0,0,0");
		flashVarStr += "&CustomServer=64.34.169.15";
	}
	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_lang != "")
	{
		flashVarStr += "&lang=" + Omni_lang;
	}


	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 > ";

		OmniDate_ShowHide("OmniFloatingLayerInfo", true);

		jQuery("#containerX").html(Omni_data);
	}
}

function HideInfo()
{
	OmniDate_ShowHide("OmniFloatingLayerInfo", false);
}




var PremiumShowing = false;

function ShowRegisterBox()
{
	if (!BannerShowing)
	{
		if (Omni_Debugging) Omni_data += "<br />ShowRegisterBox() > ";
		PremiumShowing = true;

		SetPremiumHTML();
		OmniDate_ShowHide("OmniFloatingLayerRegister"+Omni_verb, true);

		jQuery("#containerX").html(Omni_data);
	}
}
function HideRegisterBox()
{
	//if (Omni_Debugging) Omni_data += "<br />HideRegisterBox() > ";
	PremiumShowing = false;

	OmniDate_ShowHide("OmniFloatingLayerRegister"+Omni_verb, false);

	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);
}


var Omni_ChatShowing = true;
function Omni_ShowHideChat()
{
	var _show;
	if (arguments[0] == true || arguments[0] == false)
		_show = arguments[0];
	else
		_show = !Omni_ChatShowing;
	

	Omni_ChatShowing = _show;

	//OmniDate_ShowHide('OmniFloatingLayerChatApp', _show);
	if(document.layers)	   //NN4+
	{
		document.layers['OmniFloatingLayerChat'].marginLeft = (_show) ? '-285px' : '-35px';
		document.layers['OmniFloatingLayerChat'].width = (_show) ? '285px' : '35px';
	}
	else if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById('OmniFloatingLayerChat');
		obj.style.marginLeft = (_show) ? '-285px' : '-35px';
		obj.style.width = (_show) ? '285px' : '35px';

		if (document.getElementById('OmniFloatingLayerChatApp') != null)
			document.getElementById('OmniFloatingLayerChatApp').style.marginTop = (_show) ? '0px' : '20px';
	}
	else if(document.all)	// IE 4
	{
		document.all['OmniFloatingLayerChat'].style.marginLeft = (_show) ? '-285px' : '-35px';
		document.all['OmniFloatingLayerChat'].style.width = (_show) ? '285px' : '35px';
	}


}


function OmniDate_ShowHide(OmniLayer, ShowOnScreen)
{
	if (Omni_Debugging) Omni_data += "OmniDate_ShowHide(" + OmniLayer +", "+ ShowOnScreen + ")<br />";
	jQuery("#containerX").html(Omni_data);

	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";
	}
}

/***************************************************************************************************************
************	Request Date
***************************************************************************************************************/
function OnDate(useridIn, buttonType)
{
	if (Omni_Debugging) Omni_data += "OnDate("+useridIn+") Pressed, BannerShowing = " + BannerShowing + "<br />";
	jQuery("#containerX").html(Omni_data);

	if (!BannerShowing && (useridIn != Omni_userid))
	{

		if(buttonType == "chat")
		{
			OnRequest(useridIn, "1");
		}
		else
		{
			Omni_Destination = "";
			BannerShowing = true;
			InactiveAll();

			OmniDate_VisibleBanner('OmniFloatingLayerInvite', true);

			var target = document.getElementById('OmniFloatingLayerInvite');
			target.innerHTML = "<div class='Omni"+Omni_bannerStyle+"bg00'>"+
			"	<div style='padding:25px;'>"+

			"		<div class='Omni"+Omni_bannerStyle+"Heading02' style='float:left'>"+
			"			"+OmniLangAr["SelectDest"]+"..."+
			"		</div>"+
			"		<div onclick='MoreInfo(\"2\");' class='Omni"+Omni_bannerStyle+"Select' style='float:right'>"+OmniLangAr["SelectAvatar"]+"</div><div style='clear:both'></div>"+

			"		<div style='width:400px;height:130px;margin-top:5px;'>"+Omni_Destinations()+"</div>"+
			"		<div class='Omni"+Omni_bannerStyle+"Heading03' style='margin-top:-7px;'>"+OmniLangAr["PersonalMsg"]+"...</div>"+
			"		<textarea name='OmniInviteText' id='OmniInviteText' class='Omni"+Omni_bannerStyle+"InviteText' onClick='OmniSelectAll(\"OmniInviteText\");' onKeyDown='OmniTextCounter(this,140);' onKeyUp='OmniTextCounter(this,140);'>"+OmniLangAr["DefaultInv"]+"</textarea>"+
			"		<div>"+
			"			<div style='float:left; margin-left:60px; text-align:center;'>"+
			"				<div id='btnOmniInvite' name='btnOmniInvite' onclick='OnRequest(\""+useridIn+"\", \"0\");' class='Omni"+Omni_bannerStyle+"Invite01'>"+OmniLangAr["Invite"]+"</div>"+
			"			</div>"+
			"			<div style='float:left; margin-left:34px;'>"+
			"				<div id='btnOmniCancel' name='btnOmniCancel' onclick='ActiveAll();OmniDate_VisibleBanner(\"OmniFloatingLayerInvite\", false);Send();' class='Omni"+Omni_bannerStyle+"CancelOkay01'>"+OmniLangAr["Cancel"]+"</div>"+
			"			</div>"+
			"		</div>"+

			"	</div>"+
			"</div>";
	
			if ((Omni_dbid == "JDUK" || Omni_dbid == "JDFR") && (typeof(s_gi) != 'undefined') && (typeof(s_account) != 'undefined'))
			{
				var s= s_gi( s_account);
				s.linkTrackVars="events";
				s.linkTrackEvents="event46";
				s.events="event46";
				s.tl(true,'o','Click to Initiate OmniDate');
			}

		}
	}
	Send();
}

function OmniTextCounter(field, maxlimit)
{
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
}

function OmniSelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

var Omni_Destination = "";
function OmniSetDestination(_Destination)
{
	Omni_Destination = _Destination;
}

function OnRequest(useridIn, _Mode)
{
	if (Omni_Debugging) Omni_data += "OnRequest (BannerShowing = " + BannerShowing + ", "+_Mode+")<br />";
	jQuery("#containerX").html(Omni_data);
	OmniDate_VisibleBanner('OmniFloatingLayerInvite', false);
	
	if (useridIn != Omni_userid)
	{
		if (Omni_premium == "")
		{
			if (Omni_Popup != "")
				OpenDateWindow();

			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 + "&mode=" + _Mode;
			if (Omni_dbid != "")
			{
				requestStr += '&dbid=' + Omni_dbid;
			}
			if (Omni_lcId != "")
			{
				requestStr += '&browser=' + Omni_lcId;
			}
			if (Omni_ShowDate != "")
			{
				requestStr += '&showdate=false';
			}
			if (Omni_Destination != "")
			{
				requestStr += '&venue=' + Omni_Destination;
			}
			if (document.getElementById('OmniInviteText') != null && _Mode != "1")
			{
				var target = document.getElementById('OmniInviteText');
				requestStr += '&invitemsg=' + encodeURIComponent(target.value);
			}
			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
		{
			Omni_AppMode = _Mode;
			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);


	if (_this.Status == "ERROR")
	{
		BroadcastStatus("1", "1", "6", "0", "", "", "", "", "", "");
	}
	else if (_this.Status != "SUCCESS")
	{
		BroadcastStatus("1", "1", "10", "0", "", "", "", "", "", "");
	}

	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 AvatarSpark01 = new Object;
AvatarSpark01.imageM = Omni_Server+"images/btn-edit-avatar.png";
AvatarSpark01.imageF = Omni_Server+"images/btn-edit-avatar.png";
AvatarSpark01.text = "Select Your Virtual Character";
AvatarSpark01.height = "25";
AvatarSpark01.width = "95";


/*
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['Spark01'] = AvatarSpark01;
//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 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";
*/

var BannerObj = new Object;
BannerObj['Banner01'] = true;
BannerObj['Spark01'] = true;
//BannerObj['BannerSTB'] = BannerSTB;
//BannerObj['BannerNF'] = BannerNF;



var MessageAr = new Array();
var OmniLangAr = new Array();
OmniLangAr["Inviting"] = "Inviting";
OmniLangAr["Invite"] = "Invite";
OmniLangAr["Cancel"] = "Cancel";
OmniLangAr["Okay"] = "Okay";
OmniLangAr["Accept"] = "Accept"
OmniLangAr["Decline"] = "Decline"
OmniLangAr["SecsRem"] = "Seconds Remaining";
OmniLangAr["Secs"] = "Seconds";
OmniLangAr["SelectDest"] = "Select a destination";
OmniLangAr["PersonalMsg"] = "Write a personal message";
OmniLangAr["Decline1"] = "Sorry, not right now.";
OmniLangAr["Decline2"] = "You're not really my type.";
OmniLangAr["Decline3"] = "Let's reschedule.";
OmniLangAr["DefaultInv"] = "Hi, would you like to join me on a virtual date?";
OmniLangAr["InvDate"] = "You are being invited on a VIRTUAL DATE!";
OmniLangAr["ViewProfile"] = "view profile";
OmniLangAr["SelectAvatar"] = "select your avatar";




function Omni_Language()
{

	if (Omni_lang == "fr")
	{
		OmniLangAr["Inviting"] = "Inviter"
		OmniLangAr["Invite"] = "Inviter";
		OmniLangAr["Cancel"] = "Annuler";
		OmniLangAr["Okay"] = "Okay";
		OmniLangAr["Accept"] = "Accepter"
		OmniLangAr["Decline"] = "Refuser";
		OmniLangAr["SecsRem"] = "Secondes Restantes";
		OmniLangAr["Secs"] = "Secondes";
		OmniLangAr["SelectDest"] = "Choisissez une destination";
		OmniLangAr["PersonalMsg"] = "Ecrivez un message personnel";
		OmniLangAr["Decline1"] = "Désolé, pas maintenant.";
		OmniLangAr["Decline2"] = "Vous ne me correspondez pas vraiment.";
		OmniLangAr["Decline3"] = "Une autre fois, oui.";
		OmniLangAr["DefaultInv"] = "Hey, voulez-vous me joindre pour un Date Virtuel?";
		OmniLangAr["InvDate"] = "Vous êtes invité à un DATE VIRTUEL!";
		OmniLangAr["ViewProfile"] = "voir profil";
		OmniLangAr["SelectAvatar"] = "choisissez votre avatar";
	
		// French
		MessageAr["0"] = "à un Date Virtuel...";
		MessageAr["1"] = "à un Chat...";
		MessageAr["2"] = "Votre demande est expirée.";
		MessageAr["3"] = "Vous êtes actuellement occupé.";
		MessageAr["4"] = "Vous emmène à l'application...";
		MessageAr["5"] = "n'est pas disponible maintenant."; // _____ declined...
		MessageAr["6"] = "Oops, une erreur est survenue.";
		MessageAr["7"] = "a refusé votre demande.";  // _____ has cancelled...
		MessageAr["8"] = "Vous venez de rater une invitation de"; // from _____.
		MessageAr["9"] = "n'est plus disponible pour le moment."; // _____ no longer...
		MessageAr["10"] = "Cet utilisateur n'est plus disponible pour le moment.";
	}
	else
	{
		// English

		if (Omni_lang == "chat")
		{
			MessageAr["0"] = "to chat...";
			MessageAr["1"] = "to chat...";
			MessageAr["2"] = "Your request has expired.";
			MessageAr["3"] = "You are currently occupied.";
			MessageAr["4"] = "Taking you to the chat...";
			MessageAr["5"] = "is not available right now."; // _____ declined...
			MessageAr["6"] = "Woops, error detected.";
			MessageAr["7"] = "has cancelled their request.";  // _____ has cancelled...
			MessageAr["8"] = "You missed an invitation from"; // from _____.
			MessageAr["9"] = "is no longer available."; // _____ no longer...
			MessageAr["10"] = "That user is no longer available.";
		}
		else
		{
			MessageAr["0"] = "on a Virtual Date...";
			MessageAr["1"] = "to Chat...";
			MessageAr["2"] = "Your request has expired.";
			MessageAr["3"] = "You are currently occupied.";
			MessageAr["4"] = "Taking you to the application...";
			MessageAr["5"] = "is not available right now."; // _____ declined...
			MessageAr["6"] = "Woops, error detected.";
			MessageAr["7"] = "has cancelled their request.";  // _____ 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.";
		}
	}


}

function OmniGetBannerMessage(_MessageIn, _DateId, _DateName)
{
	var txtOmniStatus = "";

	if (_MessageIn != null && _MessageIn != "")
	{
		if (_MessageIn == "8")
		{
			if (Omni_profile != "")
				txtOmniStatus = MessageAr[_MessageIn] + " <a style='color:#0077cc;' href='#' onclick='onOkayClick();GoToProfile(\""+_DateId+"\",\""+_DateName+"\");'>"+ _DateName +"</a>";
			else
				txtOmniStatus = MessageAr[_MessageIn] + " " + _DateName;
		}
		else if (_MessageIn == "7" || _MessageIn == "9" || _MessageIn == "5")
			txtOmniStatus =  _DateName + " " + MessageAr[_MessageIn];
		else if (_MessageIn == "0" || _MessageIn == "1")
			txtOmniStatus =  OmniLangAr["Inviting"] + " " + _DateName + " " + MessageAr[_MessageIn];
		else
			txtOmniStatus = MessageAr[_MessageIn];
	}

	return txtOmniStatus;
}

function OmniGetBannerButton(buttonCode)
{
	// Button Codes (buttonCode)
	// 0 - Hide Both
	// 1 - Show "Okay"
	// 2 - Show "Cancel"
	var buttonhtml = "";
	
	if (buttonCode == "1")
	{
		buttonhtml = "<div style='float:left;' id='btnOmniDecline' name='btnOmniDecline' onclick='javascript:onOkayClick();' class='Omni"+Omni_bannerStyle+"CancelOkay02'>"+OmniLangAr["Okay"]+"</div>";
	}
	else if (buttonCode == "2")
	{
		buttonhtml = "<div style='float:left;' id='btnOmniDecline' name='btnOmniDecline' onclick='javascript:onCancelClick();' class='Omni"+Omni_bannerStyle+"CancelOkay02'>"+OmniLangAr["Cancel"]+"</div>";
	}
	else
	{
		buttonhtml = "";
	}

	return buttonhtml
}


function OmniGetBannerASL(DateId)
{
	var bannerASL = "";
	var firstone = true;

	if (OmniCurrentDate.YourDateId == DateId)
	{
		if (OmniCurrentDate.profileGender != null && OmniCurrentDate.profileGender != "")
		{
			bannerASL += OmniCurrentDate.profileGender;
			firstone = false;
		}
		if (OmniCurrentDate.profileAge != null && OmniCurrentDate.profileAge != "")
		{
			bannerASL += (firstone) ? "" : " / ";
			bannerASL += OmniCurrentDate.profileAge;
			firstone = false;
		}
		if (OmniCurrentDate.profileLocation != null && OmniCurrentDate.profileLocation != "")
		{
			bannerASL += (firstone) ? "" : "<br />";
			bannerASL += OmniCurrentDate.profileLocation;
			firstone = false;
		}
	}

	return bannerASL;
}

function OmniGetViewProfile(_DateId, _DateName)
{
	if (_DateName != "" && _DateId != "")
		return "<a style='font-size:11px; color:#0077cc;' href='javascript:GoToProfile(\""+_DateId+"\",\""+_DateName+"\");'>"+OmniLangAr["ViewProfile"]+"</a>";
	else
		return "";
}


var OmniCurrentDate = new Object();

function OmniGetProfile(_DateId)
{

	var profileurl = "";
	if (Omni_userxml != "")
		profileurl = encodeURIComponent(Omni_userxml + _DateId);


	if (Omni_Debugging) Omni_data += "<h2>OmniGetProfile(OmniCurrentDate.YourDateId="+OmniCurrentDate.YourDateId+", _DateId="+_DateId+");</h2>";
	jQuery("#containerX").html(Omni_data);

	if (profileurl != "" && (OmniCurrentDate.YourDateId == null || OmniCurrentDate.YourDateId != _DateId))
	{
		OmniCurrentDate = new Object();

		var getprofileStr = "http://" + g_Omnidate_Server + "/od/GetUserProfile.aspx?userid=" + Omni_userid + "&url=" + profileurl;
		if (Omni_dbid != "")
		{
			getprofileStr += '&dbid=' + Omni_dbid;
		}
		if (Omni_lcId != "")
		{
			getprofileStr += '&browser=' + Omni_lcId;
		}
		if (Omni_ShowDate != "")
		{
			getprofileStr += '&showdate=false';
		}
		getprofileStr += "&jsonp=?";


		if (Omni_Debugging) Omni_data += "OmniGetProfile("+getprofileStr+");<br />";
		jQuery("#containerX").html(Omni_data);

		jQuery.getJSON(getprofileStr, 
		function(data)
		{
			//if (Omni_dbid == "SM" && (_DateId=="9" || _DateId=="76"))
			//	alert(data.ProfilePhoto+","+data.ProfileGender+","+data.ProfileAge+","+data.ProfileLocation+","+data.RetCode);

			if (data.RetCode == "SUCCESS")
			{
				OmniCurrentDate.YourDateId = _DateId;
				OmniCurrentDate.profileGender = data.ProfileGender;
				OmniCurrentDate.profileAge = data.ProfileAge;
				OmniCurrentDate.profileLocation = data.ProfileLocation;
				OmniCurrentDate.profilePhoto = data.ProfilePhoto;
				if (Omni_Debugging) Omni_data += "OmniGetProfile("+OmniCurrentDate.profilePhoto+");<br />";
				jQuery("#containerX").html(Omni_data);
				Send();
			}
		}
		);
	}
}





var OmniTimeRemaining = 0;
var OmniInviteIntv = null;

function OmniCountdownTimer() 
{
	if (Omni_Debugging) Omni_data += "OmniCountdownTimer("+OmniTimeRemaining+");<br />";
	jQuery("#containerX").html(Omni_data);

	//if (OmniInviteIntv != null)
	//{
	//	clearInterval(OmniInviteIntv);
	//	OmniInviteIntv = null;
	//}
	OmniInviteIntv = clearTimeout(OmniInviteIntv);

	OmniTimeRemaining--;

	if (OmniTimeRemaining > 0 && document.getElementById('OmniBannerTimeRem') != null)
	{
		document.getElementById('OmniBannerTimeRem').innerHTML = OmniTimeRemaining;
		OmniInviteIntv = setTimeout( "OmniCountdownTimer()", 1000 );
	}
	else
	{
		if (document.getElementById('OmniBannerTimeRem') != null)
			document.getElementById('OmniBannerTimeRem').innerHTML = "0";
		if (document.getElementById('OmniBannerAcceptDecline') != null)
			document.getElementById('OmniBannerAcceptDecline').innerHTML = "";
	}
}





function omnidateBanner(buttonCode, messageIn, inviteStatus, DateName, DateId, TimeRem, InviteMsg)
{
	// Invite Status
	// 0 = Notifiation
	// 1 = Sending Invite
	// 2 = VDate
	// 3 = VChat

	if (Omni_Debugging) Omni_data += "omnidateBanner("+buttonCode+", "+messageIn+", "+inviteStatus+", "+DateName+", "+DateId+", "+TimeRem+", "+InviteMsg+");<br />";
	jQuery("#containerX").html(Omni_data);


	var txtTimeRem = "0";
	// Set Time
	if (parseInt(TimeRem) > 0)
	{
		txtTimeRem = OmniTimeRemaining = parseInt(TimeRem);
		OmniInviteIntv = setTimeout( "OmniCountdownTimer()", 1000 );
	}
	else
	{
		txtTimeRem = "0";
		OmniInviteIntv = clearTimeout(OmniInviteIntv);
		//OmniInviteIntv = null;
	}
	// Set Message
	var txtOmniStatus = OmniGetBannerMessage(messageIn, DateId, DateName);
	BannerMessageNumber = messageIn;

	// Set Button
	var buttonhtml = OmniGetBannerButton(buttonCode);
	BannerButtonStatus = buttonCode;

	// Set Profile
	var ASLhtml = OmniGetBannerASL(DateId);
	var profilePhoto = "";
	if (OmniCurrentDate.profilePhoto != null && OmniCurrentDate.profilePhoto != "")
		profilePhoto = "<img src='"+OmniCurrentDate.profilePhoto+"'/>";

	if (InviteMsg != "")
		InviteMsg = "\"" + InviteMsg + "\"";




	if (inviteStatus == "1") // Sending
	{
		return "<div class='Omni"+Omni_bannerStyle+"bg01' >"+
			"	<div style='padding:25px;'>"+
			"		<div class='Omni"+Omni_bannerStyle+"Heading01b' id='OmniBannerMessage'>" + txtOmniStatus + "</div>"+

			"		<table cellpadding='5' class='Omni"+Omni_bannerStyle+"Table'>"+
			"			<tr>"+
			"				<td rowspan='2'><div id='OmniBannerPhoto'>"+profilePhoto+"</div></td>"+
			"				<td width='100%'><div id='OmniBannerInvMsg'><em>"+InviteMsg+"</em></div></td>"+
			"			</tr>"+
			"			<tr>"+
			"				<td><span style='font-size:18px;'>"+DateName+"</span><div id='OmniBannerASL'>"+ASLhtml+"</div></td>"+
			"			</tr>"+
			"		</table>"+

			"		<div style='float:right; margin-top:40px;'>"+
			"			<div style='float:left; margin-right:5px;'><div id='OmniBannerTimeRem' class='Omni"+Omni_bannerStyle+"TimeRem02'>"+txtTimeRem+"</div><div class='Omni"+Omni_bannerStyle+"TimeRem03'>"+OmniLangAr["SecsRem"]+"</div></div>"+
			"			<div style='float:left;' id='btnOmniCancel' onclick='onCancelClick();' class='Omni"+Omni_bannerStyle+"CancelOkay02'>"+OmniLangAr["Cancel"]+"</div>"+
			"		</div>"+
					Omni_AudioPreloader("false") +
			"	</div>"+
			"</div>";
	}
	else if (inviteStatus == "2" || inviteStatus == "3") // Receiving
	{
		var txtInviteType = "";
		
		if (inviteStatus == "2") // Receving Virtual Date Invite
			txtInviteType = OmniLangAr["InvDate"]; // by "+DateName+"!";
		else if (inviteStatus == "3") // Receiving Chat Invite
			txtInviteType = "You are being invited to CHAT!"; // by "+DateName+"!";


		return "<div class='Omni"+Omni_bannerStyle+"bg02'>"+
			"	<div style='padding:25px;'>"+
			"		<div class='Omni"+Omni_bannerStyle+"Heading01a'>"+txtInviteType+"</div>"+

			"		<table cellpadding='5' class='Omni"+Omni_bannerStyle+"Table'>"+
			"			<tr>"+
			"				<td rowspan='2'><div id='OmniBannerPhoto'>"+profilePhoto+"</div></td>"+
			"				<td width='100%'><div id='OmniBannerInvMsg'><em>"+InviteMsg+"</em></div></td>"+
			"			</tr>"+
			"			<tr>"+
			"				<td><span style='font-size:18px;'>"+DateName+"</span> "+OmniGetViewProfile(DateId, DateName)+"<div id='OmniBannerASL'>"+ASLhtml+"</div></td>"+
			"			</tr>"+
			"		</table>"+

			"		<div style='margin-top:15px;'>"+
			"			<div style='float:left; margin-left:35px;'>"+
			"				<div class='Omni"+Omni_bannerStyle+"TimeRem01'><span style='padding-top:5px;'><span id='OmniBannerTimeRem'>"+txtTimeRem+"</span> "+OmniLangAr["Secs"]+"</span></div>"+
			"				<div id='btnOmniAccept' name='btnOmniAccept' onclick='acceptOrDecline(\"true\");' class='Omni"+Omni_bannerStyle+"Accept01'>"+OmniLangAr["Accept"]+"</div>"+
			"			</div>"+
			"			<div style='float:left; margin-left:42px;' id='OmniBannerAcceptDecline'>"+
			"				<div id='OmniBannerTimeRem' style='height: 25px;'>"+
			"					<select name='OmniDeclineDrop' id='Omni"+Omni_bannerStyle+"DeclineDrop' class='limited-width' onMouseDown=\"if(document.all) this.className='expanded-width';\" onBlur=\"if(document.all) this.className='limited-width';\" onChange=\"if(document.all) this.className='limited-width';\">"+
			"						<option value=\""+OmniLangAr["Decline1"]+"\">"+OmniLangAr["Decline1"]+"</option>"+
			"						<option value=\""+OmniLangAr["Decline2"]+"\">"+OmniLangAr["Decline2"]+"</option>"+
			"						<option value=\""+OmniLangAr["Decline3"]+"\">"+OmniLangAr["Decline3"]+"</option>"+
			"					</select>"+
			"				</div>"+
			"				<div id='btnOmniDecline' name='btnOmniDecline' onclick='acceptOrDecline(\"false\");' class='Omni"+Omni_bannerStyle+"CancelOkay02'>"+OmniLangAr["Decline"]+"</div>"+
			"			</div>"+
			"		</div>"+
					Omni_AudioPreloader("true") +
			"	</div>"+
			"</div>";
	}
	else if (inviteStatus == "0")
	{
		// Status Notification
		var printthistable = "";
		if (InviteMsg != "")
		{

			printthistable = "			<tr><td rowspan='2'><div id='OmniBannerPhoto'>"+profilePhoto+"</div></td>"+
							"				<td width='100%'><div id='OmniBannerInvMsg'><em>"+InviteMsg+"</em></div></td></tr>"+
							"			<tr><td><span style='font-size:18px;'>"+DateName+"</span> "+OmniGetViewProfile(DateId, DateName)+"<div id='OmniBannerASL'>"+ASLhtml+"</div></td></tr>";
		}
		else
		{
			printthistable = "			<tr><td><div id='OmniBannerPhoto'>"+profilePhoto+"</div></td>"+
							"			<td width='100%'><span style='font-size:18px;'>"+DateName+"</span> "+OmniGetViewProfile(DateId, DateName)+"<div id='OmniBannerASL'>"+ASLhtml+"</div></td></tr>";
		}

	
		return "<div class='Omni"+Omni_bannerStyle+"bg03'>"+
			"	<div style='padding:25px;'>"+
			"		<div class='Omni"+Omni_bannerStyle+"Heading01b' id='OmniBannerMessage'>" + txtOmniStatus + "</div>"+

			"		<table cellpadding='5' class='Omni"+Omni_bannerStyle+"Table'>"+
						printthistable +
			"		</table>"+

			"		<div style='float:right; margin-top:40px;' id='OmniBannerButton'>" + buttonhtml + "</div>"+

			"	</div>"+
			"</div>";
	}


	OmniDate_HideBanner();
	return "";
}


function changeUI(buttonCode, messageIn, inviteStatus, DateName, DateId, TimeRem, InviteMsg)
{
	if (Omni_Debugging) Omni_data += "changeUI("+buttonCode+", "+messageIn+", "+inviteStatus+", "+DateName+", "+DateId+", "+TimeRem+", "+InviteMsg+");<br />";


	// Set Message
	if (messageIn != BannerMessageNumber && document.getElementById('OmniBannerMessage') != null)
	{
		var target = document.getElementById('OmniBannerMessage');
		target.innerHTML = OmniGetBannerMessage(messageIn, DateId, DateName);
		BannerMessageNumber = messageIn;
	}

	// Set Button
	if (buttonCode != BannerButtonStatus && document.getElementById('OmniBannerButton') != null)
	{
		var target = document.getElementById('OmniBannerButton');
		target.innerHTML = OmniGetBannerButton(buttonCode);
		BannerButtonStatus = buttonCode;
	}

	// Set Profile
	if (document.getElementById('OmniBannerASL') != null)
	{
		var target = document.getElementById('OmniBannerASL');
		var newASL = OmniGetBannerASL(DateId);
		if (target.innerHTML != newASL)
			target.innerHTML = newASL;
	}

	if (OmniCurrentDate.YourDateId == DateId && OmniCurrentDate.profilePhoto != null && document.getElementById('OmniBannerPhoto') != null)
	{
		var target = document.getElementById('OmniBannerPhoto');
		var newphoto = "";
		if (OmniCurrentDate.profilePhoto != "")
			newphoto = "<img src='"+OmniCurrentDate.profilePhoto+"'/>";

		if (target.innerHTML != newphoto)
			target.innerHTML = newphoto;
	}
}



function Omni_Destinations()
{
	var tag = new FlashTag("http://www.omnidate.net/destinations_1_1.swf", "400", "130", "9,0,0,0");
	tag.setAllowScriptAccess("always");
	tag.setId("OmniDestinations");
	tag.setWmode("transparent");

	if (Omni_appver.charAt(0) == "5")
		tag.setFlashvars("XMLinput=destinationsAS3.xml");

	Omni_Unique++;
	return tag.toString();
}

function Omni_AudioPreloader(_PlayInvite)
{
	var flashVars = "You=" + You + "&YourDate=" + YourDate + "&PlayInvite=" + _PlayInvite + "&SoundStart=" + Omni_sound;
	
	if (Omni_alert != "")
		flashVars += "&AlertSound=" + Omni_alert;
	else if (Omni_AppMode == "1")
		flashVars += "&AlertSound=chime";

	if (Omni_AppMode == "1")
		flashVars += "&Preload=false";

	var YourDateGraphicServerLoader = (YourDate.substr(0,4) == "User") ? YourDateGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net
	var YourGraphicServerLoader = (You.substr(0,4) == "User") ? YourGraphicServer : "www.omnidate.net"; // All presets are on omnidate.net;
	flashVars += "&YourDateGraphicServer=" + YourDateGraphicServerLoader;
	flashVars += "&YourGraphicServer=" + YourGraphicServerLoader;
	

	var tag = new FlashTag("http://www.omnidate.net/OmniAudioPreloader.swf", "1", "1", "9,0,0,0");
	tag.setAllowScriptAccess("always");
	tag.setId("OmniAudioPreloader");
	tag.setWmode("transparent");
	tag.setFlashvars(flashVars);

	Omni_Unique++;
	return tag.toString();
}












function OmniDate_HideBanner()
{
	if (Omni_Debugging) Omni_data += "OmniDate_HideBanner()<br />";
	OmniInviteIntv = clearTimeout(OmniInviteIntv);
	//OmniInviteIntv = null;
	OmniDate_VisibleBanner('OmniFloatingLayer', false);
	var target = document.getElementById('OmniFloatingLayer');
	target.innerHTML = "";
}

function OmniDate_VisibleBanner(OmniLayer, ShowOnScreen)
{
	if (Omni_Debugging) Omni_data += "OmniDate_VisibleBanner(" + OmniLayer +", "+ ShowOnScreen + ")<br />";
	jQuery("#containerX").html(Omni_data);


	// 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 (ShowOnScreen) {
		BannerShowing = true;
		InactiveAll();
		//HideInfo();
		//HideRegisterBox();
	}

	OmniDate_ShowHide(OmniLayer, ShowOnScreen);
}


function onEndNotify(_omniuserid, _omniusername)
{
	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(_omniuserid, _omniusername);
		if (Omni_Debugging) Omni_data += cancelStr + "<br />";
		jQuery("#containerX").html(Omni_data);
	}
	);
}
function OnEndNotifyComplete(_omniuserid, _omniusername)
{
	if (Omni_Debugging) Omni_data += "OnEndNotifyComplete()<br />";

	dating = "";
	AreWeOnADate = false;
	Send();

	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 = "";
	var declineStr = "";

	if (acceptdecline == "false")
	{
		doAction = "exitnow";

		var target = document.getElementById("Omni"+Omni_bannerStyle+"DeclineDrop");
		declineStr = '&declinemsg=' + encodeURIComponent(target.options[target.selectedIndex].value);

		OmniDate_HideBanner();
	}
	else if (acceptdecline == "true")
	{
		doAction = "accept";
		InactiveAll();
		if (Omni_ShowDate == "")
		{
			Omni_Modal(true);
		}
		BroadcastStatus("1", "0", "4", "0", "", "", "", "", "", "");
	}


	//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';
		}
		if (declineStr != "")
		{
			acceptdeclineStr += declineStr;
		}
		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.
		if (_this.Status != "SUCCESS")
			BroadcastStatus("1", "1", "6", "0", "", "", "", "", "", "");
	}
}
function OnDeclineComplete(_this)
{
	if (Omni_Debugging) Omni_data += "OnDeclineComplete(Success="+_this.Status+")<br />";
	BroadcastStatus("0", "", "", "", "", "", "", "", "", "")
	Send();
}






/***************************************************************************************************************
************	POPUP Functions
***************************************************************************************************************/
//var omnidateWindow = window.open('', 'omnidate');
var omnidateWindow;
/*
function DateWindowFocus()
{
	if (typeof(omnidateWindow)!="undefined" && !omnidateWindow.closed){
		omnidateWindow.blur();
		omnidateWindow.focus();
	}
	else {
		AreWeOnADate = false;
		TakeMeOnTheDate();
	}
}
*/

function OpenDateWindow()
{
	var popupstringvars = "YourId="+YourId+"&YourName="+YourName+"&YourGender="+YourGender+"&DbId="+Omni_dbid;
	var WindowConfig = 'status=no, toolbar=no, location=no, directories=no, menubar=no, scrollbars=no';

	if (navigator.appName.indexOf("Microsoft")>=0)
	{
		WindowConfig+=',left=10,top=10,width=820,height=550';
	}
	else
	{
		WindowConfig += ',screenX=10,screenY=10,width=820,height=550';
	}
	omnidateWindow = window.open(Omni_Popup + '?' + popupstringvars, 'omnidate', WindowConfig);
}

function AssociateDateWindow()
{
	omnidateWindow = window.open('', 'omnidate');
}


function ShowDateAlert(ShowOnScreen)
{
	if (window.self.name != "omnidate" && (Omni_Popup != ""))
	{

		if (typeof(omnidateWindow)=="undefined" && ShowOnScreen)
		{
			//alert("associated");
			//OpenDateWindow();
			AssociateDateWindow();
		}


		OmniDate_ShowHide("OmniFloatingLayerDateAlert", ShowOnScreen);



		var target = document.getElementById('OmniFloatingLayerDateAlert');
		if (ShowOnScreen)
			target.innerHTML = 'You are on a date.<br /><input type="button" id="DateWin" name="DateWin" onclick="DateWindowFocus();" value="Go To Your Date" />';
		else
			target.innerHTML = '';
	}
}

function DateWindowFocus()
{
	if (typeof(omnidateWindow)!="undefined" && !omnidateWindow.closed){
		omnidateWindow.blur();
		omnidateWindow.focus();
	}
	else {
		//AreWeOnADate = false;
		OpenDateWindow();
		//TakeMeOnTheDate();
	}
}



/***************************************************************************************************************
************	Go On The Date
***************************************************************************************************************/
function TakeMeOnTheDate()
{
	if (!AreWeOnADate) // This is NO window open
	{
		dating = "true";
		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;
	dateObj.lang = Omni_lang;



	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;
	};




	if (Omni_Popup == "")
	{
		GoToDate(flashVars);
	}
	else 
	{
		ShowDateAlert(true);
		//alert (omnidateWindow.location);
		/*
		if (typeof(omnidateWindow)=="undefined" || omnidateWindow.closed )
		{
		}
		else
		{
			alert("associated");
			OpenDateWindow();
		}
		*/
	}

	IgnorePingReturn = false;
}





function GoToDate(OmniDate_variables)
{
	if (Omni_Debugging) Omni_data += "GoToDate()<br />";
	jQuery("#containerX").html(Omni_data);
	jQuery("#msgX").html(OmniDate_variables);

	dating = "true";

	Omni_AppProxy = new FlashProxy(Omni_lcId+"_"+Omni_Unique, Omni_Server+"JavaScriptFlashGateway.swf"); 
	var omniapptype = "";


	if (Omni_AppMode == "1")
	{
		omniapptype = "OmniFloatingLayerChat";

		var target = document.getElementById('OmniFloatingLayerChat');
		target.innerHTML = "<div id='OmniFloatingLayerChatClick' title='Click to Open/Hide' onclick='Omni_ShowHideChat();'></div>";
		
		var tag = new FlashTag("http://www.omnidate.net/SimpleChat.swf", "250", "450", "9,0,0,0");
		tag.setWmode("transparent");
		tag.setBgcolor("FFFFFF");
		tag.setId("OmniChatMovie1");
		tag.setFlashvars("lcId=" + Omni_lcId+"_"+Omni_Unique+"&"+OmniDate_variables);
		tag.setAllowScriptAccess("always");


		if (getMyHeight() < 450 && Omni_Popup == "")
		{
			var target2 = document.getElementById('OmniFloatingLayerChat');
			target2.style.position = "absolute";
			target2.style.top = "0px";
			target2.style.marginTop = "10px";
		}

		target.innerHTML += "<div style='float:left;' id='OmniFloatingLayerChatApp'>"+tag.toString()+"</div>";
		Omni_ShowHideChat(true);
	}
	else
	{
		omniapptype = "OmniFloatingLayerDate";

		if (Omni_appver.charAt(0) == "4" || Omni_appver.charAt(0) == "5")
			var tag = new FlashTag("http://www.omnidate.net/OmniDate_"+Omni_appver+".swf", "820", "550", "9,0,0,0");

		var target = document.getElementById('OmniFloatingLayerDate');
		//tag.setWmode("transparent");
		tag.setBgcolor("838383");
		tag.setId("OmniDateMovie1");
		tag.setFlashvars("lcId=" + Omni_lcId+"_"+Omni_Unique+"&"+OmniDate_variables);
		tag.setAllowScriptAccess("always");


		if (getMyHeight() < 550 && Omni_Popup == "")
		{
			var target2 = document.getElementById('OmniFloatingLayerDate');
			target2.style.position = "absolute";
			target2.style.top = "0px";
			target2.style.marginTop = "10px";
		}

		target.innerHTML = tag.toString();
	}
	Omni_Unique++;


	OmniDate_HideBanner();

	OmniDate_ShowHide("OmniFloatingLayerInfo", false);
	OmniDate_ShowHide(omniapptype, true);
}


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
	);
}


var ModalShowing = false;
function Omni_Modal() 
{
	if (arguments[0] == true || arguments[0] == false)
		ModalShowing = arguments[0];

	var ShowOnScreen = ModalShowing;

	if (Omni_Popup == "" && Omni_AppMode != "1")
	{
		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();

			//alert("width="+clientWidth+", height="+clientHeight);

			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)
{

	if (Omni_Debugging) Omni_data += "EndTheDate("+redirect+")<br />";
	jQuery("#containerX").html(Omni_data);


	if (redirect == "1" && window.self.name == "omnidate")
	{
		OnEndDate(_omniuserid, _omniusername);
	}
	else if (redirect == "1" || Omni_dbid == "IS")
	{

		OmniDate_ShowHide("OmniFloatingLayerDate", false);
		OmniDate_ShowHide("OmniFloatingLayerChat", false);


		Omni_Modal(false);
		var target = document.getElementById('OmniFloatingLayerDate');
		target.innerHTML = "";
		var target = document.getElementById('OmniFloatingLayerChat');
		target.innerHTML = "";

		if (Omni_Debugging) Omni_data += "<br /><br />END THE DATE<br /><br />";

		onEndNotify(_omniuserid, _omniusername); //hard close
		// 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);

		dating = "";
		AreWeOnADate = false;

		if (window.self.name == "omnidate")
			window.self.close();
		else 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_profile != "")
		Omni_MoveTo(Omni_profile + _omniusername, Omni_movetype);
	else if (Omni_profile != "")
		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 += "CallTimeout();<br />";

	if (Omni_AppMode == "1")
	{
		Omni_getFlashMovie("OmniChatMovie1").CallTimeout();
	}
	else
	{
		if (Omni_appver.charAt(0) == "4")
			Omni_AppProxy.call('CallFinished');
		else if(Omni_appver.charAt(0) == "5")
			Omni_getFlashMovie("OmniDateMovie1").CallTimeout();
	}
	jQuery("#containerX").html(Omni_data);
}
function CallFinished()
{
	if (Omni_Debugging) Omni_data += "CallFinished();<br />";
	
	if (Omni_AppMode == "1")
	{
		Omni_getFlashMovie("OmniChatMovie1").CallFinished();
	}
	else
	{
		if (Omni_appver.charAt(0) == "4")
			Omni_AppProxy.call('CallFinished');
		else if(Omni_appver.charAt(0) == "5")
			Omni_getFlashMovie("OmniDateMovie1").CallFinished();
	}
	jQuery("#containerX").html(Omni_data);
}

function Omni_getFlashMovie(movieName)
{
	var omni_isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (omni_isIE) ? window[movieName] : document[movieName];
}





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 =	"";
var Omni_subtext = ""
var Omni_question = "";
var Omni_buttonyes = "";
var Omni_buttonno = "";



/*
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();
	}

	var strPopUpElement6 = "<div id='OmniFloatingLayerDateAlertOuter'><div id='OmniFloatingLayerDateAlert' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement6);

	var strPopUpElement7 = "<div id='OmniFloatingLayerInviteOuter'><div id='OmniFloatingLayerInvite' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement7);

	var strPopUpElement8 = "<div id='OmniFloatingLayerChatOuter'><div id='OmniFloatingLayerChat' style='display: none;'></div></div>";
	jQuery("body").append(strPopUpElement8);


	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";
            }
            var ele6 = document.getElementById("OmniFloatingLayerDateAlert");
            if (ele6) {
                ele6.className = "OmniPopUpHack";
            }
            var ele7 = document.getElementById("OmniFloatingLayerInvite");
            if (ele7) {
                ele7.className = "OmniPopUpHack";
            }
            var ele8 = document.getElementById("OmniFloatingLayerChat");
            if (ele8) {
                ele8.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:6px; font-size:11px;'>"+Omni_subtext+"</div>";
	if (Omni_question != "")
		Omni_question = "<div style='padding-top:6px;'><em>"+Omni_question+"</em></div>";

	SetPremiumHTML();
}

function SetPremiumHTML()
{
	if (Omni_premiumxml == "")
	{
		if (Omni_AppMode == "1")
		{
			Omni_maintext =		"		Please upgrade your account to invite someone on a virtual chat now.<br />" +
									"		<br /><img src='http://www.omnidate.net/images/asseenon.gif' />";
			Omni_subtext =		"";
			Omni_question =		"";
			Omni_buttonyes =	"Okay";
			Omni_buttonno =		"Maybe Later";
		}
		else
		{
			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' />";
			Omni_subtext =		"<div style='padding-top:7px; font-size:11px;'><a href='javascript:MoreInfo(\"2\")'>Choose your virtual character now</a></div>";
			Omni_question =		"";
			Omni_buttonyes =	"Okay";
			Omni_buttonno =		"Maybe Later";
		}
	}

	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:13px;'></div>" +
			"		<div onclick='YesRegisterPremium();' class='OmniRegisterButton1' style='margin-left:40px;'>" + Omni_buttonyes + "</div>" +
			"		<div onclick='NoRegisterPremium();' class='OmniRegisterButton2' style='margin-left:20px;'>" + 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];
				break;
			case "popup":
				Omni_Popup = arguments[i+1];
				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 "premiumpop":
				if (arguments[i+1] != "true" && arguments[i+1] != "")
				{
					Omni_premium = arguments[i+1];
					Omni_premiumpop = true;
				}
				break;
			case "premiumxml":
				if (arguments[i+1] != "")
					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 "alert":
				Omni_alert = 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":
				arguments[i+1] = arguments[i+1].toLowerCase();
				if (arguments[i+1] == "chat")
					Omni_lang = arguments[i+1];
				Omni_verb = arguments[i+1];
				break;
			case "language":
				arguments[i+1] = arguments[i+1].toLowerCase();
				Omni_lang = arguments[i+1];
				break;
			case "userxml":
				Omni_userxml = arguments[i+1];
				break;
			case "survey":
				Omni_survey = arguments[i+1];
				break;
			case "appver":
				Omni_appver = arguments[i+1];
				break;
			default:
				argObj[arguments[i]] = arguments[i+1];
		}
	}


	/* Avatars */
	if ((Omni_dbid == "OD" || Omni_dbid == "IS" || Omni_dbid == "TW" || Omni_dbid == "STB") && Omni_avatars == "")
		Omni_avatars = "3";
	else if (Omni_dbid == "SM" && Omni_avatars == "")
		Omni_avatars = "2";
	else if (Omni_avatars == "")
		Omni_avatars = "1";

	/* App versions */
	if ((Omni_dbid == "OD" || Omni_dbid == "JDFR" || Omni_dbid == "JDUK" || Omni_dbid == "IS" || Omni_dbid == "TW" || Omni_dbid == "STB"|| Omni_dbid == "GUEST" || Omni_dbid == "IV1" || Omni_dbid == "IV2") && Omni_appver == "")
		Omni_appver = "5_1";
	else if (Omni_appver == "")
		Omni_appver = "4_16";

	if (Omni_alert == "" && Omni_dbid == "TW")
		Omni_alert = "chime";

/*
	if (Omni_dbid == "OD")
	{
		Omni_lang = "fr";
	}

	if (Omni_dbid == "TW")
	{
		Omni_DefaultFreq = 12;
		Omni_Frequency = Omni_DefaultFreq;
	}
*/

	// Set the language
	Omni_Language();


	// Default Banner Style
	if (Omni_bannerStyle == "" || typeof(BannerObj[Omni_bannerStyle]) == "undefined")
	{
		Omni_bannerStyle = "Banner01";
	}
	
	OmniWriteDivs();

	jQuery("#msgX").ajaxSuccess(function(event, request, settings)
	{
		jQuery("#msgX").html("<b>Number of Successful Ajax Calls:</b> " + ++ajaxCount + " Updated: " + OmniTime());
	});


/*jQuery(window).resize(function(){
 if(TO !== false)
    clearTimeout(TO);
 TO = setTimeout(alertSize, 200); //200 is time in miliseconds
alertSize();
});
*/


var resizeTimer = null;
jQuery(window).resize(function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(Omni_Modal, 500);
});




	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);

}






function getMyWidth()
{
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }

  return myWidth;
}
function getMyHeight()
{
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}




//var jquery = {};
//jquery.omnidate = jQuery.noConflict();
