/* Thickbox 3.1 - (jQuery) -Customized*/
var tb_LoadingImage = '/images/loading.gif';
var tb_PrevImage = '/images/prev.gif';
var tb_PrevImage_D = '/images/prev-disabled.gif';
var tb_NextImage = '/images/next.gif';
var tb_NextImage_D = '/images/next-disabled.gif';
var tb_CloseImage_Gal = '/images/g_close.gif';
var tb_CloseImage_S = '/images/cross.png';
jQuery(document).ready(function(){
	tb_init('a.thickbox, area.thickbox, input.thickbox');
	imgLoader = new Image();
	imgLoader.src = tb_LoadingImage;
});
function tb_init(domChunk){
	jQuery(domChunk).click(function(){
		var t=this.title||this.name||null;
		var a=this.href||this.alt;
		var g=this.rel||false;
		tb_show(t,a,g);
		this.blur();
		return false;
	})
};
function tb_show(caption,url,imageGroup){
	try{
		jQuery('embed, object, select').css('visibility', 'hidden');
		if(typeof document.body.style.maxHeight==='undefined'){
			jQuery('body','html').css({height:'100%',width:'100%'});
			jQuery('html').css('overflow','hidden');
			if(document.getElementById('TB_HideSelect')===null){
				jQuery('body').append('<iframe id="TB_HideSelect"></iframe><div id="TB_overlay"></div><div id="TB_window"></div>');
				jQuery('#TB_overlay').click(tb_remove)
			}
			var overlayViewportHeight = document.documentElement.offsetHeight + document.documentElement.scrollTop - 4;
			var overlayViewportWidth = document.documentElement.offsetWidth - 21;
			$('#TB_overlay').css({'height':overlayViewportHeight +'px','width':overlayViewportWidth+'px'});
		}else{
			if(document.getElementById('TB_overlay')===null){
				jQuery('body').append('<div id="TB_overlay"></div><div id="TB_window"></div>');
				jQuery('#TB_overlay').click(tb_remove)
			}
			$('#TB_overlay').css({'height':'100%','width':'100%','position':'fixed'});
		}
		if(tb_detectMacXFF()){
			jQuery('#TB_overlay').addClass('TB_overlayMacFFBGHack');
		}else{
			jQuery('#TB_overlay').addClass('TB_overlayBG');
		}
		if(caption===null){
			caption='';
		}
		jQuery('body').append('<div id="TB_load"><img src="'+imgLoader.src+'" /></div>');
		jQuery('#TB_load').show();
		var baseURL;
		if(url.indexOf("?")!==-1){
			baseURL=url.substr(0,url.indexOf("?"));
		}else{
			baseURL=url;
		}
		var urlString=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
		var urlType=baseURL.toLowerCase().match(urlString);
		if(urlType=='.jpg'||urlType=='.jpeg'||urlType=='.png'||urlType=='.gif'||urlType=='.bmp'){
			TB_Prev_Need=false;
			TB_PrevCaption="";
			TB_PrevURL="";
			TB_PrevHTML="";
			TB_Next_Need=false;
			TB_NextCaption="";
			TB_NextURL="";
			TB_NextHTML="";
			TB_imageCount="";
			TB_FoundURL=false;
			if(imageGroup){
				TB_TempArray=jQuery("a[@rel="+imageGroup+"]").get();
				for(TB_Counter=0;((TB_Counter<TB_TempArray.length)&&(TB_Next_Need===false));TB_Counter++){
					var urlTypeTemp=TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
					if(!(TB_TempArray[TB_Counter].href==url)){
						if(TB_FoundURL){
							TB_NextCaption=TB_TempArray[TB_Counter].title;
							TB_NextURL=TB_TempArray[TB_Counter].href;
							TB_Next_Need=true;
							TB_NextHTML='<span id="TB_next"><a href="#"><img src="'+tb_NextImage+'" border="0" alt="Next &gt;" style="padding-left: 10px; vertical-align:middle;" /></a></span>';
						}else{
							TB_PrevCaption=TB_TempArray[TB_Counter].title;
							TB_PrevURL=TB_TempArray[TB_Counter].href;
							TB_Prev_Need=true;
							TB_PrevHTML='<span id="TB_prev"><a href="#"><img src="'+tb_PrevImage+'" border="0" alt="&lt; Prev" style="padding-right: 10px; vertical-align:middle;" /></a></span>';
						}
					}else{
						TB_FoundURL=true;
						TB_imageCount=(TB_Counter+1)+' / '+(TB_TempArray.length);
						if(TB_NextHTML==='') {
							TB_NextHTML='<span id="TB_next"><img src="'+tb_NextImage_D+'" border="0" alt="" style="padding-left: 10px; vertical-align:middle;" /></span>';
						}
						if(TB_PrevHTML==='') {
							TB_PrevHTML='<span id="TB_prev"><img src="'+tb_PrevImage_D+'" border="0" alt="" style="padding-right: 10px; vertical-align:middle;" /></span>';
						}
					}
				}
			}
			imgPreloader=new Image();
			imgPreloader.onload=function(){
				imgPreloader.onload=null;
				var pagesize=tb_getPageSize();
				var x=pagesize[0]-150;
				var y=pagesize[1]-150;
				var imageWidth=imgPreloader.width;
				var imageHeight=imgPreloader.height;
				if (x<=0 || imageWidth<=x) { xratio=1; } else { xratio=imageWidth/x; }
				if (y<=0 || imageHeight<=y) { yratio=1; } else { yratio=imageHeight/y; }
				if (xratio > yratio)
				{
					imageWidth = Math.ceil(imageWidth / xratio);
					imageHeight = Math.ceil(imageHeight / xratio);
				}
				else
				{
					imageWidth = Math.ceil(imageWidth / yratio);
					imageHeight = Math.ceil(imageHeight / yratio);
				} 

				TB_WIDTH=imageWidth+30;
				TB_HEIGHT=imageHeight+60; /* <a href="#" id="TB_ImageOff" title="Close"> */
				jQuery("#TB_window").append('<div id="TB_imageBox"><div id="TB_imageContainer"><img id="TB_Image" src="'+url+'" width="'+imageWidth+'" height="'+imageHeight+'" alt="'+caption+'" /><div id="TB_nav"><a href="#" id="TB_nav_btnPrev"></a><a href="#" id="TB_nav_btnNext"></a></div></div></div><div id="TB_infoBox"><div id="TB_infoContainer"><div id="TB_caption">'+TB_PrevHTML+TB_imageCount+TB_NextHTML+'</div><div id="TB_closeWindow"><a href="#" id="TB_closeWindowButton" title="Close or Press ESC"><img src="'+tb_CloseImage_Gal+'" border="0" alt="X" style="vertical-align:middle;" /></a></div></div></div>');
				jQuery('#TB_nav').css({ height: imageHeight + 15}); 
				jQuery("#TB_closeWindowButton").click(tb_remove);
				if(TB_Prev_Need===true){
					function goPrev(){
						if(jQuery(document).unbind("click",goPrev)){
							jQuery(document).unbind("click",goPrev);
						}
						jQuery("#TB_window").remove();
						jQuery("body").append('<div id="TB_window"></div>');
						tb_show(TB_PrevCaption,TB_PrevURL,imageGroup);
						return false;
					}
					// Prev
					$('#TB_nav_btnPrev').unbind().hover(function() { // over
						$(this).css({ 'background' : 'url(' + tb_PrevImage + ') left 45% no-repeat' });
					},function() { // out
						$(this).css({ 'background' : 'transparent url(/images/blank.gif) no-repeat' });
					}).click(goPrev);

					jQuery("#TB_prev").click(goPrev);
				}
				if(TB_Next_Need===true){
					function goNext(){
						jQuery("#TB_window").remove();
						jQuery("body").append('<div id="TB_window"></div>');
						tb_show(TB_NextCaption,TB_NextURL,imageGroup);
						return false;
					}
					// Next
					$('#TB_nav_btnNext').unbind().hover(function() { // over
						$(this).css({ 'background' : 'url(' + tb_NextImage + ') right 45% no-repeat' });
					},function() { // out
						$(this).css({ 'background' : 'transparent url(/images/blank.gif) no-repeat' });
					}).click(goNext);

					jQuery("#TB_next").click(goNext);
				}
				
				document.onkeydown=function(e){
					if(e==null){
						keycode=event.charCode||event.keyCode||-1;
					}else{
						keycode=e.which;
					}
					switch(keycode){
						case 27:tb_remove();break;
						case 39:case 34:case 32:case 110:case 78:case 190:
							if(TB_Next_Need===true){document.onkeydown="";goNext();}
							break;
						case 37:case 8:case 33:case 80:case 112:case 188:
						if(TB_Prev_Need===true){document.onkeydown="";goPrev();}
						break;
					}
				};
				tb_position();
				jQuery("#TB_load").remove();
//				jQuery("#TB_ImageOff").click(tb_remove);
				jQuery("#TB_window").css({display:"block"});
			};
			imgPreloader.src=url;
		}else{
			var queryString=url.replace(/^[^\?]+\??/,'');
			var params=tb_parseQuery(queryString);
			if(params['fs']=="true"){
				var pagesize=tb_getPageSize();
				jQuery("#TB_overlay").unbind();
				params['width']=pagesize[0]-150;
				params['height']=pagesize[1]-150;
			}
			TB_WIDTH=(params['width']*1)+30||630;
			TB_HEIGHT=(params['height']*1)+40||440;
			ajaxContentW=TB_WIDTH-30;
			ajaxContentH=TB_HEIGHT-45;
			if(url.indexOf('TB_iframe')!=-1){
				urlNoQuery=url.split('TB_');
				jQuery("#TB_iframeContent").remove();
				if(params['modal']!="true"){
					jQuery("#TB_window").append('<div id="TB_title"><div id="TB_ajaxWindowTitle">'+caption+'</div><div id="TB_closeAjaxWindow"><a href="#" id="TB_closeWindowButton" title="Close or Press ESC"><img src="'+tb_CloseImage_S+'" border="0" alt="X" style="vertical-align:middle;" /></a></div></div><iframe frameborder="0" hspace="0" src="'+urlNoQuery[0]+'" id="TB_iframeContent" name="TB_iframeContent'+Math.round(Math.random()*1000)+'" onload="tb_showIframe()" style="width:'+(ajaxContentW+29)+'px;height:'+(ajaxContentH+17)+'px;" > </iframe>');
				}else{
					jQuery("#TB_overlay").unbind();
					jQuery("#TB_window").append('<iframe frameborder="0" hspace="0" src="'+urlNoQuery[0]+'" id="TB_iframeContent" name="TB_iframeContent'+Math.round(Math.random()*1000)+'" onload="tb_showIframe()" style="width:'+(ajaxContentW+29)+'px;height:'+(ajaxContentH+17)+'px;"> </iframe>');
				}
			}else{
				if(jQuery("#TB_window").css("display")!="block"){
					if(params['modal']!="true"){
						jQuery("#TB_window").append('<div id="TB_title"><div id="TB_ajaxWindowTitle">'+caption+'</div><div id="TB_closeAjaxWindow"><a href="#" id="TB_closeWindowButton" title="Close or Press ESC"><img src="'+tb_CloseImage_S+'" border="0" alt="X" style="vertical-align:middle;" /></a></div></div><div id="TB_ajaxContent" style="width:'+ajaxContentW+'px;height:'+ajaxContentH+'px"></div>');
					}else{
						jQuery("#TB_overlay").unbind();
						jQuery("#TB_window").append('<div id="TB_ajaxContent" class="TB_modal" style="width:'+ajaxContentW+'px;height:'+ajaxContentH+'px;"></div>');
					}
				}else{
					jQuery("#TB_ajaxContent")[0].style.width=ajaxContentW+"px";
					jQuery("#TB_ajaxContent")[0].style.height=ajaxContentH+"px";
					jQuery("#TB_ajaxContent")[0].scrollTop=0;
					jQuery("#TB_ajaxWindowTitle").html(caption);
				}
			}
			jQuery("#TB_closeWindowButton").click(tb_remove);
			if(url.indexOf('TB_inline')!=-1){
				jQuery("#TB_ajaxContent").append(jQuery('#'+params['inlineId']).children());
				jQuery("#TB_window").unload(function(){
					jQuery('#'+params['inlineId']).append(jQuery("#TB_ajaxContent").children());
				});
				tb_position();
				jQuery("#TB_load").remove();
				jQuery("#TB_window").css({display:"block"});
			}else if(url.indexOf('TB_iframe')!=-1){
				tb_position();
				if(jQuery.browser.safari){
					jQuery("#TB_load").remove();
					jQuery("#TB_window").css({display:"block"});
				}
			}else{
				jQuery("#TB_ajaxContent").load(url+="&random="+(new Date().getTime()),function(){tb_position();jQuery("#TB_load").remove();tb_init("#TB_ajaxContent a.thickbox");jQuery("#TB_window").css({display:"block"})});
			}
		}
		if(!params['modal']){
			document.onkeyup=function(e){
				if(e==null){
					keycode=event.keyCode;
				}else{
					keycode=e.which;
				}
				if(keycode==27){
					tb_remove();
				}
			}
		}
	}
	catch(e){}
};
function tb_showIframe(){
	jQuery("#TB_load").remove();
	jQuery("#TB_window").css({display:"block"});
};
function tb_remove(){
//	jQuery("#TB_imageOff").unbind("click");
	jQuery("#TB_closeWindowButton").unbind("click");
	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove()});
	jQuery("#TB_load").remove();
	if(typeof document.body.style.maxHeight=="undefined"){
		jQuery("body","html").css({height:"auto",width:"auto"});
		jQuery("html").css("overflow","");
	}
	jQuery('embed, object, select').css({ 'visibility' : 'visible' });
	document.onkeydown="";
	document.onkeyup="";
	return false;
};
function tb_position(){
	jQuery("#TB_window").css({marginLeft:'-'+parseInt((TB_WIDTH/2),10)+'px',width:TB_WIDTH+'px'});
	if(!(jQuery.browser.msie&&jQuery.browser.version<7)){
		jQuery("#TB_window").css({marginTop:'-'+parseInt((TB_HEIGHT/2),10)+'px'});
	}
};
function tb_parseQuery(query){
	var Params={};
	if(!query){
		return Params;
	}
	var Pairs=query.split(/\&|\&amp\;/);
	for(var i=0;i<Pairs.length;i++){
		var KeyVal=Pairs[i] || null;
		if(KeyVal===null) { continue; }
		KeyVal=KeyVal.split('=');
		if(KeyVal===null || !KeyVal||KeyVal.length!=2){continue;}
		var key=decodeURIComponent(KeyVal[0]);
		var val=decodeURIComponent(KeyVal[1]);
		val=val.replace(/\+/g,' ');
		Params[key]=val;
	}
	return Params;
};
function tb_getPageSize(){
	var de=document.documentElement;
	var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
	var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
	arrayPageSize=[w,h];
	return arrayPageSize;
};
function tb_detectMacXFF(){
	var userAgent=navigator.userAgent.toLowerCase();
	if(userAgent.indexOf('mac')!=-1&&userAgent.indexOf('firefox')!=-1){return true;}
};


