// Javascript variables available for all!
var gFpc = "WT_FPC";
var gDcsId = 'dcscpr6sbugmf60fc2jbe86ep_2g4h'; 

function bb_off ()
{
    document.domain = document.domain.substring(document.domain.indexOf('.')+1);
    if ( top.shut )
    {
        top.shut = false;
    }
    top.location = 'http://www.google.com';
}



/**
 * This function finds the top and left offsets of an element.
 */
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

/**
 * This function returns the current user's profile ID.
 */
function getCurrentProfileID()
{
	return js_current_profile_id;
}

function updateImStatus(responseText, args)
{
	if (responseText.indexOf('force_redirect=') === 0)
	{
		window.location = responseText.substring('force_redirect='.length);
		return;
	}
	
	if (responseText.indexOf('ON') != -1)
		imFlashOverlayIsActive = false;
	else
		imFlashOverlayIsActive = true;

	var elt_sidebar = document.getElementById('dvImSwitch');
	elt_sidebar.innerHTML 	= '<span class="imSwitch">' + responseText + '</span>';
}



/**
 * This function will control the flash overlay 
 * 
 */
function displayFlashOverlay( )
{
	if( imFlashOverlayIsActive == true )
	{
		showImPopup( imStartCode );
		dcsMultiTrack( 'WT.ti', 'flash_overlay_launch', 'DCS.dcsuri', imFlashOverlaySelector );
	}
}


// From: image_swap.js
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// From: add_event.js
// Cross browser add event wrapper
function addEvent(elm, evType, fn, useCapture) {
  if (elm.addEventListener) {
	  elm.addEventListener(evType, fn, useCapture);
	  return true;
  }
  else if (elm.attachEvent) {
	  var r = elm.attachEvent('on' + evType, fn);
	  return r;
  }
  else {
	  elm['on' + evType] = fn;
  }
}


// From: DropMenuClass.js
// =================================================================================
// Class properties
// =================================================================================
DropMenu.registry = [];
DropMenu.submenuRegistry = [];
DropMenu.animationLength = 150;
DropMenu.minCPUResolution = 10;
DropMenu.hideDelay = 200;
DropMenu.openDelay = 300;
DropMenu.openDelayDown = 200;
DropMenu.openDelayUp = 200;
// =================================================================================
// End Class properties
// =================================================================================


// =================================================================================
// Define constructor
// =================================================================================
function DropMenu(id,direction,useOpenDelay) {
	// Define instance properties
	//
	// Class variables
	this.id = id;
	this.direction = direction;
	DropMenu.registry[id] = this;
	this.useOpenDelay = useOpenDelay ? true : false;
	//
	// HTML variables
	this.htmlVariablesSet = false;
	this.menu_rootNode = null;
	this.menuNode = null;
	this.height = null;
	this.width = null;
	this.iFrameNode = 0;
	//
	// Animation variables
	this.hideTimer = false;
	this.showTimer = false;
	this.submenuHideTimer = false;
	this.aniTimer = false;
	this.open = false;
	this.over = false;
	this.startTime = 0;
	this.animationHeight = null;
}
// =================================================================================
// End define constructor
// =================================================================================


