/*
This lib for cross browser handling taken from http://www.alistapart.com/articles/popuplinks
extended version is at http://v2studio.com/k/code/lib/


ARRAY EXTENSIONS

push(item [,...,item])
    Mimics standard push for IE5, which doesn't implement it.


find(value [, start])
    searches array for value starting at start (if start is not provided,
    searches from the beginning). returns value index if found, otherwise
    returns -1;


has(value)
    returns true if value is found in array, otherwise false;
	

FUNCTIONAL

map(list, func)
    traverses list, applying func to list, returning an array of values returned
    by func

    if func is not provided, the array item is returned itself. this is an easy
    way to transform fake arrays (e.g. the arguments object of a function or
    nodeList objects) into real javascript arrays.

    map also provides a safe way for traversing only an array's indexed items,
    ignoring its other properties. (as opposed to how for-in works)

    this is a simplified version of python's map. parameter order is different,
    only a single list (array) is accepted, and the parameters passed to func
    are different:
    func takes the current item, then, optionally, the current index and a
    reference to the list (so that func can modify list)


filter(list, func)
    returns an array of values in list for which func is true

    if func is not specified the values are evaluated themselves, that is,
    filter will return an array of the values in list which evaluate to true

    this is a similar to python's filter, but parameter order is inverted


DOM

getElem(elem)
    returns an element in document. elem can be the id of such element or the
    element itself (in which case the function does nothing, merely returning
    it)

    this function is useful to enable other functions to take either an    element
    directly or an element id as parameter.

    if elem is string and there's no element with such id, it throws an error.
    if elem is an object but not an Element, it's returned anyway


hasClass(elem, className)
    Checks the class list of element elem or element of id elem for className,
    if found, returns true, otherwise false.

    The tested element can have multiple space-separated classes. className must
    be a single class (i.e. can't be a list).


getElementsByClass(className [, tagName [, parentNode]])
    Returns elements having class className, optionally being a tag tagName
    (otherwise any tag), optionally being a descendant of parentNode (otherwise
    the whole document is searched)


DOM EVENTS

listen(event,elem,func)
    x-browser function to add event listeners

    listens for event on elem with func
    event is string denoting the event name without the on- prefix. e.g. 'click'
    elem is either the element object or the element's id
    func is the function to call when the event is triggered

    in IE, func is wrapped and this wrapper passes in a W3CDOM_Event (a faux
    simplified Event object)


mlisten(event, elem_list, func)
    same as listen but takes an element list (a NodeList, Array, etc) instead of
    an element.


W3CDOM_Event(currentTarget)
    is a faux Event constructor. it should be passed in IE when a function
    expects a real Event object. For now it only implements the currentTarget
    property and the preventDefault method.

    The currentTarget value must be passed as a paremeter at the moment    of
    construction.


MISC CLEANING-AFTER-MICROSOFT STUFF

isUndefined(v)
    returns true if [v] is not defined, false otherwise

    IE 5.0 does not support the undefined keyword, so we cannot do a direct
    comparison such as v===undefined.
*/

// ARRAY EXTENSIONS

if (!Array.prototype.push) Array.prototype.push = function() {
    for (var i=0; i<arguments.length; i++) this[this.length] = arguments[i];
    return this.length;
}

Array.prototype.find = function(value, start) {
    start = start || 0;
    for (var i=start; i<this.length; i++)
        if (this[i]==value)
            return i;
    return -1;
}

Array.prototype.has = function(value) {
    return this.find(value)!==-1;
}

// FUNCTIONAL

function map(list, func) {
    var result = [];
    func = func || function(v) {return v};
    for (var i=0; i < list.length; i++) result.push(func(list[i], i, list));
    return result;
}

function filter(list, func) {
    var result = [];
    func = func || function(v) {return v};
    map(list, function(v) { if (func(v)) result.push(v) } );
    return result;
}


// DOM

function getElem(elem) {
    if (document.getElementById) {
        if (typeof elem == "string") {
            elem = document.getElementById(elem);
            if (elem===null) throw 'cannot get element: element does not exist';
        } else if (typeof elem != "object") {
            throw 'cannot get element: invalid datatype';
        }
    } else throw 'cannot get element: unsupported DOM';
    return elem;
}

function hasClass(elem, className) {
    return getElem(elem).className.split(' ').has(className);
}

function getElementsByClass(className, tagName, parentNode) {
    parentNode = !isUndefined(parentNode)? getElem(parentNode) : document;
    if (isUndefined(tagName)) tagName = '*';
    return filter(parentNode.getElementsByTagName(tagName),
        function(elem) { return hasClass(elem, className) });
}


// DOM EVENTS

function listen(event, elem, func) {
    elem = getElem(elem);
    if (elem.addEventListener)  // W3C DOM
        elem.addEventListener(event,func,false);
    else if (elem.attachEvent)  // IE DOM
        elem.attachEvent('on'+event, function(){ func(new W3CDOM_Event(elem)) } );
        // for IE we use a wrapper function that passes in a simplified faux Event object.
    else throw 'cannot add event listener';
}

function mlisten(event, elem_list, func) {
    map(elem_list, function(elem) { listen(event, elem, func) } );
}

function W3CDOM_Event(currentTarget) {
    this.currentTarget  = currentTarget;
    this.preventDefault = function() { window.event.returnValue = false }
    return this;
}

// MISC CLEANING-AFTER-MICROSOFT STUFF
function isUndefined(v) {
    var undef;
    return v===undef;
}

//<--lib ends

//Our functions starts....

