var clicks = 0; // expand center furder, for Display More function in Compose;

function open_submenu(id)
{
	document.getElementById(id).style.display = 'block';
}

function hideNavigation()
{
	
	document.getElementById('my_sourcesSSS').style.display = 'none';
	document.getElementById('my_websites').style.display = 'none';
	//document.getElementById('my_projects').style.display = 'none';
	document.getElementById('my_group').style.display = 'none';
	document.getElementById('my_feeds').style.display = 'none';
	
}


function open_pop_tools(id)
{
	document.getElementById(id).style.display = 'block';
}		

function hidePopTools()
{
	
	document.getElementById('preloader').style.display = 'none';
	
}


function openContentTab(id)
	{
		document.getElementById('contentTab' + document.getElementById('openedTab').value).style.display = 'none';
		document.getElementById('contentTab' + id).style.display = 'block';

		document.getElementById('link' + document.getElementById('openedTab').value).className = 'inactiveTab';
		document.getElementById('link' + id).className = 'activeTab';

		document.getElementById('openedTab').value = id;
	}

/*
function openContentTab(id)
	{
		document.getElementById('contentTab' + document.getElementById('openedTab').value).style.display = 'none';
		document.getElementById('contentTab' + id).style.display = 'block';

		document.getElementById('link' + document.getElementById('openedTab').value).className = 'inactiveTab';
		document.getElementById('link' + id).className = 'activeTab';

		document.getElementById('openedTab').value = id;
	}

*/


/*
function openContentTabPrompt(id)
{
	document.getElementById('contentTab_' + document.getElementById('openedTab').value).style.display = 'none';
	document.getElementById('contentTab_' + id).style.display = 'block';
	
	document.getElementById('imageTab_' + document.getElementById('openedTab').value).src = 'images/new/products/' + document.getElementById('openedTab').value + '_off.gif';
	document.getElementById('imageTab_' + id).src = 'images/new/products/' + id + '_on.gif';
	

	document.getElementById('openedTab').value = id;
}
*/
function openContentTabPrompt(id)
{
	
	document.getElementById('contentTab_' + document.getElementById('openedTab').value).style.display = 'none';
	document.getElementById('contentTab_' + id).style.display = 'block';
	
	document.getElementById('imageTab_' + document.getElementById('openedTab').value).style.backgroundImage = 'url(images/new/products/' + document.getElementById('openedTab').value + '-button-off.gif)';
	document.getElementById('imageTab_' + id).style.backgroundImage = 'url(images/new/products/' + document.getElementById('openedTab').value + '-button-on.gif)';
	
	document.getElementById('imageTab_' + document.getElementById('openedTab').value).style.color = '#ffffff';
	document.getElementById('imageTab_' + id).style.color = '#000000';

	document.getElementById('openedTab').value = id;
	if(id == 'images' ) {		
		document.getElementById('big_cb').checked = false;
		document.getElementById('cb'+lastImage).checked = false;
	}
	
}

/*
function change_buttons(dem , img_down)
{
	var handler = document.getElementById('search_handler').value;

	document.getElementById(handler).src = 'images/new/home/search_' + handler + '.gif';
	document.getElementById(dem).src = img_down;
	document.getElementById('search_handler').value = dem;
}*/
function change_buttons(dem , img_down)
{
	var handler = document.getElementById('search_handler').value;

	document.getElementById(handler).src = 'images/new/search/search_' + handler + '.gif';
	document.getElementById(dem).src = img_down;
	document.getElementById('search_handler').value = dem;
}

// replacement for change_buttons function
function changeSearchConditions(id)
{
	// input section
	//document.getElementById('searchContent-' + document.getElementById('openedTab').value).style.display = 'none';
	//document.getElementById('searchContent-' + id).style.display = 'block';

	// active & inactive tabs
	document.getElementById('tab-' + document.getElementById('openedTab').value).style.backgroundImage = 'url(images/new/search/search_' + document.getElementById('openedTab').value + '_out.gif)';

	document.getElementById('openedTab').value = id;
	document.getElementById('search_handler').value = document.getElementById('openedTab').value = id;
	document.getElementById('tab-' + id).style.backgroundImage = 'url(images/new/search/search_' + document.getElementById('openedTab').value + '_over.gif)';

	//alert(document.getElementById('openedTab').value = id);
	// search conditions t=
	//document.getElementById('searchContent-' + id).style.display = 'block';
}

function button_down(dem,img_over)
{
	if (dem != document.getElementById('search_handler').value)
	{
		document.getElementById(dem).src = img_over;
	}
}

function button_down1(dem,img_over)
{
		document.getElementById(dem).src = img_over;
}

function change_button(dem , img_down)
{
	var handler = document.getElementById('search_handler').value;

	document.getElementById(handler).src = 'images/search_' + handler + '.jpg';
	document.getElementById(dem).src = img_down;
	document.getElementById('search_handler').value = dem;
}

function roll_button(dem , img_down)
{
	var handler = document.getElementById('roll_handler').value;

	document.getElementById(handler).src = 'images/tour/' + handler + '.gif';
	document.getElementById(dem).src = img_down;
	document.getElementById('roll_handler').value = dem;
}

