/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_ov'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ov'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//------------------------
//for IE error
var curvyCornersVerbose = false;



function viewTop(){
    var flashvars = null;
	var params = null;
	var attributes = null;
	swfobject.embedSWF("/preloader.swf", "swfarea", "100%", "324", "9","expressInstall.swf", flashvars, params, attributes);
}

function viewTop2(){

	var pause = 8000; // define the pause for each tip (in milliseconds) 
	var length = jQuery("#topvisual .vis").length; 
	//var temp = -1;

	this.getRan = function(){
		// get the random number
		var ran = Math.floor(Math.random()*length) + 1;
		return ran;
	};

	var temp = getRan();

	this.show = function(){
		//alert(temp+'////'+getRan()+'---'+length);
		/*var ran = getRan();
		// to avoid repeating
		while (ran == temp){
			ran = getRan();
		};
		temp = ran; */
		var ran = temp+1;
		if (ran > length){
			ran = ran % length;
		};
		temp = ran;
		
		jQuery("#topvisual .vis").hide();	
		jQuery("#topvisual .vis:nth-child(" + ran + ")").fadeIn("slow");
		jQuery("#topvisual .ldim").hide();
	};
	
	show(); setInterval(show,pause);
	
}

function fozInit(){
	initRollovers();
	jQuery('#topvisual img.vis').hide();
	jQuery(".sscrl a").click(function(){
		jQuery("html, body").animate({
			scrollTop:jQuery(jQuery(this).attr("href")).offset().top
		}, 'slow', 'swing');
		return false;
	});
    jQuery(".contx").click(function(){
         window.location=jQuery(this).find("a").attr("href");
         return false;
    });
	jQuery("ul.entry-list > li").click(function(){
        window.location=jQuery(this).find("a").attr("href");
        return false;
    });
    jQuery("ul.entry-list > li").mouseover(function(){
        jQuery(this).css("background-color", "#ebf1d1");
        jQuery(this).css("cursor", "hand");
        jQuery(this).css("cursor", "pointer");
        return false;
    });
    jQuery("ul.entry-list > li").mouseout(function(){
        jQuery(this).css("background-color", "");
        return false;
    });
    jQuery("ul.related_post > li").click(function(){
        window.location=jQuery(this).find("a").attr("href");
        return false;
    });
    jQuery("ul.related_post > li").mouseover(function(){
        jQuery(this).css("background-color", "#f5f5f5");
        jQuery(this).css("cursor", "hand");
        jQuery(this).css("cursor", "pointer");
        return false;
    });
    jQuery("ul.related_post > li").mouseout(function(){
        jQuery(this).css("background-color", "");
        return false;
    });
    jQuery("#banner-iwinfo").click(function(){
        window.location=jQuery(this).find("a").attr("href");
        return false;
    });
    jQuery("#banner-iwinfo").mouseover(function(){
        jQuery(this).css("background-image", "url(/wp-content/themes/foz2010/images/2011/iw_info_ov.jpg)");
        jQuery(this).css("cursor", "hand");
        jQuery(this).css("cursor", "pointer");
        return false;
    });
    jQuery("#banner-iwinfo").mouseout(function(){
        jQuery(this).css("background-image", "url(/wp-content/themes/foz2010/images/2011/iw_info.jpg)");
        return false;
    });
    //if(jQuery("#tagcloud").length){
		//jquery版背景など微妙
		/*jQuery("#tagcloud").corner({
			tl: { radius: 20 },
			tr: { radius: 20 },
			bl: { radius: 20 },
			br: { radius: 20 },
			antiAlias: true,
			autoPad: true,
			validTags: ["div", "li"]
		});*/
		//↓追加
		//var curvyCornersNoAutoScan = true;
		//↓要素ない場合エラーでるので
		//curvyCorners.init();
		////var settings = {
		////tl: { radius: 6 },
		////tr: { radius: 6 },
		////bl: { radius: 6 },
		////br: { radius: 6 },
		////antiAlias: true
		////}
		////curvyCorners(settings, "#tagcloud");
	////}
	/*var settings6 = {
		tl: { radius: 6 },
		tr: { radius: 6 },
		bl: { radius: 6 },
		br: { radius: 6 },
		antiAlias: true
		}
	if(jQuery(".subcat").length){
		curvyCorners(settings6, ".subcat");
	}
	if(jQuery(".entry .prm").length){
		curvyCorners(settings6, ".prm");
	}*/
	
		//jquery.corner
	if (!(jQuery.support.borderRadius)) {
		//IE
		jQuery("#tagcloud").corner("6px");
		jQuery(".subcat").corner("6px");
		jQuery(".entry .prm").corner("6px");
		jQuery(".pnavi .current").corner("6px");
		jQuery(".pnavi a.page-numbers").corner("6px");
	}
}