// =================================================================================
// Define Class methods
// =================================================================================
DropMenu.initialize = function(node) {
	// id is a string value of the node id from the current menu
	var id = node.id;
	// thisMenu is an instance of the object controling the current menu
	var thisMenu = DropMenu.registry[id];
	// Save some html variables if they not already saved
	if (!thisMenu.htmlVariablesSet) {
		// Set flag to true so we are only doing this once
		thisMenu.htmlVariablesSet = true;
		// Save the root menu node
		thisMenu.menu_rootNode = node;
		// Find the first UL child and save it, it will be our menu
		var kids = thisMenu.menu_rootNode.childNodes;
		var numKids = kids.length;
		for(var i = 0; i < numKids ; i++){
			// Look for iframes and save them
			if (kids[i].nodeName == 'IFRAME') {
				thisMenu.iFrameNode = kids[i];
			}
			if (kids[i].nodeName == 'UL') {
				// Save the first UL child, this is our menu
				thisMenu.menuNode = kids[i];
			}
		}
		// Save the width and height
		thisMenu.width = thisMenu.menuNode.offsetWidth;
		thisMenu.height = thisMenu.menuNode.offsetHeight;
		// show the menu and hide it with clip
		thisMenu.menuNode.style.visibility = "visible";
		thisMenu.menuNode.style.clip ="rect(0px 0px 0px 0px)";
		// Set up the iframe
		if (thisMenu.iFrameNode) {
			thisMenu.iFrameNode.style.width = thisMenu.width + "px";
			thisMenu.iFrameNode.style.height = thisMenu.height + "px";
			thisMenu.iFrameNode.style.visibility = "visible";
			thisMenu.iFrameNode.style.clip ="rect(0px 0px 0px 0px)";
			thisMenu.iFrameNode.style.overflow = "hidden";
			if (thisMenu.direction == 'up') 
			{
				thisMenu.iFrameNode.style.top = "-" + thisMenu.height + "px";
			}
		}
		// Find out if there are any submenus and safe them to an array
		var kids = thisMenu.menuNode.childNodes;
		var numKids = kids.length;
		for(var i = 0; i < numKids ; i++){
			// if the childNode has an id then it's probable be a submenu
			if (kids[i].id) {
				// Save a reference of the submenu Class instance in var thisSubmenu
				var thisSubmenu = DropMenu.registry[kids[i].id];
				// Save the root of this submenu node
				thisSubmenu.menu_rootNode = kids[i];
				// Save a reference in an array linking the submenu to the root menu parent node
				DropMenu.submenuRegistry[kids[i].id] = node;
				// Create mouseover and mouseout functions for the root submenu node
				thisSubmenu.menu_rootNode.onmouseover=DropMenu.submenuOnMouseOver;
				thisSubmenu.menu_rootNode.onmouseout=DropMenu.submenuOnMouseOut;
				// Find the first UL child and save it, it will be our submenu
				var kids = thisSubmenu.menu_rootNode.childNodes;
				var numKids = kids.length;
				for(var i = 0; i < numKids ; i++){
					if (kids[i].nodeName == 'UL') {
						// Save the first UL child, this is our submenu
						thisSubmenu.menuNode = kids[i];
					}
				}
				// Save the width and height
				thisSubmenu.width = thisSubmenu.menuNode.offsetWidth;
				thisSubmenu.height = thisSubmenu.menuNode.offsetHeight;
			}
		}
		// Create mouseover and mouseout functions for the root menu node
		thisMenu.menu_rootNode.onmouseover=DropMenu.onMouseOver;
		thisMenu.menu_rootNode.onmouseout=DropMenu.onMouseOut;
		
		// Call DropMenu.onMouseOver
		node.onmouseover();
	}
}
//
//
DropMenu.closeAll = function() {}
//
//
DropMenu.onMouseOver = function(mouseEvent) {
	// id is a string value of the node id from the current menu
	var id = this.id;
	
	// reg is an instance of the DropMenu.registry array which holds a referance to
	// all the menu objects created with the constructor
	var reg = DropMenu.registry;
	var obj = DropMenu.registry[id];
	
	obj.over = true;
	
	// loop through all the menus in the registry and close other menus.
	for (menu in reg) if (id != menu) DropMenu.hide(menu);
	
	// if this menu is scheduled to close, cancel it.
	if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
	
	// if this menu is closed, open it.
	if (!obj.open && !obj.aniTimer && !obj.useOpenDelay) reg[id].startSlide(true);
	
	if (!obj.open && !obj.aniTimer && obj.useOpenDelay) {
		//reg[id].startSlide(true);
		if (obj.showTimer) window.clearTimeout(obj.showTimer);		
		if (obj.direction == "down")
		{
			obj.showTimer = window.setTimeout(function(){obj.startSlide(true);},DropMenu.openDelayDown);
		}
		else
		{
			obj.showTimer = window.setTimeout(function(){obj.startSlide(true);},DropMenu.openDelayUp);
		}
	}
}
//
//
DropMenu.onMouseOut = function(mouseEvent) {
	// id is a string value of the node id from the current menu
	var id = this.id;
	
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = DropMenu.registry[id];
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer);
	if (obj.showTimer) window.clearTimeout(obj.showTimer);
	obj.hideTimer = window.setTimeout("DropMenu.hide('" + id + "')", DropMenu.hideDelay);
}
//
//
DropMenu.submenuOnMouseOver = function(mouseEvent) {
	// id is a string value of the node id from the current menu
	var id = this.id;
	var rootMenu = (DropMenu.submenuRegistry[id]).id;
	var submenuObj = DropMenu.registry[id];
	var rootMenuObj = DropMenu.registry[rootMenu];
	
	window.clearTimeout(submenuObj.submenuHideTimer);
	// flag that this scheduled event has occured.
	submenuObj.submenuHideTimer = 0;
	
	submenuObj.menuNode.style.visibility = "visible";
	//rect (top, right, bottom, left)
	rootMenuObj.menuNode.style.clip ="rect(0px "+ (rootMenuObj.width + submenuObj.width) +"px "+ ((rootMenuObj.height)+(submenuObj.height)) +"px "+ (submenuObj.width)*-1 +"px)";
}
//
//
DropMenu.submenuOnMouseOut = function(mouseEvent) {
	// id is a string value of the node id from the current menu
	var id = this.id;
	var submenuObj = DropMenu.registry[id];
	
	if (submenuObj.submenuHideTimer) window.clearTimeout(submenuObj.submenuHideTimer);
	submenuObj.submenuHideTimer = window.setTimeout(function(){submenuObj.menuNode.style.visibility = "hidden";},DropMenu.hideDelay);
}
//
//
DropMenu.hide = function(id) {
	var obj = DropMenu.registry[id];
	obj.over = false;

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer);
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0;

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false);

}
// =================================================================================
// End define Class methods
// =================================================================================


