var questionMaxLength=5000;if(top.location!=self.location)top.location=self.location;function searchTypeOnchange(){var a;box=document.search_form.type;a=box.options[box.selectedIndex].value;document.search_form.system.disabled=a>=6&&a;var b=document.getElementById("genreRow");if(a==1)b.style.display="block";else{b.style.display="none";a=document.getElementById("genre_master");if(a!=null&&typeof a!="undefined")a.value="0";document.getElementById("genre").selectedIndex=0}}
function searchReset(){document.getElementById("type").selectedIndex=0;document.getElementById("prod_name").value="";document.getElementById("system").selectedIndex=0;document.getElementById("reviewer").selectedIndex=0}
function sb_TipN4GLink(a,b,c,d){document.write("<a href='http://www.n4g.com/tips.aspx?url="+escape(a)+"&title="+escape(b)+(typeof d=="undefined"?"":escape(" ("+d.toUpperCase()+")"))+"' target='_blank'><img src='"+c+"' border='0' alt='Submit a Tip to N4G about this story...'></a>")}
function sb_TipN4GThisPage(){typeof system=="undefined"?sb_TipN4GLink(document.location,document.title,"http://www.gamevortex.com/psc/button_tips_n4g.gif"):sb_TipN4GLink(document.location,document.title,"http://www.gamevortex.com/psc/button_tips_n4g.gif",system)}
function tr_Language(a,b){if(typeof b=="undefined")b="Translate";var c=tr_originalURL;if(a!="en")c="http://translate.google.com/translate?u="+escape(tr_originalURL)+"&hl=en&sl=en&tl="+a;document.write("<a href='"+c+"' title='"+b+"'><img src='http://www.gamevortex.com/SCRIPTS/languageAssets/flag_"+a+".gif' border='0' width='25' height='20' alt='"+b+"'></a><br>")}
function tr_LanguageButtons(){tr_Language("en","English");tr_Language("ar","Arabian");tr_Language("bg","Bulgarian");tr_Language("zh-CN","Chinese (Simplified)");tr_Language("zh-TW","Chinese (Traditional)");tr_Language("hr","Croatian");tr_Language("cs","Czech");tr_Language("da","Danish");tr_Language("nl","Dutch");tr_Language("fi","Finnish");tr_Language("fr","French");tr_Language("de","German");tr_Language("el","Greek");tr_Language("it","Italian");tr_Language("ja","Japanese");tr_Language("ko","Korean");
tr_Language("pl","Polish");tr_Language("pt","Portuguese");tr_Language("ro","Romanian");tr_Language("ru","Russian");tr_Language("es","Spanish");tr_Language("sv","Swedish")};
// CLASS: GV Menu
function gvMenu(menuID)
{
	var _menuID = menuID;
	var subOpened = new Array();
	var menuHasChildren = new Array();

	$("#"+_menuID+" ul li").each(function(i) {
		$(this).find("ul").css("display", "none");
	});
	
	$("#"+_menuID+" ul li").each(function(i) {
		subOpened[$(this).find('a:eq(0)').html()] = false;
		menuHasChildren[$(this).find('a:eq(0)').html()] = ($(this).children("ul").size() > 0);
		
		if($(this).parent().parent().attr("id") == _menuID)
		{
			$(this).hover(function() {
				var key = $(this).find('a:eq(0)').html();
				// late position sub menus
				if(menuHasChildren[key] && !subOpened[key])
				{
					var thisATag = $(this).find('a:eq(0)');
					var newTop = thisATag.outerHeight()+parseInt($(this).parent().css("padding-top"));
					$(this).children("ul:eq(0)").css({ top: newTop });
					
					var newLeft = thisATag.position().left+(thisATag.outerWidth()/2)-($(this).children("ul:eq(0)").outerWidth()/2);//   $(this).children("ul:eq(0)").outerWidth()/2

					if(newLeft < 0) 
						newLeft = 0;
					else if (newLeft+$(this).children("ul:eq(0)").outerWidth() >  $("#"+_menuID+" ul").outerWidth())
						newLeft = $("#"+_menuID+" ul").outerWidth()-$(this).children("ul:eq(0)").outerWidth();
					newLeft = Math.floor(newLeft);

					$(this).children("ul:eq(0)").css({ top: newTop, left : newLeft/*, width:$("#"+_menuID+" ul").outerWidth()-newLeft*/}); // position submenu
					subOpened[key] = true;
				}
				
				// show/hide submenu
				selectTab($(this)); // make UI/CSS changes for top-level menu
				if(menuHasChildren[key]) {
					$(this).children("ul:eq(0)").show(); // show submenu
				}
				else // use the right class to make the button look right
				{
					$(this).addClass(_menuID+"_active_noChildren");
				}
			}, function() {
				selectTab(null); // hide submenus, and clear tabs (don't select a new one)
				$(this).removeClass(_menuID+"_active_noChildren"); // remove this class if necessary
			});
		}
	});
	
	$("#"+_menuID+" ul li ul li").each(function(i) { // only the 2nd layer menu items
		$(this).hover(function() {
			selectSubItem($(this)); // make UI/CSS changes for sub-menu items
		}, function() {
			selectSubItem(null); // un-hightlight any submenus
		});
	});
	
	var selectSubItem = function(item){
		$("#"+_menuID+" ul li ul li").removeClass("hoverRightBottom");
		$("#"+_menuID+" ul li ul li a").removeClass("hoverLeftBottom");
	
		// now show the passed in tab's            
		if (item != null) {
			item.addClass("hoverRightBottom");
			item.children("a").addClass("hoverLeftBottom");
		}
	}
	
	var selectTab = function(tab) {
		$("#"+_menuID+" ul li ul").hide(); // hide all submenus that might be open
		
		// remove all css indicators
		$("#"+_menuID+" ul li").removeClass("hoverRightTop");
		$("#"+_menuID+" ul li a").removeClass("hoverLeftTop");
		$("#"+_menuID+" ul li ul li").removeClass("hoverRightBottom");
		$("#"+_menuID+" ul li ul li a").removeClass("hoverLeftBottom");

		// now show the passed in tab's            
		if (tab != null) {
			tab.addClass("hoverRightTop");
			tab.children("a").addClass("hoverLeftTop");
		}
	}
} // END CLASS: GV Menu
// CLASS: GV Object Positioner
function gvObjectPositioner(placementArrays)
{
	var _placementArrays = placementArrays;

	var placeOverArea = function(placeHolderID, objectToMoveID, Pos) 
	{
		var placeHolder = $("#" + placeHolderID);
		var movingObject = $("#" + objectToMoveID);
		var newLeft = placeHolder.offset().left;
		if(Pos == "center")
		{
			distance = parseInt((parseInt(placeHolder.width())/2)-(parseInt(movingObject.width())/2));
			//alert(distance);
			newLeft += distance;//(distance>0?distance:-distance);
		}
		
		movingObject.css({ left: newLeft, top: placeHolder.offset().top });
	}

	this.positionObjects = function() 
	{
		for(i=0;i< _placementArrays.length;i++)
		{
			placeOverArea(_placementArrays[i][0], _placementArrays[i][1], _placementArrays[i][2]);
		}
	}	

	this.positionObjects();
	$(window).resize(this.positionObjects);
}// END CLASS: GV Object Positioner


$(document).ready(function(){
	objPos = new gvObjectPositioner(
		Array(
			Array("TopMenuArea", "TopMenuItems>ul", "center")
		)
	);

	menu = new gvMenu("TopMenuItems");
});

