/*!
 * Sizzle CSS Selector Engine
 *  Copyright 2011, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
	done = 0,
	toString = Object.prototype.toString,
	hasDuplicate = false,
	baseHasDuplicate = true,
	rBackslash = /\\/g,
	rNonWord = /\W/;

// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
// function. If that is the case, discard the hasDuplicate value.
//   Thus far that includes Google Chrome.
[0, 0].sort(function() {
	baseHasDuplicate = false;
	return 0;
});

var Sizzle = function( selector, context, results, seed ) {
	results = results || [];
	context = context || document;

	var origContext = context;

	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
		return [];
	}
	
	if ( !selector || typeof selector !== "string" ) {
		return results;
	}

	var m, set, checkSet, extra, ret, cur, pop, i,
		prune = true,
		contextXML = Sizzle.isXML( context ),
		parts = [],
		soFar = selector;
	
	// Reset the position of the chunker regexp (start from head)
	do {
		chunker.exec( "" );
		m = chunker.exec( soFar );

		if ( m ) {
			soFar = m[3];
		
			parts.push( m[1] );
		
			if ( m[2] ) {
				extra = m[3];
				break;
			}
		}
	} while ( m );

	if ( parts.length > 1 && origPOS.exec( selector ) ) {

		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
			set = posProcess( parts[0] + parts[1], context );

		} else {
			set = Expr.relative[ parts[0] ] ?
				[ context ] :
				Sizzle( parts.shift(), context );

			while ( parts.length ) {
				selector = parts.shift();

				if ( Expr.relative[ selector ] ) {
					selector += parts.shift();
				}
				
				set = posProcess( selector, set );
			}
		}

	} else {
		// Take a shortcut and set the context if the root selector is an ID
		// (but not if it'll be faster if the inner selector is an ID)
		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {

			ret = Sizzle.find( parts.shift(), context, contextXML );
			context = ret.expr ?
				Sizzle.filter( ret.expr, ret.set )[0] :
				ret.set[0];
		}

		if ( context ) {
			ret = seed ?
				{ expr: parts.pop(), set: makeArray(seed) } :
				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );

			set = ret.expr ?
				Sizzle.filter( ret.expr, ret.set ) :
				ret.set;

			if ( parts.length > 0 ) {
				checkSet = makeArray( set );

			} else {
				prune = false;
			}

			while ( parts.length ) {
				cur = parts.pop();
				pop = cur;

				if ( !Expr.relative[ cur ] ) {
					cur = "";
				} else {
					pop = parts.pop();
				}

				if ( pop == null ) {
					pop = context;
				}

				Expr.relative[ cur ]( checkSet, pop, contextXML );
			}

		} else {
			checkSet = parts = [];
		}
	}

	if ( !checkSet ) {
		checkSet = set;
	}

	if ( !checkSet ) {
		Sizzle.error( cur || selector );
	}

	if ( toString.call(checkSet) === "[object Array]" ) {
		if ( !prune ) {
			results.push.apply( results, checkSet );

		} else if ( context && context.nodeType === 1 ) {
			for ( i = 0; checkSet[i] != null; i++ ) {
				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
					results.push( set[i] );
				}
			}

		} else {
			for ( i = 0; checkSet[i] != null; i++ ) {
				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
					results.push( set[i] );
				}
			}
		}

	} else {
		makeArray( checkSet, results );
	}

	if ( extra ) {
		Sizzle( extra, origContext, results, seed );
		Sizzle.uniqueSort( results );
	}

	return results;
};

Sizzle.uniqueSort = function( results ) {
	if ( sortOrder ) {
		hasDuplicate = baseHasDuplicate;
		results.sort( sortOrder );

		if ( hasDuplicate ) {
			for ( var i = 1; i < results.length; i++ ) {
				if ( results[i] === results[ i - 1 ] ) {
					results.splice( i--, 1 );
				}
			}
		}
	}

	return results;
};

Sizzle.matches = function( expr, set ) {
	return Sizzle( expr, null, null, set );
};

Sizzle.matchesSelector = function( node, expr ) {
	return Sizzle( expr, null, null, [node] ).length > 0;
};

Sizzle.find = function( expr, context, isXML ) {
	var set;

	if ( !expr ) {
		return [];
	}

	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
		var match,
			type = Expr.order[i];
		
		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
			var left = match[1];
			match.splice( 1, 1 );

			if ( left.substr( left.length - 1 ) !== "\\" ) {
				match[1] = (match[1] || "").replace( rBackslash, "" );
				set = Expr.find[ type ]( match, context, isXML );

				if ( set != null ) {
					expr = expr.replace( Expr.match[ type ], "" );
					break;
				}
			}
		}
	}

	if ( !set ) {
		set = typeof context.getElementsByTagName !== "undefined" ?
			context.getElementsByTagName( "*" ) :
			[];
	}

	return { set: set, expr: expr };
};

Sizzle.filter = function( expr, set, inplace, not ) {
	var match, anyFound,
		old = expr,
		result = [],
		curLoop = set,
		isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );

	while ( expr && set.length ) {
		for ( var type in Expr.filter ) {
			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
				var found, item,
					filter = Expr.filter[ type ],
					left = match[1];

				anyFound = false;

				match.splice(1,1);

				if ( left.substr( left.length - 1 ) === "\\" ) {
					continue;
				}

				if ( curLoop === result ) {
					result = [];
				}

				if ( Expr.preFilter[ type ] ) {
					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );

					if ( !match ) {
						anyFound = found = true;

					} else if ( match === true ) {
						continue;
					}
				}

				if ( match ) {
					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
						if ( item ) {
							found = filter( item, match, i, curLoop );
							var pass = not ^ !!found;

							if ( inplace && found != null ) {
								if ( pass ) {
									anyFound = true;

								} else {
									curLoop[i] = false;
								}

							} else if ( pass ) {
								result.push( item );
								anyFound = true;
							}
						}
					}
				}

				if ( found !== undefined ) {
					if ( !inplace ) {
						curLoop = result;
					}

					expr = expr.replace( Expr.match[ type ], "" );

					if ( !anyFound ) {
						return [];
					}

					break;
				}
			}
		}

		// Improper expression
		if ( expr === old ) {
			if ( anyFound == null ) {
				Sizzle.error( expr );

			} else {
				break;
			}
		}

		old = expr;
	}

	return curLoop;
};

Sizzle.error = function( msg ) {
	throw "Syntax error, unrecognized expression: " + msg;
};

var Expr = Sizzle.selectors = {
	order: [ "ID", "NAME", "TAG" ],

	match: {
		ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
		CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
		TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
		CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
		PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
	},

	leftMatch: {},

	attrMap: {
		"class": "className",
		"for": "htmlFor"
	},

	attrHandle: {
		href: function( elem ) {
			return elem.getAttribute( "href" );
		},
		type: function( elem ) {
			return elem.getAttribute( "type" );
		}
	},

	relative: {
		"+": function(checkSet, part){
			var isPartStr = typeof part === "string",
				isTag = isPartStr && !rNonWord.test( part ),
				isPartStrNotTag = isPartStr && !isTag;

			if ( isTag ) {
				part = part.toLowerCase();
			}

			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
				if ( (elem = checkSet[i]) ) {
					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}

					checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
						elem || false :
						elem === part;
				}
			}

			if ( isPartStrNotTag ) {
				Sizzle.filter( part, checkSet, true );
			}
		},

		">": function( checkSet, part ) {
			var elem,
				isPartStr = typeof part === "string",
				i = 0,
				l = checkSet.length;

			if ( isPartStr && !rNonWord.test( part ) ) {
				part = part.toLowerCase();

				for ( ; i < l; i++ ) {
					elem = checkSet[i];

					if ( elem ) {
						var parent = elem.parentNode;
						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
					}
				}

			} else {
				for ( ; i < l; i++ ) {
					elem = checkSet[i];

					if ( elem ) {
						checkSet[i] = isPartStr ?
							elem.parentNode :
							elem.parentNode === part;
					}
				}

				if ( isPartStr ) {
					Sizzle.filter( part, checkSet, true );
				}
			}
		},

		"": function(checkSet, part, isXML){
			var nodeCheck,
				doneName = done++,
				checkFn = dirCheck;

			if ( typeof part === "string" && !rNonWord.test( part ) ) {
				part = part.toLowerCase();
				nodeCheck = part;
				checkFn = dirNodeCheck;
			}

			checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
		},

		"~": function( checkSet, part, isXML ) {
			var nodeCheck,
				doneName = done++,
				checkFn = dirCheck;

			if ( typeof part === "string" && !rNonWord.test( part ) ) {
				part = part.toLowerCase();
				nodeCheck = part;
				checkFn = dirNodeCheck;
			}

			checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
		}
	},

	find: {
		ID: function( match, context, isXML ) {
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
				var m = context.getElementById(match[1]);
				// Check parentNode to catch when Blackberry 4.6 returns
				// nodes that are no longer in the document #6963
				return m && m.parentNode ? [m] : [];
			}
		},

		NAME: function( match, context ) {
			if ( typeof context.getElementsByName !== "undefined" ) {
				var ret = [],
					results = context.getElementsByName( match[1] );

				for ( var i = 0, l = results.length; i < l; i++ ) {
					if ( results[i].getAttribute("name") === match[1] ) {
						ret.push( results[i] );
					}
				}

				return ret.length === 0 ? null : ret;
			}
		},

		TAG: function( match, context ) {
			if ( typeof context.getElementsByTagName !== "undefined" ) {
				return context.getElementsByTagName( match[1] );
			}
		}
	},
	preFilter: {
		CLASS: function( match, curLoop, inplace, result, not, isXML ) {
			match = " " + match[1].replace( rBackslash, "" ) + " ";

			if ( isXML ) {
				return match;
			}

			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
				if ( elem ) {
					if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
						if ( !inplace ) {
							result.push( elem );
						}

					} else if ( inplace ) {
						curLoop[i] = false;
					}
				}
			}

			return false;
		},

		ID: function( match ) {
			return match[1].replace( rBackslash, "" );
		},

		TAG: function( match, curLoop ) {
			return match[1].replace( rBackslash, "" ).toLowerCase();
		},

		CHILD: function( match ) {
			if ( match[1] === "nth" ) {
				if ( !match[2] ) {
					Sizzle.error( match[0] );
				}

				match[2] = match[2].replace(/^\+|\s*/g, '');

				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
				var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
					match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);

				// calculate the numbers (first)n+(last) including if they are negative
				match[2] = (test[1] + (test[2] || 1)) - 0;
				match[3] = test[3] - 0;
			}
			else if ( match[2] ) {
				Sizzle.error( match[0] );
			}

			// TODO: Move to normal caching system
			match[0] = done++;

			return match;
		},

		ATTR: function( match, curLoop, inplace, result, not, isXML ) {
			var name = match[1] = match[1].replace( rBackslash, "" );
			
			if ( !isXML && Expr.attrMap[name] ) {
				match[1] = Expr.attrMap[name];
			}

			// Handle if an un-quoted value was used
			match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );

			if ( match[2] === "~=" ) {
				match[4] = " " + match[4] + " ";
			}

			return match;
		},

		PSEUDO: function( match, curLoop, inplace, result, not ) {
			if ( match[1] === "not" ) {
				// If we're dealing with a complex expression, or a simple one
				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
					match[3] = Sizzle(match[3], null, null, curLoop);

				} else {
					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);

					if ( !inplace ) {
						result.push.apply( result, ret );
					}

					return false;
				}

			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
				return true;
			}
			
			return match;
		},

		POS: function( match ) {
			match.unshift( true );

			return match;
		}
	},
	
	filters: {
		enabled: function( elem ) {
			return elem.disabled === false && elem.type !== "hidden";
		},

		disabled: function( elem ) {
			return elem.disabled === true;
		},

		checked: function( elem ) {
			return elem.checked === true;
		},
		
		selected: function( elem ) {
			// Accessing this property makes selected-by-default
			// options in Safari work properly
			if ( elem.parentNode ) {
				elem.parentNode.selectedIndex;
			}
			
			return elem.selected === true;
		},

		parent: function( elem ) {
			return !!elem.firstChild;
		},

		empty: function( elem ) {
			return !elem.firstChild;
		},

		has: function( elem, i, match ) {
			return !!Sizzle( match[3], elem ).length;
		},

		header: function( elem ) {
			return (/h\d/i).test( elem.nodeName );
		},

		text: function( elem ) {
			var attr = elem.getAttribute( "type" ), type = elem.type;
			// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 
			// use getAttribute instead to test this case
			return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
		},

		radio: function( elem ) {
			return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
		},

		checkbox: function( elem ) {
			return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
		},

		file: function( elem ) {
			return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
		},

		password: function( elem ) {
			return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
		},

		submit: function( elem ) {
			var name = elem.nodeName.toLowerCase();
			return (name === "input" || name === "button") && "submit" === elem.type;
		},

		image: function( elem ) {
			return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
		},

		reset: function( elem ) {
			var name = elem.nodeName.toLowerCase();
			return (name === "input" || name === "button") && "reset" === elem.type;
		},

		button: function( elem ) {
			var name = elem.nodeName.toLowerCase();
			return name === "input" && "button" === elem.type || name === "button";
		},

		input: function( elem ) {
			return (/input|select|textarea|button/i).test( elem.nodeName );
		},

		focus: function( elem ) {
			return elem === elem.ownerDocument.activeElement;
		}
	},
	setFilters: {
		first: function( elem, i ) {
			return i === 0;
		},

		last: function( elem, i, match, array ) {
			return i === array.length - 1;
		},

		even: function( elem, i ) {
			return i % 2 === 0;
		},

		odd: function( elem, i ) {
			return i % 2 === 1;
		},

		lt: function( elem, i, match ) {
			return i < match[3] - 0;
		},

		gt: function( elem, i, match ) {
			return i > match[3] - 0;
		},

		nth: function( elem, i, match ) {
			return match[3] - 0 === i;
		},

		eq: function( elem, i, match ) {
			return match[3] - 0 === i;
		}
	},
	filter: {
		PSEUDO: function( elem, match, i, array ) {
			var name = match[1],
				filter = Expr.filters[ name ];

			if ( filter ) {
				return filter( elem, i, match, array );

			} else if ( name === "contains" ) {
				return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;

			} else if ( name === "not" ) {
				var not = match[3];

				for ( var j = 0, l = not.length; j < l; j++ ) {
					if ( not[j] === elem ) {
						return false;
					}
				}

				return true;

			} else {
				Sizzle.error( name );
			}
		},

		CHILD: function( elem, match ) {
			var type = match[1],
				node = elem;

			switch ( type ) {
				case "only":
				case "first":
					while ( (node = node.previousSibling) )	 {
						if ( node.nodeType === 1 ) { 
							return false; 
						}
					}

					if ( type === "first" ) { 
						return true; 
					}

					node = elem;

				case "last":
					while ( (node = node.nextSibling) )	 {
						if ( node.nodeType === 1 ) { 
							return false; 
						}
					}

					return true;

				case "nth":
					var first = match[2],
						last = match[3];

					if ( first === 1 && last === 0 ) {
						return true;
					}
					
					var doneName = match[0],
						parent = elem.parentNode;
	
					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
						var count = 0;
						
						for ( node = parent.firstChild; node; node = node.nextSibling ) {
							if ( node.nodeType === 1 ) {
								node.nodeIndex = ++count;
							}
						} 

						parent.sizcache = doneName;
					}
					
					var diff = elem.nodeIndex - last;

					if ( first === 0 ) {
						return diff === 0;

					} else {
						return ( diff % first === 0 && diff / first >= 0 );
					}
			}
		},

		ID: function( elem, match ) {
			return elem.nodeType === 1 && elem.getAttribute("id") === match;
		},

		TAG: function( elem, match ) {
			return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
		},
		
		CLASS: function( elem, match ) {
			return (" " + (elem.className || elem.getAttribute("class")) + " ")
				.indexOf( match ) > -1;
		},

		ATTR: function( elem, match ) {
			var name = match[1],
				result = Expr.attrHandle[ name ] ?
					Expr.attrHandle[ name ]( elem ) :
					elem[ name ] != null ?
						elem[ name ] :
						elem.getAttribute( name ),
				value = result + "",
				type = match[2],
				check = match[4];

			return result == null ?
				type === "!=" :
				type === "=" ?
				value === check :
				type === "*=" ?
				value.indexOf(check) >= 0 :
				type === "~=" ?
				(" " + value + " ").indexOf(check) >= 0 :
				!check ?
				value && result !== false :
				type === "!=" ?
				value !== check :
				type === "^=" ?
				value.indexOf(check) === 0 :
				type === "$=" ?
				value.substr(value.length - check.length) === check :
				type === "|=" ?
				value === check || value.substr(0, check.length + 1) === check + "-" :
				false;
		},

		POS: function( elem, match, i, array ) {
			var name = match[2],
				filter = Expr.setFilters[ name ];

			if ( filter ) {
				return filter( elem, i, match, array );
			}
		}
	}
};

