/*==============================================
	Cookie plugin

	Copyright (c) 2006 Klaus Hartl (stilbuero.de)
	Dual licensed under the MIT and GPL licenses:
	http://www.opensource.org/licenses/mit-license.php
	http://www.gnu.org/licenses/gpl.html
==============================================*/
jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};if(I===null){I="";L.expires=-1}var E="";if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;if(typeof L.expires=="number"){F=new Date();F.setTime(F.getTime()+(L.expires*24*60*60*1000))}else{F=L.expires}E="; expires="+F.toUTCString()}var K=L.path?"; path="+(L.path):"";var G=L.domain?"; domain="+(L.domain):"";var A=L.secure?"; secure":"";document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")}else{var D=null;if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");for(var H=0;H<J.length;H++){var C=jQuery.trim(J[H]);if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));break}}}return D}}

/*==============================================
	New window Module
==============================================*/
$(function(){
	$('a.blank').click(function(){
		window.open(this.href,'_blank');
		return false;
	});
});

/*==============================================
	Swap image Module
==============================================*/
$(function(){
	var image_cache=new Object();
	$("img.swap").not("[src*='_ovr.']").each(function(i){
		var imgsrc=this.src;
		var dot=this.src.lastIndexOf('.');
		var imgsrc_ovr=this.src.substr(0,dot)+'_ovr'+this.src.substr(dot,4);
		image_cache[this.src]=new Image();
		image_cache[this.src].src=imgsrc_ovr;
		$(this).hover(function(){
			this.src=imgsrc_ovr;
		},function(){
			this.src=imgsrc;
		});
	});
});

/*==============================================
	Font Size Module
==============================================*/
$(function(){
	var i=$.cookie('jpnhd_fontsize');
	i ? $('div#container').css('font-size',i+'%') : $('div#container').css('font-size','100%');
});

function setFontsize(i){
	$('div#container').css('font-size',i+'%');
	$.cookie('jpnhd_fontsize',i,{expires:30,path:'/'});
}

/*==============================================
	Utility Result
==============================================*/
var sd,td,gd,so,to,go;
$(function(){
	sd=$('div#utility img.item09').attr('src');
	td=$('div#utility img.item10').attr('src');
	gd=$('div#utility img.item11').attr('src');
	so=getOvrPath(sd);
	to=getOvrPath(td);
	go=getOvrPath(gd);
	var j=$.cookie('jpnhd_fontsize');
	var k=Number(j);
	setBtns(k);
	$('div#utility dl dd img').each(function(i){
		$(this).click(function(){
			switch(i){
				case 0:
				setFontsize(80);
				setBtns(80);
				break;
				case 1:
				setFontsize(100);
				setBtns(100);
				break;
				case 2:
				setFontsize(120);
				setBtns(120);
				break;
			}
		}).mouseover(function(){
			$(this).css('cursor','pointer');
		});
	})
});

function getOvrPath(i){
	var j=i.lastIndexOf('.');
	var k=i.substr(0,j)+'_ovr'+i.substr(j,4);
	return k;
}

function setBtns(i){
	$('div#utility img.item09').attr('src',sd);
	$('div#utility img.item10').attr('src',td);
	$('div#utility img.item11').attr('src',gd);
	switch(i){
		case 80:
		$('div#utility img.item09').attr('src',so);
		break;
		case 100:
		$('div#utility img.item10').attr('src',to);
		break;
		case 120:
		$('div#utility img.item11').attr('src',go);
		break;
		default:
		$('div#utility img.item10').attr('src',to);
		break;
	}
}

/*==============================================
	Active style
==============================================*/
$(function(){
	$('div.zwei div#sideNavi ul li:last').css('border-bottom','none');
	$('div.zwei div#sideNavi ul li').each(function(){
		$(this).mouseover(function(){
			$(this).css('background-color','#dbe1e8');
		}).mouseout(function(){
			if(!$(this).attr('class')){
				$(this).css('background-color','#f9f9f9');
			}
		});
	});
});
