// JavaScript Document
var CurrentFontSize = 2;
function addFavorite(url,title){
		window.external.AddFavorite(url, title)	;
}

function CreateBookmarkLink(url,title) {

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }


	
	function FloatTopDiv()
	{
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		if(!ns)
		{
			startLX = ((document.body.clientWidth -1230)/2) + 380 , startLY = 80;
			//startRX = ((document.body.clientWidth -770)/2) + 760 +2 , startRY = 62;
			//startRX = ((document.body.clientWidth)/2) + 390 , startRY = 62;
		}
		else
		{
			startLX = ((document.body.clientWidth -1230)/2) + 380, startLY = 80;
			//startRX = ((document.body.clientWidth -770)/2) + 760 + 4 , startRY = 62;
		}

		var d = document;
		
		function m2(id)
		{
			var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			e2.sP=function(x,y){this.style.left=x;this.style.top=y};
			e2.x = startLX;
			e2.y = startLY;
			return e2;
		}
		window.stayTopLeft=function()
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY =  document.documentElement.scrollTop;
			else if (document.body)
				var pY =  document.body.scrollTop;
			if (document.body.scrollTop < 0){
				startLY = 3;startRY = 3;
			} else {
				startLY = 450;
				startRY = 450;
			};
		
			ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			setTimeout("stayTopLeft()", 1);
		}
		
		//stayTopLeft();
		ftlObj2 = m2("divAdCenter");
		stayTopLeft();
	}
	
	function ShowAdDiv()
	{
		
		var objAdDivCenter = document.getElementById("divAdCenter");		
		
		if (document.body.clientWidth < 980)
		{		   
			objAdDivCenter.style.display = "none";
		}
		else
		{
			
			objAdDivCenter.style.display = "block";
			FloatTopDiv();
		}
	}

	function closeDiv() {
		var objAdDivCenter = document.getElementById("divAdCenter");		
		
		objAdDivCenter.style.display = "none";
	
	}


function switchFontSize (ckname,val){
		
	var bd = document.getElementById('bd');
	
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	if(!ns)
	{
		
		switch (val) {
				case 'inc':
				if (CurrentFontSize + 1 < 6) {
					
					CurrentFontSize++;
					bd.className = 'fs'+CurrentFontSize;
					
				}
				break;
				case 'dec':
				if (CurrentFontSize-1 > 0) {			
					CurrentFontSize--;
					bd.className = 'fs'+CurrentFontSize;
					
				}
				break;
				default:
				
				CurrentFontSize = val;		
				bd.className = 'fs'+CurrentFontSize;
				
			}
	}
	else
	{
		switch (val) {
				case 'inc':
				if (CurrentFontSize + 1 < 6) {
					
					CurrentFontSize++;
					bd.setAttribute('class','fs'+CurrentFontSize)
					
				}
				break;
				case 'dec':
				if (CurrentFontSize-1 > 0) {			
					CurrentFontSize--;
					bd.setAttribute('class','fs'+CurrentFontSize)
					
				}
				break;
				default:
				
				CurrentFontSize = val;		
				bd.setAttribute('class','fs'+CurrentFontSize)
				
			}
	}
		
	
	Cookie.set(ckname, CurrentFontSize,{duration:365});
		
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function frmSubmit() {
	var frm = document.frm;
	frm.submit();
}

function validForm(){
	var valid = true;
	var h = $H({ name: 'name', day: 'day', month:'month', year:'year', email:'email'}); 
	h.each(function(pair) { 
			if($(pair).value=='') valid = false;
	}); 
	
	if(!valid) {
		alert('Bạn hãy nhập đầy đủ thông tin yêu cầu')	
		return false;
	}
	return validEmail($('email').value);	
	
}

function validEmail()
{
	var str = document.getElementById('email').value;
	
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(str.match(emailRegEx))
		return true;
	alert('Email của bạn không đúng quy cách!');
	return false;
}