//Open popup. Can be called directly
function Popup(url, target, features)
{
	var theWindow = window.open(url, target, features);
	theWindow.focus();
	return theWindow;
}
//Holder for Popup(). As it's to be registered with event listener
function PopupHolder(e)
{
	Popup(e.currentTarget.getAttribute('href'), e.currentTarget.getAttribute('target') || J_POPUP_TARGET, J_POPUP_FEATURES);
	e.preventDefault();
}
//show balloon. Can be called directly
function ShowBalloon(objA, x, y)
{
	gTmp_ATitle = objA.title; //preserve the title in global var
	objA.title = ''; //empty it, so that it won't popup
	var tmp_title = 'Help', tmp_desc = gTmp_ATitle, pos_colon; //safe init
	//e.g., gTmp_ATitle = 'Help: Help is a help...'
	if ((pos_colon=gTmp_ATitle.indexOf(':')) !=-1 )
		{
			tmp_title = gTmp_ATitle.substring(0, pos_colon);
			tmp_desc = gTmp_ATitle.substring(pos_colon+1);
		}
	var balloon = document.getElementById(J_BALLOON);
	balloon.className = J_CLSBALLOON;
	balloon.style.display = 'inline';
	balloon.style.width = J_BALLOONWIDTH + 'px';
	balloon.style.top = y + 'px';
	balloon.style.left = x + 'px';
	balloon.innerHTML = '<span class="' + J_CLSBALLOONTITTLE + '">'+ tmp_title +'<\/span><div class="' + J_CLSBALLOONDESC + '">'+ tmp_desc + '<\/div>';
	return true;
}
//Holder for ShowBalloon(). As it's to be registered with event listener
function ShowBalloonHolder(e)
{
	var posx = 0, posy = 0;
	if (e.pageX || e.pageY) //Moz
		{
			posx = e.pageX;
			posy = e.pageY;
		}
	 else if (event.clientX || event.clientY) //IE. Note: event.x not working fine
		{
			posx = event.clientX + document.body.scrollLeft;
			posy = event.clientY + document.body.scrollTop;
		}
	//Note: using the x, y as it is cause the div to flicker in certain border points in FF (IE, Opera works find).
	ShowBalloon(e.currentTarget, posx+J_BALLOONPOSADJX, posy+J_BALLOONPOSADJY);
	e.preventDefault();
}
//Hides balloon.
function HideBalloon(objA)
{
	var balloon = document.getElementById(J_BALLOON);
	balloon.style.display = 'none';
	objA.title = gTmp_ATitle; //re-assign
}
//Holder for HideBaloon. As it's to be registered with event listener
function HideBalloonHolder(e)
{
	HideBalloon(e.currentTarget);
	e.preventDefault();
}

//code execution starts here...

//global vars
var gTmp_ATitle; //temp variable to hold and swap title attributes
//global constants. Used to change behaviors quickly
//presumably IE doesn't support const on strings
var J_BALLOON = 'balloon'; //balloon id
var J_CLSHELP = 'clsHelp';
var J_CLSBALLOON = 'clsBalloon';
var J_CLSBALLOONTITTLE = 'clsBalloonTittle';
var J_CLSBALLOONDESC = 'clsBalloonDesc';
var J_BALLOONPOSADJX = 10;
var J_BALLOONPOSADJY = 10;
var J_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=400,height=300,top=200,left=200';
var J_POPUP_TARGET = 'help';
var J_BALLOONWIDTH = 160;

listen('load',
		window,
		function()
		{
			//create balloon div...
			var balloon = document.createElement('div');
			balloon.id = J_BALLOON;
			document.body.appendChild(balloon);
			//listen...
			mlisten('mouseover', getElementsByClass(J_CLSHELP,'a'), ShowBalloonHolder);
			mlisten('mouseout', getElementsByClass(J_CLSHELP,'a'), HideBalloonHolder);
			mlisten('click', getElementsByClass(J_CLSHELP,'a'), PopupHolder);
		}
	);

//	====Need cssQuery and Behaviour====

/**
 * @author		rajesh_04ag02
 * @copyright	Copyright (c) 2005-2006 {@link http://www.agriya.com Agriya Infoway}
 * @version		SVN: $Id: script.js 521 2006-09-29 04:35:55Z rajithn_46ag05 $
 * @todo		Possibly replace help tips' libs with Behaviour
 */

//oh my, holy hack http://groups.google.com/group/comp.lang.javascript/msg/923c83ebf78b818a
//CSS2 browsers require 'table-row-group' to display tbody tag properly
//Note: if IE display.style is set to 'table-row-group', it will bug with "Error: Could not get the display property. Invalid argument."
var display_tbl_block = (document.all) ? 'block' : 'table-row-group';
var catch_rules =
	{
		//for admin/depositPlans.php toggling of options...
		'#adminuserProfilesEdit #usr_status' : function(element)
		{
			document.getElementById("activate_user_block").style.display = (element.value=="0-Ok") ? display_tbl_block : 'none';
			//onchange show it only for appropriate values...
			element.onchange = function()
			{
				document.getElementById("activate_user_block").style.display = (this.value=="0-Ok") ? display_tbl_block : 'none';
			}
		}
	};
//Behaviour.register(catch_rules);

//set the Email id to parent window through select from the child window
	function setEmailString(frmName, parentId, objName, typeName, charLength, parentMemberNameId, parentMemberCustID, extractName)
		{

			var frmObj = document.forms[frmName];
			var len = frmObj.elements.length;
			var custName = document.getElementsByName(extractName);
			var emailCustid = '';
			var emailName = '';

			for(i=0; i < len; i++) //>
				{
				 	varName = frmObj.elements[i].name;
				 	subName = varName.substring(0,charLength);
				 	if (subName == objName && frmObj.elements[i].type == typeName  && frmObj.elements[i].checked == true)
				 		{
				 			extractNameID = extractName+ '['+frmObj.elements[i].value +']';
							if (emailName == '')
								emailName = frmObj.elements[extractNameID].value;
							else
								emailName += ','+ frmObj.elements[extractNameID].value;


							if (emailCustid == '')
								emailCustid = frmObj.elements[i].value;
							else
								emailCustid += ','+ frmObj.elements[i].value;
						}
				 }

			window.opener.document.forms[parentId].elements[parentMemberNameId].value = emailName;
			window.opener.document.forms[parentId].elements[parentMemberCustID].value = emailCustid;
			window.opener.focus();
			window.close();
		}
