	function update_happening(){
		if (happen_count == 0){
			$('f_h3').style.backgroundImage = "url("+sRelativePath+"images/index_happen_box/"+happen_id+".jpg)"; 
			var trailer = new SWFObject("previewloader_l.swf", "mymovie", "210", "120", "8", "#336699");
			trailer.addParam("wmode", "transparent");
			trailer.addParam("movie", "previewloader_l.swf");
			trailer.addVariable("myswfpath", sSwfPath);
			trailer.addVariable("articleID", happen_id);
			trailer.addVariable("myjsfunction", "CallPage");
			trailer.write("f_h3");
			//happen_count++;
		}
		/*else if (happen_count == 1){
			$('f_h3').style.backgroundImage = "url("+sRelativePath+"images/index_happen_box/280.jpg)"; 
			var trailer = new SWFObject("previewloader_l.swf", "mymovie", "210", "120", "8", "#336699");
			trailer.addParam("wmode", "transparent");
			trailer.addParam("movie", "previewloader_l.swf");
			trailer.addVariable("myswfpath", sSwfPath);
			trailer.addVariable("articleID", "280");
			trailer.addVariable("myjsfunction", "CallPage");
			trailer.write("f_h3");
			happen_count=0;
		}*/
	}
	function update_video_img(){
		i = video_img_count;
		
		$('papa2_txt').innerHTML = papa2_txt[i];
		$('papa2_img').src = image_base+'article_images/'+papa2_id[i]+'/'+papa2_img[i];
		$('papa2_img').onclick = function (){location.href = sRelativePath+'index.php?aid='+papa2_id[i];}
	
		$('intv2_txt').innerHTML = intv2_txt[i];
		$('intv2_img').src = image_base+'article_images/'+intv2_id[i]+'/'+intv2_img[i];
		$('intv2_img').onclick = function (){location.href = sRelativePath+'index.php?aid='+intv2_id[i];} 
		
		$('excul2_txt').innerHTML = excul2_txt[i];
		$('excul2_img').src = image_base+'article_images/'+excul2_id[i]+'/'+excul2_img[i];
		$('excul2_img').onclick = function (){location.href = sRelativePath+'index.php?aid='+excul2_id[i];} 
		
		$('hotvideo_txt').innerHTML = hotvideo_txt[i];
		$('hotvideo_img').src = image_base+'article_images/'+hotvideo_id[i]+'/'+hotvideo_img[i];
		$('hotvideo_img').onclick = function (){location.href = sRelativePath+'index.php?aid='+hotvideo_id[i];} 
		
		if (video_img_count == 0){
			video_img_count++;
		}
		else if (video_img_count == 1){
			video_img_count=0;
		}
	}
	
	function openUIWindow(url,width,height) {
	try{
			//if (0){
			//alert(width);
			
			if (typeof(ui_window)=='object'){
				ui_window.setUrl(url).show().setSize(parseInt(width),parseInt(height)).center().activate();
			}else{
				ui_window = new UI.URLWindow({
				width: parseInt(width) || 700, 
				height: parseInt(height) || 765,
				wired:true,
				shadow: true,
				url: url || '404.php' }).show().center().activate();
				ui_window.adapt();
			}
		try{
			var min = document.getElementsByClassName('minimize');
			var max = document.getElementsByClassName('maximize');
			for (var i=0;i<min.length;i++){
				min[i].style.display = 'none';
				max[i].style.display = 'none';
			}
		}catch(e)
		{alert(e.message);}
	}catch(e){alert(e.message);}
	}

	var loading = 'Loading...';
	var action = true;
	function showLoginBox(){
		if ($('login_box').style.display == 'none')
			$('login_box').style.display = 'block';
		else
			$('login_box').style.display = 'none';
	}
	function logout(){
		if (action) {
			action = false;
			new Ajax.Request(sRelativePath+'component/membership/action/ajax.php',{
					method:'post',
					parameters:'action=logout',
					requestHeaders:{accept:'application/json'},
					onSuccess:function(json){
						try{
							var response = json.responseText.evalJSON(true);
							action = true;
							logged = false;
							window.location = sRelativePath+"index.php"
						}catch(e){alert(e.message);}
					}
			});
		}
	}

	// Validates the email. The form is not submitted.
	function validateEmail(email)
	{
		var emailRe = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; 

		if ( !emailRe.test(email.value) ) {
			alert('請輸入電郵地址。\n');
			email.focus();
				return false;
		}
		return true;
	}

	function trim(str) {
		if (str == null)
			return str;

		return str.replace(/^\s*|\s*$/g,"");
	}
	function noScroll(){
		//document.body.scroll="no";
	}

	function addFavourite(type,component_id,issue){
		//var member_id = member_id;
		if (member_id == '') {
			alert('Please Login First');
			return false;
		}
		//$('login-status').update(loading);
		if (action) {
			action = false;
			new Ajax.Request(sRelativePath+'component/membership/action/ajax.php',{
					method:'post',
					parameters:'action=add_favourite&type='+type+'&component_id='+component_id+'&issue='+issue+'&member_id='+member_id,
					requestHeaders:{accept:'application/json'},
					onSuccess:function(json){
						try{
							var response = json.responseText.evalJSON(true);
							action = true;
						}catch(e){alert(e.message);}
					}
			});
		}
	}
	function show_image(url){
		var width = 670;
		var height = 680;
		openUIWindow(url,width,height)
		//alert(src.width);
		return false;
	}
	function show_blog_image(url){
		var width = 300;
		var height = 300;
		openUIWindow(url,width,height)
		//alert(src.width);
		return false;
	}
	function show_video(url){
		var width = 630;
		var height = 460;
		openUIWindow(url,width,height)

		return false;
	}
	function show_trailer(url){

		var width = 600;
		var height = 390;
		openUIWindow(url,width,height)
		return false;
	}
	function show_page(url){

		var width = 710;
		var height = 720;
		openUIWindow(url,width,height)

		return false;
	}
	function show_coupon(url){
	//alert(url);
		var width = 505;
		var height = 680;
		openUIWindow(url,width,height)

		return false;
	}
	function seach_keyword(){
	//alert(type);
		//var type;
		if ($('search_a').checked)
			type = 'a';
		if ($('search_1').checked)
			type = '1';
		//alert(type);
		var keyword = encodeURI(trim($('search_keyword').value));
	 //alert(keyword);
		var link = sRelativePath+'index.php?link=search&keyword='+keyword+'&t='+type;
		//alert(link);
		if (keyword)
			window.location = link;
			//alert (keyword);
		return false;
	}
	function change_type(select_type){
		type = select_type;
	}
	function email_friend(text) {
		u=location.href;
		window.open(sRelativePath+'_email_friend.php?t='+text+'&u='+encodeURIComponent(u),'email_friend','toolbar=0,status=0,width=606,height=256');
		return false;
	}
	function chooseArticle(id){
		 //var aid = trim($('search_aid').value);
		 var link = sRelativePath+'index.php?link=content_detail&article_id='+id;
			if (id)
				window.location = link;
				//alert (keyword);
		return false;
	}
	function change_border(obj,color){
		obj.style.borderColor = color;
	}
	function CallPage(articleID)
	{
		location.href= 'index.php?link=content_detail&article_id='+articleID;
	}
	function CallGroup(groupID)
	{
		location.href= 'index.php?link=content_list&group='+groupID;
	}
	function CallSubGroup(subgroupID)
	{
		location.href= 'index.php?link=content_list&subgroup='+subgroupID;
	}
	function html_entity_decode(str) {
		var ta = document.createElement("textarea");
		ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
		toReturn = ta.value;
		ta = null;
		return toReturn
	}