$(function(){

//===subcategories===
$("li.selected > ul >li").each(function(){
	$(this).css({'display':'list-item'});
});

$("li.selected_parents > ul >li").each(function(){
	$(this).css({'display':'list-item'});
});

$("#left_column > ul.category_list > li.selected").addClass("selected_parents")

//===addclass===
$("tr:even").addClass("even");
$("tr:odd").addClass("odd");

//===h1===
$("#main_column h1").addClass("ui-corner-top");
$("#wrapper > h1").addClass("ui-corner-top");

//===form label===
//$("label:has(input)").each(function(){
//	$(this).css({'display':'inline', 'margin-right':'5px', 'font-size':'100%'});
//});

//===button===
$("input:submit").each(function(){
	$(this).css({'font-size':'90%','font-size':'80%','padding':'5px 15px','color':'#111'});
	$(this).button();
});
$("button, a.button, a.btn").each(function(){
	$(this).css({'font-size':'90%','padding':'1px 4px','color':'#111'});
	$(this).button();
});

//===buttonset===
$("div.buttonset ").each(function(){
	$(this).buttonset();
});


//===button4konan===
$(".next").each(function(){
	$(this).css({'font-size':'90%','font-weight':'bold','padding':'3px 8px 5px 22px','color':'#fff','background-position':'0 50%','background-image':'url(/view/images/btn_bg_df.gif)','border':'2px #228E2C solid'});
	$(this).button();
});

$(".next").hover(function(){
	$(this).css({'background':'0 50% url(/view/images/btn_bg_ro.gif)'});
},function(){
	$(this).css({'background':'0 50% url(/view/images/btn_bg_df.gif)'});
});

//===pause function===
$.fn.pause = function(duration) {
	$(this).animate({ dummy: 1 }, duration);
	return this;
};

//===message_brief===
$(".message_brief li").each(function(){
	$(this).addClass("ui-corner-all");
	$(this).fadeTo(0,0.8).pause(1000).fadeOut(1000);
});

//===growl===
$.fn.growl = function(message) {
	$('body').prepend('<ul class="message_brief"></ul>');
	$('.message_brief').prepend('<li>'+message+'</li>');
	$('.message_brief li').addClass("ui-corner-all");
	$('.message_brief').fadeTo(0,0.8).pause(1000).fadeOut(1000);
	return this;
};

//==floatimage margin==
$('#CenterWrapper img').each(function(){
	if($(this).attr('align')=='left'){
		$(this).css({'margin':'0 10px 10px 0','float':'left'});
		$(this).removeAttr('align');
	}else if($(this).attr('align')=='right'){
		$(this).css({'margin':'0 0 10px 10px','float':'right'});
		$(this).removeAttr('align');
	}else if($(this).attr('align')=='center'){
		$(this).css({'margin':'0 10px 10px 10px'});
	}
});

//==== a.rollover img ====
$('a.rollover').hover(function(){
	var imgsrc = $(this).find('img').attr('src').replace('_df.gif','_ro.gif');
	$(this).find('img').attr('src',imgsrc);
	},function(){
	var imgsrc = $(this).find('img').attr('src').replace('_ro.gif','_df.gif');
	$(this).find('img').attr('src',imgsrc);
});

//==== a.current img ====
$('a.current img').each(function(){
	var imgsrc = $(this).find('img').attr('src').replace('_df.gif','_ro.gif');
	$(this).find('img').attr('src',imgsrc);
});

//==== input.rollover ====
$('input.rollover').hover(function(){
	var imgsrc = $(this).attr('src').replace('_df.gif','_ro.gif');
	$(this).attr('src',imgsrc);
	},function(){
	var imgsrc = $(this).attr('src').replace('_ro.gif','_df.gif');
	$(this).attr('src',imgsrc);
});

// ===captionblock===
$('img.fcr').each(function(){
	var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
	var capwidth = $(this).attr('width');
	capwidth=capwidth+10;
//		$(this).wrap('<span style="width:'+capwidth+'px;font-size:90%;float:right;margin:0 0 10px 10px;text-align:center;dispay:block;">');
	$(this).wrap('<div style="width:'+capwidth+'px;font-size:90%;float:right;margin:0 0 10px 10px;text-align:center;">');
	$(this).attr('alt','').after('<br />'+captxt);
});

$('img.fcl').each(function(){
	var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
	var capwidth = $(this).attr('width');
	capwidth=capwidth+10;
//		$(this).wrap('<span style="width:'+capwidth+'px;font-size:90%;float:left;margin:0 10px 10px 0;text-align:center;dispay:block;">');
	$(this).wrap('<div style="width:'+capwidth+'px;font-size:90%;float:left;margin:0 10px 10px 0;text-align:center;">');
	$(this).attr('alt','').after('<br />'+captxt);
});


$('img.fcc').each(function(){
	var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
//		$(this).wrap('<span style="text-align:center;font-size:90%;margin:0 10px 10px 0;clear:both;dispay:block;">');
	$(this).wrap('<div style="text-align:center;font-size:90%;margin:0 10px 10px 0;clear:both;">');
	$(this).attr('alt','').after('<br />'+captxt);
});

// ===lightbox===
$('a.lb').each(function(){
	var capwidth = $(this).find('img').attr('width');
	capwidth=capwidth+10;
	var altx = $(this).find('img').attr('alt');
	var altx = 'enlearge image (to back to press x)' + altx;
	$(this).find('img').attr('alt',altx);
	$(this).lightBox();
});

});

