var url_img=new Array();
var width_img=new Array();
var height_img=new Array();

function add_data(index,url,w,h)
{
	setCookie('url_img'+index,url,365);
	setCookie('width_img'+index,w,365);
	setCookie('height_img'+index,h,365);
	setCookie('index',1,365);
	//alert(index);
	//alert(url_img[index]);
	//alert(width_img[index]);
	//alert(height_img[index]);	
	
}
function Get_Cookie( name )
{

	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
//------------------ tao cookie--------------------
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
//------------------ kiem tra cookie--------------------
function gofirst()
{
	setCookie('index',1,365);
	show_img(1);
}
function golast()
{
	setCookie('index',3,365);
	show_img(3);
}
function goto(where)
{	
	
	switch(where)
	{
		
		case 0:
			k=Get_Cookie('index');
			switch(k)
			{
				case '1':
					alert('Đang ở hình đầu tiên !.');
				break;
				case '2':
					setCookie('index',1,365);
					show_img(1);
				break;
				case '3':
					setCookie('index',2,365);
					show_img(2);
				break;
				default:
						alert('pre khong duoc');
				break;
			}
		break;
		case 1:
			k=Get_Cookie('index');			
			switch(k)
			{
				case '1':				
					setCookie('index',2,365);
					show_img(2);
				break;
				case '2':
					setCookie('index',3,365);
					show_img(3);
				break;
				case '3':					
					alert('Đang ở hình cuối cùng !.');
				break;
				default:
						alert('next khong duoc');
				break;
			}
		break;
	}	
}
function show_img(index)
{
	
	//alert(index);
	//alert(Get_Cookie('url_img'+Get_Cookie('index')));
	//alert(Get_Cookie('width_img'+Get_Cookie('index')));
	//alert(Get_Cookie('height_img'+Get_Cookie('index')));
	
	if (typeof Get_Cookie('width_img'+Get_Cookie('index')) == 'undefined') setCookie('width_img'+Get_Cookie('index'),600,365);
	
	if (typeof Get_Cookie('height_img'+Get_Cookie('index')) == 'undefined') setCookie('height_img'+Get_Cookie('index'),600,365);
	
	$("#facebox").find("#img1").attr( "src", Get_Cookie('url_img'+Get_Cookie('index')) );
	
	$("#facebox").find("#img1").attr( "width", Get_Cookie('width_img'+Get_Cookie('index')) );
	
	$("#facebox").find("#img1").attr( "height", Get_Cookie('height_img'+Get_Cookie('index')) );
}
function changeimg(obj){
	$("#facebox").find("#img1").attr( "src",obj);	

}
function Menu_MouseOver(id)
{
	
	document.getElementById(id).style.backgroundImage='../css/image/vited.gif';
	
}
function Menu_MouseOut(id)
{
	
	document.getElementById(id).style.backgroundImage='../css/image/menu_hover.gif';
	
}
function buttonHover(id)
{
	
	document.getElementById(id).style.backgroundImage="url('search_btn_hover.png')";
	alert(document.getElementById(id).style.backgroundImage);
	
}
function buttonOut(id)
{
	
	document.getElementById(id).style.backgroundImage="url('search_btn.png')";
	alert(document.getElementById(id).style.backgroundImage);
}