// JavaScript Document
function sendmail(fromValue) {
	frm = document.getElementById('frmSendmail');
	if(frm.fromname.value == '') { alert('กรุณากรอกชื่อของคุณด้วยคะ.');frm.fromname.focus();return false;}
	if(frm.fromemail.value == '') { alert('กรุณากรอกอีเมลล์ของคุณด้วยคะ.');frm.fromemail.focus();return false;}
	if(frm.toname.value == '') { alert('กรุณากรอกชื่อของเพื่อนคุณด้วยคะ.');frm.toname.focus();return false;}
	if(frm.toemail.value == '')  {alert('กรุณากรอกอีเมลล์ของเพื่อนคุณด้วยคะ.');frm.toemail.focus();return false;}
	frm.btnSendmail.disabled=true
	ajax_sendtofriend(fromValue);
}
function showSendmail() {
	disablePage(false);
	document.getElementById('frmSendmail').reset();
	document.getElementById('actionBox').style.zIndex='60002';
	document.getElementById('actionBox').style.display='block';
	document.getElementById('frmSender').style.display='block';
	document.getElementById('frmSave').style.display='none';
}
function showSave() {
	disablePage(false);
	document.getElementById('actionBox').style.zIndex='60002';
	document.getElementById('actionBox').style.display='block';
	document.getElementById('frmSender').style.display='none';
	document.getElementById('frmSave').style.display='block';
}
function closeBoxaction() {
	document.getElementById('actionBox').style.display='none';
	document.getElementById('frmSender').style.display='none';
	document.getElementById('frmSave').style.display='none';
	document.getElementById('frmSendmail').btnSendmail.disabled=false;
	document.getElementById('frmSendmail').reset();	
	enablePage();
}
function voteContent(score,contentID) {
	disablePage(true);
	ajax_voteContent(contentID,score,document.getElementById('tableInfo').value);
}
function sendBan(contentID) {
	disablePage(true);
	ajax_sendBand(contentID,document.getElementById('tableInfo').value);
}

function enablePage() {
	targetObj.style.visibility='visible';
//	document.getElementById('disable'+2).style.visibility='hidden';
	document.getElementById('actionBox').style.visibility='hidden';
	targetObj=document.body;
	targetObj.removeChild(targetObj.lastChild);
}
function loading() {
	newMSG=document.createElement('div');
	//targetHeight = document.body.clientHeight;
	//if(targetHeight < 1) targetHeight = '500%';

	//targetHeight = '100%';
	
	//targetHeight = targetHeight + document.body.scrollTop;
	//newMSG.style.width=1024;
	//newMSG.style.width='100%';
	newMSG.innerHTML='<table width="100%" height="'+targetHeight+'" ><tr><td width="100%" align="center" valign="middle"><table width="200" height="150"><tr><td align="center" valign="middle"><img src="/js/tdalert/images/loading.gif" border="0" alt="Loading..." onclick="enablePage(); "  /></td></tr></table></td></tr></table>';
	newMSG.style.zIndex='60003';
	actionBox_obj = document.getElementById('actionBox');
	var curleft = curtop = 0;
//	if (newMSG.offsetParent) {
//		curleft = actionBox_obj.offsetLeft
//		curtop = actionBox_obj.offsetTop
//		while (actionBox_obj = actionBox_obj.offsetParent) {
//			curleft += actionBox_obj.offsetLeft
//			curtop += actionBox_obj.offsetTop
//		}
//	}
	targetObj=document.body;
	targetObj.lastChild.appendChild(newMSG);
}
function disablePage(showloading){
		targetObj=document.body;
//		object.style.visibility='visible' or 'collapse' or 'hidden'
//		targetHeight = document.body.clientHeight;
//		if(targetHeight < 1) targetHeight = '300%';
//		else targetHeight +='px';
//
//		newBOX=document.createElement('div'); 
//		newBOX.id='disable'+2;
//		newBOX.style.left=0;
//		newBOX.style.top=0;
//		newBOX.style.width='100%';
////		newBOX.style.height=targetHeight;
//		newBOX.style.height='100%';
//		newBOX.style.background='#99ff99';
//		newBOX.style.zIndex='60000';
//		newBOX.style.filter='alpha(opacity=30)';
//		newBOX.style.opacity='.3';
//		newBOX.style.position='absolute';
//		//targetObj.appendChild(newBOX);		
		
		targetObj.style.visibility='hidden';
		//document.getElementById('disable'+2).style.visibility='visible';
		document.getElementById('actionBox').style.visibility='visible';
		if(showloading) loading();
}

