/* 
---------------------------------------------------------------
  start General
--------------------------------------------------------------- 
*/
var loading = '<img src="images/model/loading.gif" alt="loading" />';

// 開新視窗
function windowOpen(url) {
	window.open(url);
}
/* 
---------------------------------------------------------------
  end   General
--------------------------------------------------------------- 
---------------------------------------------------------------
  start Style
--------------------------------------------------------------- 
*/
// 切換樣式
function styleChange(style, sum, id, styleLink, styleHover) {
	var self = $(style+id);
	
	for (var i=0; i<=sum; i++) {
		if ($(style+i) == self) {
			$(style+i).className = styleHover;
		} else {
			$(style+i).className = styleLink;
		}
	}
}
/* 
---------------------------------------------------------------
  end   Style
--------------------------------------------------------------- 
---------------------------------------------------------------
  start Rico
--------------------------------------------------------------- 
*/



/* 
---------------------------------------------------------------
  end   Rico
--------------------------------------------------------------- 
---------------------------------------------------------------
  start Ajax
--------------------------------------------------------------- 
*/
function ajaxGet(source, obj) {
	new Ajax.Updater (
		obj, 
		source, 
		{
			method      : "get",
			evalScripts : true,
			/*onLoading   : function () {
				if ($(obj).type == undefined) {
					$(obj).innerHTML = loading;
				}
			},*/
			onComplete  : function (request) {
				if ($(obj).type == undefined) {
					$(obj).innerHTML = request.responseText;
				}	else {
					$(obj).value = request.responseText;
				}
			}
		}
	);
}

function ajaxForm(source, form, obj) {		
	new Ajax.Updater (
		obj, 
		source, 
		{ 
			method      : "post",
			evalScripts : true,
			parameters  : Form.serialize(form),
			onLoading   : function () {
				$(obj).innerHTML = loading;
			},
			onComplete  : function (request) {
				$(obj).innerHTML = request.responseText;
			}
		}
	);
}

function ajaxEvent(source, input, obj) {
	var keyInput = $(input).value;
	source += keyInput;	
	
	ajaxGet(source, obj);
}
/* 
---------------------------------------------------------------
  end   Ajax
--------------------------------------------------------------- 
*/