// =================================================================================
// Define Class instance methods
// =================================================================================
DropMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open;
	//if (open) this.setVisibility(true);
	var self = this;
	this.startTime = (new Date()).getTime();
	this.aniTimer = window.setInterval(function(){self.slide();},DropMenu.minCPUResolution);
}
//
//
DropMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	//this.moveTo(this.open ? this.outPos : this.homePos)
	if (this.open) {
		// open position
		//rect (top, right, bottom, left)
		this.menuNode.style.clip ="rect(auto auto auto auto)";
		if (this.iFrameNode) {
			this.iFrameNode.style.clip ="rect(auto auto auto auto)";
		}
	} else {
		// closed position
		this.menuNode.style.clip ="rect(0px 0px 0px 0px)";
		if (this.iFrameNode) {
			this.iFrameNode.style.clip ="rect(0px 0px 0px 0px)";
		}
	}
	//if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over);
	}
}
//
//
DropMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime;
	if (elapsed > DropMenu.animationLength) this.endSlide()
	else {
		// Open or close the menu by animating clip
		var percentElapsed = elapsed/DropMenu.animationLength;
		this.animationHeight = Math.round(this.height * percentElapsed);
		//
		if (this.open) {
			// open it
			if (this.direction == "up") {
				//rect (top, right, bottom, left)
				this.animationHeight = this.height +(this.animationHeight*-1);
				this.menuNode.style.clip ="rect("+ this.animationHeight +"px " + this.width + "px "+ this.height +"px 0px)";
				if (this.iFrameNode) {
					this.iFrameNode.style.clip ="rect("+ this.animationHeight +"px " + this.width + "px "+ this.height +"px 0px)";
				}
			} else if (this.direction == "down") {
				// animate clip down
				this.menuNode.style.clip ="rect(0px " + this.width + "px "+ this.animationHeight +"px 0px)";
				if (this.iFrameNode) {
					this.iFrameNode.style.clip ="rect(0px " + this.width + "px "+ this.animationHeight +"px 0px)";
				}
			}
			//
			//var debugNode2 = document.getElementById('debug02');
			//debugNode2.innerHTML = "this.animationHeight: " + this.animationHeight;
		} else {
			// close it
			if (this.direction == "up") {
				//
				this.menuNode.style.clip ="rect("+ this.animationHeight +"px " + this.width + "px "+ this.height +"px 0px)";
				if (this.iFrameNode) {
					this.iFrameNode.style.clip ="rect("+ this.animationHeight +"px " + this.width + "px "+ this.height +"px 0px)";
				}
			} else if (this.direction == "down") {
				// animate clip closed
				this.animationHeight = this.height +(this.animationHeight*-1);
				this.menuNode.style.clip ="rect(0px " + this.width + "px "+ this.animationHeight +"px 0px)";
				if (this.iFrameNode) {
					this.iFrameNode.style.clip ="rect(0px " + this.width + "px "+ this.animationHeight +"px 0px)";
				}
			}
		}
	}
}
// Events
DropMenu.prototype.onactivate		= function() { }
DropMenu.prototype.ondeactivate	= function() { }
// =================================================================================
// End define Class instance methods
// =================================================================================


