// Delete Error Message
function HideError(){
	return true;
}
window.onerror = HideError;

// OS Browser Info
var mac = (navigator.userAgent.indexOf('Mac') != -1 || navigator.userAgent.indexOf('mac') != -1);
var win = (navigator.userAgent.indexOf('Win') != -1 || navigator.userAgent.indexOf('win') != -1);

var an = navigator.appName;
var ua = navigator.userAgent;
var netscape = (an=="Netscape");
var opr = (ua.indexOf("Opera")!=-1);
var gecko = (ua.indexOf("Gecko")!=-1);
var n6 = (ua.indexOf("Netscape6")!=-1);
var n7 = (ua.indexOf("Netscape7")!=-1);
var ie = (an=="Microsoft Internet Explorer");
var saf = (ua.indexOf("Safari")!=-1);

// Select StyleSheet

csstype = GetCookie('CSSTYPE');
if ( csstype == null )
{
	csstype = 'm';
}

ostype = 'win';
if ( saf )
{
	ostype = 'saf';
}
else if ( mac )
{
	ostype = 'mac';
}

if ( mac )
{
	document.write('<link rel="stylesheet" href="/css/font' + csstype + '.css" type="text/css">');
}
else
{
	if ( win && netscape )
	{
		document.write('<link rel="stylesheet" href="/css/font' + csstype + '.css" type="text/css">');
	}
	else
	{
		AddLink('stylel', '/css/fontl.css');
		AddLink('stylem', '/css/fontm.css');
		AddLink('styles', '/css/fonts.css');
		if( gecko )
		{
			document.write('<META http-equiv="Default-Style" content="style' + csstype + '">');
		}
		else
		{
			SLIST = document.styleSheets;
			for ( i = 0; i < SLIST.length; i++)
			{
				if (SLIST[i].title) {
					SLIST[i].disabled = (SLIST[i].title != 'style' + csstype);
				} else {
					SLIST[i].disabled = false;
				}
			}
		}
	}
}

// Get Object
function GetObj(n, d) {
	var p,i,x;
	if(!d) d = document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x = d.all[n];
	for(i=0; !x&&i<d.forms.length; i++) x = d.forms[i][n];
	for(i=0; !x&&d.layers&&i<d.layers.length; i++) x = GetObj(n,d.layers[i].document);
	if(!x && document.getElementById) x = document.getElementById(n);
	return x;
}

// Get Cookie
function GetCookie(NAME)
{
	str = NAME + '=';
	val = null;
	c = document.cookie + ';';
	p = c.indexOf(str);
	if (p != -1)
	{
		p_st = p + str.length;
		p_ed = c.indexOf(';', p_st);
		val = unescape(c.substring(p_st, p_ed));
	}
	return val;
}


// Set Cookie
function SetCookie(NAME, VALUE, EXP, PATH, DOMAIN)
{
	c = NAME + '=' + escape(VALUE) + ';';
	if ( EXP > 0 )
	{
		dt = new Date();
		dt.setTime(dt.getTime()+(EXP * 1000));
		c = c + ' expires=' + dt.toGMTString() + ';';
	}
	if ( PATH != '' )
	{
		c = c + ' path=' + PATH + ';';
	}
	if ( DOMAIN != '' )
	{
		c = c + ' domain=' + DOMAIN + ';';
	}
	document.cookie = c;
}

// Set CSS
function SetStyleSheet(TYPE)
{
	csstype = TYPE;
	SetCookie('CSSTYPE', csstype, 30*24*60*60, '/', '');

	if ( mac )
	{
		window.location.reload();
	}
	else
	{
		if ( win && netscape )
		{
			window.location.reload();
		}
		else
		{
			if ( !document.styleSheets ) return;

			for ( i = 0; i < SLIST.length; i++)
			{
				if (SLIST[i].title) {
					SLIST[i].disabled = (SLIST[i].title != 'style' + csstype);
				}
			}
		}
	}
}

function AddLink(TITLE, URL)
{
	if ( document.all )
	{
		var nLink = document.createStyleSheet(URL);
		nLink.title = TITLE;
		nLink.disabled = true;
	}
	else if ( document.styleSheets )
	{
		var nLink = document.createElement('LINK');
		nLink.rel = 'alternate stylesheet';
		nLink.type = 'text/css';
		nLink.href = URL;
		nLink.title = TITLE;
		var oHEAD = document.getElementsByTagName('HEAD').item(0);
		oHEAD.appendChild(nLink);
	}
}

function SSINIT()
{
	if ( gecko )
	{
		SLIST = document.styleSheets;
		SetStyleSheet(csstype);
		importScript();
	}
}

function copyright(){
	var _year = new Date();
	myYear = _year.getFullYear();
	document.write('&copy;'+myYear+'&nbsp;KONAMI');
}

function bgChange(){
	var linkArr = ["a.map0","a.map1","a.map2","a.map3","a.map4"];
	$(function(){
		$("a.map0").hover(
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_am_en.gif)");
			},
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_df_en.gif)");
			}
		)
		$("a.map1").hover(
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_eu_en.gif)");
			},
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_df_en.gif)");
			}
		)
		$("a.map2").hover(
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_as_en.gif)");
			},
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_df_en.gif)");
			}
		)
		$("a.map3").hover(
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_jp_en.gif)");
			},
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_df_en.gif)");
			}
		)
		$("a.map4").hover(
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_oc_en.gif)");
			},
			function(){
				$("dt#world_map").css("background","url(../new_img/en/bg_products_df_en.gif)");
			}
		)
	});
}

function initRollOverImages() {
	var image_cache = new Object();
	$(".rollover a img").not("[src*='_on.']").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; }
		);
	});
}
$(document).ready(initRollOverImages);


// E N D
