/*************************************************
* default functions with jQuery
* 	since : {
* 		date    : "2009-01-15",
* 		author  : "akato"
* 	},
* 	lastmodified : {
* 		date    : "2009-01-15",
* 		author  : "akato"
* 	},
* 	methods : {
* 		//description
* }
*************************************************/

//class "df"
var df = {};

$(function() {
/*noscript*/
//$("#identityNoscript").remove();


//dummy value for input
jQuery.fn.dfDummyValueForm = function(config){
	config = jQuery.extend({
		value: "値を入力してください",
		color: "#aaaaaa"
	},config);
	//logic
	var $target = $(this);
	var setDummy = function() {
		$target.css("color",config.color);
		$target.val(config.value);
	};
	$target
		.focus(function() {
			if($(this).val() !== config.value) return;
			$(this).val("");
			$(this).css("color","");
		})
		.blur(function() {
			if($(this).val()) return;
			setDummy();
		});
	setDummy();
	return this;
};

//blanket checking
jQuery.fn.dfCheckboxBlanket = function(config){
	config = jQuery.extend({
		navi: "ul.selectList"
	},config);

	var $target = $(this);
	var blanketCheck = function() {
		$target.find(":checkbox").each(function() {
			if(!this.checked) this.checked=true;
		});
	};
	var blanketCheckReset = function() {
		$target.find(":checkbox").each(function() {
			if(this.checked) this.checked=false;
		});
	};
	$(config.navi).find("a").each(function(i) {
		if(i === 0 || i === 2) {
			$(this).click(function() {
				blanketCheck()
				return false;
			});
		}
		if(i === 1 || i === 3) {
			$(this).click(function() {
				blanketCheckReset();
				return false;
			});
		}
		return;
	});

	return this;
};

//window.event for cross browser
df.WindowEventX = function() {
	if(window.attachEvent && document.getElementById) return;//not for ie
	for (var property in Event.prototype){
		if(property.match(/MOUSE|CLICK/)){
			window.addEventListener(property.toLowerCase(), function(e){window.event = e;}, true);
		}
	}
};

//auto image rollover with class="rollover"
df.RollOver = function(exists) {
	var aPreLoad = new Array();
	var sTempSrc;
	var imageExists = function(sImageUrl) {
		if(!exists) return true;
		var img = new Image();
		img.src = sImageUrl;
		return img.height > 0;//noimage > return false
	};
	$("img.rollover,input.rollover:[type='image']").each(function(i) {
		var src = $(this).attr('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_on'+ftype);
		if(!imageExists(hsrc)) return;
		$(this).attr('hsrc', hsrc);
		aPreLoad[i] = new Image();
		aPreLoad[i].src = hsrc;
		$(this)
			.mouseover(function() {
				sTempSrc = $(this).attr('src');
				$(this).attr('src', $(this).attr('hsrc'));
			})
			.mouseout(function() {
				if (!sTempSrc) sTempSrc = $(this).attr('src').replace('_on'+ftype, ftype);
				$(this).attr('src', sTempSrc);
			});
	});
};

//like a _blank with rel="external"
df.NewWindow = function() {
	$('a[rel="external"]').click(function() {
		window.open($(this).attr("href"));
		return false;
	});
};

//auto select on readonly textarea
df.TextareaAutoSelecta = function() {
	$('textarea[readonly],input[readonly]')
		.click(function() {
			this.select();
		})
		.focus(function() {
			this.select();
		});
};


});




/*--------------------------------------------------------------------------*
*  heightLine JavaScript Library beta4
*  MIT-style license. 
*  2007 Kazuma Nishihata 
*  http://www.webcreativepark.net
*--------------------------------------------------------------------------*/
new function(){
function heightLine(){
this.className="heightLine";
this.parentClassName="heightLineParent"
reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
objCN =new Array();
var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
for(var i = 0; i < objAll.length; i++) {
var eltClass = objAll[i].className.split(/\s+/);
for(var j = 0; j < eltClass.length; j++) {
if(eltClass[j] == this.className) {
if(!objCN["main CN"]) objCN["main CN"] = new Array();
objCN["main CN"].push(objAll[i]);
break;
}else if(eltClass[j] == this.parentClassName){
if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
objCN["parent CN"].push(objAll[i]);
break;
}else if(eltClass[j].match(reg)){
var OCN = eltClass[j].match(reg)
if(!objCN[OCN]) objCN[OCN]=new Array();
objCN[OCN].push(objAll[i]);
break;
}
}
}
var e = document.createElement("div");
var s = document.createTextNode("S");
e.appendChild(s);
e.style.visibility="hidden"
e.style.position="absolute"
e.style.top="0"
document.body.appendChild(e);
var defHeight = e.offsetHeight;
changeBoxSize = function(){
for(var key in objCN){
if (objCN.hasOwnProperty(key)) {
if(key == "parent CN"){
for(var i=0 ; i<objCN[key].length ; i++){
var max_height=0;
var CCN = objCN[key][i].childNodes;
for(var j=0 ; j<CCN.length ; j++){
if(CCN[j] && CCN[j].nodeType == 1){
CCN[j].style.height="auto";
max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
}
}
for(var j=0 ; j<CCN.length ; j++){
if(CCN[j].style){
var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
var newheight = max_height;
if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
CCN[j].style.height =newheight+"px";
}
}
}
}else{
var max_height=0;
for(var i=0 ; i<objCN[key].length ; i++){
objCN[key][i].style.height="auto";
max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
}
for(var i=0 ; i<objCN[key].length ; i++){
if(objCN[key][i].style){
var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
var newheight = max_height;
if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
objCN[key][i].style.height =newheight+"px";
}
}
}
}
}
}
checkBoxSize = function(){
if(defHeight != e.offsetHeight){
changeBoxSize();
defHeight= e.offsetHeight;
}
}
changeBoxSize();
setInterval(checkBoxSize,1000)
window.onresize=changeBoxSize;
}
function addEvent(elm,listener,fn){
try{
elm.addEventListener(listener,fn,false);
}catch(e){
elm.attachEvent("on"+listener,fn);
}
}
addEvent(window,"load",heightLine);
}
