/*
* yuga.js 0.7.1 - 優雅なWeb制作のためのJS
*
* Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Since:     2006-10-30
* Modified:  2009-01-27
*
* jQuery 1.3.1
* ThickBox 3.1
*/

(function($) {

$(function() {
$.yuga.css3class();
});

//---------------------------------------------------------------------

$.yuga = {
// URIを解析したオブジェクトを返すfunction
Uri: function(path){
var self = this;
this.originalPath = path;
//絶対パスを取得
this.absolutePath = (function(){
var e = document.createElement('span');
e.innerHTML = '<a href="' + path + '" />';
return e.firstChild.href;
})();
//絶対パスを分解
var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
for (var field in fields) {
this[field] = r[fields[field]];
}
this.querys = {};
if(this.query){
$.each(self.query.split('&'), function(){
var a = this.split('=');
if (a.length == 2) self.querys[a[0]] = a[1];
});
}
},
//css3のクラスを追加
css3class: function() {
//:first-child, :last-childをクラスとして追加
$('body :first-child').addClass('firstChild');
$('body :last-child').addClass('lastChild');
}
};
})(jQuery);
