function setHomePage() {
  if (document.all) 
  {
    document.body.style.behavior = "url(#default#homepage)";
    document.body.setHomePage('http://www.baoyenbai.com.vn');
  }
  else
    alert("only works in IE 4.0 or higher!");
}
function showTVNew(tmp){
	window.open("/tvnews.asp?MTmpVideo=" + tmp, "TV_window","scrollbars=no, resizable=no, width=950, height=450");
	}
//////Ajax functions

var xmlHttp;
function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	
}



function startRequest(strUrl, strDivName, strObj) {
	createXMLHttpRequest();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	if (strDivName == "BodyContent"){
	window.scrollTo(0,0);
	};
	if (strObj!=null && strObj!="")
		strUrl = strUrl + document.getElementById(strObj).value;
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				document.getElementById(strDivName).innerHTML = xmlHttp.responseText;
			}
		}
		else
			document.getElementById(strDivName).innerHTML = "<br><p align=\"center\"> <br> <br> <font  color='#FF0000' style='font-size:24px' > &#272;ang t&#7843;i v&#7873;...</font> <br><img border=\"0\" src=\"/images/loading.gif\"></p><br>";
	};
	xmlHttp.open("GET",strUrl, true);
	xmlHttp.send(null);
}


function CreateControlFlash(UrlObjectID, WIDTH, HEIGHT)
{
  document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'"); 
  document.write("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + WIDTH + "' height='" + HEIGHT + "'>" );
  document.write("<param name='movie' value='" + UrlObjectID + "' />");
  document.write("<param name='quality' value='high' />");
  document.write("<PARAM NAME='WMode' VALUE='Transparent'/>");
  document.write("<embed src='" + UrlObjectID + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + WIDTH + "' height='" + HEIGHT + "' ></embed></object> " );
 
}



/// gui phan hoi
function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}
function CheckEmailAddress(Email)
{
	Email = Trim(Email);

	while (Email != '')
	{
		c = Email.charAt(0);	
		if (c==' ' || c=='<' || c==39 || c==':' || c=='.')
		{
			Email = Email.substr(1);
		}
		else
		{
			break;
		}
	}

	i = Email.indexOf('>');
	if (i==-1)
	{
		while (Email != '')
		{
			c = Email.charAt(Email.length - 1);
			if (c==' ' || c==39 || c=='.')
			{
				Email = Email.substr(0, Email.length - 1);
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		Email = Email.substr(0, i);
	}

	if (Email.length > 96)
		return '';

	i = Email.lastIndexOf('@');
	j = Email.lastIndexOf('.');
	if (i < j)
		i = j;

	switch (Email.length - i - 1)
	{
	case 2:
		break;
	case 3:
		switch (Email.substr(i))
		{
		case '.com':
		case '.net':
		case '.org':
		case '.edu':
		case '.mil':
		case '.gov':
		case '.biz':
		case '.pro':
		case '.int':
			break;
		default:
			return '';
		}
		break;
	default:
		switch (Email.substr(i))
		{
		case '.name':
		case '.info':
			break;
		default:
			return '';
		}
		break;
	}

	Email = Email.toLowerCase();

	if (Email == '')
		return '';

	if (Email.indexOf(' ') != -1)
		return '';

	if (Email.indexOf('..') != -1)
		return '';

	if (Email.indexOf('.@') != -1)
		return '';

	if (Email.indexOf('@.') != -1)
		return '';

	if (Email.indexOf(':') != -1)
		return '';

	for (i=0; i < Email.length; i++)
	{
		c = Email.charAt(i);

		if (c >= '0' && c <= '9')
			continue;
		
		if (c >= 'a' && c <= 'z')
			continue;
		
		if ('`~!#$%^&*-_+=?/\\|@.'.indexOf(c) != -1)
			continue;

		return '';
	}

	if ((i=Email.indexOf('@'))==-1)
		return '';

	if (Email.substr(i + 1).indexOf('@')!=-1)
		return '';

	if (Email.charAt(0)=='.' || Email.charAt(Email.length - 1)=='.')
		return '';

	return Email;
}

 function onFocus(id)
    {
        document.getElementById(id).value="";
    }
    function onBlur(id)
    {
        switch(id)
        {
            case "HoTen": 
                if(document.getElementById(id).value=="")
                {
                    document.getElementById('HoTen').value="Họ và tên";
                }
                break;
            case "Email": 
                if(document.getElementById(id).value=="")
                {
                    document.getElementById('Email').value="Địa chỉ hòm thư";
                }
                break;
            case "NoiDung": 
                if(document.getElementById(id).value=="")
                {
                    document.getElementById('NoiDung').value="Ý kiên của bạn";
                }
                break;
        }
    }
    function reset()
    {
        document.getElementById('HoTen').value="Họ và tên";
        document.getElementById('Email').value="Địa chỉ hòm thư";
        document.getElementById('NoiDung').value="Ý kiên của bạn";
    }
    function validate()
    {
        document.getElementById('HoTen').value = Trim(document.getElementById('HoTen').value);
		if ((document.getElementById('HoTen').value=="Họ và tên") || (document.getElementById('HoTen').value==""))
        {
            alert('Bạn chưa nhập tên của mình');
            document.getElementById('HoTen').focus();
            return;
        }					
        if(document.getElementById('Email').value=="Địa chỉ hòm thư")
        {
            alert('Bạn chưa nhập tên hòm thư của mình');
            document.getElementById('Email').focus();
            return;
        }
		if ((SEmail = CheckEmailAddress(document.getElementById('Email').value))=='')
		{
			alert('Địa chỉ hòm thư không hợp lệ!');
			document.getElementById('Email').value.focus();
			return;
		}
        if(document.getElementById('NoiDung').value=="Ý kiên của bạn")
        {
            alert('Bạn chưa nhập nội dung phản hồi của mình');
            document.getElementById('NoiDung').focus();
            return;
        }
       if(confirm('Bạn muốn gửi phản hồi này ?'))
       {
        document.getElementById('Guibai').submit();
       }
    }
