//BOOKMARK

function bookmark(title,url){
	if(window.sidebar){
		window.sidebar.addPanel(title,url,"");
	}
	else if(window.external){
		window.external.AddFavorite(url,title);
	}
	else if(window.opera&&window.print){
		return true;
	}
}

///FORM CONTACT
function check(str)
{
	var count=str.length;		
	var s=document.frmcontact.comment.value;
	if(count>500)	
	{	
		var s2=s.substring(0,500);		
		document.frmcontact.comment.value=s2;
		document.frmcontact.comment.focus();
		document.frmcontact.comment.select();
	}
	
}
///

function checkContact(value)
{
	
	resetDisplay();
	
	if(document.frmcontact.name.value=="")
	{
		document.frmcontact.name.focus();
		document.getElementById("div11").style.display='';
		return false;
	}
	if(document.frmcontact.email.value=="")
	{
		document.frmcontact.email.focus();
		document.getElementById("div22").style.display='';
		return false;
	}
	if(document.frmcontact.email.value!="")
	{
		if(!isEmail(document.frmcontact.email.value))
		{
			document.frmcontact.email.focus();
			document.frmcontact.email.select();
			document.getElementById("div22").style.display='';
			return false;
		}
	}
	
	if(document.frmcontact.tel.value=="")
	{
		document.frmcontact.tel.focus();
		document.getElementById("div33").style.display='';
		return false;
	}
	if(!validTel(document.frmcontact.tel.value))
	{
		document.frmcontact.tel.focus();
		document.frmcontact.tel.select();
		document.getElementById("div33").style.display='';
		return false;
	}
	
	if(document.frmcontact.comment.value=="")
	{
		document.frmcontact.comment.focus();
		document.getElementById("div44").style.display='';
		return false;
	}
	
	if(document.frmcontact.txtrandom.value=="")
	{
		document.frmcontact.txtrandom.focus();
		document.getElementById("div55").style.display='';
		return false;
	}
	if(document.frmcontact.txtrandom.value.toUpperCase()!=value.toUpperCase())
	{
		document.frmcontact.txtrandom.focus();
		document.getElementById("div55").style.display='';
		return false;
	}
	
return true;
}

///
function resetDisplay()
{
	for(i=1;i<=5;i++)
	{
		document.getElementById("div"+i+""+i).style.display='none';
	}
}
	


function selectAll(object)
{
		object.select();
}


function modelessDialogShow(url,width,height)
{
	if (document.all&&window.print) //if ie5
	eval('window.showModelessDialog(url,window,"dialogWidth:'+width+'px;dialogHeight:'+height+'px;edge:Raised;center:1;help:0;resizable:1;")');
	else
	eval('window.open(url,"a","width='+width+'px,height='+height+'px,resizable=1,scrollbars=1,copyhistory=yes")')
}

function isEmail(s)
{   
  if (s=="") return false;
  if(s.indexOf(" ")>0) return false;
  var i = 1;
  var sLength = s.length;
  if (s.indexOf(".")==sLength) return false;
  if (s.indexOf(".")<=0) return false;
  if (s.indexOf("@")!=s.lastIndexOf("@")) return false;

  while ((i < sLength) && (s.charAt(i) != "@"))
  { i++
  }

  if ((i >= sLength) || (s.charAt(i) != "@")) return false;
  else i += 2;

  while ((i < sLength) && (s.charAt(i) != "."))
  { i++
  }

  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
   var str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghikjlmnopqrstuvwxyz-@._"; 
   for(var j=0;j<s.length;j++)
	if(str.indexOf(s.charAt(j))==-1)
		return false;
   return true;
}
function validTel(s)
{	
	var str="0123456789)(- .";
	if(s.length>=20||s.length<=5) return false;
	for(var i=0;i<s.length;i++)
	{
		if(str.indexOf(s.charAt(i))==-1)	return false;
	}
	return true;
	
}
/**/
function addToFavorites() { 
	var urlAddress = "http://www.congnghemoipleiku.net"; 
	var pageName = "Cng Ngh? M?i Pleiku - Computer & Network Solution"; 
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName);
	} else { 
		alert("Sorry! Your browser doesn't support this function."); 
	} 
} 
	function showhide(thecell)
	{	
		if(theoldcell == thecell){
			eval('document.all.'+thecell).style.display = 'none'
			eval('document.all.'+theoldcell).style.display = 'none'
			theoldcell = ""
		}else{
			if(theoldcell != thecell){
				if(theoldcell != "")
				eval('document.all.'+theoldcell).style.display = 'none'
				eval('document.all.'+thecell).style.display = ''
				theoldcell = thecell
			}
		}
}
	
/**/
function mOvr(src) {
		if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		}
	}
	function mOut(src) {
		if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		}
	}
	function mClk(src) {
		if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
		}
	}
	
