﻿/*
▼bingoya-building.com　サイト全体のjavaScript
*/



/*�　　ロールオーバー　　*/

function initRollOvers() {
	if (!document.getElementById){
		return;
	}
	
	var preLoads = new Array();
	var allImages = document.getElementsByTagName('img');

	for (var i = 0; i < allImages.length; i++) {		
		if (allImages[i].className == 'rollover') {
			var src = allImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var oSrc = src.replace(ftype, '_on'+ftype);

			//-- スワップ元、スワップ先画像の登録
			allImages[i].setAttribute('pSrc', src);
			allImages[i].setAttribute('oSrc', oSrc);

			//-- イメージのプリロード
			preLoads[i] = new Image();
			preLoads[i].src = oSrc;

			//-- イベントの設定
			allImages[i].onmouseover = function() {
				this.setAttribute('src', this.getAttribute('oSrc'));
			}
			allImages[i].onmouseout = function() {
				this.setAttribute('src', this.getAttribute('pSrc'));
			}
		}
	}
}

function addOnload(func){
	if ( typeof window.addEventListener != "undefined" ){
		window.addEventListener( "load", func, false );
	}else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", func );
	}else{
		if ( window.onload != null ){
			var oldOnload = window.onload;
			window.onload = function ( e ) {
			oldOnload( e );
			window[func]();
		};
	}else
		window.onload = func;
	}
}
addOnload(initRollOvers);





/* 　ブックマーク　 */

function bookmarkYahoo(){
window.open('http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t='+encodeURIComponent(document.title)+'&u='+encodeURIComponent(window.location.href)+'&opener=bm&ei=UTF-8','popup','width=550px,height=480px,status=1,location=0,resizable=1,scrollbars=0,left=100,top=50',0);
}
function bookmarkDel(){
url='http://atricot.jp/';
title='ニット＆羊　atricot.jp';
newWin=window.open();
newWin.location.href='http://del.icio.us/post?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title);
}
function bookmarkFC2(){
location.href='http://bookmark.fc2.com/user/post?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
}
function bookmarkNewsing(){
window.location='http://newsing.jp/nbutton?title='+encodeURIComponent('ニット＆羊　atricot.jp')+'&url='+encodeURIComponent('http://atricot.jp');
}

function bookmark(){
document.write('<ol> \n');
document.write('<!-- Yahoo --> \n');
document.write('<li><a href="javascript:bookmarkYahoo()"><img src="http://i.yimg.jp/images/sicons/ybm16.gif" width="16" height="16" alt="" /></a></li> \n');
document.write('<!-- google --> \n');
document.write('<li><a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http://atricot.jp/&title=ニット＆羊　atricot.jp" target="_blank"><img alt="" src="http://www.google.co.jp/favicon.ico" border="0" width="16" height="16" /></a></li> \n');
document.write('<!-- はてな --> \n');
document.write('<li><a href="http://b.hatena.ne.jp/append?http://atricot.jp/" target="_blank"><img src="http://b.hatena.ne.jp/images/append.gif" alt="" width="16" height="12" border="0" /></a></li> \n');
document.write('<!-- del.icio.us --> \n');
document.write('<li><a href="javascript:bookmarkDel()"><img src="http://del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="" /></a></li> \n');
document.write('<!-- ニフティクリップ --> \n');
document.write('<li><a href="http://clip.nifty.com/create?url=http://atricot.jp&title=ニット＆羊　atricot.jp" rel="nofollow"><img src="http://clip.nifty.com/images/addclip_icn.gif" alt="" width="12" height="12" border="0" /></a></li> \n');
document.write('<!-- Livedoorクリップ --> \n');
document.write('<li><a href="http://clip.livedoor.com/clip/add?link=window.self.location.href&title=document.title&jump=myclip" target="_blank"><img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_16_b.gif" width="16" height="16" alt="" /></a></li> \n');
document.write('<!-- Buzzurl --> \n');
document.write('<li><a href="http://buzzurl.jp/entry/http://atricot.jp/" target="_blank"><img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_08.gif" alt="" style="border:0"></a></li> \n');
document.write('</ol> \n');
}







/* 　透過PNGをIE6で表示　 */


var clear="../img/unitpngfix/clear.gif"

pngfix=function(){var els=document.getElementsByTagName('*');var ip=/\.png/i;var i=els.length;while(i-- >0){var el=els[i];var es=el.style;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";el.src=clear;}else{var elb=el.currentStyle.backgroundImage;if(elb.match(ip)){var path=elb.split('"');var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';var elkids=el.getElementsByTagName('*');if (elkids){var j=elkids.length;if(el.currentStyle.position!="absolute")es.position='static';while (j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}}
window.attachEvent('onload',pngfix);
