
var sGpotatoUrl = "http://gpotato.jp";
var sImageUrl = "http://image.gpotato.jp";
var sRappelzUrl = "http://rappelz.gpotato.jp";
var sHeroUrl = "http://hero.gpotato.jp";
var sSecureUrl = "https://secure.gpotato.jp";
var sBillUrl = "http://bill.gpotato.jp";
	
var domain = location.hostname;

if (domain.indexOf("test")!= -1){
	sGpotatoUrl = "http://test.gpotato.jp";
	sImageUrl = "http://test.image.gpotato.jp";
	sRappelzUrl = "http://test.rappelz.gpotato.jp";
	sHeroUrl = "http://test.hero.gpotato.jp";
	sSecureUrl = "https://test.secure.gpotato.jp";
	sBillUrl = "http://test.bill.gpotato.jp";
}

$(function(){

	var sTopicsUrl = sGpotatoUrl + "/topics.txt";
	
	$.get(sTopicsUrl,  function(data){
		var topics = [];
		var lines = data.split(/[\r]?\n/g);
		for (var i=0, len=lines.length; i<len; i++) {
			if (lines[i] != '') topics.push(lines[i]);
		}
		$('p.topics2:first').slideNews({
			items: topics,
			next: 'p.topics1>a',
			prev: 'p.topics3>a'
		});
	});


	
	var num = 0;
	var url = location.href;
	var dir = url.split('&')[1];
	if (dir == 'game') {
		num = 1;
	} else if (dir == 'ItemMall') {
		num = 2
	} else if (dir == 'News') {
		num = 3
	} else if (dir == 'help') {
		num = 4
	} else  {
		num = 0
	}
	$('#header').flash({
		// test.swf is the flash document
			swf: sImageUrl + '/gpotato/common/header.swf',
			width: '900',
			height: '68',
			params: {
				allowScriptAccess: 'always',
				flashvars: {
					loca: num
				}
			}
	});

	$('#header2').flash({
		// test.swf is the flash document
			swf: sImageUrl + '/gpotato/common/header2.swf',
			width: '900',
			height: '68',
			params: {
				allowScriptAccess: 'always',
				flashvars: {
					loca: num
				}
			}
	});
});

$(function(){
	$('#rotation').flash({
		swf: sImageUrl + '/gpotato/top/rotationItems.swf',
		width: 503,
		height: 306,
		params: {
			allowScriptAccess: 'always',
			wmode: 'transparent',
			flashvars: {
				'images': sImageUrl + '/gpotato/top/gametitle01.png;'+sImageUrl + '/gpotato/top/gametitle02.png;'+sImageUrl + '/gpotato/top/gametitle03.png;'+sImageUrl + '/gpotato/top/gametitle04.png',
				'links':'http://flyff.gpotato.jp/' + ';http://iris.gpotato.jp/' + ';http://hero.gpotato.jp/' + ';http://rappelz.gpotato.jp/'
			},
			salign : 't'
			
		}
	});
});

$(function(){
	$('#event_top').flash({
			swf: sImageUrl + '/gpotato/common/event01.swf',
			width: '187',
			height: '169',
			params: {
				allowScriptAccess: 'always',
				wmode: 'transparent'
			}
	});
});

$(function(){
	$('#event_left').flash({
			swf: sImageUrl + '/gpotato/common/event02.swf',
			width: '200',
			height: '169',
			params: {
				allowScriptAccess: 'always',
				wmode: 'transparent'
			}
	});
});

$(function(){
	$('#game_top').flash({
			swf: sImageUrl + '/gpotato/game/gametop.swf',
			width: '454',
			height: '202',
			params: {
				allowScriptAccess: 'always',
				wmode: 'transparent'
			}
	});
});

$(function(){
	$('#game_top_right').flash({
			swf: 'Untitled-1.swf',
			width: '197',
			height: '190',
			params: {
				allowScriptAccess: 'always',
				wmode: 'transparent'
			}
	});
});
