$(document).ready(function() {	
	$("input:text, input:password, textarea").addClass("text");
/*	//footer置底
	if($(document).height() < $(window).height()){
		x = $(window).height() - $(document).height();
		y = $("#content").height();
		$("#content").height(y + x);
	}
	
	//Sidebar與Content等高
	c = $("#content").height();
	s = $("#sidebar").height();		
	( c > i ) ? $('#sidebar').height(c) : $('#content').height(s) ;
	
	//選單換圖效果
	//參考來源：Mika Tuupola - http://www.appelsiini.net/2007/6/sequentially-preloading-images
    $("img.current").each(function() {
		s = $(this).attr("src").replace(/\.(gif)$/i, "_c.$1");
        $(this).attr("src", s);
	});
    $("img.hover").hover(function() {
        s = $(this).attr("src").replace(/\.(gif)$/i, "_h.$1");
        $(this).attr("src", s);
    }, function() {
        s = $(this).attr("src").replace(/_h\.(gif)$/i, ".$1");
        $(this).attr("src", s);
    });
*/
	$("a[rel='external']").click(function(){
		window.open(this.href);
		return false;
	});
	$("#logo").click(function(){
    	window.location="/index.php";
		return false;
	});
	$("select[@name='year']").change(function(){
    	y = $(this).val();
		window.location.href=window.location.href+'&year='+y;
	});
	$("ul.files").prev("p:first").css("margin-bottom", "5px");
	$("#goback").click(function(){
		window.history.go(-1);							
	});
	$("form[@name='register']").submit(function(){
		return confirmAlert('Are You Sure to submit this form and \r\napply for membership at ITRI.com?');																				
	});
	$("form[@name='profile']").submit(function(){
		return confirmAlert('Are You Sure to update your profile?');																				
	});
	$("form[@name='register'], form[@name='profile']").validate({
		rules: {
			pwagain: {
				equalTo: "#pw"
			}
		}
	});
	
	$(".index #intro").cycle({ 
		fx:    'fade'
	});
});

function confirmAlert(msg){
	var agree = confirm(msg);
	if(agree)
		return true;
	else
		return false;
}