var strToggeCookie = 'au_toggle';

$j(function(){
	
	// init
	var strCookie = fncGetCookie(strToggeCookie);
	if(strCookie){
		$j('#toggleList').removeClass('toggleListClose');
		$j('#toggleList').removeClass('toggleListOpen');
		$j('#toggleList').addClass(strCookie);
	}
	$j('#toggleList .toggleListButton').show();
	$j('.toggleListClose .toggle').hide();
	$j('.toggleListClose #toggleButtonMin').attr({ src: '/english/shared/image/button_togglelist_min_on.gif' });
	$j('.toggleListOpen #toggleButtonMax').attr({ src: '/english/shared/image/button_togglelist_max_on.gif' });
	
	// onclick
	$j('#toggleButtonMax').click(function(){
		var strNewCookie = 'toggleListOpen';
		fncSetCookie(strNewCookie, strToggeCookie);
		$j('.toggle').show();
		$j('#toggleButtonMin').attr({ src: '/english/shared/image/button_togglelist_min.gif' });
		$j('#toggleButtonMax').attr({ src: '/english/shared/image/button_togglelist_max_on.gif' });
	});
	$j('#toggleButtonMin').click(function(){
		var strNewCookie = 'toggleListClose';
		fncSetCookie(strNewCookie, strToggeCookie);
		$j('.toggle').hide();
		$j('#toggleButtonMin').attr({ src: '/english/shared/image/button_togglelist_min_on.gif' });
		$j('#toggleButtonMax').attr({ src: '/english/shared/image/button_togglelist_max.gif' });
	});
});

/*=============================================
 fncSetCookie()
=============================================*/
function fncSetCookie(vstrArg , vstrKey){
	var intDate = 365;
	var strCur  = fncGetFileName();
	
	objDate = new Date();
	objDate.setTime(objDate.getTime()+(intDate*24*60*60*1000));
	
	strData = "@" + vstrKey + '<>' + strCur + "=" + escape(vstrArg) + ";";
	
	strTerm = "expires="+objDate.toGMTString();
	document.cookie =  strData + strTerm;
}

/*=============================================
 fncGetCookie()
=============================================*/
function fncGetCookie(vstrKey){
	var i = 0;
	var strCur      = fncGetFileName();
	var strKey      = '@' + vstrKey + '<>' + strCur + '=';
	var strCookie   = '';
	var astrCookies = document.cookie.split(';');
	var strValue    = '';
	
	for (i = 0; i < astrCookies.length; i ++) {
		if (astrCookies[i].indexOf(strKey) >= 0) {
			strCookie = astrCookies[i].replace(/ /i,'');
		}
	}
	if (strCookie.indexOf(strKey) >= 0) {
		strValue = strCookie.substr(strCookie.indexOf(strKey) + strKey.length, strCookie.length);	
	}
	return strValue;
}

/*=============================================
 fncGetFileName()
=============================================*/
function fncGetFileName(){
	var strLocation = location.pathname;
//	var astrLocationTmp = strLocation.split("/");
//	var strFileName = astrLocationTmp[astrLocationTmp.length - 1];
//	return strFileName;
	return strLocation;
}

