// JavaScript Document
function flash(url,w,h,id,bg,win){
	var str =
		"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
		"<param name='allowScriptAccess' value='sameDomain' />"+
		"<param name='allowFullScreen' value='false' />"+
		"<param name='movie' value='"+url+"' />"+
		"<param name='quality' value='high' />"+
		"<param name='wmode' value='"+win+"' />"+
		"<param name='bgcolor' value='"+bg+"' />"+
		"<embed src='"+url+"' quality='high' wmode='"+win+"' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
		"</object>";
	document.write(str);
}
function readCookie(name)

{

  var cookieValue = "";

  var search = name + "=";

  if(document.cookie.length > 0)

  { 

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;

}

// Example:

// writeCookie("myCookie", "my name", 24);

// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

function writeCookie(name, value, hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }

  document.cookie = name + "=" + escape(value) + expire;

}

idbody="inner";
function changefont(sizedf)
{
	size=readCookie('fontSize');
	size*=1;
	size+=sizedf;
	if(size<2) size=2;
	if(size>8) size=8;
	if(sizedf==0) size=5;
	element=document.getElementById(idbody);
	element.className="f"+size;
	writeCookie("fontSize",size,5);

}
function setdefault()
{
	element=document.getElementById(idbody);
	element.className="f"+5;
	writeCookie("fontSize",5,5);
}
function check_lienhe()
{
	if(document.frmlienhe.name.value=="")
	{
		document.frmlienhe.name.style.backgroundColor="#ffffcc";
		document.frmlienhe.name.focus();
		return false;
	}
	else
	{
		document.frmlienhe.name.style.backgroundColor="#fff";
	}
	if(document.frmlienhe.email.value=="")
	{
		document.frmlienhe.email.style.backgroundColor="#ffffcc";
		document.frmlienhe.email.focus();
		return false;
	}
	else
	{
		document.frmlienhe.email.style.backgroundColor="#fff";
	}
	if(document.frmlienhe.email.value.indexOf('@')==-1 || document.frmlienhe.email.value.indexOf('.')==-1 || document.frmlienhe.email.value.indexOf('')==1)
	{
		document.frmlienhe.email.style.backgroundColor="#ffffcc";
		document.frmlienhe.email.focus();
		return false;
	
	}
	else
	{
		document.frmlienhe.email.style.backgroundColor="#fff";
	}
	if(document.frmlienhe.tieude.value=="")
	{
		document.frmlienhe.tieude.style.backgroundColor="#ffffcc";
		document.frmlienhe.tieude.focus();
		return false;
	}
	else
	{
		document.frmlienhe.tieude.style.backgroundColor="#fff";
	}
	if(document.frmlienhe.noidung.value=="")
	{
		document.frmlienhe.noidung.style.backgroundColor="#ffffcc";
		document.frmlienhe.noidung.focus();
		return false;
	}
	else
	{
		document.frmlienhe.noidung.style.backgroundColor="#fff";
	}
}


var http_request = false;
function makeRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('myspan').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}

function makeRequest1(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.onreadystatechange = alertContents1;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function alertContents1() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('myspan1').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}



function submitForm(hovaten,email,diachi,congty,tieude,maxacnhan,noidung)
	{
		/*if(hovaten=="" || hovaten=="Họ và tên *")
		{
			alert("Vui lòng nhập họ và tên");
			document.getElementById("hovaten").focus();
		}
		else if(email=="" || email=="Email *")
		{
			alert("Vui lòng nhập email");
			document.getElementById("email").focus();
		}
		else if(tieude==""|| tieude=="Tiêu đề *")
		{
			alert("Vui lòng nhập tieude");
			document.getElementById("tieude").focus();
		}
		else if(maxacnhan=="" || maxacnhan=="Mã xác nhận *")
		{
			alert("Vui lòng nhập mã xác nhận");
			document.getElementById("maxacnhan").focus();
		}
		else if(noidung=="")
		{
			alert("Vui lòng nhập nôi dung");
			document.getElementById("noidung").focus();
		}
		else if(email.indexOf('@')==-1 || email.indexOf('.')==-1 || email.indexOf('')==1)
			alert("Email không hợp lệ")
		else
		{*/
		url  = 'components/detail_congnghethietbi/validate.php';
		makeRequest1(url,'?hovaten='+ hovaten+'&email='+email+'&diachi='+diachi+'&congty='+congty+'&tieude='+tieude+'&maxacnhan='+maxacnhan+'&noidung='+noidung);
		//}
			
	}
	