var origPOS = Expr.match.POS,
	fescape = function(all, num){
		return "\\" + (num - 0 + 1);
	};

for ( var type in Expr.match ) {
	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}

var makeArray = function( array, results ) {
	array = Array.prototype.slice.call( array, 0 );

	if ( results ) {
		results.push.apply( results, array );
		return results;
	}
	
	return array;
};

// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
// Also verifies that the returned array holds DOM nodes
// (which is not the case in the Blackberry browser)
try {
	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;

// Provide a fallback method if it does not work
} catch( e ) {
	makeArray = function( array, results ) {
		var i = 0,
			ret = results || [];

		if ( toString.call(array) === "[object Array]" ) {
			Array.prototype.push.apply( ret, array );

		} else {
			if ( typeof array.length === "number" ) {
				for ( var l = array.length; i < l; i++ ) {
					ret.push( array[i] );
				}

			} else {
				for ( ; array[i]; i++ ) {
					ret.push( array[i] );
				}
			}
		}

		return ret;
	};
}

var sortOrder, siblingCheck;

if ( document.documentElement.compareDocumentPosition ) {
	sortOrder = function( a, b ) {
		if ( a === b ) {
			hasDuplicate = true;
			return 0;
		}

		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
			return a.compareDocumentPosition ? -1 : 1;
		}

		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
	};

} else {
	sortOrder = function( a, b ) {
		// The nodes are identical, we can exit early
		if ( a === b ) {
			hasDuplicate = true;
			return 0;

		// Fallback to using sourceIndex (in IE) if it's available on both nodes
		} else if ( a.sourceIndex && b.sourceIndex ) {
			return a.sourceIndex - b.sourceIndex;
		}

		var al, bl,
			ap = [],
			bp = [],
			aup = a.parentNode,
			bup = b.parentNode,
			cur = aup;

		// If the nodes are siblings (or identical) we can do a quick check
		if ( aup === bup ) {
			return siblingCheck( a, b );

		// If no parents were found then the nodes are disconnected
		} else if ( !aup ) {
			return -1;

		} else if ( !bup ) {
			return 1;
		}

		// Otherwise they're somewhere else in the tree so we need
		// to build up a full list of the parentNodes for comparison
		while ( cur ) {
			ap.unshift( cur );
			cur = cur.parentNode;
		}

		cur = bup;

		while ( cur ) {
			bp.unshift( cur );
			cur = cur.parentNode;
		}

		al = ap.length;
		bl = bp.length;

		// Start walking down the tree looking for a discrepancy
		for ( var i = 0; i < al && i < bl; i++ ) {
			if ( ap[i] !== bp[i] ) {
				return siblingCheck( ap[i], bp[i] );
			}
		}

		// We ended someplace up the tree so do a sibling check
		return i === al ?
			siblingCheck( a, bp[i], -1 ) :
			siblingCheck( ap[i], b, 1 );
	};

	siblingCheck = function( a, b, ret ) {
		if ( a === b ) {
			return ret;
		}

		var cur = a.nextSibling;

		while ( cur ) {
			if ( cur === b ) {
				return -1;
			}

			cur = cur.nextSibling;
		}

		return 1;
	};
}

// Utility function for retreiving the text value of an array of DOM nodes
Sizzle.getText = function( elems ) {
	var ret = "", elem;

	for ( var i = 0; elems[i]; i++ ) {
		elem = elems[i];

		// Get the text from text nodes and CDATA nodes
		if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
			ret += elem.nodeValue;

		// Traverse everything else, except comment nodes
		} else if ( elem.nodeType !== 8 ) {
			ret += Sizzle.getText( elem.childNodes );
		}
	}

	return ret;
};

// Check to see if the browser returns elements by name when
// querying by getElementById (and provide a workaround)
(function(){
	// We're going to inject a fake input element with a specified name
	var form = document.createElement("div"),
		id = "script" + (new Date()).getTime(),
		root = document.documentElement;

	form.innerHTML = "<a name='" + id + "'/>";

	// Inject it into the root element, check its status, and remove it quickly
	root.insertBefore( form, root.firstChild );

	// The workaround has to do additional checks after a getElementById
	// Which slows things down for other browsers (hence the branching)
	if ( document.getElementById( id ) ) {
		Expr.find.ID = function( match, context, isXML ) {
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
				var m = context.getElementById(match[1]);

				return m ?
					m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
						[m] :
						undefined :
					[];
			}
		};

		Expr.filter.ID = function( elem, match ) {
			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");

			return elem.nodeType === 1 && node && node.nodeValue === match;
		};
	}

	root.removeChild( form );

	// release memory in IE
	root = form = null;
})();

(function(){
	// Check to see if the browser returns only elements
	// when doing getElementsByTagName("*")

	// Create a fake element
	var div = document.createElement("div");
	div.appendChild( document.createComment("") );

	// Make sure no comments are found
	if ( div.getElementsByTagName("*").length > 0 ) {
		Expr.find.TAG = function( match, context ) {
			var results = context.getElementsByTagName( match[1] );

			// Filter out possible comments
			if ( match[1] === "*" ) {
				var tmp = [];

				for ( var i = 0; results[i]; i++ ) {
					if ( results[i].nodeType === 1 ) {
						tmp.push( results[i] );
					}
				}

				results = tmp;
			}

			return results;
		};
	}

	// Check to see if an attribute returns normalized href attributes
	div.innerHTML = "<a href='#'></a>";

	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
			div.firstChild.getAttribute("href") !== "#" ) {

		Expr.attrHandle.href = function( elem ) {
			return elem.getAttribute( "href", 2 );
		};
	}

	// release memory in IE
	div = null;
})();

if ( document.querySelectorAll ) {
	(function(){
		var oldSizzle = Sizzle,
			div = document.createElement("div"),
			id = "__sizzle__";

		div.innerHTML = "<p class='TEST'></p>";

		// Safari can't handle uppercase or unicode characters when
		// in quirks mode.
		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
			return;
		}
	
		Sizzle = function( query, context, extra, seed ) {
			context = context || document;

			// Only use querySelectorAll on non-XML documents
			// (ID selectors don't work in non-HTML documents)
			if ( !seed && !Sizzle.isXML(context) ) {
				// See if we find a selector to speed up
				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
				
				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
					// Speed-up: Sizzle("TAG")
					if ( match[1] ) {
						return makeArray( context.getElementsByTagName( query ), extra );
					
					// Speed-up: Sizzle(".CLASS")
					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
						return makeArray( context.getElementsByClassName( match[2] ), extra );
					}
				}
				
				if ( context.nodeType === 9 ) {
					// Speed-up: Sizzle("body")
					// The body element only exists once, optimize finding it
					if ( query === "body" && context.body ) {
						return makeArray( [ context.body ], extra );
						
					// Speed-up: Sizzle("#ID")
					} else if ( match && match[3] ) {
						var elem = context.getElementById( match[3] );

						// Check parentNode to catch when Blackberry 4.6 returns
						// nodes that are no longer in the document #6963
						if ( elem && elem.parentNode ) {
							// Handle the case where IE and Opera return items
							// by name instead of ID
							if ( elem.id === match[3] ) {
								return makeArray( [ elem ], extra );
							}
							
						} else {
							return makeArray( [], extra );
						}
					}
					
					try {
						return makeArray( context.querySelectorAll(query), extra );
					} catch(qsaError) {}

				// qSA works strangely on Element-rooted queries
				// We can work around this by specifying an extra ID on the root
				// and working up from there (Thanks to Andrew Dupont for the technique)
				// IE 8 doesn't work on object elements
				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
					var oldContext = context,
						old = context.getAttribute( "id" ),
						nid = old || id,
						hasParent = context.parentNode,
						relativeHierarchySelector = /^\s*[+~]/.test( query );

					if ( !old ) {
						context.setAttribute( "id", nid );
					} else {
						nid = nid.replace( /'/g, "\\$&" );
					}
					if ( relativeHierarchySelector && hasParent ) {
						context = context.parentNode;
					}

					try {
						if ( !relativeHierarchySelector || hasParent ) {
							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
						}

					} catch(pseudoError) {
					} finally {
						if ( !old ) {
							oldContext.removeAttribute( "id" );
						}
					}
				}
			}
		
			return oldSizzle(query, context, extra, seed);
		};

		for ( var prop in oldSizzle ) {
			Sizzle[ prop ] = oldSizzle[ prop ];
		}

		// release memory in IE
		div = null;
	})();
}

(function(){
	var html = document.documentElement,
		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;

	if ( matches ) {
		// Check to see if it's possible to do matchesSelector
		// on a disconnected node (IE 9 fails this)
		var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
			pseudoWorks = false;

		try {
			// This should fail with an exception
			// Gecko does not error, returns false instead
			matches.call( document.documentElement, "[test!='']:sizzle" );
	
		} catch( pseudoError ) {
			pseudoWorks = true;
		}

		Sizzle.matchesSelector = function( node, expr ) {
			// Make sure that attribute selectors are quoted
			expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");

			if ( !Sizzle.isXML( node ) ) {
				try { 
					if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
						var ret = matches.call( node, expr );

						// IE 9's matchesSelector returns false on disconnected nodes
						if ( ret || !disconnectedMatch ||
								// As well, disconnected nodes are said to be in a document
								// fragment in IE 9, so check for that
								node.document && node.document.nodeType !== 11 ) {
							return ret;
						}
					}
				} catch(e) {}
			}

			return Sizzle(expr, null, null, [node]).length > 0;
		};
	}
})();

(function(){
	var div = document.createElement("div");

	div.innerHTML = "<div class='test e'></div><div class='test'></div>";

	// Opera can't find a second classname (in 9.6)
	// Also, make sure that getElementsByClassName actually exists
	if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
		return;
	}

	// Safari caches class attributes, doesn't catch changes (in 3.2)
	div.lastChild.className = "e";

	if ( div.getElementsByClassName("e").length === 1 ) {
		return;
	}
	
	Expr.order.splice(1, 0, "CLASS");
	Expr.find.CLASS = function( match, context, isXML ) {
		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
			return context.getElementsByClassName(match[1]);
		}
	};

	// release memory in IE
	div = null;
})();

function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];

		if ( elem ) {
			var match = false;

			elem = elem[dir];

			while ( elem ) {
				if ( elem.sizcache === doneName ) {
					match = checkSet[elem.sizset];
					break;
				}

				if ( elem.nodeType === 1 && !isXML ){
					elem.sizcache = doneName;
					elem.sizset = i;
				}

				if ( elem.nodeName.toLowerCase() === cur ) {
					match = elem;
					break;
				}

				elem = elem[dir];
			}

			checkSet[i] = match;
		}
	}
}

