var no_toggle = '';
//*********************************************************************************************************
//	insert flash object and embed tags
//*********************************************************************************************************
function IsSignupEmail()
{
	form = document.newslettersignup;
	control = form["fields[Email]"].value;
	if ( !control.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi) )
	{
		alert('Please enter a valid email address');
		return false;
	}
	
	return true;
}

function VidBgOn( id )
{
//	document.getElementById( id ).style.backgroundImage = '';
	document.getElementById( id ).style.backgroundImage = 'url(/stuff/contentmgr/files/b43bc6c1da8bc36af35b8627d2c91214/misc/videotextbackground.gif)';
}

function openVideoPopup( urlstring )
{
	sizeX = 630;
	sizeY = 460;
	
	//	Center the window
	leftpos	= (screen.width)  ? (screen.width-sizeX)/2 : 100;
	toppos	= (screen.height) ? (screen.height-sizeY)/2 : 100;

	//	Define the window size
	widthVar  = 'width=' + sizeX + ',';
	heightVar = 'height=' + sizeY + ',';
	
	//	Open the window
	content					= urlstring;

	winobject				= window.open(content,'nfvideo',"menubar=0,statusbar=0,scrollbars=1,toolbar=0,location=0," + widthVar + heightVar + "left=" + leftpos + ",top=" + toppos + ",resizable=1" );
	winobject.focus();
}

function VidBgOff( id )
{
	document.getElementById( id ).style.backgroundImage = 'url(/stuff/contentmgr/files/b43bc6c1da8bc36af35b8627d2c91214/misc/videotextbackground_off.gif)';
}


function insertVideo( video_path )
{
	flashembed( "player1",
	{ src: '/uber/FlowPlayerLight.swf', width:294, height:236, bgcolor:'#ffffff'},
	{ config: { videoFile: video_path, showMenu: false  
		, autoPlay: true 
		, usePlayOverlay: '1' 
		, initialScale: true 
	} } );

}

function growALittle( elem )
{
	elem.style.width = '95px';
	elem.style.marginLeft = '-3';
	elem.style.marginTop = '-3';
}

function shrinkALittle( elem )
{
	elem.style.width = '89px';
	elem.style.marginTop = '0';
	elem.style.marginLeft = '0';
}

function toggleVisibility( id )
{
	if('video_arrow_' + no_toggle == id)
	{
	   	return;
	}

	alert(id);

	var elem = document.getElementById(id);
	if(elem.style.display == 'none')
	{
		elem.style.display = 'block';
	}
	else
	{
		elem.style.display = 'none';
	}
}

function placeDiv(src_div, dest_div)
{
	var src_div = document.getElementById(src_div);
	var dest_div = document.getElementById(dest_div);
	dest_div.innerHTML=src_div.innerHTML;
}

function makeFlash(swf,w,h,bg) 
{
	document.write("<center><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + w + "\" height=\"" + h + "\" id=\"pr\" align=\"middle\">")
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />")
	document.write("<param name=\"movie\" value=\"" + swf + "\" />")
	document.write("<param name=\"quality\" value=\"high\" />")
	document.write("<param name=\"bgcolor\" value=\"" + bg + "\" />")
	document.write("<embed src=\"" + swf + "\" quality=\"high\" bgcolor=\"" + bg + "\" width=\"" + w + "\" height=\"" + h + "\" name=\"pr\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />")
	document.write("</object></center>")
}


function toggleSubscribeWidget()
{
	obj = document.getElementById('subscribewidget');
	
	if (obj.style.display == 'none')
	{
		
		obj.style.display = 'block';
		
		setTimeout( "changeWidgetSize('subscribewidget',0);",	100 );
		setTimeout( "changeWidgetSize('subscribewidget',10);",	125 );
		setTimeout( "changeWidgetSize('subscribewidget',20);",	150 );
		setTimeout( "changeWidgetSize('subscribewidget',30);",	175 );
		setTimeout( "changeWidgetSize('subscribewidget',40);",	200 );
		setTimeout( "changeWidgetSize('subscribewidget',50);",	225 );
		setTimeout( "changeWidgetSize('subscribewidget',60);",	250 );
		setTimeout( "changeWidgetSize('subscribewidget',70);",	275 );
		setTimeout( "changeWidgetSize('subscribewidget',80);",	300 );
		setTimeout( "changeWidgetSize('subscribewidget',90);",	325 );
		setTimeout( "changeWidgetSize('subscribewidget',100);",	350 );
		setTimeout( "changeWidgetSize('subscribewidget',110);",	375 );
		setTimeout( "changeWidgetSize('subscribewidget',120);",	400 );
		setTimeout( "changeWidgetSize('subscribewidget',130);",	425 );
		setTimeout( "changeWidgetSize('subscribewidget',140);",	450 );
	//	setTimeout( "changeWidgetSize('subscribewidget',150);",	475 );
	//	setTimeout( "changeWidgetSize('subscribewidget',160);",	500 );
	//	setTimeout( "changeWidgetSize('subscribewidget',170);",	525 );
	//	setTimeout( "changeWidgetSize('subscribewidget',180);",	550 );
	//	setTimeout( "changeWidgetSize('subscribewidget',190);",	575 );
	//	setTimeout( "changeWidgetSize('subscribewidget',200);",	600 );
	//	setTimeout( "changeWidgetSize('subscribewidget',210);",	625 );
	//	setTimeout( "changeWidgetSize('subscribewidget',220);",	650 );
	//	setTimeout( "changeWidgetSize('subscribewidget',230);",	675 );
	}

	else
	{
		obj.style.height  = '0px';
		obj.style.display = 'none';
	}
}