function roll_button1(dem , img_down)
{
	var handler = document.getElementById('roll_handler').value;

	document.getElementById(handler).src = 'images/tour/' + handler + '_over' + '.gif';
	document.getElementById(dem).src = img_down;
	document.getElementById('roll_handler').value = dem;
}

function open_desc(id) 
{
	clicks++;

	if (document.getElementById('desc_' + id).style.display != 'none') {
		document.getElementById('desc_' + id).style.display = 'none';
		
	}
	else {
		document.getElementById('desc_' + id).style.display = 'block';
	}
	
	if (clicks > '0') {
		document.getElementById("center_content").style.height = "auto";
	}
	
	if (document.getElementById("center_content").clientHeight < 600) {
		document.getElementById("center_content").style.height = "599px";
	}
}

function changeView(view_id , handler_id)
{
	if (document.getElementById(handler_id).value != view_id && document.getElementById(handler_id).value != '')
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(view_id).style.display = 'block';

		document.getElementById(handler_id).value = view_id;
	}
	else
	{	
		document.getElementById(view_id).style.display = 'block';
		document.getElementById(handler_id).value = view_id;
	}

}


function browse_profile(prof_id)
{
	if (document.getElementById('prof_handler').value != prof_id)
	{
		document.getElementById(document.getElementById('prof_handler').value).style.display = 'none';
		document.getElementById(prof_id).style.display = 'block';
		

		document.getElementById(document.getElementById('prof_handler').value + '_btn').className = 'profile_btn_txt';
		document.getElementById(prof_id + '_btn').className = 'profile_btn_txt_down';

		document.getElementById('prof_handler').value = prof_id;
	}
}

function browse_library(prof_id)
{
	if (document.getElementById('prof_handler').value != prof_id)
	{
		document.getElementById(document.getElementById('prof_handler').value).style.display = 'none';
		document.getElementById(prof_id).style.display = 'block';
		

		document.getElementById(document.getElementById('prof_handler').value + '_btn').className = 'library_btn_txt';
		document.getElementById(prof_id + '_btn').className = 'library_btn_txt_down';

		document.getElementById('prof_handler').value = prof_id;
	}
}

function changeproj(proj_id , handler_id)
{
	if (document.getElementById(handler_id).value != proj_id)
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(proj_id).style.display = 'block';
		
		document.getElementById(document.getElementById(handler_id).value + '_btn').className = 'proj_list';
		document.getElementById(proj_id +'_btn').className = 'proj_list_down'

		document.getElementById(handler_id).value = proj_id;

	}
}


function changelist(proj_id , handler_id)
{
	if (document.getElementById(handler_id).value != proj_id)
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(proj_id).style.display = 'block';
		
		document.getElementById(document.getElementById(handler_id).value + '_btn').className = 'blue_list';
		document.getElementById(proj_id +'_btn').className = 'blue_list_down';

		document.getElementById(handler_id).value = proj_id;

	}
}


function changelists(proj_id , handler_id)
{
	if (document.getElementById(handler_id).value != proj_id)
	{
		document.getElementById(document.getElementById(handler_id).value).style.display = 'none';
		document.getElementById(proj_id).style.display = 'block';
		
		document.getElementById(document.getElementById(handler_id).value + '_btn').className = 'blue_list';
		document.getElementById(proj_id +'_btn').className = 'blue_list_down_u';

		document.getElementById(handler_id).value = proj_id;

	}
}


function clearMenus() 
{
	$j("#submenu-friends, .catdropm").hide();
	$j("#friends-alink").removeClass("current");
	document.getElementById('my_websites').src = 'images/my_websites_btn.gif';
	document.getElementById('my_websites').setAttribute('srcover' , 'images/my_websites_btn_over.gif');

	document.getElementById('my_projects').src = 'images/my_projects_btn.gif';
	document.getElementById('my_projects').setAttribute('srcover' , 'images/my_projects_btn_over.gif');

	document.getElementById('my_groups').src = 'images/my_groups_btn.gif';
	document.getElementById('my_groups').setAttribute('srcover' , 'images/my_groups_btn_over.gif');

	document.getElementById('my_feeds').src = 'images/my_feeds_btn.gif';
	document.getElementById('my_feeds').setAttribute('srcover' , 'images/my_feeds_btn_over.gif');

}
/*
function handleHover() 
{
	$j("body").bind("click", 
		function (event) 
		{
			if (!$j(event.target).is(".catdrop, #friends-activity") && (!$j(event.target).attr("id") || $j(event.target).attr("id").substring(0, 10) != "tooltoggle"))
			{
				clearMenus();
			}
		}
	);

	$j(".catdrop").click(
		function () {
			document.getElementById('my_websites').src = 'images/my_websites_btn.gif';
			document.getElementById('my_websites').setAttribute('srcover' , 'images/my_websites_btn_over.gif');

			document.getElementById('my_projects').src = 'images/my_projects_btn.gif';
			document.getElementById('my_projects').setAttribute('srcover' , 'images/my_projects_btn_over.gif');

			document.getElementById('my_groups').src = 'images/my_groups_btn.gif';
			document.getElementById('my_groups').setAttribute('srcover' , 'images/my_groups_btn_over.gif');

			document.getElementById('my_feeds').src = 'images/my_feeds_btn.gif';
			document.getElementById('my_feeds').setAttribute('srcover' , 'images/my_feeds_btn_over.gif');

			var m = $j(this).parents("li.h-drop").children(".catdropm");
			m.toggle();
			$j(".catdropm:visible, #submenu-friends").not(m).hide();
			$j("#friends-alink").removeClass("current");
			
			var image_parent_top = document.getElementById(this.id.replace('_hnd' , ''));
			var image_to_be_changed = image_parent_top.getAttribute("srcover");
			image_parent_top.setAttribute("srcover" , image_parent_top.src);
			image_parent_top.src = image_to_be_changed;
			
			//alert("da");
			return false;

		}
	);
}
*/