function popupOldData(parentId, elementId, objName, frmName, previousElement)
	{

		listValue = window.opener.document.forms[parentId].elements[elementId].value;
		listValueArr = listValue.split(',');
		objectArr = document.getElementsByName(objName);
		listValueCnt = listValueArr.length;
		objectCnt = objectArr.length;
		for(i=0; i<= listValueCnt; i++)
			{
				for(j=0; j< objectCnt; j++)
					{
						if (listValueArr[i] == objectArr[j].value )
							objectArr[j].checked = true;
					}
			}

		len = document.forms[frmName].elements.length;
		for(i=0; i< len; i++)
			{
				if (document.forms[frmName].elements[i].name == previousElement)
					document.forms[frmName].elements[i].value = listValue;
			}
	}
function searchAlpha( frmName, elementName, val, changeName)
	{
		len = document.forms[frmName].elements.length;
		for(i=0; i< len; i++)
			{
				if (document.forms[frmName].elements[i].name == elementName)
					document.forms[frmName].elements[i].value = val;
				if (document.forms[frmName].elements[i].name == changeName)
					document.forms[frmName].elements[i].value = 1;
			}
		document.forms[frmName].submit();
	}

function PopupMembers(url)
{
	var theWindow = window.open(url,'members','height=400,width=760');
	theWindow.focus();
	return theWindow;
}

