// JavaScript Document
var mondayimg="images/flashimages/1.jpg";
var tuesdayimg="images/flashimages/2.jpg"; 
var wednesdayimg="images/flashimages/3.jpg"; 
var thursdayimg="images/flashimages/4.jpg"; 
var fridayimg="images/flashimages/5.jpg"; 
var saturdayimg="images/flashimages/6.jpg"; 
var sundayimg="images/flashimages/7.jpg"; 

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function loadImagesTopLeft()
{
	var mydate=new Date(); 
	var today=mydate.getDay();
	var obj = MM_findObj("hinhtopleft");
	if (obj!=null){
		if (today==1) obj.innerHTML = '<img src="'+mondayimg+'">';
		else if (today==2) obj.innerHTML = '<img src="'+tuesdayimg+'">';
		else if (today==3) obj.innerHTML = '<img src="'+wednesdayimg+'">';
		else if (today==4) obj.innerHTML = '<img src="'+thursdayimg+'">';
		else if (today==5) obj.innerHTML = '<img src="'+fridayimg+'">';
		else if (today==6) obj.innerHTML = '<img src="'+saturdayimg+'">';
		else obj.innerHTML = '<img src="'+sundayimg+'">';
	}
}

var start_left=1;

var start_right=1;

var start_center=1;

function showDateViet() {
	// variables declaration
	var dt = new Date(shownDate + 7*3600*1000);
	
	var strMonth = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
	var strDay = new Array("Ch&#7911; Nh&#7853;t","Th&#7913; Hai","Th&#7913; Ba","Th&#7913; T&#432;","Th&#7913; N&#259;m","Th&#7913; S&aacute;u","Th&#7913; B&#7843;y");
	var date=strDay[dt.getDay()] + ", ";
	var years= dt.getYear();
	if (years<1900) years+= 1900;
	date +=" " + dt.getDate() + "-" + strMonth[dt.getMonth()] + "-" + years;
	document.write (date);	
}

function showDateENG() {

	var dt=new Date(shownDate + 7*3600*1000);
	
	var strMonth = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var strDay = new Array("Sun","Mon","Tue","Wed","Thur","Fri","Sat");
	var date=strDay[dt.getDay()] + ", ";
	var years= dt.getYear();
	if (years<1900) years+= 1900;
	date +=" " + dt.getDate() + "-" + strMonth[dt.getMonth()] + "-"+years;
	document.write (date);	
}

function showLeftAds()
{					
	if (leftAds.length>=leftCount[start_left-1]*1)	{
		document.write('<table cellspacing=0 cellpadding=0 border=0 align=center>');	
		//var endcount=leftCount[start];
		
		for(count= leftCount[start_left-1]*1; count< leftCount[start_left]*1; count++) {
			document.write('<tr><td><a href="?cmd=160&ads=',leftAds[count][2],'&url=',leftAds[count][1],'&hit=',leftAds[count][3],'" target="_blank"><img src="', leftAds[count][0], '" border=0 style="border:1px solid #0066CC;margin-bottom:5"></a></td></tr>');
		}
		
		document.write('</table>');
		start_left++;
	}
}

function showRightAds()
{		
	if (rightAds.length>=rightCount[start_right-1]*1)	{
		document.write('<table cellspacing=0 cellpadding=0 align=center>');	
		//var endcount=startcount + rightCount[start];
		
		for(count= rightCount[start_right-1]*1; count< rightCount[start_right]*1; count++) {
			document.write('<tr><td><a href="?cmd=160&ads=',rightAds[count][2],'&url=',rightAds[count][1],'&hit=',rightAds[count][3],'" target="_blank"><img src="', rightAds[count][0], '" border=0 style="border:1px solid #0066CC;margin-bottom:5"></a></td></tr>');
		}
		
		document.write('</table>');
		start_right++;	
	}
}

function showCenterAds()
{		
	if (centerAds.length>=centerCount[start_center-1]*1)	{
		
		document.write('<table cellspacing=0 cellpadding=0 border=0 align=center>');		
		
		for(count = centerCount[start_center-1]*1; count < centerCount[start_center]*1; count++) {			
			document.write('<tr><td align="center"><a href="?cmd=160&ads=',centerAds[count][2],'&url=',centerAds[count][1],'&hit=',centerAds[count][3],'" target="_blank"><img src="', centerAds[count][0], '" border=0"></a></td></tr>');
		}
		
		document.write('</table>');
		start_center++;	
	}
}

function showCounter(){
	document.write("<span id='counter' class='counter'>" + counter + "</span>");
}

function search_google() {
	document.getElementById("q").value = document.getElementById("textsearch").value;
	document.getElementById("frm_search_google").submit();
}

function search_3cms() {
	var str = document.getElementById("textsearch").value;	
	if(str.length >= 3){			
		document.getElementById("txt_search").value = str;		
		document.getElementById("search_3cms").submit();
	}	
}

