// minmax.js: make IE5+/Win support CSS min/max-width/height
// version 1.0, 08-Aug-2003
// written by Andrew Clover <and@doxdesk.com>, use freely

/*@cc_on
@if (@_win32 && @_jscript_version<5.7)

var minmax_elements;

minmax_props= new Array(
  new Array('min-width', 'minWidth'),
  new Array('max-width', 'maxWidth'),
  new Array('min-height','minHeight'),
  new Array('max-height','maxHeight')
);

// Binding. Called on all new elements. If <body>, initialise; check all
// elements for minmax properties

function minmax_bind(el) {
  var i, em, ms;
  var st= el.style, cs= el.currentStyle;

  if (minmax_elements==window.undefined) {
    // initialise when body element has turned up, but only on IE
    if (!document.body || !document.body.currentStyle) return;
    minmax_elements= new Array();
    window.attachEvent('onresize', minmax_delayout);
    // make font size listener
    em= document.createElement('div');
    em.setAttribute('id', 'minmax_em');
    em.style.position= 'absolute'; em.style.visibility= 'hidden';
    em.style.fontSize= 'xx-large'; em.style.height= '5em';
    em.style.top='-5em'; em.style.left= '0';
    if (em.style.setExpression) {
      em.style.setExpression('width', 'minmax_checkFont()');
      document.body.insertBefore(em, document.body.firstChild);
    }
  }

  // transform hyphenated properties the browser has not caught to camelCase
  for (i= minmax_props.length; i-->0;)
    if (cs[minmax_props[i][0]])
      st[minmax_props[i][1]]= cs[minmax_props[i][0]];
  // add element with properties to list, store optimal size values
  for (i= minmax_props.length; i-->0;) {
    ms= cs[minmax_props[i][1]];
    if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
      st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
      minmax_elements[minmax_elements.length]= el;
      // will need a layout later
      minmax_delayout();
      break;
  } }
}

// check for font size changes

var minmax_fontsize= 0;
function minmax_checkFont() {
  var fs= document.getElementById('minmax_em').offsetHeight;
  if (minmax_fontsize!=fs && minmax_fontsize!=0)
    minmax_delayout();
  minmax_fontsize= fs;
  return '5em';
}

// Layout. Called after window and font size-change. Go through elements we
// picked out earlier and set their size to the minimum, maximum and optimum,
// choosing whichever is appropriate

// Request re-layout at next available moment
var minmax_delaying= false;
function minmax_delayout() {
  if (minmax_delaying) return;
  minmax_delaying= true;
  window.setTimeout(minmax_layout, 0);
}

function minmax_stopdelaying() {
  minmax_delaying= false;
}

function minmax_layout() {
  window.setTimeout(minmax_stopdelaying, 100);
  var i, el, st, cs, optimal, inrange;
  for (i= minmax_elements.length; i-->0;) {
    el= minmax_elements[i]; st= el.style; cs= el.currentStyle;

    // horizontal size bounding
    st.width= st.minmaxWidth; optimal= el.offsetWidth;
    inrange= true;
    if (inrange && cs.minWidth && cs.minWidth!='0' && cs.minWidth!='auto' && cs.minWidth!='') {
      st.width= cs.minWidth;
      inrange= (el.offsetWidth<optimal);
    }
    if (inrange && cs.maxWidth && cs.maxWidth!='none' && cs.maxWidth!='auto' && cs.maxWidth!='') {
      st.width= cs.maxWidth;
      inrange= (el.offsetWidth>optimal);
    }
    if (inrange) st.width= st.minmaxWidth;

    // vertical size bounding
    st.height= st.minmaxHeight; optimal= el.offsetHeight;
    inrange= true;
    if (inrange && cs.minHeight && cs.minHeight!='0' && cs.minHeight!='auto' && cs.minHeight!='') {
      st.height= cs.minHeight;
      inrange= (el.offsetHeight<optimal);
    }
    if (inrange && cs.maxHeight && cs.maxHeight!='none' && cs.maxHeight!='auto' && cs.maxHeight!='') {
      st.height= cs.maxHeight;
      inrange= (el.offsetHeight>optimal);
    }
    if (inrange) st.height= st.minmaxHeight;
  }
  try{
    //setContentsHgt();
  }catch(e){
    
  }
}

// Scanning. Check document every so often until it has finished loading. Do
// nothing until <body> arrives, then call main init. Pass any new elements
// found on each scan to be bound   

var minmax_SCANDELAY= 500;

function minmax_scan() {
  var el;
  for (var i= 0; i<document.all.length; i++) {
    el= document.all[i];
    if (!el.minmax_bound) {
      el.minmax_bound= true;
      minmax_bind(el);
  } }
}

var minmax_scanner;
function minmax_stop() {
  window.clearInterval(minmax_scanner);
  minmax_scan();
}

minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
window.attachEvent('onload', minmax_stop);

@end @*/





