function popup(fileurl, windowname, w, h) {
	win = window.open(fileurl, windowname, "toolbar=0,scrollbars=0,status=0,menubar=0,resizable=yes,width="+w+",height="+h+",location=0,top=90,left=210");
	win.focus();
	return false;
}
function verifypopup(fileurl, windowname, w, h) {
	win = window.open(fileurl, windowname, "toolbar=0,scrollbars=0,status=0,menubar=0,resizable=yes,width="+w+",height="+h+",location=0,top=90,left=210");
	if (win) {
		win.focus();
		return false;
	}
	return true;
}
function smartpopup(fileurl, windowname, w, h) {
	win = window.open(fileurl, windowname, "toolbar=0,scrollbars=0,status=0,menubar=0,resizable=yes,width="+w+",height="+h+",location=0,top=90,left=210");
	if (win) {
		win.focus();
		return false;
	}
	document.location.href = '/help/popup.html?ref=' + escape(document.location.href);
	return false;
}
function popupIM(username, status, url, session, w, h) {
	if (!checkDeleted(status)) {
		return false;
	}
	return smartpopup(url + "/im/chat.html?" + session + "&u=" + escape(username), "ftchat_im_" + username, w, h);
}
function popupacceptIM(username, status, url, session, w, h, pimid) {
	return smartpopup(url + "/im/chat.html?" + session + "&imid="+pimid+"&u=" + escape(username), "imreq" + pimid, w, h);
}
function popupxhflIM(liid, username, status, url, session, w, h) {
	checkstatus = document.getElementById(liid).className;
	if (checkstatus != 'active') {
		return false;
	}
	return popupIM(username, status, url, session, w, h);
}
function popupChat(url, session_name, session_id, extra, shortname) {
	return smartpopup(url + "/chat/chat.html?" + session_name + "=" + session_id + extra, shortname + "_chat", 650, 500);
}
function popupExtended() {
	return verifypopup("/profile/colorcode/extended_profile_view.html?prepare=1", "colorcode", 800, 600);
}
function sendMyProfile(u) {
	return confirm("Are you sure you want to send your profile to " + u + "?");
}
function blockUser(u) {
	return confirm("Are you sure you want to block " + u + " from viewing your profile?");
}
function hideUser(u) {
	return confirm("Are you sure you want to hide " + u + " from your search results?");
}
function addToFavorites(u) {
	return confirm("Are you sure you want to add " + u + " to your list of favorites?");
}
function addToFriends(u) {
	return confirm("Are you sure you want to add " + u + " to your list of friends?");
}
function resetCounter() {
	return confirm('Are you sure you want to reset this counter?');
}
function checkDeleted(status) {
	if (status == 2) {
		alert("This member's account is no longer active.");
		return false;
	}
	return true;
}
function openSpellChecker(formname,content) {
	if (formname.length==0) {
		var formname = "compose";
	}
	var txt = eval("document." + formname + "." + content);
	var speller = new spellChecker(txt);
	speller.openChecker();
	return false;
}
function deleteFavorite(formname, item, u) {
	if (confirm('Are you sure you want to remove ' + u + ' from your list of favorites?')) {
		eval("document." + formname + "." + item).value = u;
		eval("document." + formname).submit();
	}
}
function shades_toggle(element, subelement) {
	if (element.className.indexOf('open') == -1) {
		shades_open(element);
		shades_open(subelement);
	} else {
		shades_close(element);
		shades_close(subelement);
	}
	return false;
}
function shades_open(theelement) {
	theelement.className += " open";
}
function shades_close(theelement) {
	theelement.className = theelement.className.replace(" open", "");
}
function highlight(elementid, style, box) {
	if (!ishighlighted(elementid, style)) {
		highlight_on(elementid,style,box);
	} else {
		highlight_off(elementid,style,box);
	}
}
function ishighlighted(elementid, style) {
	if (document.getElementById(elementid).className.indexOf(style) == -1) {
		return false;
	}
	return true;
}
function ischecked(elementid) {
	return document.getElementById(elementid).checked;
}
function highlightover(elementid, style, box) {
	if (!ischecked(box)) {
		highlight(elementid, style, box);
	}
}
function highlight_on(elementid, style, box) {
	if (!ischecked(box) || !ishighlighted(elementid, style)) {
		document.getElementById(elementid).className += " " + style;
	}
}
function highlight_off(elementid, style, box) {
	if (!ischecked(box)) {
		if (document.getElementById(elementid).className.indexOf(" " + style) >= 0) {
			document.getElementById(elementid).className = document.getElementById(elementid).className.replace(" " + style, "");
		} else if (document.getElementById(elementid).className.indexOf(style) >= 0) {
			document.getElementById(elementid).className = document.getElementById(elementid).className.replace(style, "");
		}
	}
}
function highlightall(prefix,max,style,box,boxprefix) {
	if (ischecked(box)) {
		for (i=1; i<=max; i++) {
			if (!ischecked(boxprefix + i, style)) {
				highlight_on(prefix + i,style,boxprefix + i);
			}
		}
	} else {
		for (i=1; i<=max; i++) {
			if (document.getElementById(prefix + i).className.indexOf(" " + style) >= 0) {
				document.getElementById(prefix + i).className = document.getElementById(prefix + i).className.replace(" " + style, "");
			} else if (document.getElementById(prefix + i).className.indexOf(style) >= 0) {
				document.getElementById(prefix + i).className = document.getElementById(prefix + i).className.replace(style, "");
			}
		}
	}
}
var today = new Date();
var thisyear = today.getYear();
if (thisyear < 2000) { thisyear += 1900; }
var disableclickmessage = 'Copyright ' + thisyear + '.\nAll rights reserved.';
function disablerightclick(event) {
	if (document.all) {
		if (event.button==2||event.button==3) {
			if (event.srcElement.tagName=="IMG"){
				alert(disableclickmessage);
			}
		}
	} else if (document.layers) {
		if (event.which == 3) {
			alert(disableclickmessage);
		}
	} else if (document.getElementById){
		if (event.which==3&&event.target.tagName=="IMG"){
			alert(disableclickmessage)
		}
	}
	return false;
}