function search_3cms_detail(){
	var obj = document.getElementById("txt_searchDetail");	
	var sPara = "";	
	
	if(obj && obj.value!=""){
		sPara = "&txt_search=" + obj.value;		
	}
	obj = document.getElementById("txt_search_title");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_title=" + obj.value;		
	}
	obj = document.getElementById("txt_search_summary");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_summary=" + obj.value;		
	}
	obj = document.getElementById("txt_search_content");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_content=" + obj.value;		
	}
	obj = document.getElementById("txt_search_starttime_form");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_starttime_form=" + obj.value;		
	}
	obj = document.getElementById("txt_search_starttime_to");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_starttime_to=" + obj.value;		
	}
	obj = document.getElementById("txt_search_endtime");
	if(obj && obj.value!=""){
		sPara = sPara + "&txt_search_endtime=" + obj.value;		
	}
	obj = document.getElementById("search_site");
	if(obj && obj.value!=""){
		sPara = sPara + "&search_site=" + obj.value;		
	}
	if(sPara!="") window.location = "/3cms?cmd=140"+sPara;
	
}

function switchSearch(){
	var obj = document.getElementById("rdo_search");	
	if(obj.checked){
		search_3cms();	
	}
	else {
		search_google();
	}
	
	return false;
}
function switchSearchIn(){	
	search_3cms();		
	return false;
}

function change_website_songanh(form) {
	var selected_item = form.select_songanh.selectedIndex;
	if(selected_item != 0)
	{
		form.action = form.select_songanh[selected_item].value;
		form.submit();
	}
}

function change_baodientu(form) {
	var selected_item = form.select_baodientu.selectedIndex;
	if(selected_item != 0)
	{
		form.action = form.select_baodientu[selected_item].value;
		form.submit();
	}
}

function check_binhchon(form, poll_id) {
	var poll_option_id = 0;
	for(var i = 0; i < form.poll_option.length; i++)
	{
		if (form.poll_option[i].checked) {
			poll_option_id = form.poll_option[i].value;
		}
	}
	window.open( "?cmd=150&poll_id=" + poll_id + "&poll_option_id=" +poll_option_id, "myWindow","toolbar=no,status = 0, height = 300, width = 550, resizable = 0" );
}

function openFormMail(url,name) {
	var options = "width=550,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no";		
	new_window = window.open(url, name, options);		
	window.self.name = "main";
	new_window.focus();		
}

function openform(url,width,height,view) {	
	var options;		
	if(width==""){
		width = "500" ;
	}
	if(height==""){
		height = "300" ;
	}
	options = "width=" + width + ",height=" + height + ",";
	if(view==1){
		options = options + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no";
	}	
	new_window = window.open(url,"openform", options);
	window.self.name = "main";
	new_window.focus();
}

function openWithSelfMain(url,name,width,height) {
	var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no";
	new_window = window.open(url, name, options);
	window.self.name = "main";
	new_window.focus();
}
//ta

function vnitt_changeTheme(defaultskin,str){
			var mydomain=window.location.hostname;	
			var pathname = window.location.pathname;					
			if(Get_Cookie("cookie_theme") == null && defaultskin=="1")
				{ 					
					
				}				
			else if(Get_Cookie("cookie_theme") != null && defaultskin=="1")
				{			
					str=Get_Cookie("cookie_theme");					
				}		
				
			if(Get_Cookie("cookie_theme")!=str){
				Delete_Cookie( "cookie_theme", "/3cms", "" );
			}
			var themeName  = "css/" +str+".css";
			
			Set_Cookie("cookie_theme",str,0,"/3cms",mydomain,"");			
			fileref = document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", themeName);
			document.getElementsByTagName("head").item(0).appendChild(fileref);
	}
function Open_URL(url, vWidth, vHeight) 
{

	winDef = 'status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=no,copyhistory=no,directories=no,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open(url, '_blank', winDef);
}
function Open_Popup(url, vWidth, vHeight) 
{

	winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=no,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open(url, '_blank', winDef);
}
function hidenForm(idDiv)
{
	if(document.getElementById(idDiv).style.display=="none")
	{
		document.getElementById(idDiv).style.display="block";
	}
	else
	{
		document.getElementById(idDiv).style.display="none";
	}
}
// danh cho phan textbox search
function checkTextSearch(obj)
{
	//alert(obj.value);
	if(obj.value == "" || obj.value=="Tìm kiếm...")
	{
		obj.value ="Tìm kiếm..."
	}
}
function submitenter(e)
{
	var rdo_search = document.getElementById("rdo_search");
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	   {
	   rdo_search.submit();
	   return false;
	   }
	else
	   return true;
}

function checkFocus(obj)
{
	obj.value="";
}

function searchMartyr(){
		
		if(document.getElementById("radiosearchmartyr1").checked){		
			frmsearch.submit();
		}
		if(document.getElementById("radiosearchmartyr2").checked)
		{
			frm_searchmartyr.name.value=radiosearchmartyr=document.getElementById("hotenls").value;		
			frm_searchmartyr.unit.value=radiosearchmartyr=document.getElementById("Donvils").value;
			frm_searchmartyr.birthplace.value=radiosearchmartyr=document.getElementById("quequanls").value;
			frm_searchmartyr.deathplace.value=radiosearchmartyr=document.getElementById("noimatls").value;	
			frm_searchmartyr.cemeteries.value=0;		
			frm_searchmartyr.submit();			
		}
	
}