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 setCenter2(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 setCenter2(id){
//	$(id).style.left=((getWindowSizeAll(true)[0]-$(id).offsetWidth)-($(id).offsetWidth/2)+getScrollXY()[0])+"px";
//	$(id).style.top=((getWindowSizeAll(true)[1]-$(id).offsetHeight)/5+getScrollXY()[1])+"px";
//	$(id).style.zIndex="1001";
//	}

var ie = (document.all && !window.opera);
var safari = navigator.userAgent.indexOf("Safari") != -1;
function drawMask3(fn){
	html="";
	mask=document.createElement('div');
	mask.setAttribute('id','mask');
	mask.style.background = "#ffffff";
	mask.style.left="0px";
	mask.style.top="0px";
	mask.style.bottom="0px";
	mask.style.position="absolute";
	mask.style.zIndex="9001";
	
	document.body.appendChild(mask);
	mask.style.width="100%";
//	mask.style.width=getWindowSizeAll(false)[0]+"px";
	mask.style.height=getWindowSizeAll(false)[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 fadeUp2(Id,step,fps){
	for(var i=0;i<=step;i++){
		setTimeout("fadeOpacity2('"+Id+"',"+(Math.round(100/step)*i)+")",i*fps);
	}
};
function fadeOpacity2(Id,Op){
	obj=$(Id);
	if(ie){obj.style.filter="alpha(opacity="+Op+")";}
	else{obj.style.MozOpacity=Op/100;}
}
function loadding3(fnCancel){
	drawMask3(fnCancel);
	loaddingNode=document.createElement('div');
	loaddingNode.setAttribute('id','loadding')
	loaddingNode.style.position="absolute";
	loaddingNode.style.zIndex="9002";
	loaddingNode.innerHTML="<img src=\"../images/icon/loading_2.gif\" />";
	document.body.appendChild(loaddingNode);
	setCenter2('loadding');
}
function cancelLoad3(){
	/* alert("b"); */
	document.body.removeChild($('loadding'));
	document.body.removeChild($('mask')); 
}
function closeManage3(){
	/* alert("a"); */
	//cancelLoad3();
	document.body.removeChild($('showManage'));
	showObject();
	$('cklogin').value = 0;
}

<!--     ------log in--------     -->

function loginBlog(pathLogin,servMember,ref){
	//loadding2(closeManage);
//	if($('cklogin').value==0){
//		$('cklogin').value = 1;
		inputlogin(pathLogin,servMember,ref);
//	}
}
function inputlogin(pathLogin,servMember,ref){
//loadding3(closeManage3);
//hideObject();
var html="";
	html+="<form name=\"LogIn\" action=\""+pathLogin+"\" method=\"post\" enctype=\"multipart/form-data\" >";
	html+="<dd class=\"bodyForm2\"><ul>";
	html+="<li class=\"liHouseFile2\"><p class=\"pTitle\">"+loginSignIn+"</p>";
	html+="<p class=\"pRegis\"><a href=\"http://member.mediathai.net/\" target=\"_blank\">"+loginRegister+"</a></p>";
//	html+="<p class=\"pClose\"><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 =\"closeManage3()\" /></p></li>";
	html+="</li>";
	html+="<li class=\"liHouseFile2\"><p class=\"houseTopic2\">"+loginUsername+":</p><input name=\"txt_username\" id=\"user\" type=\"text\" value=\""+ck_usname+"\" /></li>";
	html+="<li class=\"liHouseFile2\"><p class=\"houseTopic2\">"+loginPassword+":</p><input name=\"txt_password\" id=\"pass\" type=\"password\" value=\""+ck_uspwd+"\" /></li>";
	html+="<li class=\"liRemember\">";
	if(ck_usname!='' && ck_uspwd!=''){
	html+="<input name=\"chkRemember\" id=\"chkRemember\" type=\"checkbox\" value=\"on\" class=\"checkIn\" checked=\"checked\" onclick=\"setNullCookie();\" />";
	}else{
	html+="<input name=\"chkRemember\" id=\"chkRemember\" type=\"checkbox\" value=\"on\" class=\"checkIn\" />";
	}
	html+="&nbsp;"+loginRemember+"</li>";
	html+="<li class=\"liRemember\"><input name=\"\" type=\"submit\" value=\""+loginLogin+"\" class=\"bt_edit3\" onclick=\"return inputCheckSubmit()\" /></li>";
	html+="</ul></dd>";
	html+="</form>";
		
	showManageNode=document.createElement('div');	
	showManageNode.className="popupHouse";		
	showManageNode.setAttribute("id","showManage");
	showManageNode.style.zIndex="9003";
	showManageNode.innerHTML=html;	
	document.body.appendChild(showManageNode);
	//if(ie){showManageNode.style.filter="alpha(opacity=100)";}
	//else{showManageNode.style.MozOpacity="100";}
//	setCenter2('showManage');
	//fadeUp2('showManage',10,10);
}
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.LogIn.submit();
	   }
}
function cookieLogin(){
	document.forms.frmlogin.submit();
}
function forlogin(regis,sesID,pathtogo){
	if(sesID!=null){
		if(regis=="1"){
			window.location=pathtogo+'?blog_id='+sesID;
		}else{
			alert("กรุณายืนยันสร้างบล้อคของท่านก่อน\nPlease register to open your blog.");
			window.location='http://www.allblogthai.com/index.php?owner=0';
		}
	}else{
		//loadding2(closeManage); 
		//alert("คุณยังไม่ได้เข้าสู่ระบบ");
		regislogin("http://member.mediathai.net/module/account/checkUsername.php");
	}
}
function regislogin(pathLogin){

var html="";

	html+="<form name=\"LogIn\" action=\""+pathLogin+"\" method=\"post\" enctype=\"multipart/form-data\" >";
	html+="<dd class=\"bodyForm2\"><ul>";
	html+="<li class=\"liHouseFile2\"><p class=\"pTitle\">"+loginSignIn+"</p>";
	html+="<p class=\"pRegis\"><a href=\"http://member.mediathai.net/\" target=\"_blank\">"+loginRegister+"</a></p>";
	html+="<p class=\"pClose\"><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 =\"closeManage3()\" /></p></li>";
	html+="<li class=\"liHouseFile2\"><p class=\"houseTopic2\">"+loginUsername+":</p><input name=\"txt_username\" id=\"user\" type=\"text\" value=\""+ck_usname+"\" /></li>";
	html+="<li class=\"liHouseFile2\"><p class=\"houseTopic2\">"+loginPassword+":</p><input name=\"txt_password\" id=\"pass\" type=\"password\" value=\""+ck_uspwd+"\" /></li>";
	html+="<li class=\"liRemember\">";
	if(ck_usname!='' && ck_uspwd!=''){
	html+="<input name=\"chkRemember\" id=\"chkRemember\" type=\"checkbox\" value=\"on\" class=\"checkIn\" checked=\"checked\" onclick=\"setNullCookie();\" />";
	}else{
	html+="<input name=\"chkRemember\" id=\"chkRemember\" type=\"checkbox\" value=\"on\" class=\"checkIn\" />";
	}
	html+="&nbsp;"+loginRemember+"</li>";
	html+="<li class=\"liRemember\"><input name=\"\" type=\"submit\" value=\""+loginLogin+"\" class=\"bt_edit3\" onclick=\"return inputCheckSubmit()\" /></li>";
	html+="</ul></dd>";
	html+="</form>";
		
	showManageNode=document.createElement('div');	
	showManageNode.className="popupHouse";		
	showManageNode.setAttribute("id","showManage");
	showManageNode.style.zIndex="9003";
	showManageNode.innerHTML=html;	
	document.body.appendChild(showManageNode);
	//if(ie){showManageNode.style.filter="alpha(opacity=100)";}
	//else{showManageNode.style.MozOpacity="100";}
	setCenter2('showManage');
	//fadeUp2('showManage',10,10);

}

function setNullCookie(){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()-356);
	setCookie("ck_usname","",exdate.toGMTString(),"/",".allblogthai.com");
	setCookie("ck_uspwd","",exdate.toGMTString(),"/",".allblogthai.com");
	document.getElementById("user").value="Username";
	document.getElementById("pass").value="********";
	document.getElementById("chkRemember").onclick="";
}
function setCookie(c_name,value,expiredays,path,domain){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
    ((path) ? "; path=" + path : "")+
    ((domain) ? "; domain=" + domain : "")+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function hideObject(){
	var object = document.getElementsByTagName("embed");
	for(var i=0;i<object.length;i++){
		object[i].style.visibility= 'hidden' ;
	}
}
function showObject(){
	var object = document.getElementsByTagName("embed");
	for(var i=0;i<object.length;i++){
		object[i].style.visibility= 'visible' ;
	}
}

var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