//*********************************************************************************************************
//	Apply mouseover/off style changes to all form fields...
//
//*********************************************************************************************************
function stylizeInputFields()
{
	changeTags = new Array( 'input','textarea', 'select', 'password' );
	onColor    = '#EFF3FB';
	offColor   = '#ffffff';
	
	for (c=0; c<=changeTags.length; c++)
	{
		pageElements = document.getElementsByTagName(changeTags[c]);

		if (pageElements[0])
		{
			for (i=0; i<=pageElements.length; i++)
			{
				if (pageElements[i])
				{
					if (pageElements[i].type == "checkbox" )
					{
						continue;
					}
					
					objID   = pageElements[i].id;
					objName = pageElements[i].name;
						
					if (objID)
					{
						eval( 'pageElements[i].onfocus = function() { document.getElementById("'+objID+'").style.backgroundColor = "'+onColor+'"; }; ');					
						eval( 'pageElements[i].onblur = function() { document.getElementById("'+objID+'").style.backgroundColor = "'+offColor+'"; }; ');					
					}
				}
			}
		}
	}
}


var isActive = false;
var currMenu = '';

//-------------------------------------------------------------------------------------------------------
//	ChangeSize
//-------------------------------------------------------------------------------------------------------
function changeSize( id, size )
{
	if (!isActive && (currMenu != id))
	{
		return;
	}

	document.getElementById(id).style.height = size + 'px';
}

//-------------------------------------------------------------------------------------------------------
//	ChangeSize
//-------------------------------------------------------------------------------------------------------
function changeWidgetSize( id, size )
{
	document.getElementById(id).style.height = size + 'px';
}

//-------------------------------------------------------------------------------------------------------
//	Show/ Hide menus
//-------------------------------------------------------------------------------------------------------
function showSlide(group,item,imgId,imgBase,topnavid)
{
	if( !document.getElementById )
	{
		return;
	}

	isActive	= true;
	menuCount	= eval("m_" + group);
	currMenu    = 'm' + group + '0';

	mainMenu	= document.getElementById("m" + group + "0");
	subMenu		= document.getElementById("m" + group + item);

	//	Does object exist?
	if( !subMenu )
	{
		//	No, don't process
		return false;
	}
	
	if( imgId != 'NULL' )
	{
		imgObj	= document.getElementById( imgId );
		imgObj.setAttribute( 'base', imgBase );
		imgObj.setAttribute( 'src', imgBase );
	}
	
	mainMenu.style.visibility	= 'visible';
	mainMenu.style.height		= '1px';
	
	setTimeout( "changeSize('m" + group + "0',0);",			100 );
	setTimeout( "changeSize('m" + group + "0',10);",		125 );
	setTimeout( "changeSize('m" + group + "0',20);",		150 );
	setTimeout( "changeSize('m" + group + "0',30);",		175 );
	setTimeout( "changeSize('m" + group + "0',40);",		200 );
	setTimeout( "changeSize('m" + group + "0',50);",		225 );
	setTimeout( "changeSize('m" + group + "0',60);",		250 );
	setTimeout( "changeSize('m" + group + "0',70);",		275 );
	setTimeout( "changeSize('m" + group + "0',80);",		300 );
	setTimeout( "changeSize('m" + group + "0',90);",		325 );
	setTimeout( "changeSize('m" + group + "0',100);",		350 );
	setTimeout( "changeSize('m" + group + "0',110);",		375 );
	setTimeout( "changeSize('m" + group + "0',120);",		400 );
	setTimeout( "changeSize('m" + group + "0',130);",		425 );
	setTimeout( "changeSize('m" + group + "0',140);",		450 );
	
	//	Position the menu based on the top nav'd position
	if ( topnavid )
	{
		//	Menus right
		if( menu_positioning == 1 )
		{
			subMenu.style.left = ( getOffsetLeft( topnavid ) + getOffsetWidth( topnavid )) +  'px';
			subMenu.style.top  = getOffsetTop( topnavid ) + 'px';
		}
		//	Menus below (default)
		else
		{
			subMenu.style.left = getOffsetLeft( topnavid ) + 'px';
			subMenu.style.top  = ( getOffsetTop( topnavid ) + getOffsetHeight( topnavid )) + 'px';
		}
	}

	if ((mainMenu != subMenu) && (item != 0))
	{
		subMenu.style.visibility	= "visible";
		for (i = 1; i <= menuCount; i++)
		{
			if (i != item)
			{
				document.getElementById("m" + group + i).style.visibility	= "hidden";
			}
		}
	}

	//	Get ID of parent item
	pid	= 'p' + group + item;

	//	Highlight the parent item
	tmpClassName	= document.getElementById( pid ).className;
	document.getElementById( pid ).setAttribute( "tmpClassName", tmpClassName )

	document.getElementById( pid ).className	= 'highlight';

	//	Make sure it gets displayed
	subMenu.style.display	= "block";
}