function PopupProfile(url)
{
	var theWindow = window.open(url,'userprofile','height=500,width=800,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}

function PopupPm(url)
{
	var theWindow = window.open(url,'Message','height=550,width=750,scrollbars=auto');
	theWindow.focus();
	return theWindow;
}

function PopProfileView(url)
{
	var theWindow = window.open(url,'Profile','height=700,width=1000,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}

function PopupNetwork(url)
{
	var theWindow = window.open(url,'Message','height=500,width=550,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}

function PopupEditForum(url)
{
	var theWindow = window.open(url,'editforum','height=500,width=700,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}

function PopupAbuse(url)
{
	var theWindow = window.open(url,'abuse','height=325,width=425');
	theWindow.focus();
	return theWindow;
}

function PopupDetachForum(url)
{
	var theWindow = window.open(url,'detachforum','height=700,width=400,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
function PopupAdminDetach(url)
{
	var theWindow = window.open(url,'detachforum','height=700,width=700,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
// called in composeMessage.php, replyMessage.php, forwardMessage.php
function PopupInsertAddress(url)
{
	var theWindow = window.open(url,null,'height=1000,width=400,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
function PopupConnection(url)
{
	var theWindow = window.open(url,null,'height=500,width=800,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
function PopUpLogin(url)
{
	var theWindow = window.open(url,'login','height=500,width=500,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
function PopUpUsage(url)
{
	var theWindow = window.open(url,'login','height=500,width=500,scrollbars=yes');
	theWindow.focus();
	return theWindow;
}
function PopUpUsageFull(url)
{
	var theWindow = window.open(url,'full','');
	theWindow.focus();
	return theWindow;
}
function PopAbuse(url)
{
	var theWindow = window.open(url,'login','');
	theWindow.focus();
	return theWindow;
}
function PopBanner(url)
{
	var theWindow = window.open(url,'login','menubar=no,toolbar=no');
	theWindow.focus();
	return theWindow;
}

function PopupBuySell(url)
{
	url = url +'&id='+Math.random();
	document.getElementById('selBuySellPhoneFrame').src = url;
	document.getElementById('selBuySellContent').style.display = 'block';
}


// Function to select all check boxes
// called in inboxMessages.php, sentMessages.php, savedMessages.php, trashMessages.php
function selectAll(thisForm)
	{
		for (var i=0; i<thisForm.elements.length; i++)
			{
				if (thisForm.elements[i].type == "checkbox")
					{
						if(thisForm.checkall.checked)
							{
								thisForm.elements[i].checked=true;
							}
							else
								{
									thisForm.elements[i].checked=false;
								}
					}
			}
	}
// Funtion to get all selected emails and pass the value to the opener window
// called in composeMessage.php, replyMessage.php, forwardMessage.php
function exit ()
{
	id_to_populate='';
	name_to_populate='';
	id_count = document.getElementsByName('check[]');
	name_count = document.getElementsByName('names[]');
	for (var j = 0; j < id_count.length; j++)
		{
			if(id_count[j].checked)
				{
					id_to_populate =  id_to_populate + id_count[j].value+', ';
					name_to_populate =  name_to_populate + name_count[j].value+', ';
				}
		}
	opener.document.form_show_network.select_id.value = id_to_populate;
	opener.document.form_show_network.select_names.value = name_to_populate;
	self.close();
	return false;
}
// funtion to get the selecte emails to next pages
// called in composeMessage.php, replyMessage.php, forwardMessage.php
function storeSelectedIds()
{
	id_to_populate='';
	name_to_populate='';
	list_to_populate='';
	is_list = document.form_network.lists;
	id_count = document.getElementsByName('check[]');
	name_id_count = document.getElementsByName('names[]');
	for (var j = 0; j < id_count.length; j++)
		{
			if(id_count[j].checked)
				{
					id_to_populate =  id_to_populate + id_count[j].value+', ';
					name_to_populate =  name_to_populate + name_id_count[j].value+', ';
				}

		}
	document.page_nav.previous_selected_ids.value = id_to_populate;
	document.page_nav.previous_selected_names.value = name_to_populate;
	document.form_network.previous_selected_ids.value = id_to_populate;
	document.form_network.previous_selected_names.value = name_to_populate;
	//alert(document.form_network.previous_selected_ids.value);
	//alert(document.form_network.previous_selected_names.value);
}
//Funtion which called storeSelectedIds funtion and then submit the page with given URL
function storeAndSubmit(listval)
{
	storeSelectedIds();
	document.form_network.letter.value = '';
	document.form_network.lists.value = listval;
	//document.page_nav.lists.value = listval;
}
//To setfocus to subject textbox
//Funtions called in composeMessage.php, forwardMessage.php
function setSubjectFocus(thisForm)
{
	thisForm.subject.focus();
}
function showLetter(let)
{
	storeSelectedIds();
	document.form_network.letter.value = let;
	document.page_nav.start.value = 0;
	document.form_network.submit();
}
function PopupBlogSettings(url)
{
	var theWindow = window.open(url,'blogsettings','height=300,width=400');
	theWindow.focus();
	return theWindow;
}
function storeOpenerIds()
{
	document.form_network.previous_selected_ids.value = opener.document.form_show_network.select_id.value;
	document.form_network.previous_selected_names.value = opener.document.form_show_network.select_names.value;
}

// Functions for the PROFILE() in application top


function call_ajax_profile(div_id, count, path)
{
	new AGR_ajax(path,'show_table_profile', div_id);
}
function show_table_profile(data, div_id)
{
	data = unescape(data);
	var obj = document.getElementById(div_id);
//	alert(data);
	obj.innerHTML = data;
}

function changeProfilelayerChat(count, custid)
{
/*
	var parid
	parid = "hiddenIdToClose" + count;
	alert(parid);
	var hidden = document.getElementById(parid);
	alert(hidden);
	hidden.innerHTML = "<input type='hidden' name='closeid' id='closeid' value='"+count+"' />";
	alert(hidden.innerHTML);
	*/
	//popup_blocks_arr = popup_blocks.split(',');
//	var popup_blocks_length = popup_blocks_arr.length;
	//popup_blocks_length = popup_blocks_length;

	//for(var i=0;i<popup_blocks_length;i++)
	//	{
		//	if(obj = document.getElementById('selProfilePopup'+popup_blocks_arr[i]))
			///	{
					//if(obj.style.display=='block')
					//	{
							//obj.style.display='none';
					//	}
				//}
		//}
	//alert(popup_blocks);
	//backgnd effect

	/*var bcgid = document.getElementById("selProfileLayer");
	bcgid.style.MozOpacity = 0.7;
	bcgid.style.Opacity = 0.7;
	bcgid.style.filter = "Alpha(Opacity=70)";*/

	// end
	last_open_popup = 'selProfilePopup'+count;
	var id = "selProfilePopup" + count;
	var c = document.getElementById(id);
	c.innerHTML = "";
	call_ajax_profile('selProfilePopup'+count, count, 'ajaxMemberDetails.php?custid='+custid+'&count='+count);
	var closeid = document.getElementById("closeid");

	if (closeid == null || closeid == undefined)
		{}
	else
	{
		var valclose = closeid.value;
		var id = "selProfilePopup" + valclose;
		var a = document.getElementById(id);
		//alert(a.innerHTML);
		a.style.display = "none";
		id = "hiddenIdToClose" + valclose;
		var hidden = document.getElementById(id);
		hidden.innerHTML = "";

	}
	id = "hiddenIdToClose" + count;
	//alert(id);
	var hidden = document.getElementById(id);
	//alert(hidden);
	c.style.display = "inline";
}


//var last_open_popup = '';
function changeProfilelayer(count, custid)
{
/*
	var parid
	parid = "hiddenIdToClose" + count;
	alert(parid);
	var hidden = document.getElementById(parid);
	alert(hidden);
	hidden.innerHTML = "<input type='hidden' name='closeid' id='closeid' value='"+count+"' />";
	alert(hidden.innerHTML);
	*/
	popup_blocks_arr = popup_blocks.split(',');
	var popup_blocks_length = popup_blocks_arr.length;
	popup_blocks_length = popup_blocks_length;

	for(var i=0;i<popup_blocks_length;i++)
		{
			if(obj = document.getElementById('selProfilePopup'+popup_blocks_arr[i]))
				{
					//if(obj.style.display=='block')
					//	{
							obj.style.display='none';
					//	}
				}
		}
	//alert(popup_blocks);
	//backgnd effect

	/*var bcgid = document.getElementById("selProfileLayer");
	bcgid.style.MozOpacity = 0.7;
	bcgid.style.Opacity = 0.7;
	bcgid.style.filter = "Alpha(Opacity=70)";*/

	// end
	last_open_popup = 'selProfilePopup'+count;
	var id = "selProfilePopup" + count;
	var c = document.getElementById(id);
	c.innerHTML = "";
	call_ajax_profile('selProfilePopup'+count, count, 'ajaxMemberDetails.php?custid='+custid+'&count='+count);
	var closeid = document.getElementById("closeid");

	if (closeid == null || closeid == undefined)
		{}
	else
	{
		var valclose = closeid.value;
		var id = "selProfilePopup" + valclose;
		var a = document.getElementById(id);
		//alert(a.innerHTML);
		a.style.display = "none";
		id = "hiddenIdToClose" + valclose;
		var hidden = document.getElementById(id);
		hidden.innerHTML = "";

	}
	id = "hiddenIdToClose" + count;
	//alert(id);
	var hidden = document.getElementById(id);
	//alert(hidden);
	c.style.display = "inline";
}
function hideProfilelayer(count)
{
	/*var bcgid = parent.document.getElementById("selProfileLayer");
	bcgid.style.MozOpacity = 1;
	bcgid.style.Opacity = 1;
	bcgid.style.filter = "Alpha(Opacity=10)";*/
	id = "hiddenIdToClose" + count;
	var hidden = parent.document.getElementById(id);
	hidden.innerHTML = "";

	var id = "selProfilePopup" + count;
	var a = parent.document.getElementById(id);
	a.style.display = "none";
	a.innerHTML = '';
}
function hideProfilelayerchat(count)
{
	/*var bcgid = parent.document.getElementById("selProfileLayer");
	bcgid.style.MozOpacity = 1;
	bcgid.style.Opacity = 1;
	bcgid.style.filter = "Alpha(Opacity=10)";*/
	id = "hiddenIdToClose" + count;
	var hidden = parent.document.getElementById(id);
	hidden.innerHTML = "";

	var id = "selProfileContent";
	var a = parent.document.getElementById(id);
	a.style.display = "none";
}
function changeProfilesub(a,b)
{
	var id = "selProfileBio"+b;
	var bio = document.getElementById(id);
	id = "selProfileProfession"+b;
	var prof = document.getElementById(id);
	id = "selProfileMacInterest"+b
	var mac = document.getElementById(id);
	id = "selProfileSchools"+b;
	var school = document.getElementById(id);
	//id = "selProfileGroups"+b;
	//var group = document.getElementById(id);
	id = "selProfileBioFull"+b;
	var bioFull = document.getElementById(id);
	id = "selProfileMacInterestFull"+b;
	var macFull = document.getElementById(id);
	id = "selProfileSchoolsFull"+b;
	var schoolFull = document.getElementById(id);
	//id = "selProfileGroupsFull"+b;
	//var groupFull = document.getElementById(id);
	bio.style.display = "none";
	prof.style.display = "none";
	mac.style.display = "none";
	school.style.display = "none";
	//group.style.display = "none";
	bioFull.style.display = "none";
	macFull.style.display = "none";
	schoolFull.style.display = "none";
	//groupFull.style.display = "none";
	if(a == 1)
		bio.style.display = "block";
	else if(a == 2)
		mac.style.display = "block";
	else if(a == 3)
		school.style.display = "block";
	else if(a == 4)
		group.style.display = "block";
	else if(a == 5)
		bioFull.style.display = "block";
	else if(a == 6)
		macFull.style.display = "block";
	else if(a == 7)
		schoolFull.style.display = "block";
	else if(a == 8)
		groupFull.style.display = "block";
	else if(a == 9)
		prof.style.display = "block";
	id = "selInterestNav"+b;
	var nav = document.getElementById(id);
	if((a == 1) || (a == 5))
		{
			nav.innerHTML = "<ul><li class=\"clsProfileBio\" id=\"selActiveProfileLink\" onclick=\"changeProfilesub(1,"+b+");\"><a href=\"javascript: var dummy = 0;\">Bio</a></li><li class=\"clsProfileProfession\" onClick=\"changeProfilesub(9,"+b+");\"><a href=\"javascript: var dummy = 0;\">Education</a></li><li class=\"clsProfileMacInterest\" onclick=\"changeProfilesub(2,"+b+");\"><a href=\"javascript: var dummy = 0;\">Profession</a></li><li class=\"clsProfileSchools\" onclick=\"changeProfilesub(3,"+b+");\"><a href=\"javascript: var dummy = 0;\">Groups</a></li></ul>";
		}
	else if((a == 2) || (a == 6))
		{
			nav.innerHTML = "<ul><li class=\"clsProfileBio\" onclick=\"changeProfilesub(1,"+b+");\"><a href=\"javascript: var dummy = 0;\">Bio</a></li><li class=\"clsProfileProfession\" onClick=\"changeProfilesub(9,"+b+");\"><a href=\"javascript: var dummy = 0;\">Education</a></li><li class=\"clsProfileMacInterest\" id=\"selActiveProfileLink\" onclick=\"changeProfilesub(2,"+b+");\"><a href=\"javascript: var dummy = 0;\">Profession</a></li><li class=\"clsProfileSchools\" onclick=\"changeProfilesub(3,"+b+");\"><a href=\"javascript: var dummy = 0;\">Groups</a></li></ul>";
		}
	else if((a == 3) || (a == 7))
		{
			nav.innerHTML = "<ul><li class=\"clsProfileBio\" onclick=\"changeProfilesub(1,"+b+");\"><a href=\"javascript: var dummy = 0;\">Bio</a></li><li class=\"clsProfileProfession\" onClick=\"changeProfilesub(9,"+b+");\"><a href=\"javascript: var dummy = 0;\">Education</a></li><li class=\"clsProfileMacInterest\" onclick=\"changeProfilesub(2,"+b+");\"><a href=\"javascript: var dummy = 0;\">Profession</a></li><li class=\"clsProfileSchools\" id=\"selActiveProfileLink\" onclick=\"changeProfilesub(3,"+b+");\"><a href=\"javascript: var dummy = 0;\">Groups</a></li></ul>";
		}
	else if((a == 4) || (a == 8))
		{
			nav.innerHTML = "<ul><li class=\"clsProfileBio\" onclick=\"changeProfilesub(1,"+b+");\"><a href=\"javascript: var dummy = 0;\">Bio</a></li><li class=\"clsProfileProfession\" onClick=\"changeProfilesub(9,"+b+");\"><a href=\"javascript: var dummy = 0;\">Education</a></li><li class=\"clsProfileMacInterest\" onclick=\"changeProfilesub(2,"+b+");\"><a href=\"javascript: var dummy = 0;\">Profession</a></li><li class=\"clsProfileSchools\" onclick=\"changeProfilesub(3,"+b+");\"><a href=\"javascript: var dummy = 0;\">Groups</a></li></ul>";
		}
	else if((a == 9))
		{
			nav.innerHTML = "<ul><li class=\"clsProfileBio\" onclick=\"changeProfilesub(1,"+b+");\"><a href=\"javascript: var dummy = 0;\">Bio</a></li><li class=\"clsProfileProfession\" id=\"selActiveProfileLink\" onClick=\"changeProfilesub(9,"+b+");\"><a href=\"javascript: var dummy = 0;\">Education</a></li><li class=\"clsProfileMacInterest\" onclick=\"changeProfilesub(2,"+b+");\"><a href=\"javascript: var dummy = 0;\">Profession</a></li><li class=\"clsProfileSchools\" onclick=\"changeProfilesub(3,"+b+");\"><a href=\"javascript: var dummy = 0;\">Groups</a></li></ul>";
		}
}
var data;
var div_id;
var replace_word = "check||||||||||valid||||||||login";
var find_word = "heck||||||||||valid||||||||login";
function AGR_xml(url, cmd)
	{
		if(url.length<=0 || cmd.length<=0)
			{
				alert("Error: Unable to Found the URL");return false;
			}
		this.url = url;
		this.cmd = cmd;
		this.result = "";
		this.req = null;
		if (window.XMLHttpRequest)
			{
				var req = new XMLHttpRequest();
				if (req.overrideMimeType)
					{
						req.overrideMimeType('text/html');
				 	}
			}
			else if (window.ActiveXObject)
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
		this.req = req;
		return true;
	}

function AGR_post_xml(url,cmd, fieldValues)
	{
		this.output = "NoRecords";
		var x = new AGR_xml(url,cmd);
		x.popen();
		try
			{
				x.req.onreadystatechange = function()
					{
						if (x.req.readyState==4)
							{
								if(x.req.status==200)
									{
										if(x.req.responseText)
											{
												x.result = escape(x.req.responseText);
												x.getOp();
											}
									}
							}
					}
			}
		catch(e){}
		x.psend(AGR_getURI(fieldValues));
		return true;
	}

function AGR_ajax(url,cmd,div_id)
	{
		this.output = "NoRecords";
		var x = new AGR_xml(url,cmd);
		x.opens();
		try
			{
				x.req.onreadystatechange = function()
					{
						if (x.req.readyState==4)
							{
								if(x.req.status==200)
									{
										if(x.req.responseText)
											{
												x.result = escape(x.req.responseText);
												x.getOp(div_id);
											}
									}
							}
					}
			}
		catch(e){}
		x.sends();
	}

AGR_xml.prototype.opens = function()
	{
		this.req.open("GET", this.url, true);
	}

AGR_xml.prototype.sends = function()
	{
		this.req.send(null);
	}

AGR_xml.prototype.popen = function()
	{
		this.req.open("POST", this.url, true);
	}

AGR_xml.prototype.psend = function(p)
	{
		this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		this.req.setRequestHeader("Content-length",p.length);
		this.req.send(unescape(p));
	}

AGR_xml.prototype.getOp=function(div_id)
	{
		if(arguments.length>1)
			{
				//this.cmd = arguments[0];
				//alert(this.cmd+"(\""+this.result+"\",\""+div_id+"\")");
			}
			eval(this.cmd+"(\""+this.result+"\",\""+div_id+"\")");return;
		//eval(this.cmd+"(\""+this.result+"\")");
	}
// START Object created to access the flash to the javascript function START
function thisMovie(movieName)
	{
	  if (navigator.appName.indexOf ("Microsoft") !=-1)
	  	{
	    	return window[movieName]

	  	}
	else
		{
	   		return window.document[movieName]
	  	}
	}
function createJSFCommunicatorObject(playerObj)
	{
		flashCommunicator = new JSFCommunicator(playerObj);
	}

function setHeight(height)
	{
		if (height<450)
			{
				height = 450;
			}
		//alert('height require'+height);
		var flashObj = document.getElementById('selFLashLoading');
		if (flashObj!=null)
			{
				flashObj.style.height = height+'px';
			}
	}

function setContentSize(height)
	{
		dimension = height.split(",")
		height = dimension[0];
		if (dimension[1] != null)
			{
				width = dimension[1];
			}
		else
			{
				width = 630
			}
		if (height<450)
			{
				height = 450;
			}
			/*
		if (width < 630)
			{
			*/
				width = 630;
//			}


		var flashObj = document.getElementById('selFLashLoading');
		if (flashObj!=null)
			{
				flashObj.style.height = height+'px';
				flashObj.style.width = width+'px';
			}
		var flashObj = document.getElementById('selSchduleFlashContainer');
		if (flashObj!=null)
			{
				flashObj.style.height = height+'px';
/*				flashObj.style.width = width+'px';
*/			}
	}

function flashSaveCode(functionname,url)
   {
		//call a function at _level0 of Flash Movie
		//root, functionname , arguments
		flashCommunicator.callFunction("_level0","save",[functionname,url]);
		return;
	}
// END Object created to access the flash to the javascript function  END


function showGoogleMap(title , url)
{
	ShowdivTag('selGoogleMapArea','');
	uri = url + '&custid=' + title;
	var iframeObj = document.getElementById("theLayer");
	iframeObj.src = uri; 
 }

function showNewCompany(title , url, divs, iframes)
{
	ShowdivTag(divs);
	uri = url;
	var iframeObj = document.getElementById(iframes);
	iframeObj.src = uri; 
 }

 function ShowdivTag(id, flag)
{
	var content	= $(id);
	if (flag)
	{
		content.style.left = getAbsoluteOffsetLeft(flag)+'px';
		content.style.top = getAbsoluteOffsetTop(flag)+'px';
	}
	content.style.display = 'inline';
	content.style.zIndex = 1000;
}// EOF ShowdivTag()


function HidedivTag(id)
{
	var content	= $(id);
	content.style.display = 'none';
}// EOF HidedivTag()

function $(id) {
  return document.getElementById(id);
}
 
function FlipFlopDiv(id, rootId, txt, idTxt) {
	
 	if (! $(id))
		return false;
	if(txt == 'portuguese')	{
		var showTxt = 'Mostrar';
		var hideTxt = 'Ocultar';
	}else {
		var showTxt = 'Show';
		var hideTxt = 'Hide';		
	}
		
 	if ($(id).style.display == 'block' || $(id).style.display == 'inline' || $(id).style.display == '') {
		HidedivTag(id);
		if (txt == 'root') 
			$(rootId).innerHTML = 'Expend All';
		
		if ($(id+'Txt')) {
			if (idTxt){				
				if(idTxt==true)
					$(id+'Txt').innerHTML = showTxt;
				else
					$(id+'Txt').innerHTML = showTxt + ' ' +idTxt;								
			}else
				$(id+'Txt').innerHTML = '+';
		}
	}
	else {
		ShowdivTag(id);
		if (txt == 'root') 
			$(rootId).innerHTML = 'Collapse All';

		if ($(id+'Txt')) {			
			if (idTxt)
				if(idTxt==true)
					$(id+'Txt').innerHTML = hideTxt;
				else
				$(id+'Txt').innerHTML = hideTxt + ' ' +idTxt;		
			else
				$(id+'Txt').innerHTML = '-';
		}
	}
}


// Trim function //
function Trim(TRIM_VALUE)
	{
		if(TRIM_VALUE.length < 1)
			{
				return"";
			}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE=="")
			{
				return "";
			}
		else
			{
				return TRIM_VALUE;
			}
	}

function RTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0)
			{
				return"";
			}
		var iTemp = v_length -1;
		while(iTemp > -1)
			{
				if(VALUE.charAt(iTemp) == w_space)
					{
					}
				else
					{
						strTemp = VALUE.substring(0,iTemp +1);
						break;
					}
				iTemp = iTemp-1;

			}
		return strTemp;
	}

function LTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		if(v_length < 1)
			{
				return"";
			}
		var v_length = VALUE.length;
		var strTemp = "";

		var iTemp = 0;

		while(iTemp < v_length)
			{
				if(VALUE.charAt(iTemp) == w_space)
					{
					}
				else
					{
						strTemp = VALUE.substring(iTemp,v_length);
						break;
					}
				iTemp = iTemp + 1;
			}
		return strTemp;
	}
// Trim function //
function showSearchLayer()
    {
		if(document.getElementById('divDefaultMemberSearch').style.display == 'block')
            {
                document.getElementById('divDefaultMemberSearch').style.display = 'none';
            }
        else
            document.getElementById('divDefaultMemberSearch').style.display = 'block';
    }


//Move select box option

function addSelectOption(theSelSrc, theSelDesc, theSelSrc2, theTextWithKey, theSelectedRemove)
{
  var SrcId = $(theSelSrc);   
  for (var Srci=0; Srci < SrcId.options.length; Srci++) {
	  var objOptionadd = true;
 	  if (SrcId.options[Srci].selected)  {
		  var theText = SrcId.options[Srci].text; 
		  var theValue = SrcId.options[Srci].value; 
		   
		  if (theSelSrc2)
		  {
			  var Src2Id = $(theSelSrc2);
			  if (Src2Id.selectedIndex >= 0)  {
				  var theText2 = Src2Id.options[Src2Id.selectedIndex].text; 
				  var theValue2 = Src2Id.options[Src2Id.selectedIndex].value; 
				  
				  theText = theText + ' - ' + theText2;
				  theValue = theValue + ' - ' + theValue2;
			  } else {
				  alert("Please select the source 2 fields");
				  return false;
			  }	 
		  }
		  //For checking the value already added or not...
		  for (var i=0; i < $(theSelDesc).options.length; i++) {		
				if($(theSelDesc).options[i].value == theValue)
					objOptionadd = false;
			}

		  if (objOptionadd)	{
			  if (theTextWithKey == true)
					theText = theValue + " - " + theText;
			  var newOpt = new Option(theText, theValue);
			  var selLength = $(theSelDesc).length;
			  $(theSelDesc).options[selLength] = newOpt;		
		  }
	  }
   }
	
	if (theSelectedRemove){
	   for (var Srci=0; Srci < SrcId.options.length; Srci++) {
		  if (SrcId.options[Srci].selected)  {
				SrcId.options[Srci] = null;
				Srci--;
		  }
		}
	}
}

function deleteSelectOption(theSel, theSelSrc)
{ 
    var selLength = theSel.length; 
	for (var i=0; i < selLength; i++) {
		if (theSel.options[i]) {
			if (theSel.options[i].selected) {
				if (theSelSrc) {
					var selSrcLength = theSelSrc.length; 
					theSelSrc.options[selSrcLength] = new Option(theSel.options[i].text, theSel.options[i].value);
				}
				theSel.options[i] = null; 
				i--;
			}
		}
	}

}

function showGroupInvitation()
    {
		if(document.getElementById('sendgroupinvitation').style.display == 'block')
            {
                document.getElementById('sendgroupinvitation').style.display = 'none';
            }
        else
            document.getElementById('sendgroupinvitation').style.display = 'block';
    }


function showMassInvitation()
    {
		if(document.getElementById('sendmassinvitation').style.display == 'block')
            {
                document.getElementById('sendmassinvitation').style.display = 'none';
            }
        else
            document.getElementById('sendmassinvitation').style.display = 'block';
    }

function getes()
{
	var selLength = document.forminvite.introid2.length;
	for(var i= selLength-1; i >= 0; i--)
	{
	document.forminvite.introid2.options[i].selected='true';
	}
}


function goto1(msg1,msg2,msg3,msg4,msg5,msg6) {

 var a = document.form_search.criteria.value;

	if(a=="Choose")
	 {
		var msg = msg1+"<br />&nbsp;";
		
		//Create Div...
		var confirmBox = document.createElement("div");
		confirmBox.id = "selConfirmMsgDiv";
		confirmBox.className = "widgetWindow";
		confirmBox.style.display = "block";
		confirmBox.style.height="65px";
		confirmBox.style.width="275px"; 
		
		confirmBox.innerHTML += msg;
		
		
		var inputNoButton = document.createElement("input");
		inputNoButton.type = "button";
		inputNoButton.value = msg3;
		inputNoButton.className = "clsSubmitButton";
		inputNoButton.setAttribute('onclick', "javascript:removeElement('selConfirmBox', 'selConfirmMsgDiv');return false;");
		confirmBox.appendChild(inputNoButton);
		
		var infotoDiv = document.getElementById("selConfirmBox");
		infotoDiv.appendChild(confirmBox);
		confirmBox.innerHTML += "</div>";
		return false;	   
	   
	   
	 }
	else
	{ 

		var b = "membersList.php?"+a+"&delete_submit=search_submit";
		
		var msg = "<br />&nbsp;"+msg2;
		
		//Create Div...
		var confirmBox = document.createElement('div');
		confirmBox.id = "selConfirmMsgDiv";
		confirmBox.className = "widgetWindow";
		confirmBox.style.display = 'block';
		confirmBox.style.height="95px";
		confirmBox.style.width="275px"; 
	
		var boxTitle = document.createElement("center");
		boxTitle.innerHTML = msg6;
		confirmBox.appendChild(boxTitle);
		
		confirmBox.innerHTML += msg;
		
		var inputYesButton = document.createElement("input");
		inputYesButton.type = "button";
		inputYesButton.value = msg4;
		inputYesButton.className = "clsSubmitButton";
		inputYesButton.setAttribute('onclick', "javascript:removeElement('selConfirmBox', 'selConfirmMsgDiv');window.location.href='"+ b +"'");
		confirmBox.appendChild(inputYesButton);
		confirmBox.innerHTML += "&nbsp&nbsp";
		
		var inputNoButton = document.createElement("input");
		inputNoButton.type = "button";
		inputNoButton.value = msg5;
		inputNoButton.className = "clsSubmitButton";
		inputNoButton.setAttribute('onclick', "javascript:removeElement('selConfirmBox', 'selConfirmMsgDiv');return false;");
		confirmBox.appendChild(inputNoButton);
		
		var infotoDiv = document.getElementById("selConfirmBox");
		infotoDiv.appendChild(confirmBox);
		confirmBox.innerHTML += "</div>";
		return false;
		
	}
	
}

function goto2(msg,msg1,msg2) {

 if(msg2==''){
 var a = document.form_search.criteria.value;}
 else{
 var a = '';}
 var box = "selConfirmBox";
 
 if(msg2!='')
 {
 	var a = document.form_search.save_name.value;
	var box = "selConfirmBoxes";
 }

	if(a=="Choose" || a=="")
	 {
		msg = "<br />&nbsp;"+msg+"<br />&nbsp;";
		
		//Create Div...
		var confirmBox = document.createElement("div");
		confirmBox.id = "selConfirmMsgDiv";
		confirmBox.className = "widgetWindow";
		confirmBox.style.display = "block";
		confirmBox.style.height="65px";
		confirmBox.style.width="275px"; 
		
		confirmBox.innerHTML += msg;
		
		
		var inputNoButton = document.createElement("input");
		inputNoButton.type = "button";
		inputNoButton.value = msg1;
		inputNoButton.className = "clsSubmitButton";
 		inputNoButton.setAttribute('onclick', "javascript:removeElement('"+box+"', 'selConfirmMsgDiv');return false;");
		confirmBox.appendChild(inputNoButton);
		
		var infotoDiv = document.getElementById(box);
		infotoDiv.appendChild(confirmBox);
		confirmBox.innerHTML += "</div>";
		return false;	   
	   
	   
	 }
	else
	{ 
		if(msg2=="")
		location.href = "membersList.php?"+a+"&search_submit=search_submit";
	}
	
}


function removeElement(elementID, newDivName){
	var d = document.getElementById(elementID);
	var nd = document.getElementById(newDivName);
	if (nd != null){
		d.removeChild(nd);
	}
}

//end
	function toggles(menuId, evnt) {
		//if (evnt) stopBubble(evnt);

		for(var i=1;i<=7;i++)
		{
			j=i; 
			var cur="MenuPopup"+i;
			if(menuId==cur)
			{
				//eval("document.getElementById('MenuPopup"+i+"')").className="clsActive";	
				eval("document.getElementById('selMenuPopup"+j+"')").style.display="block";
			}
			else
			{
				//eval("document.getElementById('MenuPopup"+i+"')").className="";	
				eval("document.getElementById('selMenuPopup"+j+"')").style.display="none";
			}
		}
	}

function hides(id)
	{
		document.getElementById(id).style.display='none';
	}	


// End of functions
