
function setNewBG()
{
	httpreqChangeBG=GetXmlHttpObjectChangeBG()
	if (httpreqChangeBG==null)
	{
	 alert ("Browser tidak support HTTP Request")
	 return
	} 
	var myBG = getBackground();
	var hrNtgl = getHariDanTanggal();
	var greeting = getGreeting();
	var fBGCol = getFrameBackground();
	var url="include/set-date-session-in-action.php"
	url=url+"?cTanggalSes="+hrNtgl
	url=url+"&sid="+Math.random()
	httpreqChangeBG.onreadystatechange=function(){
		if(httpreqChangeBG.readyState != 4)
		{
			//document.getElementById("clock_div_ID").innerHTML = '<span class="askLogin" style="font-size:20px"><b>'+greeting+'</b></span>';
		}
		
		if (httpreqChangeBG.readyState==4 || httpreqChangeBG.readyState=="complete")
		{ 
			//document.getElementById("clock_div_ID").innerHTML=httpreqChangeBG.responseText;
			//document.getElementById("bgColock_div").style.backgroundColor=myBG;
			document.getElementById("news_bg_dix").style.backgroundColor=fBGCol;
			//document.getElementById("td_widget_ctn").style.border="solid 2px "+fBGCol;
		} 
	}
	httpreqChangeBG.open("GET",url,true)
	httpreqChangeBG.send(null)
}

function GetXmlHttpObjectChangeBG()
{
var xmlHttpChangeBG=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttpChangeBG=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttpChangeBG=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttpChangeBG=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttpChangeBG;
}

function getHariDanTanggal()
{
	var cSekarang = new Date();
	var cYear = cSekarang.getFullYear();
	var cDate = cSekarang.getDate();
	var cMth = cSekarang.getMonth();
	var cDay = cSekarang.getDay();
	var nBln = "";
	switch (cMth) {
		case 0:
			nBln = "Januari";
			break;
		case 1:
			nBln = "Februari";
			break;
		case 2:
			nBln = "Maret";
			break;
		case 3:
			nBln = "April";
			break;
		case 4:
			nBln = "Mei";
			break;
		case 5:
			nBln = "Juni";
			break;
		case 6:
			nBln = "Juli";
			break;
		case 7:
			nBln = "Agustus";
			break;
		case 8:
			nBln = "September";
			break;
		case 9:
			nBln = "Oktober";
			break;
		case 10:
			nBln = "November";
			break;
		case 11:
			nBln = "Desember";
			break;
	}
	var cHari = "";
	switch (cDay) {
		case 0:
			cHari = "Minggu";
			break;
		case 1:
			cHari = "Senin";
			break;
		case 2:
			cHari = "Selasa";
			break;
		case 3:
			cHari = "Rabu";
			break;
		case 4:
			cHari = "Kamis";
			break;
		case 5:
			cHari = "Jumat";
			break;
		case 6:
			cHari = "Sabtu";
			break;
	}
	var cTanggal = cHari+",<br>"+cDate + " " +nBln+" "+cYear;
	
	return cTanggal;
}

function getBackground()
{
	datetoday = new Date(); 
	timenow=datetoday.getTime(); 
	datetoday.setTime(timenow); 
	thehour = datetoday.getHours(); 
	var bg;
	
	
	if (thehour > 22) 
	{
		bg = "#222222"; 
	} else if (thehour >21) 
	{
		bg = "#333333";
	} else if (thehour >20) 
	{
		bg = "#444444";
	} else if (thehour >19) 
	{
		bg = "#555555";
	} else if (thehour >18) 
	{
		bg = "#777777"; 
	} else if (thehour >17) 
	{
		bg = "#999999";
	} else if (thehour >16) 
	{
		bg = "#BBBBBB"; 
	} else if (thehour >15) 
	{
		bg = "#CCCCCC";
	} else if (thehour >14) 
	{
		bg = "#DDDDDD"; 
	} else if (thehour >13) 
	{
		bg = "#EEEEEE";
	} else if (thehour >12) 
	{
		bg = "#EEEEEE"; 
	} else if (thehour >11) 
	{
		bg = "#DDDDDD";
	} else if (thehour >10) 
	{
		bg = "#CCCCCC"; 
	} else if (thehour >9) 
	{
		bg = "#BBBBBB";
	} else if (thehour >8) 
	{
		bg = "#999999"; 
	} else if (thehour >7) 
	{
		bg = "#777777";
	} else if (thehour >6) 
	{
		bg = "#555555"; 
	} else if (thehour >5) 
	{
		bg = "#444444";
	} else if (thehour >4) 
	{
		bg = "#333333"; 
	} else if (thehour >3) 
	{
		bg = "#333333";
	} else if (thehour >2) 
	{
		bg = "#222222"; 
	} else if (thehour >1) 
	{
		bg = "#222222";
	} else if (thehour >0) 
	{
		bg = "#000000";
	} else 
	{
		bg = "#000000"; 
	}
	
	return bg;
}