// From: posBtmNavSubMenu.js
var POS_TOP = 1;
var POS_LEFT = 0;

function posBtmNavSubMenu( menuParent )
{
	var menuChild = document.getElementById( "ul" + menuParent.id.substr( 2 ) );
	
	var menuParentPos 	= findPos( menuParent); 
	var heightChild 	= menuChild.offsetHeight; 

	menuChild.style.top = ( menuParentPos[POS_TOP] - heightChild ) + "px";
	
	//just a reminder that the element is ACTUALLY this tall
	menuChild.style.height = heightChild + "px";	
}


// From: im_popup.js
/**
 * Javascript portion of the im popup that appears when userplane tries to
 * initiate a chat session with the user and they have popup blockers on.
 * 
 * Setup:
 * initializeImPopup() is run on page load to insert the popup div at the end 
 * of the document.
 * 
 * When an IM is received and a popup blocker is on:
 * 1.	up_show is called (overridden in userplane_override.js to call our 
 * 		custom function to display our popup)
 * 2.	showImPopup -> insertHtml
 *
 * When a user clicks accept:
 * 1.	up_launch(user_id) is run and calls up_clear() and resets the var up_la
 * 2.	then calls up_show() and hides our popup (because up_la.length == 0)
 *
 * When a user clicks decline/x button:
 * 1.	declineInvite() is run
 * 2.	this will call up_clear() and resets the up_la array
 * 3.	up_show() is then called and our popup is closed and a notification
 * 		is sent to userplane through up_notifyOnClickedNo(user_id)
 */
var DV_TOP_BANNER = 'dvTopBanner';
var IM_MODALIZER_DIV = 'imModalizer';
var IM_WINDOW_DIV = 'imWindow';
var IM_WINDOW_FRAME_DIV = 'imWindowFrame';
var ACCEPT_INVITATION_DIV = 'imAcceptInvitation';
var LOADING_IMAGE_PATH = 'images/box_loading.gif';
var LOADER_CLASS = 'imLoading';

var isPopupBlockerExist = false;
var flashclassid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
var flashvars = '';

function disableAllOnlineNow()
{
	var divs = document.getElementsByTagName('div');
	for(var i=0; i<divs.length; i++)
	{
		theclass = divs[i].getAttribute('class');
		if (theclass === 'searchProfileHeading')
		{
			divs[i].style.display = 'none';
		}
	}
	
	var ps = document.getElementsByTagName('p');
	for(var i=0; i<ps.length; i++)
	{
		theclass = ps[i].getAttribute('class');
		if (theclass === 'onlineNow')
		{
			ps[i].style.display = 'none';
		}
	}
	
}

function enableAllOnlineNow()
{
	var divs = document.getElementsByTagName('div');
	for(var i=0; i<divs.length; i++)
	{
		theclass = divs[i].getAttribute('class');
		if (theclass === 'searchProfileHeading')
		{
			divs[i].style.display = 'block';
		}
	}
	
	var ps = document.getElementsByTagName('p');
	for(var i=0; i<ps.length; i++)
	{
		theclass = ps[i].getAttribute('class');
		if (theclass === 'onlineNow')
		{
			ps[i].style.display = 'block';
		}
	}
	
}


function disableAllSelects()
{
	var selects = document.getElementsByTagName('select');
	for(var i=0; i<selects.length; i++)
	{
		selects[i].disabled = true;
	}
}

function enableAllSelects()
{
	var selects = document.getElementsByTagName('select');
	for(var i=0; i<selects.length; i++)
	{
		selects[i].disabled = false;
	}
}


function getPageWidth(defaultWidth) {
	var pageWidth = defaultWidth;
	if (document.body && document.body.clientWidth) {
		pageWidth = document.body.clientWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			pageWidth = document.documentElement.clientWidth;
		}
	}
	return pageWidth;
}

function getPageHeight(defaultHeight) {
	var pageHeight = defaultHeight;
	if (document.body && document.body.clientHeight) {
		pageHeight = document.body.clientHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			pageHeight = document.documentElement.clientHeight;
		}
	}
	return pageHeight;
}

