//Display banner ads by group
function ad(fn, w, h, g, url){ 	 
	var so = new SWFObject("/banners/"+fn+".swf", "banner_ads_"+fn, w, h, "0", "#FFFFFF");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addVariable("AURL", url);
	so.write("banner_ads_group"+g);
}

/******************************/

//Search Bar at the top
function ChangeSearch() {
	if (document.searchForm.engine[0].checked){ //Everyday.com.kh in Google
		document.searchForm.sitesearch.value="everyday.com.kh";
		document.searchForm.channel.value="7160702855";
		document.searchForm.action="http://www.google.com/custom";
		return true;
	}else{ // Google
		document.searchForm.sitesearch.value="";
		document.searchForm.channel.value="2774955638";
		document.searchForm.action = "http://www.google.com/custom";
		return true;
	}
}

function SubmitSearch() {
	ChangeSearch();
	if (document.searchForm.q.value=="") {
 		alert("Please enter a search term.");
		return false;
	}else{
 		if (document.searchForm.engine[1].checked) { // Google 
 			document.searchForm.target="googlewindow";
 		}
 		else { 
			document.searchForm.target="_self";
		}
		document.searchForm.submit();
 		return true;
 	}
}
/**********************************/

//switch Image menuleft
var ifriend1 = new Image();
ifriend1.src = "/imgEday/btnMenu/i-friendBlue.gif";
var ifriend2 = new Image();
ifriend2.src = "/imgEday/btnMenu/i-friendOrg.gif";
var Mail1 = new Image();
Mail1.src = "/imgEday/btnMenu/MailBlue.gif";
var Mail2 = new Image();
Mail2.src = "/imgEday/btnMenu/MailOrg.gif";
var Net1 = new Image();
Net1.src = "/imgEday/btnMenu/NetBlue.gif";
var Net2 = new Image();
Net2.src = "/imgEday/btnMenu/NetOrg.gif";
//KH preload Image
var KHMail1 = new Image();
KHMail1.src = "/imgEday/btnMenu/KHMailBlue.gif";
var KHMail2 = new Image();
KHMail2.src = "/imgEday/btnMenu/KHMailOrg.gif";
var KHNet1 = new Image();
KHNet1.src = "/imgEday/btnMenu/KHNetBlue.gif";
var KHNet2 = new Image();
KHNet2.src = "/imgEday/btnMenu/KHNetOrg.gif";
function hilite(img)
{
document[img].src	= eval(img + "2.src"); 
}

function lolite(img)
{
document[img].src	= eval(img + "1.src");
}
/************************************/

//Caching image
var ct_img_expanded = 'http://www.everyday.com.kh/styles/bullet.gif';
var ct_img_collapsed = 'http://www.everyday.com.kh/styles/bullet_wht.gif';
(new Image(15,15)).src = ct_img_expanded; // caching
(new Image(15,15)).src = ct_img_collapsed; // caching


function ct_Expand(htmlNode,imgNode) {
    
    if (document.getElementById && document.getElementById(htmlNode) != null) {
		document.getElementById(imgNode).src=ct_img_expanded;
		document.getElementById(htmlNode).className='categoryListExpanded';
	}
}

function ct_Collapse(htmlNode,imgNode) {
	
	if (document.getElementById && document.getElementById(htmlNode) !=  null) {
		document.getElementById(imgNode).src=ct_img_collapsed;
		document.getElementById(htmlNode).className='categoryListCollapsed';
	}
}

function ct_toggleExpansionStatus(htmlNode,imgNode) {
	if (document.getElementById && document.getElementById(htmlNode) !=  null) {
		nodeState = document.getElementById(htmlNode).className;
	}
    if (nodeState == 'categoryListCollapsed') {
        ct_Expand(htmlNode,imgNode);
	}
	else {
		ct_Collapse(htmlNode,imgNode);
	}
}

//Popup english new window
function news_eng(mycookie,myurl){

	myurl2 = "http://www.everyday.com.kh/dir/news/top.asp?from="+escape(mycookie);
	newWin = window.open('','','menubar=yes,scrollbars=yes,resizable=yes,width=688,height=500,left=10,top=10,toolbar=yes,status=yes');
	newWin.document.open();
	newWin.document.write('<head><title>'+ 'Everyday News</title></head>'
	+ '<FRAMESET ROWS=65,* frameborder=NO >'
	+ '<FRAME NAME=frame0 SRC='+myurl2+' noresize scrolling=NO>'
	+ '<FRAME NAME=frame1 SRC='+myurl+'>'
	+ '</FRAMESET>');
	newWin.document.close;
}
/**********************************/

//Popup window
function popfunc(theURL,winName,features) { 
	var bname = navigator.appName
	if (bname.indexOf('Netscape'))  {
		window.open(theURL,winName,features);
	} else if (bname.indexOf('Microsoft')){
		var winOpened=window.open(theURL,winName,features);
		winOpened.focus();
	}
}
/**********************************/

//Popup new window for news content
function popeye(url) {
var h = 500;		
var bname = navigator.appName
	if (bname == "Netscape")  {
		var w = 680;
	} else{
		var w = 688;
	}
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
//if (wint < 0) wint = 0;

windowprops = "height="+h+",width="+w+",top=0,left="+ winl +",location=no,"
+ "scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes";
window.open(url, "Popup", windowprops);
}

function popKU(url) {
var h = 500;		
var bname = navigator.appName
	if (bname == "Netscape")  {
		var w = 800;
	} else{
		var w = 800;
	}
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
//if (wint < 0) wint = 0;

windowprops = "height="+h+",width="+w+",top=0,left="+ winl +",location=no,"
+ "scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes";
window.open(url, "Popup", windowprops);
}
/**********************************/

//Popup new window for game services
function fullscreen(url){
	winwin=window.open(url,'popupscript','top=0,left=0,width='+(screen.availWidth-10)+',height='+(screen.availHeight-48)+',fullscreen=0,toolbar=0,location=0,status=0,menubar=0,resizable=1,scrollbars=1');
	if (window.focus) {winwin.focus()}
}
/**********************************/


//Chat Room
function Open_MainChatRoom(){
	var tnick = document.formchat.nick.value;
	var sind = document.formchat.channel.selectedIndex;
	var tchannel = document.formchat.channel.options[sind].value;
	var chatURL = "/hidden/chat/newchat.asp?tnick="+tnick+"&tchannel="+tchannel;
	var s = window.open(chatURL,"Chat","toolbar=no,status=yes,resizable=yes,location=no,scrollbar=no,width=740,height=640,top=1,left=1");
	s.focus();
}
/**********************************/

//*** Preload image ***
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//*********************************
