///////////////////////////////////////////////////////////////
//メイン関数
function make_bp(param1, design_type, side_or_under, motion){
	designs = ['left', 'right', 'bottom'];

///////////////////////////////////////////////////////////////
//ボックス部のstyle設定
	var box_style = 'position: fixed;' + side_or_under + ':0px; top:' + motion + 'px; z-index:2147483646; cursor:pointer;';
	var box_style_bottom = 'position: fixed;' + side_or_under + ':0px; left:' + motion + 'px; z-index:2147483646; cursor:pointer;';

///////////////////////////////////////////////////////////////
//ラベル部のstyle設定
	var label_style = 'position: fixed;' + side_or_under + ':0px; top:' + (parseInt(motion) - 20) + 'px; z-index:2147483647; cursor:pointer;';
	var label_style_bottom = 'position: fixed;' + side_or_under + ':0px; left:' + motion + 'px; z-index:2147483647; cursor:pointer;';

///////////////////////////////////////////////////////////////
//各選択肢の配列化

//['left']
	designs['left'] = new Array(
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_001.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_002.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:131px; background:url(http://wafuu4.com/img/bp_003.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:100px; background:url(http://wafuu4.com/img/bp_004.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_005.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_006.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_007.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_008.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_009.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_010.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_011.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_012.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_013.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_014.gif); no-repeat;" ></div>'
	);

//['right']
	designs['right'] = new Array(
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_001.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_002.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:131px; background:url(http://wafuu4.com/img/bp_003.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:100px; background:url(http://wafuu4.com/img/bp_004.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_005.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_006.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_007.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_008.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_009.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_010.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_011.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_012.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_013.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_014.gif); no-repeat;" ></div>'
	);

//['bottom']
	designs['bottom'] = new Array(
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_001.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:141px; background:url(http://wafuu4.com/img/bp_002.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:131px; background:url(http://wafuu4.com/img/bp_003.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:100px; background:url(http://wafuu4.com/img/bp_004.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_005.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_006.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_007.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:139px; background:url(http://wafuu4.com/img/bp_008.jpg); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_009.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:150px; height:104px; background:url(http://wafuu4.com/img/bp_010.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_011.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:70px; background:url(http://wafuu4.com/img/bp_012.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_013.gif); no-repeat;" ></div>',
		'<div id="box_id" style="' + box_style + ' width:100px; height:128px; background:url(http://wafuu4.com/img/bp_014.gif); no-repeat;" ></div>'
	);

///////////////////////////////////////////////////////////////
//ラベル部分
	var label = '<div id="label_id" style="' + label_style + ' width:20px; height:20px; background: url(http://wafuu4.com/img/label.gif); no-repeat;"></div>'
	var label_bottom = '<div id="label_id" style="' + label_style_bottom + ' width:20px; height:20px; background: url(http://wafuu4.com/img/label.gif); no-repeat;"></div>'

///////////////////////////////////////////////////////////////
//HTMLに出力

//新しいdivタグを生成
if (document.getElementById('box_id')){
	document.body.removeChild(document.getElementById('box_id'));
}

if (document.getElementById('label_id')){
	document.body.removeChild(document.getElementById('label_id'));
}

var new_div_box = document.createElement('div');
new_div_box.setAttribute('id', 'box_id');
document.body.appendChild(new_div_box);

var new_div_label = document.createElement('div');
new_div_label.setAttribute('id', 'label_id');
document.body.appendChild(new_div_label);

//divタグに書き出し
if(side_or_under == 'left' || side_or_under == 'right'){
	new_div_box.innerHTML = (designs[side_or_under][design_type]);
	new_div_label.innerHTML = label;
}

//divタグに書き出し(bottom用)
else{
	new_div_box.innerHTML = (designs[side_or_under][design_type]);
	new_div_label.innerHTML = label_bottom;

}

///////////////////////////////////////////////////////////////
//ボックスが読み込まれた時点ではラベルは表示されない
document.getElementById('label_id').style.visibility='hidden';

//ボックスにマウスを乗せるとラベルが表示される
document.getElementById('box_id').onmouseover = function(){
	document.getElementById('label_id').style.visibility='';
	}
document.getElementById('box_id').onmouseout = function(){
	document.getElementById('label_id').style.visibility='hidden';
	}

//ラベルにマウスを乗せ続けている間はラベルを表示し続ける
document.getElementById('label_id').onmouseover = function(){
	document.getElementById('label_id').style.visibility='';
	}

//ラベルからマウスがはずれると非表示
document.getElementById('label_id').onmouseout = function(){
	document.getElementById('label_id').style.visibility='hidden';
	}

//ボックスクリックでwindow.open
//リンク先
document.getElementById('box_id').onclick = function(){
	window.open('http://twitter.com/' + param1);
}

//ラベルクリックでwindow.open
//リンク先
document.getElementById('label_id').onclick = function(){
	window.open('http://wafuu4.com/');
	document.getElementById('label_id').style.visibility='hidden';
	}
}
