function confirmDelete() {
	var msg = 'CAUTION: This action cannot be undone. Are you sure you want to delete this entry?';
	if (confirm(msg)) {
		return true;
	}
	else {
		return false;
	}
}

function confirmAddSpouse() {
	var msg = 'CAUTION: You are about to create a new spouse. Are you sure you want to add another spouse?';
	if (confirm(msg)) {
		return true;
	}
	else {
		return false;
	}
}

function confirmDeletePerson(name) {
	var msg = 'CAUTION: You are about to delete ' + name + ' from the family tree. Other family members connected to this person will be unlinked from this tree. Are you sure you want to delete this person?';
	if (confirm(msg)) {
		return true;
	}
	else {
		return false;
	}
}

function confirmLinkPerson(name) {
	var msg = 'CAUTION: You are about link ' + name + ' as well as all other family members connected to ' + name + ' to another family tree. Continue?';
	if (confirm(msg)) {
		return true;
	}
	else {
		return false;
	}
}

function confirmUnlinkPerson(name) {
	var msg = 'CAUTION: You are about to unlink ' + name + ' from the family tree. The profile will not be deleted, but other family members connected to this person will be unlinked from this tree as well. Are you sure you want to unlink this person?';
	if (confirm(msg)) {
		return true;
	}
	else {
		return false;
	}
}

function subWin(url, x, y, bln, blnScrBar) {
	var subWin = window.open(url,'','width=' + x + ',height=' + y + ',scrollbars=' + blnScrBar + ',top=100,left=100,resizable=' + bln + ',menubar=' + bln + ',toolbar=' + bln + ',status=' + bln + ',location=' + bln);
}

function winDownload(uri) {
	var subWin = window.open(uri, '', 'width=600,height=600,scrollbars=1,top=50,left=50,resizable=1,menubar=0,toolbar=0,status=0,location=0');
}

function winLink(url) {
	subWin(url, 600, 500, 1, 1);
}

function winTerms() {
	subWin('/terms.php?pop=1', 990, 550, 1, 1);
}

function winYDNAImportForm() {
	subWin('/my/ydna_import_form.php', 650, 650, 1, 1);
}

function winContact() {
	subWin('/lib/popup_contact.php?ref=' + encodeURI(window.location.href), 450, 410, 0);
}

function winInviteToProject(recipient) {
	subWin('/lib/popup_invite_to_project.php?to=' + recipient, 650, 500, 0);
}

function winPasswordReminder() {
	subWin('/passReminder.php', 450, 300, 0);
}

function winWhatIsDNA() {
	subWin('http://www.dnaancestryproject.com/what_is_dna.php', 650, 335, 0);
}

function winSPCaseStudy() {
	subWin('http://www.dnaancestryproject.com/sp_case_study.php', 650, 335, 0);
}

function winAddImage(getNodeId, nodeId, action, eleId) {
	subWin('/3rdparty/rte/addImageEditor.php?type=rd&action=' + action + '&nodeId=' + nodeId + '&getNodeId=' + getNodeId + '&elementId=' + eleId, 570, 550, 0, 1);
}

function winTestSteps() {
	subWin('http://www.dnaancestryproject.com/test_steps.php', 650, 335, 0);
}

function winRecommendToFriend() {
	subWin('/lib/recommend_to_friend.php?ref=' + encodeURI(window.location.href), 450, 400, 0);
}

function sendMail(recipient) {
	subWin('/send_gb_mail.php?to=' + recipient, 470, 480, 0);
}

function addToBuddyList(user_id) {
	subWin('/lib/add_buddy.php?id=' + user_id,  250, 150, 0);
}

function cfmDeleteNode() {
	return confirm('CAUTION: This action is not undoable.\nAre you sure you want to delete this node?');
}

function cfmTmpFile() {
	return confirm('Do you really want to discard the preview file?');
}

function cfmReset() {
	return confirm('Do you really want to discard all the changes you made?');
}