// navigation ----------------------------------------------------------------------------------------------------
function navActive(){
	try{
	
		var tmpGnavClass = $("body").attr("class");
		var tmpGnavSrc = $("#gnav li."+tmpGnavClass+" img").attr("src");
		tmpGnavSrc = tmpGnavSrc.replace(".png","_r.png");
		$("#gnav li."+tmpGnavClass+" img").attr("src",tmpGnavSrc).removeClass("hover");
		$("#gnav li."+tmpGnavClass+" img").get(0).onmouseover = function(){}
		$("#gnav li."+tmpGnavClass+" img").get(0).onmouseout = function(){}
		/*@cc_on
		@if (@_win32 && @_jscript_version<5.7)
		$("#gnav li."+tmpGnavClass+" b").get(0).style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+tmpGnavSrc+",sizingMethod='scale')";
		$("#gnav li."+tmpGnavClass+" b").get(0).onmouseover = function(){}
		$("#gnav li."+tmpGnavClass+" b").get(0).onmouseout = function(){}
		@end @*/
	
	}catch(e){}
	
	try{
	
		var tmpPnavClass = $("#genreTitle").attr("class");
		var tmpPnavSrc = $("#profileNav li."+tmpPnavClass+" img").attr("src");
		tmpPnavSrc = tmpPnavSrc.replace(".png","_r.png");
		$("#profileNav li."+tmpPnavClass+" img").attr("src",tmpPnavSrc).removeClass("hover");
		$("#profileNav li."+tmpPnavClass+" img").get(0).onmouseover = function(){}
		$("#profileNav li."+tmpPnavClass+" img").get(0).onmouseout = function(){}
		/*@cc_on
		@if (@_win32 && @_jscript_version<5.7)
		$("#profileNav li."+tmpPnavClass+" b").get(0).style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+tmpPnavSrc+",sizingMethod='scale')";
		$("#profileNav li."+tmpPnavClass+" b").get(0).onmouseover = function(){}
		$("#profileNav li."+tmpPnavClass+" b").get(0).onmouseout = function(){}
		@end @*/
	
	}catch(e){}
	
	try{
	
		var tmpDiscoNavClass = $("#genreTitle").attr("class");
		var tmpDiscoNavSrc = $(".discography .sideList02 li."+tmpDiscoNavClass+" img").attr("src");
		tmpDiscoNavSrc = tmpDiscoNavSrc.replace(".gif","_r.gif");
		$(".discography .sideList02 li."+tmpDiscoNavClass+" img").attr("src",tmpDiscoNavSrc).removeClass("hover");
		$(".discography .sideList02 li."+tmpDiscoNavClass+" img").get(0).onmouseover = function(){}
		$(".discography .sideList02 li."+tmpDiscoNavClass+" img").get(0).onmouseout = function(){}
		/*@cc_on
		@if (@_win32 && @_jscript_version<5.7)
		$(".discography .sideList02 li."+tmpPnavClass+" b").get(0).style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+tmpDiscoNavSrc+",sizingMethod='scale')";
		$(".discography .sideList02 li."+tmpDiscoNavClass+" b").get(0).onmouseover = function(){}
		$(".discography .sideList02 li."+tmpDiscoNavClass+" b").get(0).onmouseout = function(){}
		@end @*/
	
	}catch(e){}
	
}

function layerNav(){
	$("#gnav .blog").hover(
		function(){
			$("#blogMember").css("visibility","visible");
		},
		function(){
			$("#blogMember").css("visibility","hidden");
		}
	);
}





// NEW ICON ----------------------------------------------------------------------------------------------------
function setNewIcon(){
	var currentDate = new Date();
	$('.newmarkList').each(function(){
		var pass       // passage day
		= 5;
		pass = pass*24;
		var content    // display content
		= '<span class="newicon"><span>NEW</span></span>';
		var newmarkAttr = $(this).attr('rel');
		newmarkAttr = newmarkAttr.replace(/年|月|日|時|分/g,':');
		newmarkAttr = newmarkAttr.replace(/\s|秒.*/g,'');
		var time = newmarkAttr.split(":");
		var entryDate = new Date(time[0], time[1]-1, time[2], time[3], time[4], time[5]);
		var now = (currentDate.getTime() - entryDate.getTime())/(60*60*1000); 
		now = Math.ceil(now);
		if(now <= pass){
			$(this).before(content);
		}
	});
}





// OPENING COOKIE ----------------------------------------------------------------------------------------------------
function checkCookie(){
	
	/*if(!$.cookie('firstview')){
		var cookieMin = 10;
		var cookieHour = cookieMin / 60;
		var cookieDay = cookieHour / 24;
		$.cookie('firstview', 'true', { path: '/', expires: cookieDay });
	}else{
		$("body").attr("class","second");
	}*/
	
	$("body").attr("class","second"); // without opening movie
	
}

function openFullMovie(path){
	
	fullwindow = window.open(path, "", "scrollbars=no, toolbar=no, directories=no, menubar=no, location=no, status=no, resizable=yes, width=" + window.screen.width + ", height=" + window.screen.height);
	fullwindow.moveTo(0,0);
	fullwindow.focus();
	
}









// Event --------------------------------------------------------------------------------------------------------------------
$(function(){
	
	if($.browser.msie && $.browser.version < 7){
		// for IE6
	}else{
		navActive(); // for ELSE
	}
	
	layerNav();
	
	$('.hover:not(img, area, map, b)').opOver(1.0,0.7,1,1);
	
	setNewIcon();
	
});

$(window).load(function(){
	// 
});

/*function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		return false;
	}
}

addEvent(window, 'load', xxxxxx);*/







// DW --------------------------------------------------------------------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}













