function thisMovie(movieName) 
{
  if (window.document[movieName]) 
  {
	return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
	if (document.embeds && document.embeds[movieName])
	  return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
	return document.getElementById(movieName);
  }
}
			
function hideTable()
{
	var master_ul = document.getElementById('hideFlash0').getElementsByTagName("td");
	document.getElementById('hideFlash1').style.display = 'none';
	document.getElementById('hideFlash2').style.display = 'none';
	document.getElementById('hideFlash4').style.display = 'none';
	document.getElementById('hideFlash5').style.display = 'none';
	document.getElementById('hideFlash6').style.display = 'none';
	for (var i=0; i<master_ul.length; i++)
	{
		var child_div = master_ul[i];
		child_div.style.visibility = "hidden";
	}
	document.getElementById('showFlash0').style.visibility = "visible";
}
	
function popup_kill(obj)
{
	//document.getElementById(obj).style.display = "block";
	dead = setTimeout('Modalbox.hide()',3000);
}

//open popup win
function OpenWin(url, name, width, height, property)
{
	this.x = (screen.width - width) / 2; 
	this.y = (screen.height - height - 60) / 2; 
	property = 'top=' + this.y + ',left=' + this.x + ',width=' + width + ',height=' + height + ',' + property;
//	property = "scrollbars=1,resizable=1,menubar=1,status=1,location=1,toolbar=1"
	newwindow = window.open(url,name,property);
	if (window.focus) 
	{
		newwindow.focus();
	}
}

//kiem tra so va khong co cac ky tu khac
function CheckNumber(stringIn)
{
     retval = false
     var i;
     for (i=0;i<=stringIn.length-1;i++) 
	 {
         if ((stringIn.charCodeAt(i) >= 48) && (stringIn.charCodeAt(i) <= 57))
		 {
           	retval = true;
         }
		 else
		 {
			retval = false;
			break;
         }
     }
     return retval;
}
/*
*function CheckPass chi cho phep cac ky tu a-z , A-Z , ._-@
* @param string : string can kiem  tra
* @return true neu dung yeu cau, nguoc lai la false.
*/
function CheckPass(stringIn) 
{
     retval = false;
     var i;
     for (i=0;i<=stringIn.length-1;i++) 
	 {
		mcode = stringIn.charCodeAt(i);
		if(((mcode >=64) && (mcode <=90)) || ((mcode >=97) && (mcode <=122)) || ((mcode >=48) && (mcode <=57)) || (mcode == 45) || (mcode ==95) || (mcode ==46))
		{
           	retval = true;
         }
		 else
		 {
			retval = false;
			break;
         }
     }
     return retval;
}
/*
*function CheckEmail dung de kiem tra co dung kieu email hay khong (chi co 1 dau @, va it nhat 1 dau ".")
*@param email : nhap emial can kiem tra
*@return false khong dung kieu email, true thoa dieu kien.
*/
function CheckEmail(stringIn)
{
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
	if (stringIn.search(re) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

//cat bo hai dau khoang trang
function trim(val)
{ 
	return val.replace(/^\s+|\s+$/g, "");
}

function stripPHP(str)
{
	str = trim(str);
	str = str.replace(/<\?php/g, "");
	str = str.replace(/<\?/g, "");
	str = str.replace(/\?>/g, "");
	return str;
}

//-- kiem tra loai file nhac
function CheckFile(stringIn)
{
	extension = stringIn.substr(stringIn.length-3, stringIn.length);
	extension = extension.toLowerCase();
	if (extension.search('mp3') != -1 || extension.search('wma') != -1 )
	{
		return true;
	}
	else
	{
		return false;
	}
}

//-- kiem tra loai file hinh
function CheckFileImg(stringIn)
{
	extension = stringIn.substr(stringIn.length-3, stringIn.length);
	extension = extension.toLowerCase();
	if (extension.search('jpeg') != -1 || extension.search('jpg') != -1 )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function isValidSymbol(strValue)
{
	var strSymbol = '<,>,%,$,^,*,{,},"';
	var arrSymbol = strSymbol.split(",");
	var n = arrSymbol.length;
	for (var i=0; i<n; i++)
	{
		if ( strValue.indexOf(arrSymbol[i])>-1 )
		{
			return true;
		}
	}
	return false;
}

function music_setCookie(name, value) 
{	
	document.cookie = name + "=" + value + ";path=/";
}

function music_getCookie(c_name)
{
	if( document.cookie.length > 0 )
	{
		c_start = document.cookie.indexOf(c_name + "=")
	 	if( c_start != -1 )
		{
			c_start = c_start + c_name.length + 1
			c_end	= document.cookie.indexOf(";", c_start)
			if( c_end == -1 ) c_end = document.cookie.length;
			a = unescape(document.cookie.substring(c_start, c_end)).split('-@pt@-');
			if( a[1] != window.location.href )
			{
				music_setCookie('page','1-@pt@-'+window.location.href);
				offset = 1;
			}
			else
			{
				offset = a[0];
			}
			return (offset == undefined || offset <= 0 ? 1 : offset);
		}
	}
	return 1;
}

function resetValueElement(id, maxLength)
{
	var e = document.getElementById(id);
	if(e)
	{
		if(e.value.length > maxLength)
		{
			e.value = e.value.substring(0, maxLength-1);
		}
	}
}

function checkElementLength(e, maxLength)
{
	if (e)
	{
		if (maxLength - e.value.length <=0)
		{
			return false;
		}
		return true;
	}
}

function checkFromLogin()
{
	var frm = document.getElementById('frmLogin');
	if (frm)
	{
		if (isValue(frm.tbusername) && isValue(frm.tbpass) )
		{
			frm.submit();
		}
	}
	return false;
}

function isValue(e)
{
	var strValue = trim(e.value);
	if (!strValue)
	{	
		e.select();
		e.focus();
		return false;
	}
	return true;
}