function cfmSubmit() {
	return confirm('This action is "final" and cannot be redone. Are you sure you want to proceed?');
}

function generateYDNAReport() {
	window.open('/my/ydna_analysis.php','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaStrReport() {
	window.open('/in/ydnaView.php?t=ystr&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printOrder(orderId) {
	window.open('/in/orderView.php?orderId=' + orderId + '&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');	
}

function printYDnaBackboneSnpReport() {
	window.open('/in/ydnaView.php?t=ybsnp&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaSubcladeReport(nodeId,testType) {
	window.open('/in/ydnaView.php?niId=' + nodeId + '&t=' + testType + '&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaHvr1Report(nodeId) {
	window.open('/in/mtdnaView.php?niId=' + nodeId + '&t=mt1&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaHvr2Report(nodeId) {
	window.open('/in/mtdnaView.php?niId=' + nodeId + '&t=mt2&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaBackboneSnpReport(nodeId) {
	window.open('/in/mtdnaView.php?niId=' + nodeId + '&t=mtbsnp&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaSubcladeReport(nodeId) {
	window.open('/in/mtdnaView.php?niId=' + nodeId + '&t=mthsc&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaStrCertificate(nodeId) {
	window.open('/in/ydnaCertificate.php?niId=' + nodeId + '&t=ystr','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaBackboneSnpCertificate(nodeId) {
	window.open('/in/ydnaCertificate.php?niId=' + nodeId + '&t=ybsnp','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaSnpSubcladeCertificate(nodeId,testType) {
	window.open('/in/ydnaCertificate.php?niId=' + nodeId + '&t=' + testType,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaHvr1Certificate(nodeId) {
	window.open('/in/mtdnaCertificate.php?niId=' + nodeId + '&t=mt1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaHvr2Certificate(nodeId) {
	window.open('/in/mtdnaCertificate.php?niId=' + nodeId + '&t=mt2','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaBackboneSnpCertificate(nodeId) {
	window.open('/in/mtdnaCertificate.php?niId=' + nodeId + '&t=mtbsnp','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaSnpSubcladeCertificate(nodeId,testType) {
	window.open('/in/mtdnaCertificate.php?niId=' + nodeId + '&t=' + testType,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printADnaStrCertificate(nodeId,testType) {
	window.open('/in/adnaCertificate.php?niId=' + nodeId + '&t=' + testType,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printYDnaCertificate(nodeId,type) {
	window.open('/in/ydnaCertificate.php?niId=' + nodeId + '&t=' + type,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printMtDnaCertificate(nodeId,type) {
	window.open('/in/mtdnaCertificate.php?niId=' + nodeId + '&t=' + type,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printADnaStrCertificate(nodeId,type) {
	window.open('/in/adnaCertificate.php?niId=' + nodeId + '&t=' + type,'','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printADnaStrReport(nodeId,testType) {
	window.open('/in/adnaView.php?niId=' + nodeId + '&t=' + testType + '&print=1','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printmtDNAAnalysis() {
	window.open('/my/mtdna_analysis.php','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function printDnaReportGlossary() {
	window.open('http://www.genebase.com/dnaReportGlossary.php','','width=1050,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=0,toolbar=0,status=0,location=0');
}

function printDnaConsentForm() {
	window.open('/in/dnaConsent.php','','width=980,height=700,scrollbars=1,top=50,left=50,resizable=0,menubar=1,toolbar=0,status=0,location=0');
}

function emptyIfValueIs(ele, elementValue) {
	//var ele = document.getElementById(elementID);
	if (ele.value == elementValue) {
		ele.value = '';
	}
}

function checkAll(nameEle, blnFlag) {
	var ele = document.getElementsByName(nameEle);
	for (i = 0; i < ele.length; i++) {
		if (!ele[i].disabled) {
			ele[i].checked = blnFlag;
		}
	}
}

function getSmiley(ele, smiley) {
	var frm = document.getElementById(ele);
	frm.value = frm.value + ' ' + smiley + ' ';
	frm.focus();
}

function getYCML(ele, tag, prm) {
	
	// Shortcuts to objects.
	var txa = document.getElementById(ele);
	var brw = navigator.appName.toLowerCase();
	
	// If Parameter is set, open tag should reflect that.
	var open_tag = tag;
	if (prm != '') {
		open_tag = tag + '=' + prm;
	}
	
	// Check if the user's browser is MS IE.
	if (brw.substr(0, 9) == 'microsoft') {
		
		// Yes. Get the selected text thing.
		var selectedText = document.selection.createRange().text;
		
		// Check if the selected text is not null.
		if (!selectedText) {
			txa.value += '[' + open_tag + ']Your_Text[/' + tag + ']';
		}
		else {
			// Check if the selected text is a textarea.
			if (document.selection.createRange().parentElement().tagName != 'TEXTAREA') {
				return false;
			}
			// Go enclose'em.
			document.selection.createRange().text = '[' + open_tag + ']' + selectedText + '[/' + tag + ']';
		}
		
	}
	else {
		// Not MS IE. Just append the tags.
		txa.value += '[' + open_tag + ']Your_Text[/' + tag + ']';
	}
	
	// Focus.
	txa.focus();
	
}

function getYCMLURL(ele) {
	var linkURL = prompt('Enter Link URL:', 'http://');
	var linkTitle = prompt('Enter Link Title:', linkURL);
	var txa = document.getElementById(ele);
	if (linkTitle == '') {
		linkTitle = linkURL;
	}
	txa.value += '[url=' + linkURL + ']' + linkTitle + '[/url]';
	txa.focus();
}

function getYCMLIMG(ele, returnMode) {
	var photoPickerWin = subWin('/lib/photo_picker.php?element_id=' + ele + '&return_mode=' + returnMode, 640, 580, 0, 1);
}

function setTo(to_user) {
	// Reference to the form's To field.
	var frm = document.frmCompose.To;
	// Initialize the delimitter.
	var delim = ', ';
	// If there is no To entry at all OR to_user is empty, do not add the delimitter.
	if (!frm.value || !to_user) {
		delim = '';
	}
	// Append the user with/without the delimitter.
	frm.value += delim + to_user;
	
}

function validateComment(elementIDBody) {
	// The only field to validate is the comment body.
	var err = '';
	var maxChars = 2000;
	var txaCommentBody = document.getElementById(elementIDBody);
	if (txaCommentBody.value == '') {
		err += 'Comment Body is required.';
	}
	else if (txaCommentBody.value.length > maxChars) {
		err += 'Please keep Comment Body under ' + maxChars + ' characters.' + "\n";
	}
	
	if (err == '') {
		return true;
	}
	else {
		alert(err);
		return false;
	}
}

function setVisibility(eleName, cssValue) {
	document.getElementById(eleName).style.visibility = cssValue;
}

function setDisplay(eleName, cssValue) {
	document.getElementById(eleName).style.display = cssValue;
}

function hasClass(eleName, className) {
	return document.getElementById(eleName).className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'));
}
function addClass(eleName, className) {
	if (!this.hasClass(eleName, className)) document.getElementById(eleName).className += " "+className;
}
function removeClass(eleName, className) {
	if (hasClass(eleName, className)) {
		var reg = new RegExp('(\\s|^)'+className+'(\\s|$)');
		document.getElementById(eleName).className=document.getElementById(eleName).className.replace(reg,' ');
	}
}

function showPaternal() {
	setDisplay('paternalLineage','');
	setDisplay('maternalLineage','none');
	addClass('tabPat','on');
	removeClass('tabMat','on');
	void(0);
}

function showMaternal() {
	setDisplay('paternalLineage','none');
	setDisplay('maternalLineage','');
	addClass('tabMat','on');
	removeClass('tabPat','on');
	void(0);
}

function selectSpouseType(id) {
	
	var s = document.getElementById(id+'_spouseTypeCode').selectedIndex;
	var v = document.getElementById(id+'_spouseTypeCode').options[s].value;
	
	var enga = id+'_ENGA_box';
	var marr = id+'_MARR_box';
	var div = id+'_DIV_box';
	
	if (v == 'ma') {
		setDisplay(enga,'');
		setDisplay(marr,'');
		setDisplay(div,'none');
	}
	else if (v == 'en') {
		setDisplay(enga,'');
		setDisplay(marr,'none');
		setDisplay(div,'none');
	}
	else if (v == 'pa') {
		setDisplay(enga,'none');
		setDisplay(marr,'none');
		setDisplay(div,'none');
	}
	else if (v == 'di') {
		setDisplay(enga,'');
		setDisplay(marr,'');
		setDisplay(div,'');
	}
	else if (v == 'xpa') {
		setDisplay(enga,'none');
		setDisplay(marr,'none');
		setDisplay(div,'none');
	}
	
}

function showMyUpdates() {
	setDisplay('actionLog_0','');
	setDisplay('actionLog_1','none');
	setDisplay('actionLog_2','none');
	setDisplay('actionLog_3','none');
	setDisplay('actionLog_4','none');
	addClass('tabMyUpdate','on');
	removeClass('tabContact','on');
	removeClass('tabFamily','on');
	removeClass('tabFamilyTree','on');
	removeClass('tabBookmark','on');
	void(0);
}

function showContactUpdates() {
	setDisplay('actionLog_0','none');
	setDisplay('actionLog_1','none');
	setDisplay('actionLog_2','');
	setDisplay('actionLog_3','none');
	setDisplay('actionLog_4','none');
	removeClass('tabMyUpdate','on');
	addClass('tabContact','on');
	removeClass('tabFamily','on');
	removeClass('tabFamilyTree','on');
	removeClass('tabBookmark','on');
	void(0);
}

function showFamilyUpdates() {
	setDisplay('actionLog_0','none');
	setDisplay('actionLog_1','');
	setDisplay('actionLog_2','none');
	setDisplay('actionLog_3','none');
	setDisplay('actionLog_4','none');
	removeClass('tabMyUpdate','on');
	removeClass('tabContact','on');
	addClass('tabFamily','on');
	removeClass('tabFamilyTree','on');
	removeClass('tabBookmark','on');
	void(0);
}


function showFamilyTreeUpdates() {
	setDisplay('actionLog_0','none');
	setDisplay('actionLog_1','none');
	setDisplay('actionLog_2','none');
	setDisplay('actionLog_3','none');
	setDisplay('actionLog_4','');
	removeClass('tabMyUpdate','on');
	removeClass('tabContact','on');
	removeClass('tabFamily','on');
	addClass('tabFamilyTree','on');
	removeClass('tabBookmark','on');
	void(0);
}

function showBookmarkUpdates() {
	setDisplay('actionLog_0','none');
	setDisplay('actionLog_1','none');
	setDisplay('actionLog_2','none');
	setDisplay('actionLog_3','');
	setDisplay('actionLog_4','none');
	removeClass('tabMyUpdate','on');
	removeClass('tabContact','on');
	removeClass('tabFamily','on');
	removeClass('tabFamilyTree','on');
	addClass('tabBookmark','on');
	void(0);
}

function setDisplayYDNAResult() {
	setDisplay('pBox', '');
	setDisplay('mBox', 'none');
	setDisplay('ydnaTabOn', '');
	setDisplay('ydnaTabOff', 'none');
	setDisplay('ydnaTabOver', 'none');
	setDisplay('mtdnaTabOn', 'none');
	setDisplay('mtdnaTabOff', '');
	setClass('p', 'on');
	setClass('m', '');
}

function setDisplayMtDNAResult() {
	setDisplay('pBox', 'none');
	setDisplay('mBox', '');
	setDisplay('ydnaTabOn', 'none');
	setDisplay('ydnaTabOff', '');
	setDisplay('mtdnaTabOn', '');
	setDisplay('mtdnaTabOff', 'none');
	setDisplay('mtdnaTabOver', 'none');
	setClass('p', '');
	setClass('m', 'on');
	}

function setHaplogroupDisplay(eleName) {
	if (eleName == 'gmap') {
		setClass('gmap','on');
		setClass('desc','');
		setClass('tree','');
		setDisplay('gmapD','');
		setDisplay('descD','none');
		setDisplay('treeD','none');
	}
	else if (eleName == 'desc') {
		setClass('gmap','');
		setClass('desc','on');
		setClass('tree','');
		setDisplay('gmapD','none');
		setDisplay('descD','');
		setDisplay('treeD','none');
	}
	else {
		setClass('gmap','');
		setClass('desc','');
		setClass('tree','on');
		setDisplay('gmapD','none');
		setDisplay('descD','none');
		setDisplay('treeD','');
	}
}

function setClass(eleName, cName) {
	document.getElementById(eleName).className = cName;
}

function colorPicker(pickFor, previewIn, imgEditing) {
	var x = 199;
	var y = 134;
	var bln = 0;
	winColorPicker = window.open('/my/colorPicker.php?pick_for=' + pickFor + '&preview_in=' + previewIn + '&img_editing=' + imgEditing, 'ColorPicker', 'width=' + x + ',height=' + y + ',scrollbars=' + bln + ',top=100,left=100,resizable=' + bln + ',menubar=' + bln + ',toolbar=' + bln + ',status=' + bln + ',location=' + bln);
	//if (imgEditing != '') {
		//document.getElementById(imgEditing).src = '/template/img/now_editing.gif';
	//}
	winColorPicker.focus();
}

function clearPicker(clearFor) {
	document.getElementById(clearFor).value='';	
	document.getElementById(clearFor).focus();
	}
	
function hideEdit(hideFor) {
	document.getElementById(hideFor).style.display = 'none';
	document.getElementById(hideFor + 'Show').style.display = '';
	document.getElementById(hideFor + 'Hide').style.display = 'none';
	}
	
function showEdit(showFor) {
	document.getElementById(showFor).style.display = '';
	document.getElementById(showFor + 'Show').style.display = 'none';
	document.getElementById(showFor + 'Hide').style.display = '';
	}
	
function tweakPageWidth(tweakFor) {

	if (tweakFor == 'txtPageWidthPercent') {
		document.frmG.txtPageWidthPercent.disabled = false;
		document.frmG.txtPageWidthFixed.disabled = true;
		}
		
		else {
			document.frmG.txtPageWidthPercent.disabled = true;
			document.frmG.txtPageWidthFixed.disabled = false;
			}
	
		}

function tweakBackgroundImage(tweakFor, flag) {

	if (flag == 1) {
		document.getElementById(tweakFor).style.display = '';
		}
		else {
			document.getElementById(tweakFor).style.display = 'none';
			}

	}

function tweakBackgroundMusic(tweakFor, flag) {

	if (flag == 1) {
		document.getElementById(tweakFor).style.display = '';
		}
		else {
			document.getElementById(tweakFor).style.display = 'none';
			}	

	}

function tweakBackground(tweakFor, flag) {
	
	document.getElementById(tweakFor).style.display = ( (flag == 1) ? '' : 'none' );
	
}


/*  */
function getWorksheetEntries() {
	var worksheetEntries = document.getElementsByName('worksheet_entries[]');
	var getParam = '';
	for (i = 0; i < worksheetEntries.length; i++) {
		if (worksheetEntries[i].checked) {
			getParam += '_' + worksheetEntries[i].value;
		}
	}
	return getParam.substring(1);
}


function switchFeatured(type, ranking, interval, isPrev) {
	
	// IE.
	if (window.ActiveXObject) {
		var objHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	// Others.
	else if (document.implementation) {
		var objHttpReq = new XMLHttpRequest();
	}
	
	objHttpReq.open('get', '/lib/js_switchFeatured.php?type=' + type + '&ranking=' + ranking + '&interval=' + interval + '&is_prev=' + isPrev);
	objHttpReq.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
	objHttpReq.send(null);
	
	objHttpReq.onreadystatechange = function() {
		if (objHttpReq.readyState == 4) {
			PHPResult = objHttpReq.responseText.split('}+{');
			document.getElementById('currentRanking').value = PHPResult[0];
			
			for (i = 1; i <= interval; i++) {
				featuredInnerHTML = PHPResult[i].split('}-{');
				switch (type) {
					case 'fu':
					case 'fp':
						document.getElementById('featuredHTML' + i).innerHTML = '<div style="margin: 0 0 10px ! important; font-weight: bold ! important; ">' + featuredInnerHTML[2] + '</div><a href="' + featuredInnerHTML[1] + '"><img src="' + featuredInnerHTML[0] + '" alt="" style="float: right ! important; margin-left: 10px ! important; border: 1px solid #CCCCCC ! important;" /></a><a href="' + featuredInnerHTML[1] + '" style="color: #999999 ! important;">' + featuredInnerHTML[3] + '</a>';
						break;
					case 'fg':
						document.getElementById('featuredHTML' + i).innerHTML = '<a href="' + featuredInnerHTML[1] + '"><img src="' + featuredInnerHTML[0] + '" alt="" style="margin: 0px 10px 0px 0px; float: left; border: 1px solid #CCCCCC;" /></a><strong><a href="' + featuredInnerHTML[1] + '">' + featuredInnerHTML[2] + '</a></strong><br /><a href="' + featuredInnerHTML[1] + '">' + featuredInnerHTML[3] + '</a>';
						break;
				}
			}
			
		}
		return false;
	}
	
}


function switchFeaturedSet(ranking, interval, isPrev) {
	
	// IE.
	if (window.ActiveXObject) {
		var objHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	// Others.
	else if (document.implementation) {
		var objHttpReq = new XMLHttpRequest();
	}
	
	
	objHttpReq.open('get', '/lib/js_switchFeaturedSet.php?current_ranking=' + ranking + '&interval=' + interval + '&is_prev=' + isPrev);
	objHttpReq.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
	objHttpReq.send(null);
	
	objHttpReq.onreadystatechange = function() {
		if (objHttpReq.readyState == 4) {
			PHPResult = objHttpReq.responseText.split('}+{');
			featuredInnerHTML = PHPResult[0].split('}-{');
			document.getElementById('featuredUserHTML').innerHTML = '<a href="' + featuredInnerHTML[1] + '"><img src="' + featuredInnerHTML[0] + '" alt="" style="float: right; margin-left: 10px; border: 1px solid #CCCCCC;" /></a><a href="' + featuredInnerHTML[1] + '" style="color: #999999; "><strong>' + featuredInnerHTML[2] + '</strong><br />' + featuredInnerHTML[3] + '</a>';
			featuredInnerHTML = PHPResult[1].split('}-{');
			document.getElementById('featuredProjectHTML').innerHTML = '<a href="' + featuredInnerHTML[1] + '"><img src="' + featuredInnerHTML[0] + '" alt="" style="float: right; margin-left: 10px; border: 1px solid #CCCCCC;" /></a><a href="' + featuredInnerHTML[1] + '" style="color: #999999; "><strong>' + featuredInnerHTML[2] + '</strong><br />' + featuredInnerHTML[3] + '</a>';
			featuredInnerHTML = PHPResult[2].split('}-{');
			document.getElementById('featuredGroupHTML').innerHTML = '<a href="' + featuredInnerHTML[1] + '"><img src="' + featuredInnerHTML[0] + '" alt="" style="float: right; margin-left: 10px; border: 1px solid #CCCCCC;" /></a><a href="' + featuredInnerHTML[1] + '" style="color: #999999; "><strong>' + featuredInnerHTML[2] + '</strong><br />' + featuredInnerHTML[3] + '</a>';
			document.getElementById('currentRanking').value = PHPResult[3];
		}
		return false;
	}
	
}

function switchProjectForumThreadView(nameEle, flagCollapse) {
	
	var cssValue = (flagCollapse ? 'none' : '');
	
	/*
	   IE doesn't recognize non-input HTML tags with getElementsByName(),
	   Hence use getElementById() to loop thru children posts.
	*/
	var i = 0;
	while (ele = document.getElementById(nameEle + i)) {
		ele.style.display = cssValue;
		i++;
	}
	
	if (flagCollapse) {
		setDisplay('captionExpand', '');
		setDisplay('captionCollapse', 'none');
	}
	else {
		setDisplay('captionExpand', 'none');
		setDisplay('captionCollapse', '');
	}
	
}

function isIe() {
	return (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
}

function getWindowWidth() {
	return isIe() ? document.body.clientWidth : window.innerWidth;
}

function getWindowHeight() {
	return isIe() ? document.body.clientHeight : window.innerHeight;
}

/* Opens up a Prototype Window-version of a popup window. */
function gbpw(title, url, width, height) {
	var now = new Date();
	var newId = title + now.getMilliseconds();
	var top = ((getWindowHeight() - height) / 2) + (document.body.scrollTop > 0 ? document.body.scrollTop : document.documentElement.scrollTop);
	var left = ((getWindowWidth() - width) / 2) + (document.body.scrollLeft > 0 ? document.body.scrollLeft : document.documentElement.scrollLeft);
	var win = new Window(newId, {className: 'alphacube', title: title, top: top, left: left, width: width, height: height, resizable: true, url: url, recenterAuto: true});
	win.setDestroyOnClose();
	win.show();
}

function gbpwAbuseReport() {
	return gbpw('Report Abuse', '/3rdparty/prototypeWindow/abuseReport.php?uri=' + window.location.pathname + window.location.search.replace(/\&/g, '[and]'), 560, 450);
}

function gbpwFileLinkTo(nfId) {
	return gbpw('Tag this File', '/3rdparty/prototypeWindow/fileLinkTo.php?nfId=' + nfId, 560, 450);
}

function gbpwFileSendTo(nfId) {
	return gbpw('Email this File to Family and Friends', '/3rdparty/prototypeWindow/fileSendTo.php?nfId=' + nfId, 450, 400);
}

function gbpwFileAggrSendTo(nfaId) {
	return gbpw('Send Album to Friends', '/3rdparty/prototypeWindow/fileAggrSendTo.php?nfaId=' + nfaId, 450, 400);
}

function gbpwFeedback() {
	return gbpw('Feedback', '/3rdparty/prototypeWindow/feedback.php?uri=' + window.location.pathname + window.location.search.replace(/\&/g, '[and]'), 450, 400);
}

function gbpwAggrSendTo(naId) {
	return gbpw('Send Group to Friends', '/3rdparty/prototypeWindow/aggrSendTo.php?naId=' + naId, 450, 400);
}

function getPhotoTip(elem,url) {
	if (!yh_tt || !elem || elem.tt_div ) return ;
	var photo_id=photo_urls[url];
	
	if (!photo_id) {
		photo_id=++next_photo_id;
		photo_urls[url]=photo_id;
	}
	
	if ( !Dom.get('photo_tooltip_for_'+photo_id)) {
		var i;
		i=new Image();
		i.src=url;
		var d=document.createElement ( 'div' );
		d.className='tooltip';
		d.id='photo_tooltip_for_'+photo_id;
		var img=document.createElement ( 'img' );
		img.id='photo_for_'+photo_id;
		img.src=imgLoading.src;
		d.appendChild(img);
		document.body.appendChild(d);
		if (!i.complete) {
			Event.on ( i, 'load', function(e) {
			Dom.get('photo_for_'+photo_id).src=i.src;
		} );
	}
	else {
		img.width=i.width;
		img.height=i.height;
		img.src=i.src;
	}
	
	}
	createTip ( elem, 'photo_tooltip_for_'+photo_id, false );
}