﻿// global variable
var numPic=0;
// --------------------------------------------
function generateBG(){
	var bg=document.createElement("div");
	bg.style.cssText="position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:black;opacity:.5;display:block";
	bg.setAttribute("id","bgLogIn");
	bg.ondblclick=closeForm;
	document.body.appendChild(bg);
}
function logInForm(e_pos){
	var section=document.createElement("div");
	
	section.style.cssText="position:fixed;top:"+(e_pos.clientY-50)+"px;right:"+(e_pos.clientX-710)+"px;width:700px;height:400px;background-color:white;opacity:1;border:5px solid lightblue;-webkit-box-shadow:3px 3px 15px black;padding:10px;display:block;z-index:100;";
	section.setAttribute("id","boxForm");
	
	//document.body.style.cssText="overflow:hidden;";
	section.innerHTML="<h2>เข้าสู่ระบบ - Tonhom Web Engine</h2>";
	section.innerHTML+="User Name : <input type='text' size='10' id='userName'> || Password : <input type='password' size='10' id='password'> <button onclick='authenUser()'>เข้าสู่ระบบ</button> <button onclick='closeForm();'>ปิดหน้าต่างล็อกอิน</button><br>";
	section.innerHTML+="<br><div id='statusReport' style='border:1px solid gray;overflow:auto;height:100px;width:95%;padding:10px;'></div>";
	generateBG();
	document.body.appendChild(section);
	document.getElementById("vdoBox").style.display="none";
}
function closeForm(){
	var target=document.getElementById("bgLogIn");
	document.body.removeChild(target);
	target=document.getElementById("boxForm");
	document.body.removeChild(target);
	document.getElementById("vdoBox").style.display="block";
	//document.body.style.cssText="overflow:visible;";
}
function lastUpdate(){
	lastUpdateSection.innerHTML="";
	var url="getLastUpdate.php";
	getLastUpdate(url,"0",getLastUpdateCallback);
	//Invite_googleChrome();
}
function _dynamicPage(numParam){
	var url;
	var h;
	switch(numParam){
		case 0: url="Filecontent/services.html"; h="950"; break;
		case 1: url="Filecontent/application.html"; h="900"; break;
		case 2: url="Filecontent/help.html"; h="800"; break;	
	}
	setVisible(url,h);
}
function setVisible(url,h){
	var section=document.getElementById("_frame_content");
	section.style.cssText="width:856px;min-height:"+h+"px;background-color:#fff6c5;";
	section.innerHTML="";
	section.innerHTML+="<a name='contentPoint'></a>";
	section.innerHTML+="<iframe src="+url+" width='856px' height='"+(h-32)+"' frameborder='0'></iframe>";
	section.innerHTML+="<button onclick='closeFrame();'> [ x ] ปิดเนื้อหา </button>";
}
function closeFrame(){
	var section=document.getElementById("_frame_content");
	section.innerHTML="";
	section.style.cssText="width:0px;min-height:0px;background-color:white;visibility:hidden";
}
function func_changeBg(){ 
	++numPic;
	if(numPic==3) numPic=0;
	if(numPic==0) document.body.style.cssText="background-image:url(images/wallpaper_01.jpg)!important;"; 
	if(numPic==1)  document.body.style.cssText="background-image:url(images/wallpaper_02.jpg)!important;"; 
	if(numPic==2)  document.body.style.cssText="background-image:url(images/wallpaper_03.jpg)!important;";
}
function moreInfo_update(e,numParam){
	var url="getLastUpdate_description.php";
	getLastUpdate(url,(numParam+1),getLastUpdateCallback_description);
	descriptionBox.style.cssText="position:absolute;top:"+(e.clientY+10)+"px;left:"+(e.clientX+10)+"px;min-height:150px;width:300px;background-color:#f3f3f3;border:5px solid lightblue;-webkit-box-shadow:1px 1px 3px gray;padding:5px;";
}
function hideDescription(){
	descriptionBox.style.cssText="position:absolute;top:-3000px;height:300px;width:400px;";
	descriptionBox.innerHTML="<h3>กำลังโหลดข้อมูล....</h3>";
}

// Initial Form for some purpose . now not use it
function Invite_googleChrome(){
	alert("It 's OK - ฟังก์ชั่นนี้จะถูกแทนที่ด้วยการใส่ Initial Information(ข่าวสารเริ่มต้น) + เดี๋ยวคราวหลังผมจะเอาโฆษณามาแปะนะครับ ยังไงก็ฝากเพื่อนๆคลิ๊กด้วยนะครับ");
}
