
// 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 modalDialogShow_IE(url,width,height) //IE
	{
	return window.showModalDialog(url,window,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:No;Maximize:No");
	}
	
function modalDialogShow_Moz(url,width,height) //Moz
    {
    var left = screen.availWidth/2 - width/2;
    var top = screen.availHeight/2 - height/2;
    activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
    window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
    }
	
function openPopup(url) {
    if(navigator.appName.indexOf('Microsoft')!=-1)
		modalDialogShow_IE(url,355,455); //IE	
	else
		modalDialogShow_Moz(url,355,455); //Moz		
}

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 >');	
		//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" width="118"></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 border=0 >');	
		//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" width="50"></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 >');		
		
		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 style="border:1px solid #0066CC;margin-bottom:5" width="145"></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 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" );
	//form.submit();
}

function openFormMail(url,name) {
	var options = "width=500,height=290,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;		
	//alert("url = " + <%=HOST_URL%>);
	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();
}
