function selectService( $value ){
	var value, url;
	if( $value === '' ){}else{
		value = parseInt( $value );
		switch( value ){
			case 0:url = 'http://www.studiofnt.com';break;
			case 1:url = 'works.html';break;
			case 2:url = 'publications.html';break;
			case 3:url = 'font.html';break;
			case 4:url = 'helpjapan.html';break;
		}
		location.href = url;
	}
}
function dw( $str ){ document.write( $str ); }
var CNT = 0, isSelect;
function contentsMake( $type ){
	var temp, over, str ='<table cellpadding="0" cellspacing="0" border="0" class="f01">';
	for( i = 0, j = TITLE.length ; i < j ; i++ ){
		temp = TITLE[i].split( '|' );
		over = parseInt( temp[1] ) === 1?' onMouseOver="newOver( ' + i + ' )" onMouseOut="newOut()"':'';
		str += '<tr><td id="title' + i + '">';
		if( $type === undefined ){
			str += '<a href="javascript:contentsView1(' + i + ')"' + over + '>' + temp[2] + '</a>';
		}else{
			str += '<a href="javascript:contentsView2(' + i + ')"' + over + '>' + temp[2] + '</a>';
		}
		str += '<div id="contents' + i + '" class="f02"></div>'
		str += '</td></tr>';
	}
	str += '</table>';
	dw( str );
}
function contentsView1( $id ){
	var arr, titleObj, contentsObj, i, j, src, str = '';
	isSelect = false;
	arr = TITLE[$id].split( '|' );	
	titleObj = document.getElementById( 'title' + $id );
	contentsObj = document.getElementById( 'contents' + $id );
	if( contentsObj.style.display === 'block' ){
		titleObj.style.backgroundColor = COLOR;
		titleObj.style.fontWeight = 'normal';
		
		contentsObj.innerHTML = '';
		contentsObj.style.display = 'none';
	}else{
		for( i = 0, j = TITLE.length ; i < j ; i++ ){
			if( document.getElementById( 'contents' + i ).style.display === 'block' ){
				document.getElementById( 'title' + i ).style.backgroundColor = COLOR;
			}
			document.getElementById( 'contents' + i ).innerHTML = '';
			document.getElementById( 'contents' + i ).style.display = 'none';
			document.getElementById( 'title' + i ).style.fontWeight = 'normal';
		}
		titleObj.style.backgroundColor = '#FFFFFF';
		titleObj.style.fontWeight = 'bold';
		contentsObj.style.display = 'block';
		src = PATH + arr[4];
		switch( src.substring( src.length - 3 ) ){
		case'jpg':case'JPG':case'GIF':case'gif':
			str += '<img id="data' + $id + '" src="' + src + '">';
			CNT = 1;
			break;
		default:
			str += '<embed id="data' + $id + '" src="' + src + '" width="' + arr[5] + '" height="' + arr[6] + '"></embed>';
			break;
		}
		str += '<div id="btn' + $id + '" class="btn"></div>';
		str += '<div class="photo">' + arr[3] + '</div>';
		contentsObj.innerHTML = str;
		btnMake( $id, 0 );
		selectOn();
	}
}
function btnMake( $id, $cnt ){
	var arr, src, imgObj, len, btnObj, str = '';
	CNT += $cnt;
	
	arr = TITLE[$id].split( '|' );
	src = PATH + arr[CNT + 3];
	
	imgObj = document.getElementById( 'data' + $id );
	imgObj.src = src;
	var loadSrc = function(){
		if( imgObj.complete ){
			imgObj.src = src;			
		}else{
			imgObj.src = 'img/loading.gif';
			setTimeout( arguments.callee, 10 );
		}
	}
	loadSrc();
	
	len = arr.length - 4;
	if( len > 1 ){
		btnObj = document.getElementById( 'btn' + $id );
		btnObj.style.display = 'block';
		if( CNT === 1 ){
			str += 'prev | <a href="javascript:btnMake(' + $id + ', 1)">next</a>';
		}else if( CNT === len ){
			str += '<a href="javascript:btnMake(' + $id + ', -1)">prev</a> | next';
		}else{
			str += '<a href="javascript:btnMake(' + $id + ', -1)">prev</a> | <a href="javascript:btnMake(' + $id + ', 1)">next</a>';
		}
		str += '&nbsp;&nbsp;&nbsp;&nbsp;' + CNT + ' / ' + len + '';
		btnObj.innerHTML = str;		
	}	
}
function contentsView2( $id ){
	var arr, titleObj, contentsObj;
	isSelect = false;
	arr = TITLE[$id].split( '|' );	
	titleObj = document.getElementById( 'title' + $id );
	contentsObj = document.getElementById( 'contents' + $id );
	if( contentsObj.style.display === 'block' ){
		titleObj.style.backgroundColor = COLOR;
		titleObj.style.fontWeight = 'normal';
		
		contentsObj.innerHTML = '';
		contentsObj.style.display = 'none';
	}else{
		var i, j, src, str = '';
		for( i = 0, j = TITLE.length ; i < j ; i++ ){
			if( document.getElementById( 'contents' + i ).style.display === 'block' ){
				document.getElementById( 'title' + i ).style.backgroundColor = COLOR;
			}
			document.getElementById( 'contents' + i ).style.display = 'none';
			document.getElementById( 'contents' + i ).innerHTML = '';
			document.getElementById( 'title' + i ).style.fontWeight = 'normal';
		}
		titleObj.style.backgroundColor = '#FFFFFF';
		titleObj.style.fontWeight = 'bold';
		contentsObj.style.display = 'block';
		src = PATH + arr[3];
		switch( src.substring( src.length - 3 ) ){
		case'jpg':case'JPG':case'GIF':case'gif':
			str += '<img id="data' + $id + '" src="' + src + '">';
			break;
		default:
			str += '<embed id="data' + $id + '" src="' + src + '" width="' + arr[4] + '" height="' + arr[5] + '"></embed>';
			break;
		}
		contentsObj.innerHTML = str;
		selectOn();
	}
}
function selectOn(){
	var i, j;
	for( i = 0, j = TITLE.length ; i < j ; i++ ){
		if( document.getElementById( 'contents' + i ).style.display === 'block' ){
			isSelect = true;
			break;
		}
	}
	newOut();
}
function newOver( $num ){
	if( isSelect ){}else{
		var num, obj, w, h, rand = Math.random();
		if( rand < 0.25 ){
			num = 1;
		}else if( rand < 0.5 ){
			num = 2;
		}else if( rand < 0.75 ){
			num = 3;
		}else{
			num = 4;
		}
		// top : (0 ~ 44) * ( ¼¿³ôÀÌ * num + 1 ) + (82-55)
		h = parseInt( ( rand * 44 ) ) + ( 22 * ( $num + 1 ) );
		// left : -(270 ~ 220), 340 ~ 390
		if( num % 2 === 1 ){
			//È¦¼ö
			w = -parseInt( rand * 50 + 220 );
		}else{
			w = parseInt( rand * 50 + 340 );
		}
		
		obj = document.getElementById( 'new' );
		obj.src = 'img/new_' + num + '.png';
		obj.style.top = h;
		obj.style.left = w;
		document.getElementById( 'newBox' ).style.display = 'block';
	}
}
function newOut(){ document.getElementById( 'newBox' ).style.display = 'none'; }

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9224595-2']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