//-------------------------------------------------------------------------------------------------------
//	Hide menu
//-------------------------------------------------------------------------------------------------------
function hideSlide(group,item,imgId,imgBase)
{
	if( !document.getElementById )
	{
		return;
	}

	isActive = false;
	
	menuCount	= eval("m_" + group);

	//	Does object exist?
	if( !document.getElementById( "m" + group + menuCount ))
	{
		//	No, don't process
		return false;
	}
	
	if( imgId != 'NULL' )
	{
		imgObj	= document.getElementById( imgId );
		imgObj.setAttribute( 'base', imgBase );
		imgObj.setAttribute( 'src', imgBase );
	}
	
	if (item == 0)
	{
		startFrom	= 0;
	}
	else
	{
		startFrom	= 1;
	}
	for (i = startFrom; i <= menuCount; i++)
	{
		document.getElementById("m" + group + i).style.visibility	= "hidden";

		//	Get ID of parent item
		pid	= 'p' + group + i;

		tmpClassName	= document.getElementById( pid ).getAttribute( "tmpClassName" );
		curClassName	= document.getElementById( pid ).className;
		
		//	Determine new class name (to show arrow for submenus or not)
		if( tmpClassName == "showsub" || curClassName == "showsub" )
		{
			newClassName	= "showsub";
		}
		else
		{
			newClassName	= "";
		}
		
		//	un-Highlight the parent item
		if( document.getElementById( pid ) )
		{
			document.getElementById( pid ).className	= newClassName;
		}
	}
}

//   lixlpixel tooltips     © 2005 http://lixlpixel.com/  //
////////////////////////////////////////////////////////////
// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;										  //
var offsety =  8;										  //
////////////////////////////////////////////////////////////
function newelement(newid)
{ 
	
	if(document.createElement)
	{ 
		var el = document.createElement('div'); 
		el.id = newid;     
		with(el.style)
		{ 
			display = 'none';
			position = 'absolute';
		} 
		el.innerHTML = '&nbsp;'; 
		document.body.appendChild(el); 
	} 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e) // thanks to Grant O. Anderson from Arizona State University
{
	if(document.getElementById)
	{
		var iebody=(document.compatMode && 
			document.compatMode != 'BackCompat') ? 
				document.documentElement : document.body;
		pagex = (isapple == 1 ? 0 : (ie5)?iebody.scrollLeft:window.pageXOffset);
		pagey = (isapple == 1 ? 0 : (ie5)?iebody.scrollTop:window.pageYOffset);
		mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
		mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

		var lixlpixel_tooltip = document.getElementById('tooltip');
		lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
		lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
	}
}
function tooltip(tipdiv)
{
	var tip = document.getElementById(tipdiv).innerHTML;

	if(!document.getElementById('tooltip')) newelement('tooltip');
	
	var lixlpixel_tooltip = document.getElementById('tooltip');
	lixlpixel_tooltip.innerHTML = tip;
	lixlpixel_tooltip.style.display = 'block';
	document.onmousemove = getmouseposition;
}
function ttexit()
{
	document.getElementById('tooltip').style.display = 'none';
}
/////////////////////// end tooltips ///////////////////////


//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
//#########################################################################################################
//
//	Public AJAX functions
//
//#########################################################################################################