function startLoading()
{
	var imDiv = document.getElementById(ACCEPT_INVITATION_DIV);
	imDiv.innerHTML = '';
	imDiv.className = LOADER_CLASS;
}


function showImPopup(user_id)
{
	var domain = window.location.hostname;
	var parts = domain.toString().split(".");
	document.domain = parts[1] + '.' + parts[2]; //necessary for cross (sub)domain ajax
	var imModalizer = document.getElementById(IM_MODALIZER_DIV);
	if( imModalizer != undefined )
	{
		var imWindowFrame = document.getElementById(IM_WINDOW_FRAME_DIV);
		var imWindow = document.getElementById(IM_WINDOW_DIV);
		
		disableAllSelects();
		disableAllOnlineNow();
			
		// Set width, height of the modalizer
		var body = document.getElementsByTagName('BODY')[0];
		var pageWidth = getPageWidth(1024);
		var pageHeight = getPageHeight(2048);
		imModalizer.style.width = pageWidth + 'px';
		imModalizer.style.height = pageHeight + 'px';
		imModalizer.style.backgroundColor = "#FFFFFF";
		imModalizer.style.opacity = .1;
		imModalizer.style.filter = 'alpha(opacity=' + 10 + ')';
		// Activate the modalizer
		imModalizer.style.display = 'block';
		
		// Display the window
		imWindowFrame.style.width = pageWidth + 'px';
		imWindowFrame.style.height = pageHeight + 'px';		
		imWindowFrame.style.display = 'block';
		imWindow.style.display = 'block';
	
		// ajax call to get data using user_id
		var url = 'http://www1.' + document.domain + '/ajax_im_invitation/?profile_id=' + user_id;
		
		if(jQuery("#ajax_im_iframe").length == 0){
			jQuery("body").append('<iframe src="" border="0" width="0" height="0" id="ajax_im_iframe" style="display:none"></iframe>');
		}
		
		jQuery("#ajax_im_iframe").attr('src',url);
		jQuery("#ajax_im_iframe").load(function(){
			var myIFrame = document.getElementById('ajax_im_iframe');
			var content = myIFrame.contentWindow.document.body.innerHTML;
			var imDiv = document.getElementById(ACCEPT_INVITATION_DIV);
			imDiv.innerHTML = content;
			imDiv.className = '';
			jQuery('.resize').resizeimages();
		});
	}
}

function hideImPopup()
{
	var imModalizer = document.getElementById(IM_MODALIZER_DIV);
	var imWindowFrame = document.getElementById(IM_WINDOW_FRAME_DIV);
	var imWindow = document.getElementById(IM_WINDOW_DIV);
	
	enableAllSelects();
	enableAllOnlineNow();
	
	imModalizer.style.display= 'none';
	imWindowFrame.style.display = 'none';
	imWindow.style.display = 'none';
	startLoading();
}


function initializeImPopup()
{
	var imModalizer = document.getElementById(IM_MODALIZER_DIV);
	if( imModalizer == undefined )
	{
		var body = document.getElementsByTagName('BODY')[0];
		
		var imWindowFrame = document.createElement( 'iframe' );
		imWindowFrame.setAttribute( 'scrolling', 'no' );
		imWindowFrame.setAttribute( 'frameborder', '0' ); 
		imWindowFrame.id = 'imWindowFrame';
		imWindowFrame.style.display = 'none';
		imWindowFrame.style.opacity = .1;
		imWindowFrame.style.filter = 'alpha(opacity=' + 10 + ')';	
		body.appendChild(imWindowFrame);	
		
		var imModalizer = document.createElement('div');
		imModalizer.id = IM_MODALIZER_DIV;
		imModalizer.innerHTML = ' ';
		imModalizer.style.display = 'none';
		body.appendChild(imModalizer);	
		
		var imWindow = document.createElement('div');
		imWindow.id = IM_WINDOW_DIV;
		imWindow.innerHTML = '<div id="imTitleBar"><div id="imTitleBarDeclineButton" onclick="declineInvite();"></div></div><div id="' + ACCEPT_INVITATION_DIV + '" class="' + LOADER_CLASS + '"></div>';
		imWindow.style.display = 'none';
		body.appendChild(imWindow);
	}
}


