/* UTF-8 編碼
 * --------------------------------------------------------------------
 * func.common.js (05/2009)
 *
 * by Guan-Ting Chen, fi@livemail.tw
 *
 * Copyright (c) 2009 Guan-Ting Chen
 * Licensed under MIT (http://www.opensource.org/licenses/MIT-license.php)
*/
function website_bookmark (title, url){
	if (document.all)   {
		window.external.addFavorite(url, title);
	}

	if (window.sidebar) {
		window.sidebar.addPanel(title, url, '');
	}

	if (-1 != navigator.userAgent.toLowerCase().indexOf('webkit')) {
		alert('您的瀏覽器無法執行這個動作，您可以利用瀏覽器書籤功能將我們的網站加入到您的最愛裡。');
	}
}

function init_input_checkbox (element_name) {

	var element = $('input[type=checkbox][name='+element_name+']');

	element.bind('input-select', function () {
		$('label[for='+$(this).attr('id')+']').toggleClass('label-radio-selected');
	});
	
	element.bind('click', function () { $(this).trigger('input-select'); });

	$('input[type=checkbox][name='+element_name+']').each(function () {
		var self = $(this);
		if (true == self.attr('checked')) { self.trigger('input-select'); }
	});
}

function init_input_radio (element_name) {

	var element = $('input[type=radio][name='+element_name+']');

	element.bind('input-select', function () {
	
		id = $.map(element, function (i) {
			return $('label[for='+$(i).attr('id')+']');
		});
		
		$.each(id, function (i, items) { items.removeClass('label-radio-selected'); });
		
		$('label[for='+$(this).attr('id')+']').addClass('label-radio-selected');

	});
	
	element.bind('click', function () { $(this).trigger('input-select'); });

	$('input[type=radio][name='+element_name+']').each(function () {
		var self = $(this);
		if (true == self.attr('checked')) { self.trigger('input-select'); }
	});
}