function getGreeting()
{
	datetoday_g = new Date(); 
	timenow_g=datetoday_g.getTime(); 
	datetoday_g.setTime(timenow_g); 
	thehour_g = datetoday_g.getHours(); 
	var bg;
	if (thehour_g > 20) 
	{
		display = "Malam"; 
	} else if (thehour_g >17) 
	{
		display = "Sore";
	} else if (thehour_g >12) 
	{
		display = "Siang"; 
	} else 
	{
		display = "Pagi"; 
	}
	
	return "Selamat "+display;
}

function getFrameBackground()
{
	datetodayF = new Date(); 
	timenowF=datetodayF.getTime(); 
	datetodayF.setTime(timenowF); 
	thehourF = datetodayF.getHours(); 
	var bgF;
	
	if (thehourF > 21) 
	{
		bgF = "#0D0715"; 
	} else if (thehourF >19) 
	{
		bgF = "#211234";
	} else if (thehourF >17) 
	{
		//bgF = "#003300";
		bgF = "#412469";
	} else if (thehourF >15) 
	{
		//bgF = "#006600";
		bgF = "#8248D1";
	} else if (thehourF >13) 
	{
		//bgF = "#00AA00"; 
		bgF = "#894FDD";
	} else if (thehourF >11) 
	{
		//bgF = "#00DD00";
		bgF = "#9C65FF";
	} else if (thehourF >9) 
	{
		//bgF = "#00AA00";
		bgF = "#965EF3";
	} else if (thehourF >7) 
	{
		//bgF = "#009900";
		bgF = "#894FDD";
	} else if (thehourF >5) 
	{
		//bgF = "#006600";
		bgF = "#65369D";
	} else if (thehourF >3) 
	{
		//bgF = "#003300";
		bgF = "#412469";
	} else if (thehourF >1) 
	{
		//bgF = "#003333"; 
		bgF = "#211234";
	} else if (thehourF >0)
	{
		bgF = "#000000"; 
	} else
	{
		bgF = "#000000"; 
	}
	
	return bgF;
}

function getVLabelColor()
{
	datetodayVL = new Date(); 
	timenowVL=datetodayVL.getTime(); 
	datetodayVL.setTime(timenowVL); 
	thehourVL = datetodayVL.getHours(); 
	var bgVL;
	
	if (thehourVL > 21) 
	{
		bgVL = "#0066FF"; 
	} else if (thehourVL >19) 
	{
		bgVL = "#0066FF";
	} else if (thehourVL >17) 
	{
		//bgVL = "#003300";
		bgVL = "#0066FF";
	} else if (thehourVL >15) 
	{
		//bgVL = "#006600";
		bgVL = "#FFFFFF";
	} else if (thehourVL >13) 
	{
		//bgVL = "#00AA00"; 
		bgVL = "#FFFFFF";
	} else if (thehourVL >11) 
	{
		//bgVL = "#00DD00";
		bgVL = "#FFFFFF";
	} else if (thehourVL >9) 
	{
		//bgVL = "#00AA00";
		bgVL = "#FFFFFF";
	} else if (thehourVL >7) 
	{
		//bgVL = "#009900";
		bgVL = "#FFFFFF";
	} else if (thehourVL >5) 
	{
		//bgVL = "#006600";
		bgVL = "##0066FF";
	} else if (thehourVL >3) 
	{
		//bgVL = "#003300";
		bgVL = "##0066FF";
	} else if (thehourVL >1) 
	{
		//bgVL = "#003333"; 
		bgVL = "##0066FF";
	} else if (thehourVL >0)
	{
		bgVL = "##0066FF"; 
	} else
	{
		bgVL = "##0066FF"; 
	}
	
	return bgVL;
}