// From: ajax_location_update.js
function loadLocation( location_type )
{

    var getString = '';
    
    switch( location_type )
    {
        case "country":
            elm = document.getElementById( 'sel_locCountry' );
            if( elm )
            {
                getString = '?type=state_code&code=' + elm.value;
                clearLists( location_type );
            }
        break;
        
        case "state":
            elm = document.getElementById( 'sel_locState' );
            if( elm )
            {
                getString = '?type=city_id&code=' + elm.value;
                clearLists( location_type );
            }
        break
        
        default:
            return false;
        break;
    }
	
	
	
	
	if( getString != '')
	{
	   jQuery.get('/load_locations' + getString, function(data){
			locationList = eval('(' + data + ')');
			
			if(typeof locationList == 'object')
			{
				clearLists(location_type);
				buildSelect(location_type);
			}
			else
			{
				alert('Could not retreive location lists.');
			}
	   });
	}
}

function clearLists( location_type )
{

	

    switch( location_type )
    {
        case 'country':
            elm = document.getElementById( 'sel_locState' );
            elm.innerHTML = '';
            newOption = document.createElement( 'option' );
        	newOption.setAttribute( 'value', 0 );
        	
        	newOption.setAttribute( 'selected', 'selected' );
        	
        	newOption.innerHTML = 'Select a state/prov';
        	newOption.setAttribute( 'selected', 'selected' );
        	elm.appendChild( newOption );
        case 'state':
            elm = document.getElementById( 'sel_locCity' );
            elm.innerHTML = '';
            newOption = document.createElement( 'option' );
        	newOption.setAttribute( 'value', 0 );
        	newOption.setAttribute( 'selected', 'selected' );
        	newOption.innerHTML = 'Select a city';
        	newOption.setAttribute( 'selected', 'selected' );
	        elm.appendChild( newOption );
    
    }

	

	
}

function buildSelect( location_type )
{
    var newOption;

    switch( location_type )
    {
        case 'country':
            elm = document.getElementById( 'sel_locState' );
            
            break;
        case 'state':
            elm = document.getElementById( 'sel_locCity' );
            
            break;
    
    }
    
    for( var i = 0; i < locationList.length; i++ )
    {
        newOption = document.createElement( 'option' );
        newOption.setAttribute( 'value', locationList[i][0]);
        
		
        
        newOption.innerHTML = locationList[i][1];
        
        elm.appendChild( newOption );        
    }
    
}


// From: ajax_instantMessageAllowLaunch.js
function instantMessageAllowLaunch( profileId )
{
	jQuery.get('/instant_message_allow_launch_c?recipient_profileId=' + profileId, function(data){
	
		var instantMessageAllowLaunchResultObj;
		
		eval( "instantMessageAllowLaunchResultObj = " + data );
		
		if( typeof instantMessageAllowLaunchResultObj == 'object' )
		{
			if( instantMessageAllowLaunchResultObj.instant_message_allow_launch_check.allow_launch === true )
			{
				//launch IM chat
				up_launchWM( 'MessageWindow', profileId, 'none' );
				
			}
			else
			{
				//redirect user
				window.location = instantMessageAllowLaunchResultObj.instant_message_allow_launch_check.redirect_url;
			}
		}
		else
		{
			//add error handling
			//alert( 'Could not increment IM session count.' );
		}
	});
}



// From: functions.js
// Userplane stuff.
function up_launchWM( userID, destinationUserID, destinationName )
{
	up_localUserID = userID;
	
	window.open( "/instant_message_c?strDestinationUserID=" + destinationUserID+"&up_localUserID="+ up_localUserID, "WMWindow_" + up_replaceAlpha(userID) + "_" + up_replaceAlpha(destinationUserID), "width=360,height=397,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
}
function up_launchUL()
{		
	
}
function up_replaceAlpha( strIn )
{
	var strOut = "";
	for( var i = 0 ; i < strIn.length ; i++ )
	{
		var cChar = strIn.charAt(i);
		if( ( cChar >= 'A' && cChar <= 'Z' )
			|| ( cChar >= 'a' && cChar <= 'z' )
			|| ( cChar >= '0' && cChar <= '9' ) )
		{
			strOut += cChar;
		}
		else
		{
			strOut += "_";
		}
	}
	
	return strOut;
}



// From: AC_OETags.js
// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}


