// ActionScript Document
$(document).ready(function(){
						   
	if( (tabsetId2 != '') && (taborderId2 != '') )
	{
		switchToTab(tabsetId2, taborderId2)
	}
	// setting page tabs
	if( (tabsetId3 != '') && (taborderId3 != '') )
	{
		switchToTab(tabsetId3, taborderId3)
	}

// --- Help boxes
	$("a.help_Box").click(function() {
		var id = $( this ).attr('id');
		$("div#toggle_" + id).toggle();
		return false; // stop browser scrolling on click
	});

	// on tab click
	$(".tabnav li a").click( function() { 
		$("div.toggle_helpBox").fadeOut('fast'); // close all help boxes
		var tabId = $( this ).parents("div").attr('id');
		$( this ).blur();  // this remove dots when tab is clicked
		$( "#" + tabId + " div.tabBody" ).hide();
		$("#" + tabId + " ul li a").removeClass("active");
		$( this ).addClass("active");

		$("div#body_" + $( this ).attr('id')).fadeIn('fast');
		return false; // stop scrolling page
	} );

	$("#quickSearchForm").submit( function() {
		$("#quickSearchForm").attr({action:"" + gRelativeRoot + $("#quickSearchType").val()});
	});
    
    /* we also want to keep member filter and page*/
	$.post(gRelativeRoot + "user/setRelationFlag.php", {f:filter,o:offset}, function(data){ 
        $( "#getNbrMember" ).html(data); 
        $("#nbrMember").html($( "#getNbrMember div#nbrMemberX").html());
        $( "#memberNotepad" ).html(data); 

	});
	// alert("page loaded");
	
	// toggle removing confirmation
	$("a.remove").click(function() {
		$("div.removeBox").hide();
		$("div#box_" + $( this ).attr('id')).toggle();
		return false; // stop browser scrolling on click
	});

	// we change the sort by on membership search result page
	$("#memberSortBy").change(function() {
		document.location = './?' + paramForOrderBy + '&memberSortBy=' + $("#memberSortBy").val();
	});

	// for language filtrer on micro site page
	$("#SearchCommunityType, #sort").change(function() {
		var sortByValue = $("#sort").val();
		if(sortByValue == undefined)
		{
			sortByValue = '';
		}
		var filtrerValue = $("#SearchCommunityType").val();
		if(filtrerValue == undefined)
		{
			filtrerValue = '';
		}
		
		document.location = './?sort=' + sortByValue + '&SearchCommunityType=' + filtrerValue;
	});


	if( (tabsetId != '') && (taborderId != '') )
	{
		switchToTab(tabsetId, taborderId)
	}
	
	// update networks notepad
	$.post(gRelativeRoot + "bookmarks/getNotepadBookmarks.php", {m:MemberId,l:language,o:offset}, function(data){
		$("#bookmark").html(data);
		$("#setNbrBookmarks").html($( "#bookmark div#nbrNetworksX").html());
	});
	
	$(".bookmarkMe").click(function() {
		elem = this;
		$.post(gRelativeRoot + "bookmarks/getNotepadBookmarks.php", {m:MemberId,l:language,o:offset,s:$( this ).attr('id')}, function(data){
			$( elem ).parent("span").html('<strong>'+saved+'<\/strong>');
			$( "#bookmark" ).html(data);
			$( "#memberNotepad" ).html(data);
			$("#setNbrBookmarks").html($( "#bookmark div#nbrNetworksX").html());
		});
		return false;
	});
});


function switchToTab(tabSetId, tabId)
{
	$( "#" + tabSetId + " div.tabBody" ).hide();
	$( "#" + tabSetId + " ul li a").removeClass("active");
    $( "#" + tabId ).addClass("active");
    $( "div#body_" + $( "#" + tabId ).attr('id')).show();
	return false; // stop scrolling page
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- John Munn  (jrmunn@home.com) -->

<!-- Begin
function putFocus(formInst, elementInst) {
	if (document.forms.length > 0) {
		document.forms[formInst].elements[elementInst].focus();
	}
}
// The second number in the "onLoad" command in the body
// tag determines the form's focus. Counting starts with '0'
//  End -->

function randomString()
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++)
	{
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function submitform(theForm)
{
	theForm.onsubmit();
	theForm.submit();
}

document.onkeydown = dockeydown; 

function dockeydown(k)
{
	//alert(k.which)	
}


function switchLang(l, arrayParams)
{
	var params = ''; 
	for (var cle in arrayParams)
	{
		params += '&' + cle + '=' + arrayParams[cle];
	}
	document.location = "./?l=" + l + params;
	
	return true;
}


function switchSorting(value, page)
{
	document.location = "../" + page + "/?searching=1&sort=" + value;
	
	return true;
}