///////////////////////////////////////////////////////////////////////////////////////// popup windows by sorinh
function getStyleObject(objectId) 
{
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) 
	{	// W3C DOM
		return document.getElementById(objectId).style;
    } 
		else if (document.all && document.all(objectId)) 
	{	// MSIE 4 DOM
		return document.all(objectId).style;
    } 
		else if (document.layers && document.layers[objectId]) 
	{	// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } 
		else 
	{
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) 
{	
	// get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
	{
		styleObject.visibility = newVisibility;
		return true;
    } 
		else 
	{	// we couldn't find the object, so we can't change its visibility
		return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) 
{
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
	{
		styleObject.left = newXCoordinate;
		styleObject.top = newYCoordinate;
		return true;
    } 
	else 
	{
		// we couldn't find the object, so we can't very well move it
		return false;
    }
} // moveObject

// ********************************
// application-specific functions *
// ********************************

function showPopup (targetObjectId, eventObj) 
{
    if(eventObj) 
	{
		hideCurrentPopup();
		eventObj.cancelBubble = true;

		if( changeObjectVisibility(targetObjectId, 'visible') ) 
		{
	        window.currentlyVisiblePopup = targetObjectId;
			return true;
		} 
		else 
		{
			return false;
		}
    } 
	else 
	{
		return false;
    }
} // showPopup

function hideCurrentPopup() 
{
	if(window.currentlyVisiblePopup) 
	{
		changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
		window.currentlyVisiblePopup = false;
	}
} // hideCurrentPopup

// initialize hacks whenever the page loads
window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
document.onclick = hideCurrentPopup;

function initializeHacks() 
{
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) 
	{
		window.onresize = explorerMacResizeFix;
    }
}

///////////////////////////////////////////////////////////////////////////////////////// popup windows by sorinh
var myZIndex = 10; // the z-index of the popup divs

function open_pop(id)
{
	if (document.getElementById('pop_' + id).style.display != 'none')
	{
		document.getElementById('pop_' + id).style.display = 'none';
	}
	else
	{
		document.getElementById('pop_' + id).style.display = 'block';
		document.getElementById('pop_' + id).style.zIndex = myZIndex++;
	}
}

function close_popup(id)
{
	document.getElementById(id).style.display = 'none';
}

function open_tab(id)
{	
	clicks++;
	
	if (document.getElementById('tab_' + id).style.display != 'none')
	{
		document.getElementById('tab_' + id).style.display = 'none';
		document.getElementById('tab'+id).className = 'group_tab';
	}
	else
	{
		document.getElementById('tab_' + id).style.display = 'block';
		document.getElementById('tab'+id).className = 'group_tab_over';
	}
	
	if (clicks > '0') {
		document.getElementById("center_content").style.height = "auto";
	}
	
	if (document.getElementById("center_content").clientHeight < 600) {
		document.getElementById("center_content").style.height = "599px";
	}
}

function open_hidden(id)
{
	if (document.getElementById('hidden_' + id).style.display != 'none')
	{
		document.getElementById('hidden_' + id).style.display = 'none';
		document.getElementById('hidden'+id).className = 'blue';
	}
	else
	{
		document.getElementById('hidden_' + id).style.display = 'block';
		document.getElementById('hidden'+id).className = 'white';
	}
}

function open_section(id)
{
	if (document.getElementById('section_' + id).style.display != 'none')
	{
		document.getElementById('section_' + id).style.display = 'none';
		document.getElementById('section'+id).className = 'bold_grey';
	}
	else
	{
		document.getElementById('section_' + id).style.display = 'block';
		document.getElementById('section'+id).className = 'bold_grey';
	}
}

function switchProfileBasic(id)
{
	if (id != document.getElementById('my_profile_basic_content_box_handler').value)
	{
		document.getElementById(id + '_content').style.display = 'block';
		if (document.getElementById('my_profile_basic_content_box_handler').value != '')
		{
			document.getElementById(document.getElementById('my_profile_basic_content_box_handler').value + '_content').style.display = 'none';
		}
		document.getElementById('my_profile_basic_content_box_handler').value = id;
	}
}