//---------------------------------------------------------------------------------------------------------
//	Load an object dynamiclly with a source page
//---------------------------------------------------------------------------------------------------------
function loadDivContents( url, div )
{
	objNumber = 0;
	
	//	Have we used the div object before?
	for( i=1; i<= HTTPObjects.length; i++ )
	{
		if (HTTPObjects[i] == div)
		{
			objNumber = i
		}
	}

	//	Not found?
	if(!objNumber)
	{
		objNumber				= HTTPObjects.length;
		HTTPObjects[objNumber]	= div;
	}

	//	Generate the div object pointer
	var divObj = eval( 'document.getElementById("' + div + '");' );
	
	eval( 'http' + objNumber + ' = initHTTPObject();' );
	eval( 'if (!http' + objNumber + '){window.location=\'/site/compatability.php\';}' );
	eval( 'http' + objNumber + '.open("GET", url, true );');
	eval( 'http' + objNumber + '.onreadystatechange = function() { if (http' + objNumber + '.readyState == 4) {divObj.innerHTML = http' + objNumber + '.responseText;}};');
	eval( 'http' + objNumber + '.send(null);');
}

//---------------------------------------------------------------------------------------------------------
//	Submit a webtop form inline inisde a container
//---------------------------------------------------------------------------------------------------------
function PostFormInline( formname, processurl, div, updatepage )
{
	objNumber = 0;
	
	//	Have we used the div object before?
	for( i=1; i<= HTTPObjects.length; i++ )
	{
		if (HTTPObjects[i] == div)
		{
			objNumber = i
		}
	}

	//	Not found?
	if(!objNumber)
	{
		objNumber				= HTTPObjects.length;
		HTTPObjects[objNumber]	= div;
	}

	//	Generate the div object pointer
	var divObj = eval( 'document.getElementById("' + div + '");' );
	
	//	Get the fields
	eval( 'string = compileAllFieldValues( document.forms.' + formname + ' );');
	
	eval( 'http' + objNumber + ' = initHTTPObject();' );
	eval( 'http' + objNumber + '.onreadystatechange = function() { if (http' + objNumber + '.readyState == 4) {divObj.innerHTML = http' + objNumber + '.responseText;if(updatepage){updatePage();}}};');
	eval( 'http' + objNumber + '.open("POST", "' + processurl + '", true );');
	eval( 'http' + objNumber + '.setRequestHeader("Content-Type","application/x-www-form-urlencoded");');
	eval( 'http' + objNumber + '.send(string);');
	
	return false;
}

//#########################################################################################################
//
//	Private AJAX functions
//
//#########################################################################################################

//---------------------------------------------------------------------------------------------------------
//	Define the elements
//---------------------------------------------------------------------------------------------------------
var HTTPObjects = Array();	//	Track all the used HTTP objects on the page
var objNumber   = null;

//---------------------------------------------------------------------------------------------------------
//	Initialize a new HTTP object
//	PRIVATE
//---------------------------------------------------------------------------------------------------------
function initHTTPObject() 
{
	var xmlhttp;
	
	try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
 	 	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
			xmlhttp = false;
 		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
  			xmlhttp = new XMLHttpRequest();
		} catch (e) {
  			xmlhttp = false;
		}
	}

	return xmlhttp;
}

$(document).ready(function(){

    $('input#name,input#email').each(function(){
        var obj = $(this);
        obj.data('orig_text', obj.val())
        .focus(function(){
            obj.select();
        })
        .blur(function(){
            if(!obj.val()) {
                obj.val( obj.data('orig_text') );
            }
        });
    });

    (function(){
        var signupsuffix = $('#signupsuffix');
        if(signupsuffix.length > 0) {
            var box = $('#subscribe-box-container');
            var slide_up_amt = signupsuffix.offset().top + signupsuffix.outerHeight() - box.offset().top + 10;
            $('#subscribe-link').click(function(){
                $(this).hide();
                box.css({
                    backgroundColor: 'white',
                    marginBottom: '10px',
                    height: '140px'
                });
                box.animate( {
                    marginTop: slide_up_amt + 'px'
                }, 1000);
                return false;
            }); 
        }
    })();

    $('.web20box a.sharelink').each(function(){
        var share_link = $(this);
        share_link.toggle( 
            function(){
                share_link.parents('.web20box').toggleClass('web20box-expanded').find('.buttons').show();
                return false;
            },
            function(){
                share_link.parents('.web20box').toggleClass('web20box-expanded').find('.buttons').hide();
                return false;
            }
        );

    });

    function start_rotation( elem ) {
        var index = 0;
        var images = elem.data('images');
        var elem = $(elem);

    }

});