function rotatePhoto(sign) {
	var next_photo = 0;
	if (sign == 1) {
		if (curr_photo == total_photos) {
			next_photo = 1;
		} else {
			next_photo = curr_photo + 1;
		}
	} else {
		if (curr_photo == 1) {
			next_photo = total_photos;
		} else {
			next_photo = curr_photo - 1;
		}
	}
	curr_photo = next_photo;
	document.photo.src = "";
	document.photo.width = photo_pwidth[next_photo];
	document.photo.height = photo_pheight[next_photo];
	document.photo.src = photo_array[next_photo];
	//document.photo.alt = photo_desc[next_photo];
	//document.getElementById("photo_description")="jgjjg";
	
	var l = document.getElementById('photo_description');
	if (photo_desc[next_photo] == '') {
		l.innerHTML = '';
	} else {
		l.innerHTML = ''+photo_desc[next_photo]+'';
	}

	curr_photo_url = photo_url[next_photo];
	curr_photo_width = photo_width[next_photo];
	curr_photo_height = photo_height[next_photo];
}
function gotoPhoto() {
	return popup(curr_photo_url, "photo", curr_photo_width + 30, curr_photo_height + 30);
}
function searchToolAction(selectObj) {
	if(confirm('Are you sure you want to add the selected users to your '+selectObj.options[selectObj.selectedIndex].text.toLowerCase()+'?')) { document.searchaction.submit(); } else { selectObj.selectedIndex = 0; }
}
function greeting_showfull(newstate) {
	if (true == newstate) {
		document.getElementById('greeting_summary').style.display = 'none';
		document.getElementById('greeting_full').style.display = 'block';
	} else {
		document.getElementById('greeting_full').style.display = 'none';
		document.getElementById('greeting_summary').style.display = 'block';
	}
}

function loadpreview(imgid, previewurl, previewwidth, previewheight, fullurl, fullwidth, fullheight) {
	if (document.getElementById(imgid)) {
		document.getElementById(imgid).src = previewurl;
		document.getElementById(imgid).width = previewwidth;
		document.getElementById(imgid).height = previewheight;
		curr_photo_url = fullurl;
		curr_photo_width = fullwidth;
		curr_photo_height = fullheight;
	}
}
