stuHover = function() {
	var cssRule;
	var newSelector;
	for (var i = 0; i < document.styleSheets.length; i++)
		for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
			{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1)
			{
				 newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
		var test = document.getElementsByName("menu");
		var getElm = $('li', test);

	for (var i=0; i<getElm.length; i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}//end function;
if (window.attachEvent) window.attachEvent("onload", stuHover);

// ------- ONFOCUS, ONBLUR ------- //
function inputOnFocus(field, defaultVal){
	if(field.value==defaultVal){ field.value = ''; }
}

function inputOnBlur(field, defaultVal){
	if(field.value==''){ field.value=defaultVal;}
}
// ------- END ONFOCUS, ONBLUR ------- //

$(function() {
	// ------- FONT UPDOWN ------- //
	// UP
	$("#fontup").click(function(){
		var ftmax = 14;	
		var ftfoo;
		var ft = eval($("body").css("font-size").substr(0,2)) + 1;
		if(eval(ft <= ftmax)){
			$("body").css("font-size", "" + ft + "px");
//			if($("body").css("font-size") == "14px"){
				$(".menu > li > a").css("padding-left", "10px");
				$(".menu > li > a").css("padding-right", "10px");
				$(".menu > li > a").css("font-size", "12px");
//			}
//			if($("body").css("font-size") == "13px"){
//				$(".menu > li > a").css("padding-left","21px");
//				$(".menu > li > a").css("padding-right","21px");
//			}
//			if($("body").css("font-size") == "12px"){
//				$(".menu > li > a").css("padding-left","27px");
//				$(".menu > li > a").css("padding-right","27px");
//			}
//			if($("body").css("font-size") == "11px"){
//				$(".menu > li > a").css("padding-left","29px");
//				$(".menu > li > a").css("padding-right","28px");
//			}
			ftfoo = parseInt($("#footer").css("font-size").replace("px",'')) + 1;
			$("#footer").css("font-size", "" + ftfoo + "px");
		}
		});
	// DOWN
	$("#fontdown").click(function(){
		var ftmin = 10;
		var ftfoo;
		var ft = eval($("body").css("font-size").substr(0,2)) - 1;
		if(eval(ft >= ftmin)){
			$("body").css("font-size", "" + ft + "px");
//			if($("body").css("font-size") == "13px"){
				$(".menu > li > a").css("padding-left","10px");
				$(".menu > li > a").css("padding-right","10px");
				$(".menu > li > a").css("font-size", "12px")
//			}
//			if($("body").css("font-size") == "12px"){
//				$(".menu > li > a").css("padding-left","27px");
//				$(".menu > li > a").css("padding-right","27px");
//			}
//			if($("body").css("font-size") == "11px"){
//				$(".menu > li > a").css("padding-left","29px");
//				$(".menu > li > a").css("padding-right","28px");
//			}
//			if($("body").css("font-size") == "10px"){
//				$(".menu > li > a").css("padding-left","33px");
//				$(".menu > li > a").css("padding-right","32px");
//			}
			ftfoo = parseInt($("#footer").css("font-size").replace("px",'')) - 1;
			$("#footer").css("font-size", "" + ftfoo + "px");
		}
		});
	// NORMAL
	$("#fontdef").click(function(){
		$("body").css("font-size","12px");
		$("#footer").css("font-size", "10px");
		$(".menu > li > a").css("padding-left","10px");
		$(".menu > li > a").css("padding-right","10px");
		});
	// ------- END FONT UPDOWN ------- //

	// ------- BANNER SLIDESHOW ------- //
//	function cs1(){
//		$('#cross-slide').crossSlide({
//			sleep: 2,
//			fade: 1
//		}, [
//			{ 
//				src: 'images/Hinhflash/Gui tien nhan tien (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//	
//			},
//			{ 
//				src: 'images/Hinhflash/Lai suat bac thang (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//	
//			},
//			{ 
//				src: 'images/Hinhflash/Lai suat tha noi (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//	
//			},
//			{ 
//				src: 'images/Hinhflash/SP vang vat chat (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//	
//			},
//			{ 
//				src: 'images/Hinhflash/Vay ho tro SXKD (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//	
//			},
//			{ 
//				src: 'images/Hinhflash/Vay tieu dung (720x270).jpg' ,
//				href: '#',
//				from: 'top left',
//				to:   'bottom right 1.5x'
//			}
//		]);
//	}//end function;
//	cs1();
	// ------- END BANNER SLIDESHOW ------- //
	
	// ------- LOGO PARTNER ------- //
	$('#link').serialScroll({
		items:'a',
		step: 12,
		offset:-230, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:1, //as we are centering it, start at the 2nd
		duration:1200,
		prev:'.prev_link',
		next:'.next_link',
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		jump: false//click on the images to scroll to them
	});
	// ------- END LOGO PARTNER ------- //
	
	// ------- FIX ZOOM ------- //
	function fixzoom(){
		
		//----------------
		$menu = $('#menu');
		var liSize = 0;
		var liPercent = Array();
		liPercent[0] = 10;
		liPercent[1] = 17;
		liPercent[2] = 20;
		liPercent[3] = 15;
		liPercent[4] = 15;
		liPercent[5] = 11;
		liPercent[6] = 9;
		
		$('#menu ul.menu').children().each(function(idx) {
			liSize += $(this).width();
			//$(this).css('width',liPercent[idx] + '%' );
			$(this).css('text-align','center' );
			$(this).children().next().css('min-width','100%' );
		});

		if ($menu.width() < liSize) 
			$menu.width(liSize + 1);
	}
	fixzoom();
	$(window).resize(function() {
		fixzoom();
	});	

	
	$(".menu li").hover(function(){
		$(this).find("ul:first").animate({
			'height' : 'show',
			'opacity' : 'show'
		}, 300);
	}, function(){
		$(this).find("ul:first").stop(true, true);
		$(this).find("ul:first").hide();
	});
	// ------- END FIX ZOOM ------- //
	
});//end function;
