/**
 * onArcade 2.0.0
 * Copyright © 2006-2007 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
 **/

function popup(mylink, windowname) {
	if (!window.focus) {
		return true;
	}
	
	var href;
	if (typeof(mylink) == 'string') {
		href=mylink;
	} else {
		href=mylink.href;
	}
	window.open(href, windowname, 'width=475,height=325,resizable=yes,menubar=no,location=no,scrollbars=yes');
	return false;

}

function verify_comment() {
	if (document.comment_form.message.value=="") {
		alert(comment_not_blank);
		return false;
	} else {
		return true;
	}
}

function verify_contact() {
	if (document.form.message.value=="") {
		alert(message_not_blank);
		return false;
	} else {
		return true;
	}
}

function confirm_delete() {
	var ok=confirm(sure_want_delete_message);
	if (ok) {
		return true ;
	} else {
		return false ;
	}
}

function goto_link(link_url) {
	opener.document.location.href = link_url;
	window.close();
}

function verify_link_add() {
	if (document.form.link_title.value=="" || document.form.link_url.value=="" || document.form.link_description.value=="" || document.form.link_email.value=="") {
		alert(all_fields_required);
		return false;
	} else {
		return true;
	}
}

function verify_submit_content() {
	if (document.submit_form.title.value=="" || document.submit_form.description.value=="" || document.submit_form.upload_file.value=="" || document.submit_form.upload_image.value=="") {
		alert(all_fields_required);
		return false;
	} else {
		return true;
	}
}

function verify_pm_send() {
	if (document.compose_form.message_recipient.value=="") {
		alert(recipient_not_blank);
		return false;
	} else {
		if (document.compose_form.message_text.value=="") {
			alert(message_not_blank);
			return false;
		} else {
			return true;
		}
	}
}

function check_all(){
	for (var i=0;i<document.pm_form.elements.length;i++) {
		var e=document.pm_form.elements[i];
		if ((e.name != "all") && (e.type=="checkbox")) {
			e.checked=document.pm_form.all.checked;
		}
	}
}

function new_pm() {
	confirm_pm = confirm(new_pm_click_ok_cancel);
	if(confirm_pm == true) {
		window.location = siteurl + '/privatemessages.php';
	}
}

function edit_comment (comment_id) {
	document.getElementById('edit_comment_' + comment_id).innerHTML = '<input type="text" size="15" maxlength="100" id="edit_score_comment" /><input type="submit" value="' + submit_button + '" onclick="edit_score_comment(' + comment_id + ')" />';
}

function report_broken (file_id, what_is_wrong_with) {
	document.getElementById('report_broken').innerHTML = what_is_wrong_with + '<br /><input type="text" size="30" maxlength="100" id="report_broken_comment" /><input type="submit" value="' + submit_button + '" onclick="report_broken_submit(' + file_id + ')" />';
}

function rate_file_form (file_id) {
	document.getElementById('rate_file').innerHTML = '<select id="file_rating_select"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select><input type="submit" value="' + submit_button + '" onclick="rate_file(' + file_id + ')" />';
}

function addsmilie(code) {
	document.getElementById("comment_message").value += code;
}

function link_out(link_id) {
	window.open(siteurl + '/links.php?a=out&l=' + link_id);
	return false;
}

function verify_sponsor() {
	if (document.getElementById("os0").value == '' || document.getElementById("os1").value == '' || document.getElementById("os1").value == 'http://') {
		alert(all_fields_required);
		return false;
	} else {
		return true;
	}
}

function showInfoPop(e, title, desc) {
	if (document.compatMode && document.compatMode!="BackCompat") {
		var bodyTag = document.documentElement;
	} else {
		var bodyTag = document.body;
	}
	var windowWidth = window.innerWidth - 265;
	document.getElementById("infoPop").style.display = "block";
	if (windowWidth > (e.clientX + 10 + bodyTag.scrollLeft)) {
		document.getElementById("infoPop").style.left = (e.clientX + 10 + bodyTag.scrollLeft)+ "px";
		document.getElementById("infoPop").style.top = (e.clientY + 10 + bodyTag.scrollTop)+ "px";
	} else {
		document.getElementById("infoPop").style.left = (e.clientX - 230 - bodyTag.scrollLeft)+ "px";
		document.getElementById("infoPop").style.top = (e.clientY + 10 + bodyTag.scrollTop)+ "px";
	}
	document.getElementById("infoPopTitle").innerHTML = unescape(title);
	document.getElementById("infoPopDesc").innerHTML = unescape(desc);
}
function hideInfoPop(){
	document.getElementById("infoPop").style.display = "none";
}