function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];

		if ( elem ) {
			var match = false;
			
			elem = elem[dir];

			while ( elem ) {
				if ( elem.sizcache === doneName ) {
					match = checkSet[elem.sizset];
					break;
				}

				if ( elem.nodeType === 1 ) {
					if ( !isXML ) {
						elem.sizcache = doneName;
						elem.sizset = i;
					}

					if ( typeof cur !== "string" ) {
						if ( elem === cur ) {
							match = true;
							break;
						}

					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
						match = elem;
						break;
					}
				}

				elem = elem[dir];
			}

			checkSet[i] = match;
		}
	}
}

if ( document.documentElement.contains ) {
	Sizzle.contains = function( a, b ) {
		return a !== b && (a.contains ? a.contains(b) : true);
	};

} else if ( document.documentElement.compareDocumentPosition ) {
	Sizzle.contains = function( a, b ) {
		return !!(a.compareDocumentPosition(b) & 16);
	};

} else {
	Sizzle.contains = function() {
		return false;
	};
}

Sizzle.isXML = function( elem ) {
	// documentElement is verified for cases where it doesn't yet exist
	// (such as loading iframes in IE - #4833) 
	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;

	return documentElement ? documentElement.nodeName !== "HTML" : false;
};

var posProcess = function( selector, context ) {
	var match,
		tmpSet = [],
		later = "",
		root = context.nodeType ? [context] : context;

	// Position selectors must be done after the filter
	// And so must :not(positional) so we move all PSEUDOs to the end
	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
		later += match[0];
		selector = selector.replace( Expr.match.PSEUDO, "" );
	}

	selector = Expr.relative[selector] ? selector + "*" : selector;

	for ( var i = 0, l = root.length; i < l; i++ ) {
		Sizzle( selector, root[i], tmpSet );
	}

	return Sizzle.filter( later, tmpSet );
};

// EXPOSE

window.Sizzle = Sizzle;

})();
/*

    http://www.JSON.org/json_parse.js

    2011-03-06



    Public Domain.



    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.



    This file creates a json_parse function.



        json_parse(text, reviver)

            This method parses a JSON text to produce an object or array.

            It can throw a SyntaxError exception.



            The optional reviver parameter is a function that can filter and

            transform the results. It receives each of the keys and values,

            and its return value is used instead of the original value.

            If it returns what it received, then the structure is not modified.

            If it returns undefined then the member is deleted.



            Example:



            // Parse the text. Values that look like ISO date strings will

            // be converted to Date objects.



            myData = json_parse(text, function (key, value) {

                var a;

                if (typeof value === 'string') {

                    a =

/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);

                    if (a) {

                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],

                            +a[5], +a[6]));

                    }

                }

                return value;

            });



    This is a reference implementation. You are free to copy, modify, or

    redistribute.



    This code should be minified before deployment.

    See http://javascript.crockford.com/jsmin.html



    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO

    NOT CONTROL.

*/



/*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode,

    hasOwnProperty, message, n, name, prototype, push, r, t, text

*/



var json_parse = (function () {

    "use strict";



// This is a function that can parse a JSON text, producing a JavaScript

// data structure. It is a simple, recursive descent parser. It does not use

// eval or regular expressions, so it can be used as a model for implementing

// a JSON parser in other languages.



// We are defining the function inside of another function to avoid creating

// global variables.



    var at,     // The index of the current character

        ch,     // The current character

        escapee = {

            '"':  '"',

            '\\': '\\',

            '/':  '/',

            b:    '\b',

            f:    '\f',

            n:    '\n',

            r:    '\r',

            t:    '\t'

        },

        text,



        error = function (m) {



// Call error when something is wrong.



            throw {

                name:    'SyntaxError',

                message: m,

                at:      at,

                text:    text

            };

        },



        next = function (c) {



// If a c parameter is provided, verify that it matches the current character.



            if (c && c !== ch) {

                error("Expected '" + c + "' instead of '" + ch + "'");

            }



// Get the next character. When there are no more characters,

// return the empty string.



            ch = text.charAt(at);

            at += 1;

            return ch;

        },



        number = function () {



// Parse a number value.



            var number,

                string = '';



            if (ch === '-') {

                string = '-';

                next('-');

            }

            while (ch >= '0' && ch <= '9') {

                string += ch;

                next();

            }

            if (ch === '.') {

                string += '.';

                while (next() && ch >= '0' && ch <= '9') {

                    string += ch;

                }

            }

            if (ch === 'e' || ch === 'E') {

                string += ch;

                next();

                if (ch === '-' || ch === '+') {

                    string += ch;

                    next();

                }

                while (ch >= '0' && ch <= '9') {

                    string += ch;

                    next();

                }

            }

            number = +string;

            if (!isFinite(number)) {

                error("Bad number");

            } else {

                return number;

            }

        },



        string = function () {



// Parse a string value.



            var hex,

                i,

                string = '',

                uffff;



// When parsing for string values, we must look for " and \ characters.



            if (ch === '"') {

                while (next()) {

                    if (ch === '"') {

                        next();

                        return string;

                    } else if (ch === '\\') {

                        next();

                        if (ch === 'u') {

                            uffff = 0;

                            for (i = 0; i < 4; i += 1) {

                                hex = parseInt(next(), 16);

                                if (!isFinite(hex)) {

                                    break;

                                }

                                uffff = uffff * 16 + hex;

                            }

                            string += String.fromCharCode(uffff);

                        } else if (typeof escapee[ch] === 'string') {

                            string += escapee[ch];

                        } else {

                            break;

                        }

                    } else {

                        string += ch;

                    }

                }

            }

            error("Bad string");

        },



        white = function () {



// Skip whitespace.



            while (ch && ch <= ' ') {

                next();

            }

        },



        word = function () {



// true, false, or null.



            switch (ch) {

            case 't':

                next('t');

                next('r');

                next('u');

                next('e');

                return true;

            case 'f':

                next('f');

                next('a');

                next('l');

                next('s');

                next('e');

                return false;

            case 'n':

                next('n');

                next('u');

                next('l');

                next('l');

                return null;

            }

            error("Unexpected '" + ch + "'");

        },



        value,  // Place holder for the value function.



        array = function () {



// Parse an array value.



            var array = [];



            if (ch === '[') {

                next('[');

                white();

                if (ch === ']') {

                    next(']');

                    return array;   // empty array

                }

                while (ch) {

                    array.push(value());

                    white();

                    if (ch === ']') {

                        next(']');

                        return array;

                    }

                    next(',');

                    white();

                }

            }

            error("Bad array");

        },



        object = function () {



// Parse an object value.



            var key,

                object = {};



            if (ch === '{') {

                next('{');

                white();

                if (ch === '}') {

                    next('}');

                    return object;   // empty object

                }

                while (ch) {

                    key = string();

                    white();

                    next(':');

                    if (Object.hasOwnProperty.call(object, key)) {

                        error('Duplicate key "' + key + '"');

                    }

                    object[key] = value();

                    white();

                    if (ch === '}') {

                        next('}');

                        return object;

                    }

                    next(',');

                    white();

                }

            }

            error("Bad object");

        };



    value = function () {



// Parse a JSON value. It could be an object, an array, a string, a number,

// or a word.



        white();

        switch (ch) {

        case '{':

            return object();

        case '[':

            return array();

        case '"':

            return string();

        case '-':

            return number();

        default:

            return ch >= '0' && ch <= '9' ? number() : word();

        }

    };



// Return the json_parse function. It will have access to all of the above

// functions and variables.



    return function (source, reviver) {

        var result;



        text = source;

        at = 0;

        ch = ' ';

        result = value();

        white();

        if (ch) {

            error("Syntax error");

        }



// If there is a reviver function, we recursively walk the new structure,

// passing each name/value pair to the reviver function for possible

// transformation, starting with a temporary root object that holds the result

// in an empty key. If there is not a reviver function, we simply return the

// result.



        return typeof reviver === 'function' ? (function walk(holder, key) {

            var k, v, value = holder[key];

            if (value && typeof value === 'object') {

                for (k in value) {

                    if (Object.prototype.hasOwnProperty.call(value, k)) {

                        v = walk(value, k);

                        if (v !== undefined) {

                            value[k] = v;

                        } else {

                            delete value[k];

                        }

                    }

                }

            }

            return reviver.call(holder, key, value);

        }({'': result}, '')) : result;

    };

}());

/**

 * Sony Computer Entertainment Inc.

 * 

 * @author    ShunsukeHirota TYO/THEORIA COMMUNICATIONS Division.

 * @version   1.3.1

 * 

 * Licensed under the MIT License

 * http://www.opensource.org/licenses/mit-license.php

 */



var SCE_APP = SCE_APP || {};

var __global = {};



/**

* @class Config

*/

SCE_APP.Config = (function() {

	var exports = {},

		/**

		* ※※※ Billboard自動再生時間（秒）

		*/

		AUTOPLAY_TIME = __global.AUTOPLAY_TIME || 10,

		

		/**

		* デバッグモードの真偽

		*/

		DEBUG = false

		

		/**

		* Rootパス

		*/

		, ROOT = DEBUG ? '/sce2' : '';

	

	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	exports.DATA_PATH = DEBUG ? ROOT + '/common/data/' : ROOT + '';

	exports.DEBUG = DEBUG;

	exports.ROOT = ROOT;

	exports.AUTOPLAY_TIME = AUTOPLAY_TIME;

	return exports;

}());



SCE_APP.namespace = function (ns_string) {

	var parts = ns_string.split('.'),

		parent = SCE_APP,

		i;

		

	if (parts[0] === 'SCE_APP') {

		parts = parts.slice(1);

	}

	

	for (i = 0; i < parts.length; i += 1) {

		if (typeof parent[parts[i]] === 'undefined') {

			parent[parts[i]] = {};

		}

		parent = parent[parts[i]];

	}

	return parent;

};



/**

* ユーティリティ

* @namespace SCE_APP

* @class Utility

*/

