// JavaScript Document
function confirm_check(url,mess)
{
	anser=confirm(mess)
	
	if(anser==true)
		window.location = url
}
function linkto(url)
{
	window.location = url
}
function checknumber(o)
{
	message="Chi duoc nhap so"
	if(isNaN(o.value))
	{
		error_message ="* " + message + "\n"
		alert(error_message)
		o.value=''
		//o.select()
		return false
	}
	else return true
}
function checkemty(o,message)
{	
	if(o.value=="")
	{
		o.focus()
		error_message ="* " + message + "\n"
		alert(error_message)
		return true
	}
	else return false
}
function checkemail(e,message)
{
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	var returnval=emailfilter.test(e.value)
	if (returnval==false)
	{
		alert(message)
		e.select()
		return false
	}
	return true
}
function checkpassword(pass,cpass,message)
{
	if(pass.value!=cpass.value)
	{
		alert(message)
		return false
	}
	return true
}
function creatTextBox(name,value,stye)
{
	return "<input name='"+name+"' value='"+value+"' "+stye+" />"
}
function loadElement(divid,text)
{
	document.getElementById(divid).innerHTML=text;
}
//Array
function inArray(value,arr)
{
	for(i=0;i< arr.length;i++)
	{
		if(value==arr[i])
			return true
	}
	return false
}
function removeArrayItem(arr,pos)
{
	if(pos > arr.length -1 || pos < 0 )
		return arr
	temp = Array()
	for(i=0;i<arr.length;i++)
		if(i != pos)
			temp.push(arr[i])
	return temp
}
function searchArray(value,arr)
{
	for(i=0;i< arr.length;i++)
	{
		if(value==arr[i])
			return i
	}
	return -1
	
}
function removeArrayValue(arr,value)
{
	pos = searchArray(value,arr)
	return removeArrayItem(arr,pos)
}
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos)
{
	if(pos=="random")
	{
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center")
	{
		LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else 
		if((pos!="center" && pos!="random") || pos==null)
		{
			LeftPosition=0;
			TopPosition=20
		}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);}
// -->
function viewPage(url)
{
	//alert(url)
	NewWindow(url,'mywin','1000','600','yes','center')
}
function printpage()
{
	window.print()
}
function display(objname)
{
	o = document.getElementById(objname);
	if(o.style.display == 'none')
	{
		o.style.display = '';
	}
	else
		hidden(objname)
}

function hidden(objname)
{
	o = document.getElementById(objname);
	o.style.display = 'none';
}

function getCookie(Name)
{ 
	//alert(document.cookie)
	var re=new RegExp(Name+"-[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
	return document.cookie.match(re)[0].split("-")[1] //return its value
	return ""
}

function setCookie(name, value)
{
	document.cookie = name+"-"+value //cookie value is domain wide (path=/)
}
function clerCookie()
{
	
	setCookie('para',"" )
	setCookie('url',"" )
	//alert("clear thanh cong")
}
