/* 
	# @Copyrights 2006 by VNSS
	# @All rights reserved
	# @Write by: Hung Bui
*/

function check_all( n ) 
{
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) 
	{
		cb = eval( 'f.cb' + i );
		if (cb) 
		{
			cb.checked = c;
			n2++;
		}//end if
	}//end for

	if (c) 
	{
		document.adminForm.boxchecked.value = n2;
	}else{
		document.adminForm.boxchecked.value = 0;
	}//end if
}//end function

function isChecked(isitchecked)
{
	if (isitchecked == true)
	{
		document.adminForm.boxchecked.value++;
	}else{
		document.adminForm.boxchecked.value--;
	}//end if
}//end function

function listItemTask( id, task ) 
{
	var f = document.adminForm;
	cb = eval( 'f.' + id );
	if (cb) {
		cb.checked = true;
		submitbutton(task);
	}
	return false;
}//end if

function submitbutton(pressbutton) 
{
	submitform(pressbutton);
}//end function

function submitform(pressbutton)
{
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}//end function

function open_color(field) 
{
	this.field = field;
	window_opent = window.open('./color.php', null, 'resizable: yes; help: yes; status: yes; scroll: yes;');
	window_opent.opener = window;
	window_opent.focus();
}

function showCalendar(id) 
{
	var el = document.getElementById(id);
	if (calendar != null) 
	{
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	}else{
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}

function selected(cal, date) 
{
	cal.sel.value = date; // just update the value of the input field
}

function closeHandler(cal) 
{
	cal.hide();			// hide the calendar
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

function checkCalendar(ev) 
{
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) 
	{
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

function getSelectedValue( frmName, srcListName ) 
{
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) 
	{
		return srcList.options[i].value;
	} else {
		return null;
	}
}

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_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_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];}
}

function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
	window.open(theURL,winName,features);
}
function play(fileName) {
  document.write("<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"MediaPlayer1\"  width=\"100%\" height=\"350\">");
  document.write("<param name=\"AutoStart\" value=-1>");
  document.write("<param name=\"AnimationAtStart\" value=0>");
  document.write("<param name=EnableContextMenu value=0>");
  document.write("<param name=AutoSize value=0>");  
  document.write("<param name=EnablePositionControls value=-1>");
  
  document.write("<param name=Filename value="+ fileName +">");
  document.write("<param name=PlayCount value=500>");
  document.write("<param name=WindowlessVideo value=0>");
  document.write("<param name=ShowDisplay value=0>");  
  document.write("<param name=ShowCaptioning value=0></object>");
}