jQuery(function( $ ){
	$('#gotosankhau').click(function(){
		$.scrollTo('#htvsankhau',700);					
		return false;
	});
	$('#gotocanhac').click(function(){
		$.scrollTo('#htvcanhac', 700);					
		return false;
	});
	$('#gotophim').click(function(){
		$.scrollTo('#htvphim', 700);					
		return false;
	});
})
function htvactiveTab(){
	$('.tabitem').click(function(){
		var tabID=$(this).attr('rel');
		var obj=$(this);
		$(this).parents('.boxtop').parent().children('.boxcontent').children('.active').fadeOut(300,function(){
			$(this).removeClass('active');
			$('#'+tabID).fadeIn(50,function(){
				$(this).addClass('active');
				$(obj).parents().parents().children('.active').removeClass('active');
				$(obj).parent().addClass('active');
			});
		});
		return false;
	})
}
$(document).ready(function(){
	htvactiveTab();
});
$('.menu_htva .item').hover(
	function(){
		$(this).children('.sub').stop(true,true).slideDown();
	},
	function(){
		$(this).children('.sub').slideUp();
	}
);/* Them vao */
/*
 * Ham thuc hien chuc nang lay gia tri cua window va document
 * Type:	function
 * Name:	TNCom_getDocumentSize
 * Date:	2008/05/21
 * @param int val cac gia tri:	0: pageWidth, 1: pageHeight, 2: windowWidth, 3: windowHeight
 * @return int gia tri tra ve khi thuc hien goi ham		
 */
function TNCom_getDocumentSize(val)
{
	var xScroll,yScroll,value;
	var hasInner = typeof(window.innerWidth) == 'number';
	var hasElement = document.documentElement && document.documentElement.clientWidth;
	var numShiftY = hasInner?pageYOffset:hasElement?document.documentElement.scrollTop:document.body.scrollTop;
	if(window.innerHeight&&window.scrollMaxY)
	{
		xScroll=window.innerWidth+window.scrollMaxX;
		yScroll=window.innerHeight+window.scrollMaxY;
	}
	else if(document.body.scrollHeight>document.body.offsetHeight)
	{
		xScroll=document.body.scrollWidth;
		yScroll=document.body.scrollHeight;
	}
	else{
		xScroll=document.body.offsetWidth;
		yScroll=document.body.offsetHeight;
	}
	var windowWidth,windowHeight;
	
	if(self.innerHeight)
	{
		if(document.documentElement.clientWidth){
			windowWidth=document.documentElement.clientWidth;
		}
		else{
			windowWidth=self.innerWidth;
		}
		windowHeight=self.innerHeight;
	}
	else if(document.documentElement&&document.documentElement.clientHeight)
	{
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}
	if(yScroll<windowHeight){
		pageHeight=windowHeight;
	}
	else{
		pageHeight=yScroll
	}
	
	if(xScroll<windowWidth){
		pageWidth=xScroll
	}
	else{
		pageWidth=windowWidth
	}
	arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight,numShiftY)	
	return arrayPageSize[val]
}// end function
/*
 * Lightbox use jQuery library, rewrite in OOP - Require jQuery 1.2+
 * Type:	File
 * Name: 	CAOBox.js
 * Date:	2008/05/12
 * @Author:	Tuyen Cao <tuyenck@von-inc.com>
 * @Version:1.1
 * @Copyright 2008 Timnhanh.com
 * uptate 22/12/2008 tridn@von-inc.com
 */
