function popup($URL) {
	var $day = new Date();
	var $id = $day.getTime();
	eval("page" + $id + " = window.open('" + $URL + "', '" + $id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=650,left = 212,top = 59');");
}



function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
addLoadEvent(externalLinks);



function prepareProfileImages() {
	if (!document.getElementById) return false;
	if (!document.getElementById('profile_images')) return false;
	
	var $images_list = document.getElementById('profile_images');
	var $images = $images_list.getElementsByTagName('img');
	
	for (var $i=0; $i<$images.length; $i++) {
		$images[$i].onmouseover = function() {
			var $parent = this.parentNode;
			var $grandparent = $parent.parentNode;
			var $greatgrandparent = $grandparent.parentNode;
			$greatgrandparent.setAttribute('id','hover');
		}
		$images[$i].onmouseout = function() {
			var $parent = this.parentNode;
			var $grandparent = $parent.parentNode;
			var $greatgrandparent = $grandparent.parentNode;
			$greatgrandparent.setAttribute('id','');
		}
	}
}
addLoadEvent(prepareProfileImages);


function friends_action_buttons() {
	if (!document.getElementById) return false;
	if (document.getElementById('friends_accept_button')) {
		var $button = document.getElementById('friends_accept_button');
		$button.onclick = function() {
			var $message = prompt('If you want to include a message with your friend request acceptance then enter it below. If you do not want to reject this request press CANCEL.');
			if ($message!=null) window.location = this.href+'&response_message='+$message;
			return false;
		}
	}
	if (document.getElementById('friends_reject_button')) {
		var $button = document.getElementById('friends_reject_button');
		$button.onclick = function() {
			var $message = prompt('If you want to include a message with your friend request rejection then enter it below. If you do not want to reject this request press CANCEL.');
			if ($message!=null) window.location = this.href+'&response_message='+$message;
			return false;
		}
	}
}
addLoadEvent(friends_action_buttons);


function remove_loading_signs() {
	if (!document.getElementById) return false;
	if (!document.getElementsByClassName('loading_sign')) return false;
	
	var $loading_signs = document.getElementsByClassName('loading_sign');
	for ($i=0; $i<$loading_signs.length; $i++) {
		removeNode($loading_signs[$i]);
	}
	return false;
}
addLoadEvent(remove_loading_signs);


function prepareFormButtons() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementsByTagName('button')) return false;
	if (!document.getElementsByTagName('form')) return false;
	
	var $forms = document.getElementById('content').getElementsByTagName('form');
	
	for (var $i=0; $i<$forms.length; $i++) {
		var $form = $forms[$i];
		if (!$form.onsubmit) {
			$form.onsubmit = function() {
				var $buttons = this.getElementsByTagName('button');
				for (var $i=0; $i<$buttons.length; $i++) {
					var $button = $buttons[$i];
					$button.className = 'clicked';
					$button.disabled = 'disabled';
				}
			}
		}
	}
}
addLoadEvent(prepareFormButtons);


function showAcknowledgement($fade_in) {
	if (!document.getElementById) return false;
	if (!document.getElementById('acknowledgement')) return false;
	var $notice = document.getElementById('acknowledgement');
	if ($fade_in) {
		clearTimeout($notice.timer);
		fade('acknowledgement',0,10,false,60);
	}
	else {
		$notice.style.display = 'block';
		$notice.timer = setTimeout("showAcknowledgement(true);",500);
	}
}
addLoadEvent(showAcknowledgement);

