function selectInboxTab(id, link, sessionId) 
{
    var ajax = new Ajax(); 

    if ( id == "chat" ) 
    {
        document.getElementById( "chat" ).style.display = "";
        document.getElementById( "message" ).style.display = "none";
        ajax.post( "../include/inbox_tab_session.php", null, [ ["sessionId", sessionId], ["tab_selection", "chat"] ] ); 
    } 
    else if ( id == "message" ) 
    {
        document.getElementById( "chat" ).style.display = "none";
        document.getElementById( "message" ).style.display = "";
        ajax.post( "../include/inbox_tab_session.php", null, [ ["sessionId", sessionId], ["tab_selection", "message"] ] );
    }
}

function toggleSection_main_newsfeed( id, link, sessionId ) 
{
    var ajax = new Ajax();
    var item = document.getElementById( id );
    
    if ( item.style.display == "none" ) 
    {                                           
        ajax.post( "../include/inbox_tab_session.php", null, [ ["sessionId", sessionId], ["news_feed", "open"] ] ); 
        item.style.display = "";                                     
    } 
    else 
    {
        ajax.post( "../include/inbox_tab_session.php", null, [ ["sessionId", sessionId], ["news_feed", "close"] ] ); 
        item.style.display = "none";
    }
}

/* Added because of problem calling toggle() directly (possible name conflict) */
function toggleElement( id ) {
	toggle( id );
}
function toggle( id ) 
{
    var item = document.getElementById( id );
	if ( item.style.display == "none" ) 
    {
		item.style.display = "";
	} 
    else 
    {
		item.style.display = "none";
	}
}
function toggle2( id ) 
{
    var item = document.getElementById( id );
    if ( item.style.display == "none" ) 
    {
        item.style.display = "";
    } 
    else 
    {
        item.style.display = "none";
    }
}

function selectCountry( countryCode, prefix ) {
	if ( countryCode == "US" ) {
		document.getElementById( prefix + "_state" ).style.display = "";
		document.getElementById( prefix + "_region" ).style.display = "none";
	} else {
		document.getElementById( prefix + "_state" ).style.display = "none";
		document.getElementById( prefix + "_region" ).style.display = "";
	}
}

function toggleDialog( id ) {
	var back = document.getElementById( "blur" );
	var item = document.getElementById( id );
	if ( item.style.display == "none" ) {
		item.style.display = "";
		if ( document.documentElement ) {
			item.style.left = ( document.documentElement.clientWidth - item.offsetWidth ) / 2;
			item.style.top = ( document.documentElement.clientHeight - item.offsetHeight ) / 2 + document.documentElement.scrollTop;
			back.style.height = screen.height + document.documentElement.scrollTop;
		} else {
			item.style.left = ( document.body.clientWidth - item.offsetWidth ) / 2;
			item.style.top = ( document.body.clientHeight - item.offsetHeight ) / 2 + document.body.scrollTop;
			back.style.height = screen.height + document.body.scrollTop;
		}
		back.style.zIndex = 1;
		back.style.width = "100%";
		back.style.backgroundColor = "#ffffff";
	} else {
		back.style.width = 1;
		back.style.height = 1;
		item.style.display = "none";
		back.style.zIndex = -1;
	}
}

function selectMemberTab( id ) 
{
    var member_online = document.getElementById( "member_online" );
    var member_new = document.getElementById( "member_new" );
    if ( id == "member_online" ) 
    {
        member_online.style.display = "";
        member_new.style.display = "none";
    } 
    else if ( id == "member_new" ) 
    {
        member_online.style.display = "none";
        member_new.style.display = "";
    }
}

function showMembers(m_start) 
{
    var ajax = new Ajax();
    ajax.post2html( SYSTEM_URL + "/main/edit_members.php", "member_online", [
        ["mode", "m_online"],
        ["action", "show"],
        ["start", encodeURI(m_start)] 
    ] );
}

function showMembers_new(n_start) 
{                          
    var ajax = new Ajax();
    ajax.post2html( SYSTEM_URL + "/main/edit_members.php", "member_new", [
        ["mode", "m_new"],
        ["action", "show"],
        ["start", encodeURI( n_start )] 
    ] );
}

function showGroups_featured(gr_start) 
{
    var ajax = new Ajax();
    ajax.post2html( SYTEM_URL + "/main/edit_members.php", "right_featured_group", [
        ["mode", "gr_featured"],
        ["action", "show"],
        ["start", encodeURI( gr_start )] 
    ] );
}

function showAsianlifeEvent(ev_start) 
{
    var ajax = new Ajax();
    ajax.post2html( SYSTEM_URL + "/main/edit_members.php", "right_featured_asianevent", [
        ["mode", "event_featured"],
        ["action", "show"],
        ["start", encodeURI( ev_start )] 
    ] );
}

function showHeadBanner(banner_no) 
{
    var ajax = new Ajax();
    ajax.post2html( "../main/edit_members.php", "main_banner", [
        ["mode", "main_banner"],
        ["action", "show"],
        ["banner_no", encodeURI( banner_no )] 
    ] );
}

function showMoveEvent(move_date) 
{
    var ajax = new Ajax();
    ajax.post2html( "../main/edit_members.php", "org_event_calendar", [
        ["mode", "org_event_calendar"],
        ["action", "show"],
        ["move_date", encodeURI( move_date )] 
    ] );
}

//Group Browser
function showGroupBrowserTabs(section, section_p, tab_status, id, id2) 
{
    //Tab Section
    var ajax = new Ajax();
    ajax.post2html( "../meetpeople/edit_meetpeople_browser.php", "group_browser", [
        ["mode", "group_browser"],
        ["action", "show"],
        ["section", encodeURI( section )],
        ["section_p", encodeURI( section_p )],
        ["tab_status", encodeURI( tab_status )]
 
    ] );
     //Control Search Box
    var item_gs = document.getElementById( id );
    var item_ps = document.getElementById( id2 );
    
    if(tab_status == "g")
    {
        item_gs.style.display = "";
//        item_ps.style.display = "none";
    }
    else if(tab_status == "p")
    {
//        item_gs.style.display = "none";
        item_ps.style.display = "";
    }
}

//LOGIN - CHECK
function loginEmailCheck( login_id, email_form, session_id ) 
{   
    //var email_id = document.getElementById( email_form );  
    var ajax = new Ajax();
    ajax.post2html( "ems_ajax.php", "registration_form", [
        ["mode", "check"],
        ["login_id", encodeURI( login_id )],
        ["email_id", encodeURI( email_id )],
        ["sessionId", encodeURI( session_id )]  
    ] );
    
}

/**
* Function to stop the processing for a given event so the browser doesn't follow through.
* This is useful for nested onclick events.
*/
function stopEvent( event ) {
	if ( !event ) var event = window.event;
	event.cancelBubble = true;	
	if ( event.stopPropagation ) event.stopPropagation();
}

function notARegularMember( link, redirect ) {
	alert( "You must be a registered member at AsianLife.com to do this.  Please log in or register now if you are not already a member." );
	url = SYSTEM_URL + "/main/signup_notice.html";
	if ( link ) url+= "?link=" + encodeURI( link );
	if ( redirect ) window.location = url;
}

function notAnEmployerMember( link, redirect ) {
	alert( "You must be a registered employer member at AsianLife.com to do this.  Please log in or register now if you don't already have an employer account." );
	url = SYSTEM_URL + "/main/signup_notice.html";
	if ( link ) url+= "?link=" + encodeURI( link );
	if ( redirect ) window.location = url;
}


