// IE ANCHOR BG CACHE

var version = navigator.appVersion;
	version = version.substring(0,1);
var browser = navigator.appName;

if (browser =="Microsoft Internet Explorer"){
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {}
}




// ALPHA PNG IE

/*--------------------------------------------------------------------------*
 *  
 *  alphafilter JavaScript Library beta3
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/

new function(){

	if(window.addEventListener){
		window.addEventListener('load',alphafilter,false);
	}else if(window.attachEvent){
		window.attachEvent('onload',alphafilter);
	}
	
	function alphafilter(){
		if (typeof document.body.style.maxHeight == "undefined") {//for old ie
			var elements = getElementsByClassName("alphafilter");
			for (var i=0; i<elements.length; i++) {
				var element = elements[i];
				if(element.nodeName=="IMG"){
					var newimg  = document.createElement("b");
					newimg.id   = element.id;
					newimg.className     = element.className;
					newimg.style.display = "block";
					newimg.style.width   = element.width;
					newimg.style.height  = element.height;
					newimg.style.float   = element.align;
					newimg.style.filter  = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+element.src+",sizingMethod='scale')";
					element.parentNode.replaceChild(newimg,element);
				}else{
					var anchors = element.getElementsByTagName("a");
					for (var j=0; j<anchors.length; j++) {
						var anchor = anchors[j];
						anchor.style.position="relative";
					}
					var  newimg = element.currentStyle.backgroundImage || element.style.backgroundImage;
					newimg.match(/^url[("']+(.*\.png)[)"']+$/i)
					var newimg = RegExp.$1;
					element.style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+newimg+",sizingMethod='image')";
					element.style.background = "none";
				}
			}
		}
	}
	
	function getElementsByClassName(className){
		var i, j, eltClass;
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		var objCN = new Array();
		for (i = 0; i < objAll.length; i++) {
			eltClass = objAll[i].className.split(/\s+/);
			for (j = 0; j < eltClass.length; j++) {
				if (eltClass[j] == className) {
					objCN.push(objAll[i]);
					break;
				}
			}
		}
		return objCN;
	}
}

//
// BG SLIDE
// 背景画像のスライドショー
function slideSwitch() {
    var $active = $('#slides img.active');

    if ( $active.length == 0 ) $active = $('#slides IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slides img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 4000 );
});


//POP UP PAGES
function openPop(url) {
	pop_window = window.open(url, 'popWin','width=880,height=640,scrollbars=yes,resizable=yes');
	pop_window.focus();
}

//POP UP PAGES
function openRen(url) {
	ren_window = window.open(url, 'popRen','width=800,height=570,scrollbars=yes,resizable=yes');
	ren_window.focus();
}

//POP UP MOBILE
function openMob(url) {
	mob_window = window.open(url, 'mobWin','width=286,height=600,scrollbars=yes,resizable=yes');
	mob_window.focus();
}