var g_html;
var typecaobox=0;
var caobox = {		
	fadeEffectDuration : 900,
	fade:"#fade",
	light:"#light",
	show_popup:function(boxId,type)
	{	
		if(g_html!=null) $('body').append(g_html);
		if(type==1) typecaobox=type;
		jQuery('object, embed, select').css('visibility','hidden');
		this.init();
		g_html=$("#"+boxId);
		$(this.light).html($("#"+boxId).html());
		$("#"+boxId).remove();
		jQuery(this.light).fadeIn(this.fadeEffectDuration, function()
		{
			 jQuery(this.light).css({display:'block'}); 
		});	

		jQuery(this.light).css({left: Math.round((TNCom_getDocumentSize(2) - jQuery(this.light).width()) / 2)+"px"});
		jQuery(this.light).css({top: Math.round((TNCom_getDocumentSize(3) + TNCom_getDocumentSize(4) - jQuery(this.light).height()) / 2)+"px"});
		caobox.showalertlayer();	
		caobox.setFocusElement();
		window.onresize=caobox.resize_layers;
	},
	close_popup:function(){	
		$('#light').remove();
		$('#fade').remove();
		$('body').append(g_html);
		g_html=null;
		jQuery('object, embed, select').css('visibility','');	
		open_invite();
	},
	
	showalertlayer : function(){		
		if(TNCom_getDocumentSize(0)<974) 
			 jQuery(this.fade).css({width:"974px"});
		else 
			jQuery(this.fade).css({width:TNCom_getDocumentSize(0)+"px"});
			
		jQuery(this.fade).css({height:TNCom_getDocumentSize(1)+'px'});	
		jQuery(this.fade).css({display:'block'}); 
	},
	
	resize_layers : function(){
		if(TNCom_getDocumentSize(1 ) > TNCom_getDocumentSize(3))
			 var pageHeight=TNCom_getDocumentSize(1)
		else var pageHeight=TNCom_getDocumentSize(3)
		if(TNCom_getDocumentSize(0) < 974)
			 jQuery('#fade').css({width:974 + "px"});
		else jQuery('#fade').css({width:TNCom_getDocumentSize(0) + "px"});
		jQuery('#fade').css({height:pageHeight + 'px'});
		jQuery('#light').css({left: Math.round((TNCom_getDocumentSize(2) - jQuery('#light').width()) / 2)+"px"});
		jQuery('#light').css({top:Math.round((TNCom_getDocumentSize(3) - jQuery('#light').height()) / 2)+"px"});
	},
	
	findFucusElement:function(){
		jQuery("#light").find('object, embed, select').css({'visibility':'visible'});
		jQuery("#light").find('input[@type!=hidden], a, select, textarea').addClass('setFocusAble');			
		return jQuery('.setFocusAble');
	},
	
	setFocusElement:function(){
		var i = 0;
		var cntElement = 0;	
		var allFocusElement = caobox.findFucusElement();
		var len=allFocusElement.length;	
		
		if (len>0){
			for(var temJ = 0; temJ<len-1; temJ++){
				jQuery(allFocusElement[temJ]).attr('rel',temJ+1);
			}	
			// fix focus on 1st hidden element
			if ( allFocusElement[0].style.display == 'none') 
				allFocusElement[1].focus();
			else
				allFocusElement[0].focus();
	
	
			allFocusElement.focus(function(){ cntElement=this.getAttribute('rel'); });
			jQuery("#light").keydown(function(event){									 
				if(event.shiftKey){
					if(event.keyCode == 9){					
						if (i!=cntElement) i=cntElement;
						i--;			
						if (i == 0) {
							i = len-1;
							allFocusElement[i].focus();
							return false;
						}
					}
				}
				else{
					if(event.keyCode == 9){
						if (i != cntElement) i = cntElement;
						if (i == len-1){
							i=0;
							allFocusElement[0].focus();						
							return false;
						}
						else{
							i++;
						}
					}
				}			
			}); 
		}
	},
	init:function()
	{		
		jQuery(document).ready(function()
		{	
			$('body').append('<div id="light"></div><div id="fade"></div>');
			jQuery('#light, #fade').css({'display':'none', 'position':'absolute'});
			jQuery('#light').css({'zIndex':'10002','height':'auto','overflow':'hidden'});
			jQuery('#fade').css({'zIndex':'10001','backgroundColor':'#000','opacity':'0.6','filter':'alpha(opacity="60")','left':0,'top':0}).click( function(){																															 					if(typecaobox==0) caobox.close_popup(); 
			});
			
		})		
	}
}
/*----------------tridn22/10/2009*/
var tmnu2;
$('#hasmore').hover(		 
function(){
	var myol=$(this).offset().left;
	var myot=$(this).offset().top+20;
	$('#subtop').css("left",myol);
	$('#subtop').css("top",myot);
	clearTimeout(tmnu2);		
	$('#subtop').show();
},
function(){
	tmnu2=setTimeout(function(){
		$('#subtop').hide();
	},100);
	
});	
$('#subtop').hover(
function(){
	clearTimeout(tmnu2);
},
function(){
	tmnu2=setTimeout(function(){
		$('#subtop').hide();
	},100);
	
});	
/*------end----------tridn22/10/2009*/