// JavaScript Document
function setHomepage(url){if(document.all){document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(url);}else if(window.sidebar){if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
catch(e){var strTemp='';strTemp+="Incompatible browser !";alert(strTemp);}}
var prefs=Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',url);}}
function clickToDelete(e,text){if(e.value==text){e.value="";}}
function mouseOutToRestore(e,text){if(e.value==""){e.value=text;}}
function FormSubmit(){if(document.getElementById("searchInput").value=="Tìm kiếm")document.getElementById("searchInput").value = ""; document.getElementById('btnTim').click();}

function changeMultiboxes(obj, id){
	if (!obj) return false;
	num = obj.value;
	$(obj).parent().find(".multiboxes").css("display", "none");
	document.getElementById(id+"_"+num).style.display = "";
}

// Media player
mediaControl = "MediaPlayer";
function replaceSource(strSource, ctrl, mwidth, mheight)
{
    var s;
	if (!mwidth) mwidth=415; if (!mheight) mheight = 340;
    s="<OBJECT id=winMediaPlayerID ";
		s+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
		s+="type=application/x-oleobject height='"+mheight+"' ";
		s+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
		s+="width='"+mwidth+"' classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
		s+="name=winMediaPlayer>";
        s+="<PARAM NAME=\"URL\" VALUE=\""+strSource+"\"> ";
        s+="<PARAM NAME=\"rate\" VALUE=\"1\">";
        s+="<PARAM NAME=\"balance\" VALUE=\"0\">";
        s+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
        s+="<PARAM NAME=\"defaultFrame\" VALUE=\"0\">";
        s+="<PARAM NAME=\"playCount\" VALUE=\"999\">";
        s+="<PARAM NAME=\"CursorType\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"autoStart\" VALUE=\"1\">";
        s+="<PARAM NAME=\"currentMarker\" VALUE=\"0\">";
        s+="<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"volume\" VALUE=\"50\">";
        s+="<PARAM NAME=\"mute\" VALUE=\"0\">";
        s+="<PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
        s+="<PARAM NAME=\"windowlessVideo\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enabled\" VALUE=\"1\">";
        s+="<PARAM NAME=\"fullScreen\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enableContextMenu\" VALUE=\"0\">";
        s+="<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
        
        s+="<Embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='"+strSource+"' src='"+strSource+"' Name='MediaPlayerTV' "; 
		s+="width='"+mwidth+"' ";
		s+="height='"+mheight+"' ";
		s+="AutoSize='1' ";
		s+="AutoStart='1' ";
		s+="ClickToPlay='1' ";
		s+="DisplaySize='1' ";
		s+="EnableContextMenu='0' ";
		s+="EnableFullScreenControls='1' "; 
		s+="EnableTracker='1' ";
		s+="Mute='0' ";
		s+="PlayCount='999' "; 
		s+="ShowControls='1' "; 
		s+="ShowAudioControls='1' "; 
		s+="ShowDisplay='0' ";
		s+="ShowGotoBar='0' ";
		s+="ShowPositionControls='1' "; 
		s+="ShowStatusBar='1' ";
		s+="ShowTracker='1'> ";
		s+="</embed> ";
    s+="</OBJECT>";
	if (!ctrl) ctrl = mediaControl;
    document.getElementById(ctrl).innerHTML=s;
}
function replaceFlash(strSource, ctrl, width, height){
	if (!width) width=415;
	if (!height) height=340;
	dheight = parseInt(height)-20;
	s = "<embed type=\"application/x-shockwave-flash\" src=\"../packages/players/mediaplayer.swf\" style=\"\" id=\"playlist\" name=\"playlist\" quality=\"high\"";
	s+= "allowfullscreen=\"true\" flashvars=\"file=" + strSource + "&amp;start=1&amp;";
	s+= "displayheight="+dheight+"&amp;width="+width+"&amp;height="+height+"&amp;"; 
	s+= "backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x557722&amp;shuffle=false&amp;repeat=list\" height=\""+height+"\" width=\""+width+"\">;";
	if (!ctrl) ctrl = mediaControl;
    document.getElementById(ctrl).innerHTML=s;
}
function resizeCanvas(obj){
	if (!obj) return false;
	//obj.height = obj.contentWindow.document.height;
	$(obj).css("height", obj.contentWindow.document.height+50);
}

