// 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);
	
	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], '" ></a></td></tr>');
		}
		
		document.write('</table>');
		start_center++;	
	}
}

function showCounter(){
	document.write("<span id='counter' class='counter'>" + counter + "</span>");
}

function search_google() {
	document.frm_search_google.q.value = document.getElementById("textsearch").value;
	document.frm_search_google.submit();
}

function search_3cms() {
	var str = document.getElementById("textsearch").value;	
	if(str.length >= 3){
		document.search_3cms.txt_search.value = str;
		document.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;		
	}
	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 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 = 250, width = 500, 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(str)
{
	if(GetCookie("cookie_theme") == null && str=="")
	{
		str = "blue";
	}
	else if(GetCookie("cookie_theme") != null && str=="")
	{
		str=GetCookie("cookie_theme");
	}
		var themeName  = "css/" + str+".css";
		SetCookie("cookie_theme",str);
		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 hidenForm(idDiv)
{
	if(document.getElementById(idDiv).style.display=="none")
	{
		document.getElementById(idDiv).style.display="block";
	}
	else
	{
		document.getElementById(idDiv).style.display="none";
	}
}

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);
}
// danh cho phan textbox search
function checkTextSearch(obj)
{
	//alert(obj.value);
	if(obj.value == "" || obj.value=="Tim kiem...")
	{
		obj.value ="Tim kiem..."
	}
}
function checkFocus(obj)
{
	obj.value="";
}
// danh cho phan textbox search.
//ta
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();			
		}
	
}

//ta funciotn admin
function get_albumsimages(article)
{
	alert(article);
urlRequest = '?cmd=415&article='+article;
      var poststr = ""
      makePOSTAddRequest(urlRequest, poststr);
      s = "<table width=\"100%\" height=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=center>";
      s = s + "  <tr>";
      s = s + "    <td align=\"center\"><img src=\"images/loadingIcon.gif\" width=\"16\" height=\"16\" boder=\"0\"/><br>Please wait..</td>";
      s = s + "  </tr>";
      s = s + "</table>";
      document.getElementById("main_display").innerHTML = s;
	  featuredcontentslider.init({
			id: "slider1",  //id of main slider DIV
			contentsource: ["inline", ""],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
			toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]
			nextprev: ["Tr&#432;&#7899;c", "Ti&#7871;p"],  //labels for "prev" and "next" links. Set to "" to hide.
			revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
			enablefade: [true, 0.2],  //[true/false, fadedegree]
			autorotate: [true, 3000],  //[true/false, pausetime]
			onChange: function(previndex, curindex){  //event handler fired whenever script changes slide
				//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
				//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
			}
		})
	alert("asdf");
}
function makePOSTAddRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) http_request.overrideMimeType('text/html');
      } else if (window.ActiveXObject) { // IE
        try {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
          try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e) {}
        }
      }
      if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
      }
      http_request.onreadystatechange = processRequestStateChange;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
    }
    
    function processRequestStateChange() {
      if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          result = http_request.responseText;
          if(result!=""){
            //alert(result);
            document.getElementById("main_display").innerHTML = result;
          }
        } else alert('There was a problem with the request.');
      }
    }
	
	//ta.
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/