/* ClueTip plugin (jQuery, Dimensions, hoverIntent[O]) - Customized - Version 0.9.8  (05/22/2008) */
(function($){var $cluetip,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,$dropShadow,imgCount;$.fn.cluetip=function(js,options){
if (typeof js == 'object') { options = js; js = null; }																															
    return this.each(function(index) {
      var $this = $(this);      
      var opts = $.extend(false,{}, $.fn.cluetip.defaults, options || {}, $.metadata ? $this.metadata() : $.meta ? $this.data() : {});
var cluetipContents=false;var cluezIndex=parseInt(opts.cluezIndex,10)-1;var isActive=false,closeOnDelay=0;if(!$('#cluetip').length){$cluetipInner=$('<div id="cluetip-inner"></div>');$cluetipTitle=$('<h3 id="cluetip-title"></h3>');$cluetipOuter=$('<div id="cluetip-outer"></div>').append($cluetipInner).prepend($cluetipTitle);$cluetip=$('<div id="cluetip"></div>').css({zIndex:opts.cluezIndex}).append($cluetipOuter).append('<div id="cluetip-extra"></div>')[insertionType](insertionElement).hide();$('<div id="cluetip-waitimage"></div>').css({position:'absolute',zIndex:cluezIndex-1}).insertBefore('#cluetip').hide();$cluetip.css({position:'absolute',zIndex:cluezIndex});$cluetipOuter.css({position:'relative',zIndex:cluezIndex+1});$cluetipArrows=$('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:cluezIndex+1}).appendTo('#cluetip');}
var dropShadowSteps=(opts.dropShadow)?+opts.dropShadowSteps:0;if(!$dropShadow){$dropShadow=$([]);for(var i=0;i<dropShadowSteps;i++){$dropShadow=$dropShadow.add($('<div></div>').css({zIndex:cluezIndex-i-1,opacity:.1,top:1+i,left:1+i}));};$dropShadow.css({position:'absolute',backgroundColor:'#000'}).prependTo($cluetip);}
var tipAttribute=$this.attr(opts.attribute),ctClass=opts.cluetipClass;if(!tipAttribute&&!opts.splitTitle && !js)return true;if(opts.local&&opts.hideLocal){$(tipAttribute+':first').hide();}
var tOffset=parseInt(opts.topOffset,10),lOffset=parseInt(opts.leftOffset,10);var tipHeight,wHeight;var defHeight=isNaN(parseInt(opts.height,10))?'auto':(/\D/g).test(opts.height)?opts.height:opts.height+'px';var sTop,linkTop,posY,tipY,mouseY,baseline;var tipInnerWidth=isNaN(parseInt(opts.width,10))?275:parseInt(opts.width,10);var tipWidth=tipInnerWidth+(parseInt($cluetip.css('paddingLeft'))||0)+(parseInt($cluetip.css('paddingRight'))||0)+dropShadowSteps;var linkWidth=this.offsetWidth;var linkLeft,posX,tipX,mouseX,winWidth;var tipParts;var tipTitle=(opts.attribute!='title')?$this.attr(opts.titleAttribute):'';if(opts.splitTitle){if(tipTitle==undefined){tipTitle='';}
tipParts=tipTitle.split(opts.splitTitle);tipTitle=tipParts.shift();}
var localContent;var activate=function(event){if(!opts.onActivate($this)){return false;}
isActive=true;$cluetip.removeClass().css({width:tipInnerWidth});if(tipAttribute==$this.attr('href')){$this.css('cursor',opts.cursor);}
$this.attr('title','');if(opts.hoverClass){$this.addClass(opts.hoverClass);}
linkTop=posY=$this.offset().top;linkLeft=$this.offset().left;mouseX=event.pageX;mouseY=event.pageY;if($this[0].tagName.toLowerCase()!='area'){sTop=$(document).scrollTop();winWidth=$(window).width();}
if(opts.positionBy=='fixed'){posX=linkWidth+linkLeft+lOffset;$cluetip.css({left:posX});}else{posX=(linkWidth>linkLeft&&linkLeft>tipWidth)||linkLeft+linkWidth+tipWidth+lOffset>winWidth?linkLeft-tipWidth-lOffset:linkWidth+linkLeft+lOffset;if($this[0].tagName.toLowerCase()=='area'||opts.positionBy=='mouse'||linkWidth+tipWidth>winWidth){if(mouseX+20+tipWidth>winWidth){$cluetip.addClass(' cluetip-'+ctClass);posX=(mouseX-tipWidth-lOffset)>=0?mouseX-tipWidth-lOffset-parseInt($cluetip.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(tipWidth/2);}else{posX=mouseX+lOffset;}}
var pY=posX<0?event.pageY+tOffset:event.pageY;$cluetip.css({left:(posX>0&&opts.positionBy!='bottomTop')?posX:(mouseX+(tipWidth/2)>winWidth)?winWidth/2-tipWidth/2:Math.max(mouseX-(tipWidth/2),0)});}
wHeight=$(window).height();
if (js) { $cluetipInner.html(js); cluetipShow(pY); }
else if(tipParts){var tpl=tipParts.length;for(var i=0;i<tpl;i++){if(i==0){$cluetipInner.html(tipParts[i]);}else{$cluetipInner.append('<div class="split-body">'+tipParts[i]+'</div>');}};cluetipShow(pY);}
else if(!opts.local&&tipAttribute.indexOf('#')!=0){if(cluetipContents&&opts.ajaxCache){$cluetipInner.html(cluetipContents);cluetipShow(pY);}
else{var ajaxSettings=opts.ajaxSettings;if(tipAttribute.indexOf('.')!==-1||tipAttribute.indexOf('?')!==-1){ajaxSettings.url=tipAttribute;}else{if(vnc_lang=='en'){ajaxSettings.url='/content/ajax/news/tips/en/'+Math.floor(parseInt(tipAttribute.substr(3))/1000)+'/n'+parseInt(tipAttribute.substr(3))+'.html';}else{ajaxSettings.url='/content/ajax/news/tips/vi/'+Math.floor(parseInt(tipAttribute.substr(3))/1000)+'/n'+parseInt(tipAttribute.substr(3))+'.html';}} ajaxSettings.beforeSend=function(){$cluetipOuter.children().empty();if(opts.waitImage){$('#cluetip-waitimage').css({top:mouseY+20,left:mouseX+20}).show();}};ajaxSettings.error=function(){if(isActive){$cluetipInner.html('<i>sorry, the contents could not be loaded</i>');}};ajaxSettings.success=function(data){cluetipContents=opts.ajaxProcess(data);if(isActive){$cluetipInner.html(cluetipContents);}};ajaxSettings.complete=function(){imgCount=$('#cluetip-inner img').length; if (imgCount && !$.browser.opera) { $('#cluetip-inner img').load(function() {imgCount--;if(imgCount<1){$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}});}else{$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}};$.ajax(ajaxSettings);}}else if(opts.local){var $localContent=$(tipAttribute+':first');var localCluetip=$.fn.wrapInner?$localContent.wrapInner('<div></div>').children().clone(true):$localContent.html();$.fn.wrapInner?$cluetipInner.empty().append(localCluetip):$cluetipInner.html(localCluetip);cluetipShow(pY);}};var cluetipShow=function(bpY){$cluetip.addClass('cluetip-'+ctClass);if(opts.truncate){var $truncloaded=$cluetipInner.text().slice(0,opts.truncate)+'...';$cluetipInner.html($truncloaded);}
function doNothing(){};tipTitle?$cluetipTitle.show().html(tipTitle):(opts.showTitle)?$cluetipTitle.show().html('&nbsp;'):$cluetipTitle.hide();if(opts.sticky){var $closeLink=$('<div id="cluetip-close"><a href="#">'+opts.closeText+'</a></div>');(opts.closePosition=='bottom')?$closeLink.appendTo($cluetipInner):(opts.closePosition=='title')?$closeLink.prependTo($cluetipTitle):$closeLink.prependTo($cluetipInner);$closeLink.click(function(){cluetipClose();return false;});if(opts.mouseOutClose){if($.fn.hoverIntent&&opts.hoverIntent){$cluetip.hoverIntent({over:doNothing,timeout:opts.hoverIntent.timeout,out:function(){$closeLink.trigger('click');}});}else{$cluetip.hover(doNothing,function(){$closeLink.trigger('click');});}}else{$cluetip.unbind('mouseout');}}
var direction='';$cluetipOuter.css({overflow:defHeight=='auto'?'visible':'auto',height:defHeight});tipHeight=defHeight=='auto'?Math.max($cluetip.outerHeight(),$cluetip.height()):parseInt(defHeight,10);tipY=posY;baseline=sTop+wHeight;if(opts.positionBy=='fixed'){tipY=posY-opts.dropShadowSteps+tOffset;}else if((posX<mouseX&&Math.max(posX,0)+tipWidth>mouseX)||opts.positionBy=='bottomTop'){if(posY+tipHeight+tOffset>baseline&&mouseY-sTop>tipHeight+tOffset){tipY=mouseY-tipHeight-tOffset;direction='top';}else{tipY=mouseY+tOffset;direction='bottom';}}else if(posY+tipHeight+tOffset>baseline){tipY=(tipHeight>=wHeight)?sTop:baseline-tipHeight-tOffset;}else if($this.css('display')=='block'||$this[0].tagName.toLowerCase()=='area'||opts.positionBy=="mouse"){tipY=bpY-tOffset;}else{tipY=posY-opts.dropShadowSteps;}
if(direction==''){posX<linkLeft?direction='left':direction='right';}
$cluetip.css({top:tipY+'px'}).removeClass().addClass('clue-'+direction+'-'+ctClass).addClass(' cluetip-'+ctClass);if(opts.arrows){var bgY=(posY-tipY-opts.dropShadowSteps);$cluetipArrows.css({top:(/(left|right)/.test(direction)&&posX>=0&&bgY>0)?bgY+'px':/(left|right)/.test(direction)?0:''}).show();}else{$cluetipArrows.hide();}
$dropShadow.hide();$cluetip.hide()[opts.fx.open](opts.fx.open!='show'&&opts.fx.openSpeed);if(opts.dropShadow)$dropShadow.css({height:tipHeight,width:tipInnerWidth}).show();if($.fn.bgiframe){$cluetip.bgiframe();}
if(opts.delayedClose>0){closeOnDelay=setTimeout(cluetipClose,opts.delayedClose);}
opts.onShow($cluetip,$cluetipInner);};var inactivate=function(){isActive=false;$('#cluetip-waitimage').hide();if(!opts.sticky||(/click|toggle/).test(opts.activation)){cluetipClose();clearTimeout(closeOnDelay);};if(opts.hoverClass){$this.removeClass(opts.hoverClass);}
$('.cluetip-clicked').removeClass('cluetip-clicked');};var cluetipClose=function(){$cluetipOuter.parent().hide().removeClass().end().children().empty();if(tipTitle){$this.attr(opts.titleAttribute,tipTitle);}
$this.css('cursor','');if(opts.arrows)$cluetipArrows.css({top:''});};if((/click|toggle/).test(opts.activation)){$this.click(function(event){if($cluetip.is(':hidden')||!$this.is('.cluetip-clicked')){activate(event);$('.cluetip-clicked').removeClass('cluetip-clicked');$this.addClass('cluetip-clicked');}else{inactivate(event);}
this.blur();return false;});}else if(opts.activation=='focus'){$this.focus(function(event){activate(event);});$this.blur(function(event){inactivate(event);});}else{$this.click(function(){if($this.attr('href')&&$this.attr('href')==tipAttribute&&!opts.clickThrough){return false;}});var mouseTracks=function(evt){if(opts.tracking==true){var trackX=posX-evt.pageX;var trackY=tipY?tipY-evt.pageY:posY-evt.pageY;$this.mousemove(function(evt){$cluetip.css({left:evt.pageX+trackX,top:evt.pageY+trackY});});}};if($.fn.hoverIntent&&opts.hoverIntent){$this.mouseover(function(){$this.attr('title','');}).hoverIntent({sensitivity:opts.hoverIntent.sensitivity,interval:opts.hoverIntent.interval,over:function(event){activate(event);mouseTracks(event);},timeout:opts.hoverIntent.timeout,out:function(event){inactivate(event);$this.unbind('mousemove');}});}else{$this.hover(function(event){activate(event);mouseTracks(event);},function(event){inactivate(event);$this.unbind('mousemove');});}}});};$.fn.cluetip.defaults={width:300,height:'auto',cluezIndex:97,positionBy:'auto',topOffset:15,leftOffset:15,local:false,hideLocal:true,attribute:'rel',titleAttribute:'title',splitTitle:'',showTitle:true,cluetipClass:'default',hoverClass:'',waitImage:true,cursor:'help',arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:'hover',clickThrough:false,tracking:false,delayedClose:0,closePosition:'top',closeText:'Close',truncate:0,fx:{open:'show',openSpeed:''},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(e){return true;},onShow:function(ct,c){},ajaxCache:true,ajaxProcess:function(data){data=data.replace(/<s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g,'').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');return data;},ajaxSettings:{dataType:'html'},debug:false};var insertionType='appendTo',insertionElement='body';$.cluetip={};$.cluetip.setup=function(options){if(options&&options.insertionType&&(options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){insertionType=options.insertionType;}
if(options&&options.insertionElement){insertionElement=options.insertionElement;}};})(jQuery);

/* VFuncs */
function selectCode(a)
{var e=a.parentNode.parentNode.getElementsByTagName('CODE')[0];if(window.getSelection)
{var s=window.getSelection();if(s.setBaseAndExtent)
{s.setBaseAndExtent(e,0,e,e.innerText.length-1);}
else
{var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r);}}
else if(document.getSelection)
{var s=document.getSelection();var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r);}
else if(document.selection)
{var r=document.body.createTextRange();r.moveToElementText(e);r.select();}
return false;}
function log_out(logout_cf_msg)
{if(jQuery){if(typeof document.body.style.maxHeight==="undefined"){jQuery("body","html").css({height:"100%",width:"100%"});jQuery("html").css("overflow","hidden");if(document.getElementById("TB_HideSelect")===null){jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");jQuery("#TB_overlay").click(tb_remove);}}else{if(document.getElementById("TB_overlay")===null){jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");jQuery("#TB_overlay").click(tb_remove);}}
if(tb_detectMacXFF()){jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");}else{jQuery("#TB_overlay").addClass("TB_overlayBG");}}else{var bo=document.getElementsByTagName('body');bo[0].style.filter='Alpha(opacity="30")';bo[0].style.MozOpacity='0.3';bo[0].style.opacity='0.3';}
if(!logout_cf_msg){logout_cf_msg='Are you sure that you want to logout?';}
if(confirm(logout_cf_msg))
{return true;}
else
{if(jQuery){jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});if(typeof document.body.style.maxHeight=="undefined"){jQuery("body","html").css({height:"auto",width:"auto"});jQuery("html").css("overflow","");}}else{bo[0].style.filter='Alpha(opacity="100")';bo[0].style.MozOpacity='1';bo[0].style.opacity='1';}
return false;}}
var jcurrent_menu="";function jopenMenu(element)
{var id=element.id;var popup_id=id+"-popup";if(jcurrent_menu==id)
{jcloseMenu(jcurrent_menu);return false;}
else if(jcurrent_menu)
{jcloseMenu(jcurrent_menu);}
o=jQuery('#'+id).offset();elemOffsetTop=o.top;elemOffsetLeft=o.left;jQuery('#'+popup_id).css({position:'absolute',zIndex:'10',top:(elemOffsetTop+jQuery('#'+id).outerHeight()-1)+"px",left:(elemOffsetLeft)+"px"});elemWidth=jQuery('#'+popup_id).width();if(elemWidth)
{menuWidth=parseInt(elemWidth);}
else
{menuWidth=jQuery('#'+popup_id).outerWidth();}
bodyWidth=jQuery('body').width();if(elemOffsetLeft+menuWidth>=bodyWidth)
{moveleft=elemOffsetLeft+menuWidth-bodyWidth;if(jQuery.browser.msie)
{jQuery('#'+popup_id).css({left:(parseInt(jQuery('#'+popup_id).offset().left)-6-moveleft)+"px"})}else{jQuery('#'+popup_id).css({left:(elemOffsetLeft+jQuery('#'+id).outerWidth()-menuWidth-2-moveleft)+"px"});}}
jQuery('#'+popup_id).bind('mouseover',jhandleOverOut);jQuery('#'+popup_id).bind('mouseout',jhandleOverOut);jQuery(document).bind('click',jhandleOverOut);jQuery('#'+popup_id).show('slow');jcurrent_menu=id;return false;}
function jcloseMenu(id)
{if(!id&&jcurrent_menu)
{id=jcurrent_menu;}
var popup_id=id+"-popup";jQuery('#'+popup_id).hide('slow');jQuery('#'+popup_id).unbind('mouseout',jhandleOverOut);jQuery('#'+popup_id).unbind('mouseover',jhandleOverOut);jQuery(document).unbind('click');jcurrent_menu="";}
function jhandleOverOut(event)
{if(typeof(event)!="undefined"&&event.type=="mouseover")
{jQuery(document).unbind('click');}
else
{jQuery(document).bind('click',jhandleClick);}}
function jhandleClick(element)
{jcloseMenu("");}
function VNC_URLEncode(plaintext)
{
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function SearchVNNJob()
{window.open('http://vietnamnetjobs.com/default.aspx?tabid=620&search=true&nganhnghe='+document.getElementById('nganhnghe').value+'&noilamviec='+document.getElementById('diadiem').value,'_blank');}
function SearchVNWJob()
{window.open('http://www.vietnamworks.com/jobseekers/searchresults.php?keyword='+VNC_URLEncode(document.getElementById('vnw_keyword').value)+'&industry='+document.getElementById('vnw_industry').value+'&city='+document.getElementById('vnw_city').value+'&search=search&mustmatch=','_blank');}
function addbookmark()
{if(!error_bookmark){error_bookmark="Xin lỗi! Trình duyệt của bạn không hỗ trợ Bookmark!";}
if(window.sidebar)
{window.sidebar.addPanel(document.title,location.href,"");}
else if(document.all)
{window.external.AddFavorite(location.href,document.title);}
else
{alert(error_bookmark);}return false;}
function sethomepage(url)
{if(!error_sethomepage){error_sethomepage="Xin lỗi! Trình duyệt của bạn không hỗ trợ Bookmark!";}
if(is_ie||is_ie4||is_win)
{document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(url);}
else
{alert(error_sethomepage);}return false;}
function vnc_button_init () {
	jQuery('#col_left_close').click(function () { return ColumnClose('menusx'); });
	jQuery('#col_left_open').click(function () { return ColumnOpen('menusx'); });
	jQuery('#col_right_close').click(function () { return ColumnClose('menudx'); });
	jQuery('#col_right_open').click(function () { return ColumnOpen('menudx'); });
	
	jQuery('#vnc_go_previous_link').click(function () { window.history.back(); return false; });
	jQuery('#vnc_go_top_link').click(function () { window.scrollTo(0,0); return false; });
	jQuery('#vnc_go_next_link').click(function () { window.history.forward(); return false; });
	jQuery('#vnc_set_homepage_link').click(function () { return sethomepage(unescape(window.location.href)); });
	jQuery('#vnc_add_favourite_link').click(function () { return addbookmark(); });
}
jQuery.fn.extend({
	vnc_show_hide_cat: function() {
		return this.each(function() {jQuery(this).toggle(function(){jQuery('#'+this.id+'_cat').hide('slow'); jQuery('#'+this.id).html('[+]'); },function(){ jQuery('#'+this.id+'_cat').show('fast'); jQuery('#'+this.id).html('[-]'); }) });
	},
	vnc_pop_link: function() {
		return this.each(function() {jQuery(this).append(' <img src="/forums/images/misc/menu_open.gif" alt="[+]" />').click(function () { return jopenMenu(this); }) });
	},
	vnc_news_tip_init: function() {
		return this.each(function() {
			if (vnc_lang=='en') {
				jQuery(this).cluetip({ cluetipClass: 'jtip', arrows: true, attribute: 'name', showTitle: false });		
			} else {
				jQuery(this).cluetip({ cluetipClass: 'jtip', arrows: true, showTitle: false });
			}
		});
	}
});
jQuery(document).ready(function() {
	jQuery('.pop_link').vnc_pop_link();
	jQuery('a.snijt').vnc_news_tip_init();
	vnc_button_init();
});
