/**
 * onArcade 2.0.0
 * Copyright © 2006-2007 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
 **/

function bookmark() {
	if (document.all) {
		window.external.AddFavorite(siteurl, "Giochi Gratis");
	} else { 
		window.sidebar.addPanel("Giochi Gratis", siteurl, "");
	}
}
 
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 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 showPopup(title, width, height) {
	//window.onscroll = followPopup;
	
	swfSource = '<a href="Javascript: closePopup();">[X]</a>'+document.getElementById('file').innerHTML.replace(/\n|\s\s/g,'');
	document.getElementById('file').style.visibility = 'hidden';

	if (window.innerHeight && window.scrollMaxY) {
		popUpHeight = window.innerHeight + window.scrollMaxY;
		windowHeight = window.innerHeight;
		currentHeight = self.pageYOffset;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		popUpHeight = document.body.scrollHeight;
		windowHeight = document.body.scrollHeight;
		currentHeight = document.documentElement.scrollTop;
	} else {
		popUpHeight = document.body.offsetHeight;
		windowHeight = document.documentElement.clientHeight;
		currentHeight = document.body.scrollTop;
  	}

	document.getElementById('file').style.height = height+'px';
	
	content = document.createElement('div');
	content.setAttribute('id', 'content');
	content.style.width = width+'px';
	content.style.height = height+'px';
	content.style.left = '50%';
	content.style.top = '50%';
	content.style.padding = '40px';
	content.style.marginLeft = -(width/2+parseInt(content.style.padding))+'px';
	content.style.marginTop = -(height/2+parseInt(content.style.padding)-currentHeight)+'px';
	document.body.appendChild(content);

	popUp = document.createElement('div');
	popUp.setAttribute('id', 'popup');
	popUp.style.height = popUpHeight+'px';
	popUp.style.width = '100%';
	document.body.appendChild(popUp);
	
	/*function followPopup() {
	if (window.innerHeight && window.scrollMaxY)
		heightNow = self.pageYOffset;
	else if (document.body.scrollHeight > document.body.offsetHeight)
		heightNow = document.documentElement.scrollTop;
	else
		heightNow = document.body.scrollTop;

		document.getElementById('content').style.marginTop = (height/2-currentHeight+heightNow+windowHeight/2)+'px';
	}*/

	for (i=1; i<=100; i++) {
		setTimeout('showContent('+i+',\''+title+'\',\''+swfSource+'\','+width+','+height+')',i*4);
	}
}

function showContent(time, title, swfSource, width, height) {
	obj = document.getElementById('content');
	obj.style.opacity = time*0.01;
	obj.style.MozOpacity = time*0.01;
	obj.style.KhtmlOpacity = time*0.01;
	obj.style.filter = 'alpha(opacity='+time+')';

	if (time == 90)
		obj.innerHTML = swfSource;
}

function closePopup() {
	document.getElementById('file').style.visibility = 'visible';
	id1 = document.getElementById('popup');
	id2 = document.getElementById('content');
	document.getElementById('file').style.height = '';
	id1.parentNode.removeChild(id1);
	id2.parentNode.removeChild(id2);
}