SCE_APP.Utility = (function() {

	var DEBUG = SCE_APP.Config.DEBUG,

		FRAME_RATE = 16,

		_PS3 = 'ps3', _VITA = 'psv', _PSP = 'psp', _TOP = 'top',

		_SOFT = 'software', _SCE = 'sce',

		MASTER = [{

			name: 'playstation3',

			key: _PS3

		}, {

			name: 'playstation-vita',

			key: _VITA

		}, {

			name: 'playstation-portable',

			key: _PSP

		}, {

			name: 'index',

			key: _TOP

		}, {

			name: 'software',

			key: _SOFT

		}, {

			name: 'scesoftware',

			key: _SCE

		}]

		, ROOT = SCE_APP.Config.ROOT

		, intervals = []

		, _userAgent = (function() {

			var ua = navigator.userAgent.toLowerCase();

				

			return {

				firefox: ua.match('firefox') ? true : false,

				ie: (function(){

					var undef, v = 3, div = document.createElement('div');

					while (

						div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',

						div.getElementsByTagName('i')[0]

					) {

						

					}

					return v> 4 ? v : undef;

				})(),

				chrome: ua.match('Chrome') ? true : false,

				safari: (ua.match('AppleWebkit') && !ua.match('Chrome')) ? true : false,

				ps3: ua.match('playstation 3') ? true : false,

				vita: ua.match('playstation vita') ? true : false,

				opera: ua.match('Opera') ? true : false,

				smartphone: ua.match('iphone') || ua.match('android') || ua.match('ipad') ? true : false,

				version: (ua.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1]

			};

		}())

		, listeners = {}

		, animations = []

		, query = location.hash && location.hash.replace('#', '')

		, _disableAnimate

		, exports;

	

	if (query) {

		query = query.split('_');

	}

	_disableAnimate = {

		'fade': (_userAgent.ie <= 8 || _userAgent.ps3 || _userAgent.smartphone || _userAgent.vita),

		'slideto': (_userAgent.ps3 || _userAgent.smartphone || _userAgent.vita),

		'scrolltop': (_userAgent.ps3 || _userAgent.smartphone || _userAgent.vita)

	};

	

	/* ------------------------------------------------------------

	* Private

	* ------------------------------------------------------------*/

	/**

	* 'on' + type時のqueue化

	*/

	function addListeners(target, type, func) {

		if (!listeners[type]) {

			listeners[type] = [{

				target: target,

				func: func

			}];

		} else {

			listeners[type].push({

				target: target,

				func: func

			});

		}

	}

	

	/**

	* 指定のアニメーションが登録済みかの真偽を取得

	* @param target {Object}

	* @param type {String}

	* @return {Boolean}

	*/

	function checkAnimate(target, type) {

		var i, len, animate;

		for (i = 0, len = animations.length; i < len; ++i) {

			animate = animations[i];

			if (animate && animate.target === target && animate.type === type) {

				return true;

			}

		}

		return false;

	}

	

	/**

	* 実行中のアニメーションを登録

	* @param target {Object}

	* @param type {String}

	* @param interval {Number} interval id

	*/

	function addAnimate(target, type, interval, options) {

		var i, len, animate;

		for (i = 0, len = animations.length; i < len; ++i) {

			animate = animations[i];

			if (animate && animate.target === target && animate.type === type) {

				return;

			}

		}

		animations[animations.length] = {

			target: target,

			type: type,

			options: options,

			interval: interval

		};

	}

	

	/**

	* 実行中のアニメーションから削除

	* @param target {Object}

	* @param type {String}

	*/

	function removeAnimate(target, type) {

		var i, len, animate;

		for (i = 0, len = animations.length; i < len; ++i) {

			animate = animations[i];

			if (animate && animate.target === target && animate.type === type) {

				animations[i] = null;

				animations.splice(i, 1)

			}

		}

	}

	

	/**

	* マウス座標の取得

	* @param evt {Object} EventObject

	* @return {Object} 座標オブジェクト

	*/

	function mouseCoords(evt){

		if(evt.pageX || evt.pageY){

			return {x:evt.pageX, y:evt.pageY};

		}

		return {

			x:evt.clientX + document.body.scrollLeft - document.body.clientLeft,

			y:evt.clientY + document.body.scrollTop - document.body.clientTop

		};

	}

	

	/**

	* ポジションの取得

	* @param target {Object}

	*/

	function getPosition(target) {

		var elm = target,

			left = 0,

			top = 0;

		

		while (elm.offsetParent){

			left += elm.offsetLeft;

			top += elm.offsetTop;

			elm = elm.offsetParent;

		}

		left += elm.offsetLeft || 0;

		top += elm.offsetTop || 0;

		

		return {x:left, y:top};

	}

	

	

	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	exports = function() {};

	

	/**

	* ユーザーエージェントオブジェクトの取得

	* @method

	* @return {Object}

	*/

	exports.getUseragent = function() {

		return _userAgent;

	};

	

	/**

	* デバッグモードの真偽を取得

	*/

	exports.getDebug = function() {

		return DEBUG;

	};

	

	/**

	* アニメーション使用可否情報取得

	* @return {Object}

	*/

	exports.getDisableAnimate = function() {

		return _disableAnimate;

	};

	

	exports.setTestLink = function(selector) {

		var _alist = Sizzle(selector),

			_a,

			i, len = _alist.length,

			_domain;

		if (DEBUG) {

			for (i = 0; i < len; ++i) {

				_a = _alist[i];

				_domain = location.protocol + '//' + location.host;

				if (_a.href.match(_domain)) {

					_a.href = ROOT + (_a.href).replace(_domain, '');

				}

			}

		}

	};

	

	/**

	* ルートの取得

	* @return {String}

	*/

	exports.getRoot = function() {

		return ROOT;

	};

	

	/**

	* スクリプトファイル（モジュール）の読み込み

	* @param $script {String} スクリプトのパス

	* @param $callback {Function} コールバック関数

	*/

	exports.requireScript = function($script, $callback) {

		var _script = document.createElement('script');

		_script.type = "text/javascript";

		_script.onload = function() {

			if ($callback) {

				_script.onload = null;

				_script.onreadystatechange = null;

				$callback.apply(this);

			}

		};

		_script.onreadystatechange = function() {

			if (_script.readyState === 'loaded' || _script.readyState === 'complete') {

				if ($callback) {

					_script.onload = null;

					_script.onreadystatechange = null;

					$callback.apply(this);

				}

			}

		};

		_script.src = $script;

		Sizzle('head')[0].appendChild(_script);

	};

	

	/**

	* Query文字列の取得

	* @return {String}

	*/

	exports.getQuery = function() {

		return query;

	};

	

	/**

	* フォーマットオブジェクト（マスター）

	* @property {Object}

	*/

	exports.format = {

		TOP: _TOP,

		PS3: _PS3,

		VITA: _VITA,

		PSP: _PSP,

		current: null

	};

	

	/**

	* 現在のページフォーマットを設定

	* @method

	* @param id {String} 対象ページのbodytagID

	* @return {boolean} 該当以外のフォーマット時falseを返す

	*/

	exports.setCurrentFormat = function(id) {

		var i, len;

		for (i = 0, len = MASTER.length; i < len; ++i) {

			if (MASTER[i].name === id) {

				exports.format.current = MASTER[i].key;

				return true;

			}

		}

		return false;

	};

	

	/**

	* バナー用のボーダーを設定

	* @param bannerList {Array} <a></a><img>を包括した<li>のリスト

	*/

	exports.setBannerBorder = function(bannerList) {

		var banner, i, len;

		if (!bannerList) {

			return;

		}

		for (i = 0, len = bannerList.length; i < len; ++i) {

			banner = bannerList[i];

			exports.addEventListener(banner, 'mouseover', function(i) {

				return function() {

					var index = i,

						_a;

					_a = Sizzle('a', bannerList[index])[0];

					if (!_a) return;

					bannerList[index].style.cursor = 'pointer';

					_a.className = 'on';

				};

			}(i));

			exports.addEventListener(banner, 'mouseout', function(i) {

				return function() {

					var index = i,

						_a;

					_a = Sizzle('a', bannerList[index])[0];

					if (!_a) return;

					bannerList[index].style.cursor = 'default';

					_a.className = '';

				};

			}(i));

			exports.addEventListener(banner, 'click', function(i) {

				return function() {

					var index = i,

						_a;

					_a = Sizzle('a', bannerList[index])[0];

					if (!_a) return;

					if (_a.target === '_blank') {

						window.open(_a.href);

					} else {

						location.href = _a.href;

					}

				};

			}(i));

		}

	};

	

	/* ------------------------------------------------------------

	* Event

	* ------------------------------------------------------------*/

	/**

	* イベント登録

	* @method

	* @param target {Object} 対象のDOMObject

	* @param type {String} 登録するイベント

	* @param func {Function} 実行する関数

	*/

	exports.addEventListener = function(target, type, func) {

		var _targets, _target, i, len;

		if (!target) {

			return;

		}

		

		if (target.length) {

			_targets = target;

		} else {

			_targets = [target];

		}

		

		for (i = 0, len = _targets.length; i < len; ++i) {

			_target = _targets[i];

			if (_target.addEventListener) {

				_target.addEventListener(type, func, false);

			} else if (_target.attachEvent) {

				_target.attachEvent('on' + type, func);

			} else {

				addListeners(_target, type, func);

				_target['on' + type] = function() {

					var funcs = listeners[type], i, len = funcs.length;

					if (DEBUG) {

						alert(type + ' / funcs:' + len);

					}

					for (i = 0; i < len; ++i) {

						if (funcs[i].target === _target) {

							funcs[i].apply(target);

						}

					}

				};

			}

		}

	};

	

	/**

	* イベント登録解除

	* @method

	* @param target {Object} 対象のDOMObject

	* @param type {String} 登録するイベント

	* @param func {Function} 実行する関数

	*/

	exports.removeEventListener = function(target, type, func) {

		if (target.removeEventListener) {

			target.removeEventListener(type, func, false);

		} else if (target.detachEvent) {

			target.detachEvent('on' + type, func);

		} else {

			target['on' + type] = null;

		}

	};

	

	/**

	* デフォルトイベントをキャンセルする

	* @param evt {Object} イベントオブジェクト

	*/

	exports.cancelEvent = function(evt) {

		if (evt.preventDefault) {

			evt.preventDefault();

			evt.stopPropagation();

		} else {

			evt.cancelBubble = true;

			evt.returnValue = false;

		}

	};

	

	/* ------------------------------------------------------------

	* アニメーション

	* ------------------------------------------------------------*/

	/**

	* Windowスクロール

	* @param target {Object}

	* @param positions {Array}

	*/

	exports.scrollToTop = function(target, positions) {

		var c = Math.floor(800 / FRAME_RATE),

			interval,

			mwheel, afterWheel;

		

		if (_disableAnimate.scrolltop) {

			target.scrollTo(positions[0], positions[1]);

			return;

		}

		

		mwheel = _userAgent.firefox ? 'DOMMouseScroll' : 'mousewheel';

		interval = setInterval(function() {

			var _x = window.pageXOffset ? window.pageXOffset : (document.body.scrollLeft || document.documentElement.scrollLeft),

				_y = window.pageYOffset ? window.pageYOffset : (document.body.scrollTop || document.documentElement.scrollTop);

			

			target.scrollTo(_x - (_x - positions[0]) * .1, _y - (_y - positions[1]) * .1);

			--c;

			if ((_x - positions[0]) < 1 && (_y - positions[1]) < 1) {

				clearInterval(interval);

				target.scrollTo(positions[0], positions[1]);

				removeAnimate(target, 'scrolltop');

				exports.removeEventListener(window, mwheel, afterWheel);

			}

		}, FRAME_RATE);

		

		afterWheel = function() {

			exports.cancelAnimation(target, 'scrolltop');

			removeAnimate(target, 'scrolltop');

			exports.removeEventListener(window, mwheel, afterWheel);

			exports.removeEventListener(window, "keydow", afterWheel);

			exports.removeEventListener(document, mwheel, afterWheel);

			exports.removeEventListener(document, "keydow", afterWheel);

		};

		

		exports.addEventListener(window, mwheel, afterWheel);

		exports.addEventListener(window, "keydown", afterWheel);

		exports.addEventListener(document, mwheel, afterWheel);

		exports.addEventListener(document, "keydown", afterWheel);

		addAnimate(target, 'scrolltop', interval);

	};

	

	/**

	* スライド

	* @param target {Object}

	* @param positions {Array} 0: x, 1: y, 2: true ? ceil : floor

	* @param update {Function}

	* @param complete {Function}

	* @param speed {Number} Speed(Option)

	*/

	exports.slideTo = function(target, positions, update, complete, speed) {

		var c, interval,

			offsetX, offsetY,

			xfactor, yfactor,

			anim,

			_speed,

			_round,

			_x, _y,

			_frames = [];

		

		if (_disableAnimate.slideto) {

			target.style.left = positions[0] + 'px';

			target.style.top = positions[1] + 'px';

			if (complete) {

				complete.apply();

			}

			return;

		}

		

		c = Math.floor(2200 / FRAME_RATE);

		offsetX = target.style.left.replace('px', '');

		offsetY = target.style.top.replace('px', '');

		xfactor = (offsetX - positions[0]) / c;

		yfactor = (offsetY - positions[1]) / c;

		_speed = speed || .09;

		_round = positions[2] ? Math.ceil : Math.floor;

		

		anim = exports.getAnimation(target, 'slide');

		if (anim) {

			exports.cancelAnimation(target, 'slide');

			target.style.left = anim.options.position[0];

			target.style.top = anim.options.position[1];

		}

		

		_x = target.style.left.replace('px', '');

		_y = target.style.top.replace('px', '');

		function calcSlide() {

			var nx = _round(_x - (_x - positions[0]) * _speed),

				ny = _round(_y - (_y - positions[1]) * _speed);

			_frames[_frames.length] = [nx + 'px', ny + 'px'];

			_x = nx;

			_y = ny;

			if ((Math.abs(_x - positions[0]) < 1.4 && Math.abs(_y - positions[1]) < 1.4) || c === 0) {

				return false;

			}

			return true;

		}

		while(calcSlide()) {

			--c;

		}

		c = 0;

		interval = setInterval(function() {

			target.style.left = _frames[c][0];

			target.style.top = _frames[c][1];

			++c;

			if (update) {

				update.apply();

			}

			if (c === _frames.length) {

				clearInterval(interval);

				target.style.left = positions[0] + 'px';

				target.style.top = positions[1] + 'px';

				removeAnimate(target, 'slide');

				if (complete) {

					complete.apply();

				}

			}

		}, FRAME_RATE);

		addAnimate(target, 'slide', interval, {position: positions});

	};

	

	/**

	* フェードアウト

	* @method

	* @param target {Object} 対象DOMObject

	* @param duration {Number} 所要時間

	* @param callback {Function} コールバック関数

	* @param displaynone {Boolean} out完了時display: noneを設定するかの真偽

	*/

	exports.fadeOut = function(target, duration, callback, displaynone) {

		var c = Math.floor(duration / FRAME_RATE),

			op,

			interval,

			factor = 1 / c;

		

		if (displaynone === undefined) {

			displaynone = true;

		}

		if (!target || checkAnimate(target, 'fadeout') || target.style.opacity == '0') {

			return;

		}

		

		op = exports.getOpacity(target);

		if (!op) {

			op = 0;

		}

		exports.cancelAnimation(target, 'fadein');

		interval = setInterval(function() {

			op -= factor;

			exports.setOpacityTo(target, op);

			--c;

			if (c === 0) {

				clearInterval(interval);

				exports.setOpacityZero(target);

				if (displaynone) {

					target.style.display = 'none';

				}

				removeAnimate(target, 'fadeout');

				if (callback) callback.apply();

			}

		}, FRAME_RATE);

		addAnimate(target, 'fadeout', interval);

	};

	

	/**

	* フェードイン

	* @method

	* @param target {Object} 対象DOMObject

	* @param duration {Number} 所要時間

	* @param callback {Function} コールバック関数

	*/

	exports.fadeIn = function(target, duration, callback) {

		

		var c = Math.floor(duration / FRAME_RATE),

			interval,

			op = 0,

			factor = 1 / c;

		if (!target || target.style.opacity == '1' || checkAnimate(target, 'fadein')) {

			return;

		}

		exports.cancelAnimation(target, 'fadeout');

		target.style.display = 'block';

		target.style.visibility = 'visible';

		if (_disableAnimate.fade) {

			exports.setOpacityOne(target);

			target.style.display = 'block';

			if (callback) {

				callback.apply();

			}

			return;

		}

		interval = setInterval(function() {

			op += factor;

			exports.setOpacityTo(target, op);

			--c;

			

			if (c === 0) {

				exports.setOpacityOne(target);

				target.style.display = 'block';

				clearInterval(interval);

				removeAnimate(target, 'fadein');

				if (callback) callback.apply();

			}

			

		}, FRAME_RATE);

		addAnimate(target, 'fadein', interval);

	};

	

	/**

	* アニメーションをキャンセルする

	* @param target {Object} 対象

	* @param type {String} アニメーションタイプ 'fadein', 'fadeout'

	*/

	exports.cancelAnimation = function(target, type) {

		var i, len = animations.length, anim;

		

		for (i = 0; i < len; ++i) {

			anim = animations[i];

			if (anim.type === type && anim.target === target) {

				clearInterval(anim.interval);

				removeAnimate(target, type);

				return true;

			}

		}

		return false;

	};

	

	/**

	* 任意のアニメーションを取得する

	* @param target {Object} 対象

	* @param type {String} アニメーションタイプ 'fadein', 'fadeout' ...

	*/

	exports.getAnimation = function(target, type) {

		var i, len = animations.length, anim;

		for (i = 0; i < len; ++i) {

			anim = animations[i];

			if (anim.type === type && anim.target === target) {

				return anim;

			}

		}

		return null;

	};

	

	/**

	* 対象オブジェクトの透明度取得

	* @method

	* @param target {Object} 対象

	*/

	exports.getOpacity = function(target) {

		if (_userAgent.ie <= 8) {

			return target.style.filter.replace(/\D/mg, '') / 100;

		} else {

			return target.style.opacity;

		}

	};

	

	/**

	* 透明度を0にする

	* @param target {Object} ターゲットオブジェクト

	*/

	exports.setOpacityZero = function(target) {

		if (_userAgent.ie <= 8) {

			target.style.visibility = 'hidden';

		} else if (_disableAnimate.fade) {

			target.style.visibility = 'hidden';

			target.style.opacity = 0;

		} else {

			target.style.opacity = 0;

		}

	};

	

	/**

	* 透明度を1にする

	* @param target {Object} ターゲットオブジェクト

	*/

	exports.setOpacityOne = function(target) {

		if (_userAgent.ie <= 8) {

			target.style.visibility = 'visible';

		} else if (_disableAnimate.fade) {

			target.style.visibility = 'visible';

			target.style.opacity = 1;

		} else {

			target.style.opacity = 1;

		}

	};

	

	/**

	* 透明度を指定した値に変更する

	* @param target {Object} ターゲットオブジェクト

	* @param opacity {Number} 0-1 透明度

	*/

	exports.setOpacityTo = function(target, opacity) {

		if (!_disableAnimate.fade) {

			target.style.opacity = opacity;

		}

	};

	

	/**

	* ターゲットの子ノードを削除する

	* @param node {Element} 対象のノード

	*/

	exports.clearNode = function(node) {

		var i, len, childs = node.children;

		for (i = 0, len = childs.length; i < len; ++i) {

			node.removeChild(childs[0]);

		}

	};

	

	/**

	* groupリスト内DOMノードの高さを揃える

	* @method

	* @param group {Array} 

	*/

	exports.flatHeight = function(group) {

		var i, len, best = 0;

		for (i = 0, len = group.length; i < len; ++i) {

			if (group[i]) {

				group[i].style.height = '';

				best = Math.max(best, group[i].offsetHeight);

			}

		}

		for (i = 0; i < len; ++i) {

			if (group[i]) {

				group[i].style.height = best + 'px';

			}

		}

	};

	

	/* ------------------------------------------------------------

	* Mouse Event

	* ------------------------------------------------------------*/

	/**

	* 任意のエレメントにおけるマウス座標の取得

	* @param e {Object} targetElement

	* @param evt {Object} EventObject

	* @return {Object} 座標オブジェクト

	*/

	exports.getMouseOffset = function(e, evt){

			var ev = evt || window.event,

				ePos = getPosition(e),

				mousePos = mouseCoords(ev);

			return {x:mousePos.x - ePos.x, y:mousePos.y - ePos.y};

	};

	

	

	/**

	* ドラッグドロップ

	* @method

	* @param id_ {String} 対象エレメントのID

	* @param _max {Number} 最大移動座標

	*/

	exports.setDragDrop = function(id_, _max) {

		

		var dragDrop = {

			element: null,

			mouseOffset: null,

			minX: 0,

			maxX: _max,

			mouseCoords: function(evt){

				if(evt.pageX || evt.pageY){

					return {x:evt.pageX, y:evt.pageY};

				}

				return {

					x:evt.clientX + document.body.scrollLeft - document.body.clientLeft,

					y:evt.clientY + document.body.scrollTop  - document.body.clientTop

				};

			},

			getMouseOffset: function(e, evt){

				var ev = evt || window.event;

				var ePos = dragDrop.getPosition(e);

				var mousePos = dragDrop.mouseCoords(ev);

				return {x:mousePos.x - ePos.x, y:mousePos.y - ePos.y};

			},

			getPosition: function(e){

				var left = 0,

					top = 0;

				left += e.offsetLeft;

				top += e.offsetTop;

				return {x: left, y: top};

			},

			mouseMove: function(evt){

				var ev = evt || window.event,

					mousePos = dragDrop.mouseCoords(ev),

					e = dragDrop.element,

					_x;

				if(e){

					_x = mousePos.x - dragDrop.mouseOffset.x;

					_x = Math.max(0, Math.min(_x, dragDrop.maxX));

					e.style.left = _x + "px";

					return false;

				}

			},

			mouseUp: function(){

				dragDrop.element = null;

			},

			attach: function(e){

				if (!e) {

					return;

				}

				e.onmousedown = function(evt){

					dragDrop.element = this;

					dragDrop.mouseOffset = dragDrop.getMouseOffset(this, evt);

					return false;

				}

			}

		};

		

		dragDrop.attach(Sizzle('#' + id_)[0]);

		return dragDrop;

	};

	

	/* ------------------------------------------------------------

	* Cookie

	* ------------------------------------------------------------*/

	

	/**

	* Cookieの取得

	* @param key {String}

	* @return {String} value

	*/

	exports.getCookie = function(key) {

		var tmp1, tmp2, len,

			xx1, xx2, xx3;

		

		xx1 = xx2 = 0;

		tmp1 = ' ' + document.cookie + ';';

		len = tmp1.length;

		while (xx1 < len) {

			xx2 = tmp1.indexOf(';', xx1);

			tmp2 = tmp1.substring(xx1 + 1, xx2);

			xx3 = tmp2.indexOf('=');

			if (tmp2.substring(0, xx3) == key) {

				return (unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));

			}

			xx1 = xx2 + 1;

		}

		return '';

	};

	

	/**

	* Cookieの設定

	* @param key {String}

	* @param value {String, Number}

	* @param once {Boolean}

	*/

	exports.setCookie = function(key, val, once) {

		var tmp;

		tmp = key + '=' + escape(val) + '; ';

		if (!once) {

			tmp += 'expires=Tue, 31-Dec-2030 23:59:59; ';

		}

		document.cookie = tmp;

	};

	

	/* ------------------------------------------------------------

	* Ajax

	* ------------------------------------------------------------*/

	/**

	* JSONデータ読み込み・取得

	* @param url {String} 読み込みJSON URL

	* @param callback {Function} コールバック関数

	* @param error {Function} エラー処理関数

	*/

	exports.getJSON = function(url, callback, error) {

		var xhReq = createXMLHttpRequest(),

			requestTimer = setTimeout(function() {

				xhReq.abort();

			}, 10000);

		xhReq.open("GET", url, true);

		xhReq.setRequestHeader('Content-Type', 'applicaton/json; charset=utf-8');

		xhReq.onreadystatechange = function() {

			if (xhReq.readyState != 4) {

				return

			}

			clearTimeout(requestTimer);

			if (xhReq.status != 200) {

				if (error) {

					error.apply(this, [{

						message: 'budRequest:' + xhReq.status

					}]);

				}

				return;

			}

			var serverResponse = xhReq.responseText;

			callback.apply(this, [serverResponse]);

			

		};

		xhReq.send(null);

		function createXMLHttpRequest() {

			try {

				return new XMLHttpRequest();

			} catch (e) {

				

			}

			try {

				return new ActiveXObject("Msxml2.XMLHTTP");

			} catch (e) {

				

			}

			try {

				return new ActiveXObject("Microsoft.XMLHTTP");

			} catch (e) {

				

			}

			return null;

		}

	};

	/* ------------------------------------------------------------

	* Array

	* ------------------------------------------------------------*/

	/**

	* getUniqueArray

	* @param array {Array}

	* @return {Array} Unique Array

	*/

	exports.arrayUnique = function(array) {

		var newArray = array.concat(),

			length = newArray.length,

			i, j;

		for (i = 0; i < length; i += 1) {

			for(j = 0; j < length; j += 1) {

				if (newArray[i] === newArray[j]) {

					newArray.splice(j, 1);

				}

			}

		}

		return newArray;

	};

	

	exports.arrayGC = function(array) {

		var i, len = array.length,

			result = [];

		for (i = 0; i < len; ++i) {

			if (array[i] !== undefined && array[i] !== null) {

				result[result.length] = array[i];

			}

		}

		return result;

	};



	/* ------------------------------------------------------------

	* Helper

	* ------------------------------------------------------------*/

	/**

	 * クラス名を追加する

	 * @param element {Element Object} 対象エレメント

	 * @param name {String} クラス名

	 */

	exports.addClassName = function(element, name) {

		if (element.className.search(name) === -1) {

			if (element.className) {

				element.className += ' ' + name;

			} else {

				element.className = name;

			}

		}

	};



	/**

	 * クラス名を削除する

	 * @param element {Element Object} 対象エレメント

	 * @param name {String} クラス名

	 */

	exports.removeClassName = function(element, name) {

		element.className = element.className.replace(name, '');

		if (element.className.search(name) !== -1) {

			exports.removeClassName(element, name);

		} else {

			if (element.className.search(/\s{2}/) !== -1) {

				element.className = element.className.replace(/\s{2}/, '');

			}

		}

	};



	/**

	 * 実態参照に変換する

	 * @param str {String}

	 * @return {String}

	 */

	exports.escapeHTML = function(str) {

		str = str.replace(/&/g, '&amp;');

		str = str.replace(/"/g, '&quot;');

		str = str.replace(/'/g, '&#039;');

		str = str.replace(/</g, '&lt;');

		str = str.replace(/>/g, '&gt;');

		return str;

	};

	return exports;

}());

/**

* 共有実行

* @namespace SCE_APP

* @class Common

*/

SCE_APP.Common = (function() {

	var _util = SCE_APP.Utility;

	_util.addEventListener(window, 'load', function() {

		var util = _util,

			ua = util.getUseragent();

		

		//Current

		util.setCurrentFormat(Sizzle('body')[0].id);

		

		//Return To Top Button

		function setupReturnToTop() {

			var returnToTop;

			returnToTop = document.getElementById('return-to-top-button');

			

			util.addEventListener(window, 'scroll', function() {

				var offset = window.pageYOffset ? window.pageYOffset : (document.body.scrollTop || document.documentElement.scrollTop);

				if (offset < 100) {

					util.fadeOut(returnToTop, 400);

				} else {

					util.fadeIn(returnToTop, 400);

				}

			});

			util.addEventListener(returnToTop, 'click', function() {

				var offset = window.pageYOffset ? window.pageYOffset : (document.body.scrollTop || document.documentElement.scrollTop);

				if (offset !== 0) {

					util.scrollToTop(window, [0, 0]);

				}

			});

			

			if (ua.ps3) {

				document.getElementById('return-to-top-button').style.opacity = 1;

				document.getElementById('return-to-top-button').style.visibility = 'visible';

			}

			

		}

		setupReturnToTop();

		

		/**

		* コンテンツ内部 ゲームタイトル検索のセットアップ

		*/

		function setupSearchBox() {

			var txt = document.getElementById('search-query'),

				submitbutton = document.getElementById('search-submit'),

				defaultTxt = 'お探しのゲームに関するキーワードを入力してください。';

			

			if (!txt || !submitbutton) {

				return;

			}

			util.addEventListener(txt, 'focus', function() {

				if (txt.value === defaultTxt) {

					txt.value = '';

				}

			});

			util.addEventListener(txt, 'blur', function() {

				if (txt.value === '' || txt.value.match(/\s+/)) {

					txt.value = defaultTxt;

				}

			});

			util.addEventListener(submitbutton, 'click', function() {

				if (txt.value === defaultTxt) {

					txt.value = '';

				}

				txt.value = util.escapeHTML(txt.value);

				return false;

			});

			

			util.addEventListener(Sizzle('#menu-search-submit')[0], 'click', function() {

				var globalsearch = document.getElementById('menu-search-query');

				globalsearch.value = util.escapeHTML(globalsearch.value);

			});

		}

		setupSearchBox();

		

		/**

		* Contents Banner ・ Bottom Banner

		*/

		if (ua.ie) {

			util.setBannerBorder(Sizzle('#bottom-banners li'));

			util.setBannerBorder(Sizzle('#content-banner-wrapper li'));

		}

		

		/**

		* Open window for Regacy code on Global

		*/

		if (__global) {

			__global.openWindow = function(url, w, h) {

				window.open(url, "SCEPopupWindow", "width=" + (w || 400) + ",height=" + (h || 300));

			};

		}

		

		window.mboxOnClick = function(myMbox, clickedOnValue, myLocation, target) {

			if (target === '_blank') {

				window.open(myLocation);

			} else {

				setTimeout(function(){

					location.href = myLocation;

				},500);

			}

			mboxUpdate(myMbox, 'clickedOn=' + clickedOnValue);

		};



	});

}());



/**

* SCE_APP

* @module sceApp

* dependence on Sizzle.js

*/



var SCE_APP = SCE_APP || {};



/**

* @namespace SCE_APP

* @class GlobalMenu

*/

SCE_APP.GlobalMuen = (function() {

	/* ------------------------------------------------------------

	* private static

	* ------------------------------------------------------------*/

	var _menus = [],

		_isInit = false;

	

	/* ------------------------------------------------------------

	* private Method

	* ------------------------------------------------------------*/

	/**

	* 指定のオブジェクトを覗いたサブメニューの非表示

	* @param without {Object} 非表示させないDOMオブジェクト

	*/

	function hideSubMenuWithout(without) {

		var i, len, node;

		for (i = 0, len = _menus.length; i < len; ++i) {

			node = _menus[i];

			if (node.subMenu) {

				if (without && node.menu.id === without.id) {

					node.a.className = 'on';

					node.subMenu.style.display = 'block';

				} else {

					node.a.className = '';

					node.subMenu.style.display = 'none';

				}

			}

		}

	}

	

	/**

	* メニュー作成

	*/

	function createMenu() {

		var list = ['menu-home', 'menu-ps3', 'menu-vita', 'menu-psp', 'menu-psn', 'menu-psc', 'menu-search'],

			subList = ['', 'sub-menu-ps3', 'sub-menu-vita', 'sub-menu-psp', 'sub-menu-psn', 'sub-menu-psc', ''],

			i,

			len,

			menu, submenu,

			util = SCE_APP.Utility;

			

		for (i = 0, len = list.length; i < len; ++i) {

			menu = document.getElementById(list[i]);

			submenu = document.getElementById(subList[i]) || null;

			_menus[_menus.length] = {

				menu: menu,

				a: Sizzle('a:first', menu)[0],

				subMenu: submenu

			};

			

			util.addEventListener(menu, 'mouseover', function(_i) {

				return function(e) {

					hideSubMenuWithout(_menus[_i].menu);

				};

			}(i));

			

			util.addEventListener(menu, 'mouseout', function() {

				hideSubMenuWithout();

			});

		}

	}

	

	/**
	* メニュー部検索BOXセットアップ
	*/
	function setupMenuSearch() {
		var searchButton,
			searchArea,
			searchRadioSite,
			searchRadioSoft,
			searchCheckQA,
			searchWrap,
			siteLabel,
			softLabel,
			qaLabel,
			searchGroup,
			searchRight, _isSearch = false;
			
		searchButton = document.getElementById('menu-search-button');
		searchArea = document.getElementById('sub-menu-search');
		searchRadioSoft = document.getElementById('menu-search-soft');
		searchRadioSite = document.getElementById('menu-search-site');
		searchCheckQA = document.getElementById('menu-search-qa');
		searchWrap = document.getElementById('menu-search-wrap');
		searchRight = document.getElementById('menu-search-right');
		siteLabel = document.getElementById('menu-search-site-label');
		softLabel = document.getElementById('menu-search-soft-label');
		qaLabel = document.getElementById('menu-search-qa-label');
		searchGroup = document.getElementById('menu-search-group');

		/**
		 * サイト内検索クリック時
		 */
		util.addEventListener([siteLabel, searchRadioSite], 'click', function() {
			setTimeout(function() {
				siteLabelClicked();
			}, 200);
		});

		function siteLabelClicked() {
			searchCheckQA.disabled = false;
			searchGroup.value = 0;
			util.addClassName(siteLabel, 'on');
			util.removeClassName(softLabel, 'on');
			util.removeClassName(qaLabel, 'qadisable');
		}

		/**
		 * ゲームタイトル検索クリック時
		 */
		util.addEventListener([searchRight, searchRadioSoft], 'mouseup', function() {
			setTimeout(function() {
				searchCheckQA.checked = false;
				searchCheckQA.disabled = true;
				searchGroup.value = 1;
				util.removeClassName(qaLabel, 'qaon');
				util.removeClassName(qaLabel, 'qaoff');
				util.addClassName(qaLabel, 'qadisable');
				util.addClassName(softLabel, 'on');
				util.removeClassName(siteLabel, 'on');
			}, 100);
		});

		/**
		 * QAチェンジ時
		 */
		util.addEventListener([qaLabel, searchCheckQA], 'click', function() {
			if (softLabel.className) {
				siteLabelClicked();
				searchRadioSite.select();
				searchRadioSite.checked = true;
			}
			setTimeout(function() {
				changeQAcheck();
			}, 200);
		});

		function changeQAcheck() {
			var checked = searchCheckQA.checked;
			if (checked) {
				util.removeClassName(qaLabel, 'qaoff');
				util.addClassName(qaLabel, 'qaon');
			} else {
				util.addClassName(qaLabel, 'qaoff');
				util.removeClassName(qaLabel, 'qaon');
			}
		}
		changeQAcheck();
		
		util.addEventListener(searchButton, 'click', function() {
			var searchbox = document.getElementById('sub-menu-search'),
				onDocumentClicked, onSearchClicked;
				
			if (!_isSearch) {
				searchButton.className = 'on';
				util.setOpacityZero(searchArea);
				util.fadeIn(searchArea, 100);
				
				onDocumentClicked = function() {
					if (_isSearch) {
						searchButton.className = '';
						_isSearch = false;
						util.fadeOut(searchArea, 100);
						util.removeEventListener(searchbox, 'click', onSearchClicked);
						util.removeEventListener(document, 'click', onDocumentClicked);
					}
				};
				
				onSearchClicked = function() {
					_isSearch = false;
					setTimeout(function() {
						_isSearch = true;
					}, 100);
				};
				
				setTimeout(function() {
					util.addEventListener(document, 'click', onDocumentClicked);
					util.addEventListener(searchbox, 'click', onSearchClicked);
				}, 200);
				_isSearch = true;
			}
		});
	}
	
	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	var exports = function() {}

		, util = SCE_APP.Utility;

	

	/**

	* 初期化

	* @method

	*/

	exports.init = function() {

		if (_isInit) {

			return;

		}

		createMenu();

		setupMenuSearch();

		_isInit = true;

	};

	

	util.addEventListener(window, 'load', function() {

		exports.init();

	});

	return exports;

}());

/**

* Billboardエリア

* @namespace SCE_APP

* @class Billboard

*/



SCE_APP.Billboard = (function() {

	var util = SCE_APP.Utility,

		AUTO_TIME,

		FILE_PATH = SCE_APP.Config.DATA_PATH,

		_target, _main,

		exports,

		billboards,

		_current = 0, _max,

		isMOver = false,

		intervalID;

	/* ------------------------------------------------------------

	* Private Method

	* ------------------------------------------------------------*/

	/**

	* 「SCEJからの重要なお知らせ」表示制御

	*/

	function setupImportant() {

		var tag = document.getElementById('most-important-type-b') || document.getElementById('most-important-survey-type-b'),

			closeButton = document.getElementById('most-important-submit-button'),

			unvisibleCheck = document.getElementById('most-important-type-b-check'),

			newsDate;

		

		if (tag && closeButton) {

			newsDate = Sizzle('#most-important-date')[0].childNodes[0].nodeValue;

			if (util.getCookie('c' + newsDate) === '1') {

				tag.style.display = 'none';

			} else {

				tag.style.display = 'block';

			}

			util.addEventListener(closeButton, 'click', function() {

				if (unvisibleCheck.checked) {

					util.setCookie('c' + newsDate, 1);

				}

				tag.style.display = 'none';

			});

		}

	}

	

	/**

	* Billboard設定

	*/

	function setup() {

		var _left, _right, _la, _ra,

			ua = util.getUseragent();

		

		_left = document.getElementById('billboard-left');

		_right = document.getElementById('billboard-right');

		_la = Sizzle('a', _left)[0];

		_ra = Sizzle('a', _right)[0];

		_main = document.getElementById('billboard-contents');

		if (billboards.length <= 1) {

			_left.style.display = 'none';

			_right.style.display = 'none';

			return;

		}

		

		if (ua.smartphone || ua.vita) {

			_left.className += ' bilborard-button-smartphone-l';

			_right.className += ' bilborard-button-smartphone-r';

			_left.style.opacity = 1;

			_right.style.opacity = 1;

		} else {

			util.addEventListener([_la, _left, _ra, _right], 'mousemove', function(evt) {

				var ev = evt || window.event;

				util.cancelEvent(ev);

				util.fadeIn(_left, 200);

				util.fadeIn(_right, 200);

				isMOver = true;

			});

			util.addEventListener(_main, 'mousemove', function(evt) {

				var ev = evt || window.event,

					_util = SCE_APP.Utility;

				

				isMOver = true;

				_util.fadeIn(_left, 200);

				_util.fadeIn(_right, 200);

				_util.cancelEvent(ev);

			});

			

			util.addEventListener(document, 'mousemove', function() {

				util.fadeOut(_left, 100, null, false);

				util.fadeOut(_right, 100, null, false);

				isMOver = false;

			});

		}

		util.addEventListener([_ra, _right], 'click', function(e) {

			resetTimer();

			pagingBillboard(true);

			util.cancelEvent(e);

		});

		util.addEventListener([_la, _left], 'click', function(e) {

			resetTimer();

			pagingBillboard(false);

			util.cancelEvent(e);

		});

		autoPlay();

	}

	

	/**

	* Billboardのページング

	* @param isNext {Boolean} 次のページかの真偽

	*/

	function pagingBillboard(isNext) {

		if (isNext) {

			_current = _current === _max ? 0 : _current + 1;

		} else {

			_current = _current === 0 ? _max : _current - 1;

		}

		util.setCookie('top', _current, true);

		changeBillboard();

	}

	

	/**

	* Billboardの内容変更

	*/

	function changeBillboard() {

		util.fadeOut(_main, 60, function() {

			setTimeout( function() {

				drawBillboard();

				changeIndicator();

			}, 100);

		});

	}

	

	

	/**

	* Billboard描画

	*/

	function drawBillboard() {

		var target, _img, _a, current = billboards[_current],

			_onclick;

		

		target = document.getElementById('billboard-contents');

		if (!target) {

			return;

		}

		_a = document.createElement('a');

		_a.href = "javascript:s.eVar43=s.getBannerFirstCat();s.linkTrackVars = 'eVar43,eVar44,events';s.events=s.linkTrackEvents='event39';s.eVar43 += 'main:' + '" + current.alt + "';s.eVar44='D=v43';s.tl(this,'o','click main banner'); window.mboxOnClick('Top_Mainvisual_01', '" + current.image + "', '" + current.url + "', '" + current.window +"');";
		

		if (util.getUseragent().ps3) {

			_a.className = 'no-border';

		}

		_img = new Image();

		_img.src = current.image;

		_img.alt = current.alt;

		util.clearNode(target);

		target.appendChild(_a);

		target.appendChild(_img);

		util.setOpacityZero(target);

		util.fadeIn(target, 640);

	}

	

	

	/**

	* インジケーター描画

	*/

	function drawIndicator() {

		var i, len, container,

			li, _a, fragment, _w;

		

		container = document.getElementById('billboard-indicator');

		if (!container) {

			return;

		}

		fragment = document.createDocumentFragment();

		len = billboards.length;

		for (i = 0; i < len; ++i) {

			li = document.createElement('li');

			_a = document.createElement('a');

			if (i === _current) {

				_a.className = 'on';

			}

			li.appendChild(_a);

			fragment.appendChild(li);

		}

		_w = (len * 18);

		container.style.width = _w + 'px';

		container.style.left = (430 - _w * .5) + 'px';

		container.appendChild(fragment);

	}

	

	/**

	* インジケーター変更

	*/

	function changeIndicator() {

		var i, len, lists = Sizzle('#billboard-indicator a');

		for (i = 0, len = lists.length; i < len; ++i) {

			lists[i].className = '';

			if (i === _current) {

				lists[i].className = 'on';

			}

		}

	}

	

	/**

	* 自動再生

	*/

	function autoPlay() {

		if (SCE_APP.Utility.getUseragent().ps3) return;

		if (!intervalID) {

			if (Number(AUTO_TIME) === 0) return;

			intervalID = setInterval(function() {

				if (isMOver) {

					return;

				}

				pagingBillboard(true);

			}, AUTO_TIME)

		}

	}

	/**

	* 自動再生のリセット

	*/

	function resetTimer() {

		clearInterval(intervalID);

		intervalID = null;

		autoPlay();

	}

	

	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	exports = function() {

		

	};

	/**

	* IDを指定して初期化

	* @method

	* @param id_ {String}

	*/

	exports.prototype.initWithId = function(id_) {

		AUTO_TIME = (__global.AUTOPLAY_TIME) ? __global.AUTOPLAY_TIME * 1000 : 8000;

		_target = document.getElementById(id_);

	};

	

	/**

	* ローディング描画

	*/

	exports.prototype.drawLoading = function() {

		var target, _img;

		target = document.getElementById('billboard-contents');

		if (!target) {

			return;

		}

		

		_img = new Image();

		_img.id = "billboard-loading";

		_img.src = '/common/img/loading_l.gif';

		_img.alt = 'LOADING';

		target.appendChild(_img);

	};

	

	/**

	* 「SCEJからの重要なお知らせ」表示制御

	* @method

	*/

	exports.prototype.setupImportant = setupImportant;

	

	/**

	* ビルボード取得

	* @return {Array}

	*/

	exports.prototype.getBillboads = function() {

		return billboards;

	};

	

	/**

	* Billboard data の読み込み

	* @param format {String}

	* @param callback {Function} コールバック関数

	*/

	exports.prototype.loadBillboard = function(format, callback) {

		var file;

		if (!format) {

			return false;

		}

		file = Sizzle('#billboard-files li')[0];

		if (!file) {

			return;

		}

		

		_current = util.getCookie('top') || 0;

		_current = parseInt(_current);

		this.drawLoading();

		file = file.childNodes[0].nodeValue;

		util.getJSON(FILE_PATH + file,

			function(data) {

				billboards = json_parse(data).items;

				_max = billboards.length - 1;

				drawBillboard();

				drawIndicator();

				setup();

				if (callback) {

					callback.apply();

				}

			});

	};

	

	return exports;

}());





/**

* Pusharea for Formattop

* @namespace SCE_APP.Billboard

* @class PushArea

*/

SCE_APP.Billboard.PushArea = (function() {

	var _super = SCE_APP.Billboard,

		exports = function() {};

		

	var util = SCE_APP.Utility,

		BOARD_WIDTH = 850,

		AUTO_TIME,

		FILE_PATH = SCE_APP.Config.DATA_PATH,

		_main, _wrapper,

		billboards,

		files, _format,

		_current = 0, _max, _count = 0,

		isMOver = false,

		intervalID,

		mboxtype = {

			'ps3': 'Top_Mainvisual_02',

			'psv': 'Top_Mainvisual_03',

			'psp': 'Top_Mainvisual_04'

		};

		

	for (var i in _super.prototype) {

		exports.prototype[i] = _super.prototype[i];

	}

	_super = new exports();

	

	/* ------------------------------------------------------------

	* Private

	* ------------------------------------------------------------*/

	

	/**

	* Billboard描画

	* @param bbObject {Object}

	*/

	function drawBillboard(bbObject) {

		_count++;

		if (!_wrapper) {

			return;

		}

		switch(bbObject.type) {

			case 'A':

				files[bbObject.index].contents = drawTypeA(bbObject.billboards);

				break;

			case 'B':

				files[bbObject.index].contents = drawTypeB(bbObject.billboards);

				break;

			case 'C':

				files[bbObject.index].contents = drawTypeC(bbObject.billboards);

				break;

			case 'D':

				files[bbObject.index].contents = drawTypeD(bbObject.billboards);

				break;

			default:

				files[bbObject.index].contents = drawTypeA();

				break;

		}

		checkMax();

	}

	

	function checkMax() {

		var i, len;

		if (_count > _max) {

			files = util.arrayGC(files);

			len = files.length;

			_max = files.length - 1;

			_wrapper.style.width = (files.length * BOARD_WIDTH) + 'px';

			for (i = 0; i < len; ++i) {

				if (files[i] && files[i].contents) {

					files[i].contents.style.left = i * BOARD_WIDTH + 'px';

					_wrapper.appendChild(files[i].contents);

				}

			}

			util.setOpacityZero(_wrapper);

			changeBillboard(true);

			util.fadeIn(_wrapper, 400);

			setup();

			if (util.getUseragent().ie) {

				util.setBannerBorder(Sizzle('#billboard-contents-wrap li'));

			}

		}

	}

	

	/**

	* 単発画像ビルボード作成

	* @param billboards_ {Array} ビルボード内のパネルリスト

	*/

	function drawTypeA(billboards_) {

		var _ul, _li, _img, _a, item,

			_onclick;

		if (billboards_) {

			item = billboards_[0];

		}

		_ul = document.createElement('ul');

		_li = document.createElement('li');

		_li.className = 'billboard-type-a';

		_a = document.createElement('a');

		_a.href = "javascript:s.eVar43=s.getBannerFirstCat();s.linkTrackVars = 'eVar43,eVar44,events';s.events=s.linkTrackEvents='event39';s.eVar43 += 'main:' + '" + item.alt + "';s.eVar44='D=v43';s.tl(this,'o','click main banner'); mboxOnClick('" + mboxtype[_format] + "', '" + item.image + "', '" + item.url + "', '" + item.window + "');";


		if (util.getUseragent().ps3) {

			_a.className = 'no-border-a';

		}

		_img = new Image();

		_img.src = item.image;

		_img.alt = item.alt;

		

		_li.appendChild(_a);

		_li.appendChild(_img);

		_ul.appendChild(_li);

		return _ul;

	}

	

	/**

	* 6面サムネイルビルボード作成

	* @param billboards_ {Array} ビルボード内のパネルリスト

	*/

	function drawTypeB(billboards_) {

		var fragment, _ul, _li, _img, _a, item,

			i, len, _onclick;

		

		_ul = document.createElement('ul');

		_ul.className = 'clearfix';

		fragment = document.createDocumentFragment();

		for (i = 0, len = billboards_.length; i < len; ++i) {

			item = billboards_[i];

			_li = document.createElement('li');

			if (i % 3 === 2) {

				_li.className = 'billboard-type-br';

			} else {

				_li.className = 'billboard-type-b';

			}

			

			_a = document.createElement('a');

			_a.href = "javascript:s.eVar43=s.getBannerFirstCat();s.linkTrackVars = 'eVar43,eVar44,events';s.events=s.linkTrackEvents='event39';s.eVar43 += 'main:' + '" + item.alt + "';s.eVar44='D=v43';s.tl(this,'o','click main banner'); mboxOnClick('" + mboxtype[_format] + "', '" + item.image + "', '" + item.url + "', '" + item.window + "');";
			

			_img = new Image();

			_img.src = item.image;

			_img.alt = item.alt;

			if (util.getUseragent().ps3) {

				_a.className = 'no-border';

			}

			_li.appendChild(_a);

			_li.appendChild(_img);

			fragment.appendChild(_li);

		}

		_ul.appendChild(fragment);

		return _ul;

	}

	

	/**

	* 3面サムネイルビルボード作成

	* @param billboards_ {Array} ビルボード内のパネルリスト

	*/

	function drawTypeC(billboards_) {

		var fragment, _ul, _li, _img, _a, item,

			i, len;

		

		_ul = document.createElement('ul');

		fragment = document.createDocumentFragment();

		for (i = 0, len = billboards_.length; i < len; ++i) {

			item = billboards_[i];

			_li = document.createElement('li');

			if (i === 0) {

				_li.className = 'billboard-type-cl';

			} else {

				_li.className = 'billboard-type-c';

			}

			

			_a = document.createElement('a');

			_a.href = "javascript:s.eVar43=s.getBannerFirstCat();s.linkTrackVars = 'eVar43,eVar44,events';s.events=s.linkTrackEvents='event39';s.eVar43 += 'main:' + '" + item.alt + "';s.eVar44='D=v43';s.tl(this,'o','click main banner'); mboxOnClick('" + mboxtype[_format] + "', '" + item.image + "', '" + item.url + "', '" + item.window + "');";
			

			_img = new Image();

			_img.src = item.image;

			_img.alt = item.alt;

			_a.appendChild(_img);

			if (util.getUseragent().ps3) {

				_a.className = 'no-border';

			}

			_li.appendChild(_a);

			_li.appendChild(_img);

			fragment.appendChild(_li);

		}

		_ul.appendChild(fragment);

		return _ul;

	}

	

	/**

	* 3面逆サムネイルビルボード作成

	* @param billboards_ {Array} ビルボード内のパネルリスト

	*/

	function drawTypeD(billboards_) {

		var fragment, _ul, _li, _img, _a, item,

			i, len, list = [], _onclick;

		

		_ul = document.createElement('ul');

		fragment = document.createDocumentFragment();

		for (i = 0, len = billboards_.length; i < len; ++i) {

			item = billboards_[i];

			_li = document.createElement('li');

			if (i === 2) {

				_li.className = 'billboard-type-dr';

			} else {

				_li.className = 'billboard-type-d';

			}

			

			_a = document.createElement('a');

			_a.href = "javascript:s.eVar43=s.getBannerFirstCat();s.linkTrackVars = 'eVar43,eVar44,events';s.events=s.linkTrackEvents='event39';s.eVar43 += 'main:' + '" + item.alt + "';s.eVar44='D=v43';s.tl(this,'o','click main banner'); mboxOnClick('" + mboxtype[_format] + "', '" + item.image + "', '" + item.url + "', '" + item.window + "');";
			

			_img = new Image();

			_img.src = item.image;

			_img.alt = item.alt;

			_a.appendChild(_img);

			if (util.getUseragent().ps3) {

				_a.className = 'no-border';

			}

			_li.appendChild(_a);

			_li.appendChild(_img);

			if (i === 2) {

				list.unshift(_li);

			} else {

				list.push(_li);

			}

			//fragment.appendChild(_li);

		}

		for (i = 0; i < len; ++i) {

			fragment.appendChild(list[i]);

		}

		_ul.appendChild(fragment);

		return _ul;

	}

	

	/**

	* Billboard設定

	*/

	function setup() {

		var _left, _right, _la, _ra,

			ua = util.getUseragent(),

			i,

			c = 0,

			len = files.length,

			area;

		

		_left = document.getElementById('billboard-left');

		_right = document.getElementById('billboard-right');

		_la = Sizzle('a', _left)[0];

		_ra = Sizzle('a', _right)[0];

		_main = document.getElementById('billboard-contents');

		if (util.getUseragent().ps3) {

			_left.style.opacity = 1;

			_right.style.opacity = 1;

			_left.className += ' ps3browser';

			_right.className += ' ps3browser';

		}

		for (i = 0; i < len; i += 1) {

			if (files[i].contents) {

				c += 1;

			}

		}

		

		if (c <= 1) {

			_left.style.display = 'none';

			_right.style.display = 'none';

			if (c === 0) {

				area = document.getElementById('push-area');

				if (area) {

					area.style.display = 'none';

				}

			}

			return;

		}

		

		if (ua.smartphone || ua.vita) {

			_left.className += ' bilborard-button-smartphone-l';

			_right.className += ' bilborard-button-smartphone-r';

			_left.style.opacity = 1;

			_right.style.opacity = 1;

		} else {

			util.addEventListener([_la, _left, _ra, _right], 'mousemove', function(evt) {

				var ev = evt || window.event;

				util.cancelEvent(ev);

				util.fadeIn(_left, 200);

				util.fadeIn(_right, 200);

				isMOver = true;

			});

			util.addEventListener(_main, 'mousemove', function(evt) {

				var ev = evt || window.event;

				isMOver = true;

				util.fadeIn(_left, 200);

				util.fadeIn(_right, 200);

				util.cancelEvent(ev);

			});

			

			util.addEventListener(document, 'mousemove', function() {

				util.fadeOut(_left, 100, null, false);

				util.fadeOut(_right, 100, null, false);

				isMOver = false;

			});

		}

		

		util.addEventListener([_ra, _right], 'click', function(e) {

			pagingBillboard(true);

			resetTimer();

			util.cancelEvent(e);

		});

		util.addEventListener([_la, _left], 'click', function(e) {

			pagingBillboard(false);

			resetTimer();

			util.cancelEvent(e);

		});

		autoPlay();

	}

	

	/**

	* Billboardのページング

	* @param isNext {Boolean} 次のページかの真偽

	*/

	function pagingBillboard(isNext) {

		if (isNext) {

			if (_current === _max) {

				_current = 0;

				isNext = !isNext;

			} else {

				_current = _current + 1;

			}

		} else {

			if (_current === 0) {

				_current = _max;

				isNext = !isNext;

			} else {

				_current = _current - 1;

			}

		}

		util.setCookie(_format, _current, true);

		changeBillboard(isNext);

	}

	

	/**

	* Billboardの内容変更

	*/

	function changeBillboard(isNext) {

		var i, len = files.length;

		if (_current > _max) {

			_current = 0;

		}

		for (i = 0; i < len; ++i) {

			if (files[i].contents) {

				files[i].contents.style.display = 'block';

			}

		}

		

		util.slideTo(_wrapper, [-(_current * BOARD_WIDTH), 0, !isNext], null, function() {

			for (i = 0; i < len; ++i) {

				if (i !== _current) {

					files[i].contents.style.display = 'none';

				}

			}

		});

	}

	

	/**

	* ビルボード表示用ファイルの取得

	* @return {Array}

	*/

	function getBillboardFiles() {

		var i, len, lists, result = [],

			target, _div;

		target = document.getElementById('billboard-contents');

		if (!target) {

			return false;

		}

		target.className = 'clearfix';

		_div = document.createElement('div');

		_div.id = 'billboard-contents-wrap';

		lists = Sizzle('#billboard-files li');

		_div.style.width = (lists.length * BOARD_WIDTH) + 'px';

		for (i = 0, len = lists.length; i < len; ++i) {

			result[result.length] = {

				path: lists[i].childNodes[0].nodeValue,

				index: i

			}

		}

		util.clearNode(target);

		target.appendChild(_div);

		return result;

	}

	

	/**

	* ビルボードの読み込み

	* @param format {String} 読み込むフォーマット

	*/

	function loadBillboard(format) {

		var i, len, target = document.getElementById('billboard-contents');

		

		if (!format) {

			return false;

		}

		_format = format;

		if (!files) {

			return false;

		}

		_current = util.getCookie(_format) || 0;

		_current = parseInt(_current);

		_super.drawLoading();

		_wrapper = document.getElementById('billboard-contents-wrap');

		for (i = 0, len = files.length; i < len; ++i) {

			util.getJSON(FILE_PATH + files[i].path,

				function(i) {

					return function(data) {

						var parsed = json_parse(data),

							loader = document.getElementById('billboard-loading');

						

						if (loader) {

							target.removeChild(loader);

						}

						files[i].type = parsed.type;

						files[i].billboards = parsed.items;

						billboards = parsed.items;

						drawBillboard(files[i]);

					}

				}(i)

				, function(i) {

					return function() {

						_count++;

						delete files[i];

						checkMax();

					}

				}(i));

		}

		return false;

	}

	

	/**

	* 自動再生

	*/

	function autoPlay() {

		if (SCE_APP.Utility.getUseragent().ps3) {

			return;

		}

		if (!intervalID) {

			if (Number(AUTO_TIME) === 0) return;

			intervalID = setInterval(function() {

				if (isMOver) {

					return;

				}

				pagingBillboard(true);

			}, AUTO_TIME)

		}

	}

	

	/**

	* 自動再生のリセット

	*/

	function resetTimer() {

		clearInterval(intervalID);

		intervalID = null;

		autoPlay();

	}

	

	/* ------------------------------------------------------------

	* Exports Override

	* ------------------------------------------------------------*/

	/**

	* 初期化

	* @method

	*/

	exports.prototype.init = function() {

		AUTO_TIME = (__global.AUTOPLAY_TIME) ? __global.AUTOPLAY_TIME * 1000 : 8000;

		files = getBillboardFiles();

		if (!files) return;

		_max = files.length - 1;

	};

	

	/**

	* ビルボード読み込み

	*/

	exports.prototype.loadBillboard = loadBillboard;

	return exports;

}());



/**

* 新着ゲームタイトル エリア

* @namespace SCE_APP

* @class Lineup

*/



SCE_APP.Lineup = (function() {

	var _maxNum,

		_delegate,

		_formats = [];

	/* ------------------------------------------------------------

	* Private Method

	* ------------------------------------------------------------*/

	/**

	* ボタンイベントの追加

	*/

	function addButtonListeners() {

		var prev, next,

			util = SCE_APP.Utility,

			formatObject,

			i, len = _formats.length;

			

		for (i = 0; i < len; ++i) {

			formatObject = _formats[i];

			prev = Sizzle('a', document.getElementById(formatObject.prev))[0];

			next = Sizzle('a', document.getElementById(formatObject.next))[0];

			util.addEventListener(prev, 'click', function(i) {

				return function(evt) {

					var event = evt || window.event,

						index = i,

						format = _formats[index];

					if (format.page === 0) {

						return;

					}

					format.page--;

					changePage(format);

					changeButtonClass(format);

				}

			}(i));

			util.addEventListener(next, 'click', function(i) {

				return function(evt) {

					var event = evt || window.event,

						index = i,

						format = _formats[index];

					if (format.page >= format.maxPage - 1) {

						return;

					}

					format.page++;

					changePage(format);

					changeButtonClass(format);

				}

			}(i));

			changeButtonClass(formatObject);

		}

	}

	

	/**

	* 表示中のラインナップを再描画する

	* @param formatObject {Object} フォーマットオブジェクト

	* @param callback {Function} コールバック関数

	*/

	function changePage(formatObject, callback) {

		var util = SCE_APP.Utility;

		util.getJSON(SCE_APP.Config.DATA_PATH + formatObject.files[formatObject.page],

			function(data) {

				var json = json_parse(data);

				updateFormats();

				if (callback) {

					callback.apply(this, [json, formatObject.name]);

				} else if (_delegate && _delegate.afterChangePage) {

					_delegate.afterChangePage(json, formatObject.name, _maxNum);

				}

			},

			function() {

				if (callback) {

					callback.apply(this, [null, formatObject.name]);

				} else if (_delegate && _delegate.afterChangePage) {

					_delegate.afterChangePage(null, formatObject.name, _maxNum);

				}

			}

		);

	}

	

	/**

	*

	*/

	function updateFormats() {

		var i, len = _formats.length, _format, query = ''

			, util = SCE_APP.Utility;

			

		for (i = 0; i < len; ++i) {

			_format = _formats[i];

			query += _format.page;

			if (i !== len - 1) {

				query += '_';

			}

		}

		util.setCookie('lineup', query, false);

		

	}

	

	/**

	* next/prevボタンのクラス変更

	* @param formatObject {Object} フォーマットオブジェクト

	*/

	function changeButtonClass(formatObject) {

		var prev = Sizzle('a', document.getElementById(formatObject.prev))[0]

			, next = Sizzle('a', document.getElementById(formatObject.next))[0];

		if (Number(formatObject.page) === 0) {

			prev.className = 'none';

		} else {

			prev.className = '';

		}

		

		if (formatObject.page >= formatObject.maxPage - 1) {

			next.className = 'none';

		} else {

			next.className = '';

		}

	}

	

	/**

	* 最大ページ数の取得

	* @param format {String} フォーマット

	* return {Number}

	*/

	function getMaxPage(format) {

		return Sizzle('#lineup-' + format + '-wrap li').length;

	}

	

	/**

	* ファイルリストを取得

	* @param format {String} フォーマット

	* return {Array}

	*/

	function getPageFiles(format) {

		var li = Sizzle('#lineup-' + format + '-wrap li'),

			i, len = li.length, result = [], _li;

		for (i = 0; i < len; ++i) {

			_li = li[i];

			if (!_li) {

				continue;

			}

			result[result.length] = _li.childNodes[0].nodeValue;

		}

		return result;

	}

	

	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	var exports = function() {};

	

	/**

	* maxNum設定

	* @method

	* @param maxNum {Number} ラインナップ表示上限数

	*/

	exports.prototype.setMaxNum = function(maxNum) {

		_maxNum = maxNum;

	};

	

	/**

	* maxNum取得

	* @method

	* @return {Number} ラインナップ表示上限数

	*/

	exports.prototype.getMaxNum = function() {

		return _maxNum;

	};

	

	/**

	* 設定

	*/

	exports.prototype.setup = function() {

		addButtonListeners();

	};

	

	/**

	* ラインナップの読み込み

	* @param format {String} 読み込む対象のフォーマット

	* @param callback {Function} コールバック

	* @param page {Number} 読み込むデータのページング

	*/

	exports.prototype.loadLineupWithFormat = function(format, callback, page) {

		var formatObject

			, _max;

		if (!format) {

			return false;

		}

		_max = getMaxPage(format);

		if (!page || page === '_') {

			page = 0;

		}

		formatObject = {

			name: format,

			page: page > _max ? 0 : page,

			maxPage: _max,

			files: getPageFiles(format),

			prev: 'lineup-' + format + '-prev',

			next: 'lineup-' + format + '-next'

		};

		_formats[_formats.length] = formatObject;

		changePage(formatObject, callback);

	};

	

	/**

	* 委譲オブジェクトの設定

	*/

	exports.prototype.setDelegate = function($d) {

		_delegate = $d;

	};

	

	return exports;

}());

/**

* SCE_APP

* @module sceApp

*/



/**

* index view controller

*/

SCE_APP.IndexView = (function() {

	var _delegate;

	/* ------------------------------------------------------------

	* Private Method

	* ------------------------------------------------------------*/

	function clearLineup($ul) {

		var i, len = $ul.children.length,

			li;

			

			

		for (i = 0; i < len; ++i) {

			li = $ul.children[0];

			if (li) {

				$ul.removeChild(li);

				li = null;

			}

		}

	}

	

	/**

	* 画像読み込み後

	*/

	function afterImageLoaded() {

		--_imageLength;

		if (_imageLength === 0) {

			if (_delegate && _delegate.afterImagesLoaded) {

				_delegate.afterImagesLoaded.apply(this);

			}

		}

	}

	

	

	function createLineupTitle(item, isLast) {

		var _li, _a, _wrap, _img, _title, _genre, _onsale, _div

			, util = SCE_APP.Utility;

		_li = document.createElement('li');

		_li.className = isLast ? 'clearfix last' : 'clearfix';

		

		_a = document.createElement('a');

		_a.href = item.link;

		_a.appendChild(document.createTextNode(item.title));

		

		_wrap = document.createElement('div');

		_wrap.className = 'title-wrap clearfix';

		

		_img = new Image();

		_img.src = item.image;

		_img.style.visibility = 'hidden';

		util.addEventListener(_img, 'load', adjustImage);

		//_img.onload = adjustImage;

		

		_title = document.createElement('p');

		_title.className = 'game-title';

		_title.innerHTML = item.title;

		

		_genre = document.createElement('p');

		_genre.className = 'genre';

		_genre.appendChild(document.createTextNode(item.genre));

		

		_onsale = document.createElement('p');

		_onsale.className = 'onsale';

		_onsale.appendChild(document.createTextNode(item.onsale));

		

		_div = document.createElement('div');

		_div.className = 'wrap-right';

		_div.appendChild(_title);

		_div.appendChild(_genre);

		_div.appendChild(_onsale);

		

		_wrap.appendChild(_img);

		_wrap.appendChild(_div);

		/*

		_wrap.appendChild(_title);

		_wrap.appendChild(_genre);

		_wrap.appendChild(_onsale);

		*/

		// for IE6

		var dummy = document.createElement('span');

		dummy.style.fontSize = 0;

		dummy.style.height = 0;

		dummy.innerHTML = '&nbsp;';

		_div.appendChild(dummy);

		

		_li.style.visibility = 'visible';

		_li.appendChild(_a);

		_li.appendChild(_wrap);

		

		/**

		* 画像サイズ

		*/

		function adjustImage() {

			var w, h, hi, leftmargin = 0, margin;

			if (_img.width === 0 && _img.height === 0) {

				setTimeout(function() {

					adjustImage();

				}, 100);

				return;

			}

			w = _img.width;

			h = _img.height;

			hi = 78 / w;

			if (w < 78) {

				if (h > 90) {

					hi = 90 / h;

					w = Math.round(w * hi);

					h = 90;

				}

				margin = Math.floor((88 - w) * .5);

				if (margin - 12 > 0) {

					leftmargin = (margin - 12) * .5;

				}

				_img.style.marginLeft = margin - leftmargin + 'px';

				_img.style.marginRight = margin + leftmargin + 'px';

			} else {

				w = 78;

				h = Math.round(h * hi);

			}

			

			_img.style.width = w + 'px';

			_img.style.height = h + 'px';

			_img.style.visibility = 'visible';

			util.removeEventListener(_img, 'load', adjustImage);

			afterImageLoaded();

		}

		

		return _li;

	}

	

	/* ------------------------------------------------------------

	* Exports

	* ------------------------------------------------------------*/

	var exports = function() {

		

	};

	

	var _imageLength = 0;

	/**

	* ラインナップの描画

	* @param json {Object} パースされたjson Object

	* @param format {String} ハードウェア名

	* @param maxNum {Number} 最大表示件数

	*/

	exports.prototype.drawLineup = function(json, format, maxNum) {

		var i, len, items,

			_ul = Sizzle('#lineup-' + format + '-wrap ul')[0],

			fragment = document.createDocumentFragment();

		

		clearLineup(_ul);

		if (!json) {

			return;

		}

		items = json.items;

		len = items.length > maxNum ? maxNum : items.length;

		_imageLength += len;

		for (i = 0; i < len; ++i) {

			fragment.appendChild(createLineupTitle(items[i], i === (len - 1)));

		}

		_ul.appendChild(fragment);

	};

	

	/**

	* 委譲オブジェクトの設定

	*/

	exports.prototype.setDelegate = function($d) {

		_delegate = $d;

	};

	

	

	/**

	* ラインナップ用hoverの設定

	*/

	exports.prototype.addLineupHover = function() {

		var lists = Sizzle('#index-lineup-area li'),

			li, _a, link,

			i, len = lists.length;

			

		for (i = 0; i < len; ++i) {

			li = lists[i];

			_a = li.children[0];

			if (!_a) continue;

			link = _a.href;

			_a.href = 'javascript:void(0)';

			_a.rel = link;

			_a.target = '_self';

			

			li.onclick = function() {

				location.href = this.children[0].rel;

			};

			

			li.onmouseover = function () {

				if (this.className === 'none') return;

				if (!this.className.match('over')) {

					this.className = this.className + ' over'

				}

			};

			li.onmouseout = function () {

				if (this.className.match('over')) {

					this.className = this.className.replace(' over', '');

				}

			};

		}

	};

	

	/**

	* ラインナップ用FlatHeightの設定

	* @param maxNum {Number} 最大表示件数

	*/

	exports.prototype.lineupFlatHeight = function(maxNum) {

		var ps3_list, psv_list, psp_list,

			i, tmpList, util = SCE_APP.Utility;

			

		ps3_list = Sizzle('#lineup-ps3-wrap li .title-wrap');

		psv_list = Sizzle('#lineup-psv-wrap li .title-wrap');

		psp_list = Sizzle('#lineup-psp-wrap li .title-wrap');

		

		for (i = 0; i < maxNum; ++i) {

			tmpList = [];

			tmpList[tmpList.length] = ps3_list[i];

			tmpList[tmpList.length] = psv_list[i];

			tmpList[tmpList.length] = psp_list[i];

			

			util.flatHeight(tmpList);

		}

	};

	

	/* ------------------------------------------------------------

	* Delegate

	* ------------------------------------------------------------*/

	exports.prototype.afterChangePage = function(json, format, maxNum) {

		_imageLength = 0;

		this.drawLineup(json, format, maxNum);

		this.addLineupHover();

		//this.lineupFlatHeight(maxNum);

	};

	

	return exports;

}());



/**

* インデックス main

*/

SCE_APP.Main = (function() {

	var util = SCE_APP.Utility;

	util.addEventListener(window, 'load', function() {

		var billboard,

			lineup = new SCE_APP.Lineup(),

			view = new SCE_APP.IndexView(),

			_util = util,

			q = _util.getCookie('lineup').split('_'),//_util.getQuery(),

			lineupNumber;

		//Billboard

		//Require Config

		util.requireScript(util.getRoot() + '/common/js/config.js', function() {

			billboard = new SCE_APP.Billboard();

			billboard.initWithId('billboard');

			billboard.setupImportant();

			billboard.loadBillboard(_util.format.TOP);

		});

		

		//Lineup

		//lineup.init();

		lineupNumber = Sizzle('#lineup-number')[0];

		if (lineupNumber) {

			lineup.setMaxNum(Sizzle('#lineup-number')[0].childNodes[0].nodeValue);

			lineup.loadLineupWithFormat(_util.format.PS3, onLineupLoaded, q && q[0]);

			lineup.loadLineupWithFormat(_util.format.VITA, onLineupLoaded, q && q[1]);

			lineup.loadLineupWithFormat(_util.format.PSP, onLineupLoaded, q && q[2]);

			

			lineup.setDelegate(view);

			lineup.setup();

		}

		

		function onLineupLoaded(json, format) {

			view.drawLineup(json, format, lineup.getMaxNum());

			view.setDelegate({

				'afterImagesLoaded': function() {

					view.addLineupHover();

					view.lineupFlatHeight(lineup.getMaxNum());

				}

			});

			

		}

		if (util.getUseragent().ie) {

			util.setBannerBorder([Sizzle('#billboard')[0]]);

		}

	});

}());
