function getWindowSizeAll(a){var myWidth=0,myHeight=0;if(typeof(window.innerWidth)=='number'){scrollSize=16;myWidth=(a)?window.innerWidth:window.screen.width;myHeight=(a)?window.innerHeight:document.body.parentNode.scrollHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=(a)?document.documentElement.clientWidth:document.body.offsetWidth;myHeight=(a)?document.documentElement.clientHeight:document.body.parentNode.scrollHeight;scrollSize=2;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=(a)?document.body.clientWidth:document.body.offsetWidth;myHeight=(a)?document.body.clientHeight:document.body.offsetHeight;scrollSize=2;}return[myWidth-scrollSize,myHeight];}
function getScrollXY(){var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX= window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}return[scrOfX,scrOfY];}

function $(id){return document.getElementById(id);};
function spacialTag(txt){txt=txt.replace(/>/g,'&gt;');txt=txt.replace(/</g,'&lt;');return txt;}
function spacialChar(txt){txt=txt.replace(/\\u000a|\\u000d/g," ");txt=txt.replace(/\\u0026/g,"&");return txt;}
function getDataNode(p,t){try{return p.getElementsByTagName(t)[0].firstChild.nodeValue;}catch(e){return "";}};
function setCenter(id){$(id).style.left=((getWindowSizeAll(true)[0]-$(id).offsetWidth)/2+getScrollXY()[0])+"px";$(id).style.top=((getWindowSizeAll(true)[1]-$(id).offsetHeight)/2+getScrollXY()[1])+"px";};

function drawMask(fn){
	html="";
	mask=document.createElement('div');
	mask.setAttribute('id','mask');
	mask.style.left="0px";
	mask.style.top="0px";
	mask.style.bottom="0px";
	mask.style.position="absolute";
	mask.style.backgroundColor="#000000";
	
	document.body.appendChild(mask);
	mask.style.width=getWindowSizeAll(true)[0]+"px";
	mask.style.height=getWindowSizeAll(true)[1]+"px";
	if(ie){mask.style.filter="alpha(opacity=40)";}
	else{mask.style.opacity=0.4;}
	if(fn){mask.onclick=fn;mask.style.cursor="pointer";}
}
function fadeUp(Id,step,fps){
	for(var i=0;i<=step;i++){
		setTimeout("fadeOpacity('"+Id+"',"+(Math.round(100/step)*i)+")",i*fps);
	}
};
function fadeOpacity(Id,Op){
	obj=$(Id);
	if(ie){obj.style.filter="alpha(opacity="+Op+")";}
	else{obj.style.MozOpacity=Op/100;}
}
function loadding(fnCancel){
	drawMask(fnCancel);
	loaddingNode=document.createElement('div');
	loaddingNode.setAttribute('id','loadding')
	loaddingNode.style.position="absolute";
	//loaddingNode.innerHTML="<img src=\"../images/icon/loading_2.gif\" />";
	document.body.appendChild(loaddingNode);
	setCenter('loadding');
}
function cancelLoad(){
	document.body.removeChild($('loadding'));
	document.body.removeChild($('mask'));
}
function closeManage(){
	cancelLoad();
	document.body.removeChild($('showManage'));
}
function inputCheckSubmit(){
	if(document.getElementsByName("txt_username")[0].value==""){
		document.getElementsByName("txt_username")[0].focus();
		alert("Iuput Username");
		return false;
	}else if(document.getElementsByName("txt_password")[0].value==""){
		document.getElementsByName("txt_password")[0].focus();
		alert("Iuput Password");
		return false;
	}else{
		document.forms.fmLogin.submit();
	}
}
function inputCheckSubmit2(){
	if(document.getElementsByName("txt_username2")[0].value==""){
		document.getElementsByName("txt_username2")[0].focus();
		alert("Iuput Username");
		return false;
	}else if(document.getElementsByName("txt_password2")[0].value==""){
		document.getElementsByName("txt_password2")[0].focus();
		alert("Iuput Password");
		return false;
	}else{
		document.forms.fmLogin2.submit();
	}
}
function chklogin(sesID,pathLogin){
	var chkB=$('chkBoxLg').value;
	if(chkB=="1"){
		document.body.removeChild($('showManage'));
		$('chkBoxLg').value="0";
	}
	if(sesID==""||sesID=="0"){
		boxlogin(pathLogin);
		$('chkBoxLg').value="1";
	}
}
function boxlogin(pathLogin){
var html="";
	html+="<form name=\"fmLogin2\" id=\"fmLogin2\" action=\""+pathLogin+"\">";
	html+="<div class=\"boxPopup\">";
	html+="<div class=\"st\">";
	html+="<div class=\"stlogin\">LOGIN ";
	html+="<span class=\"stRegis\">";
	html+="<a href=\"javascript:void(0)\" onclick=\"javascript:window.open('http://member.mediathai.net');closeManage(); return false;\" target=\"_blank\">Register</a> | ";
	html+="<a href=\"javascript:void(0)\" onclick=\"javascript:window.open('http://member.mediathai.net/module/help/message_email.php');closeManage(); return false;\">Forgot Password</a>";
	html+="&nbsp;<img src=\"../images/icon/icon_close.gif\" onmouseout =\"this.src='../images/icon/icon_close.gif'\" onmouseover =\"this.src='../images/icon/icon_close_over.gif'\" onclick =\"closeManage()\" />&nbsp;";
	html+="</span></div>";
	html+="</div>";
	html+="<div class=\"sc\">";
	html+="<div class=\"sp1\">Username :</div>";
	html+="<div class=\"sp2\"><input type=\"text\" name=\"txt_username2\" id=\"txt_username2\" class=\"input\" value=\"\"/></div>";
	html+="<div class=\"sp1\">Password :</div>";
	html+="<div class=\"sp2\"><input  type=\"password\" name=\"txt_password2\" id=\"txt_username2\"  class=\"input\" value=\"\" /></div>";
	html+="<div class=\"sp1\">&nbsp;</div>";
	html+="<div class=\"sp2\"><input type=\"submit\" name=\"Button\" value=\"Login\" style=\"vertical-align:middle;\" onclick=\"return inputCheckSubmit2();\"/></div>";
	html+="</div>";
	html+="<div class=\"sf\"></div>";
	html+="</div>";
	html+="</form>";
		
	showManageNode=document.createElement('div');	
	showManageNode.className="popupHouse";		
	showManageNode.setAttribute("id","showManage");	
	showManageNode.innerHTML=html;	
	document.body.appendChild(showManageNode);
	setCenter('showManage');
}
function closeManage(){
	document.body.removeChild($('showManage'));
	$('chkBoxLg').value="0";
}


