String.prototype.ltrim = function(){
	var re = /\s*((\S+\s*)*)/;
	return this.replace(re, "$1");
}

String.prototype.rtrim = function(){
	var re = /((\s*\S+)*)\s*/;
	return this.replace(re, "$1");
}

String.prototype.trim = function(){
	return this.ltrim().rtrim();
}

function OpenWindow(url){
	window.open(url, "gamescampus", "width=1024,height=800,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes");
}

function clrImg(obj){
	obj.style.backgroundImage="";obj.onkeydown=obj.onmousedown=null;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function gotohref(str){
	if (str == "shoot") {
		//location.href = "http://mangafighter.gamescampus.com/news/notice/view.asp?num=34";
		location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=8";
	}else if (str=="xfire"){
		location.href = "http://mangafighter.gamescampus.com/news/notice/view.asp?num=61";
	}else if (str=="xfire02"){
		location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=13";
	}else if (str=="cevent"){
		window.open('/events/paybycash.html','eventPopup','scrollbars=yes,toolbar=yes,resizable=yes,width=1000,height=800'); 
	}else if (str=="mother"){
		location.href = "/news/events/view.asp?num=19";
	}else if (str=="cashshop"){
		location.href = "/news/events/view.asp?num=22";
	}else if (str=="summer"){
		location.href = "/news/events/view.asp?num=30";
	}else if (str=="father"){
		location.href = "/news/events/view.asp?num=27";
	}else if (str=="riteaid"){
		location.href = "http://mangafighter.gamescampus.com/news/notice/view.asp?num=110";
	}else if (str=="death"){
		location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=43";
	}else if (str=="melee"){
    	location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=84"; 
	}else if (str=="goo_event"){
		location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=51"; 
	}else if (str=="ppc"){
		location.href = "http://www.gamescampus.com/gamecard/ppc_teaser.htm"; 
	}else if (str=="big_update"){
		location.href = "http://mangafighter.gamescampus.com/news/notice/view.asp?num=140&page=1"; 
	}else if (str=="ppc_mf_tv"){
		location.href = "http://www.gamescampus.com/gamecard/index.asp"; 
	}else if (str=="mf_q_coin"){
		location.href = "http://mangafighter.gamescampus.com/news/events/view.asp?num=58"; 
	}else if (str=="mf_halfoff"){
		location.href = "/news/notice/view.asp?num=170"; 
	}else if (str=="mf_rainbow"){
		location.href = "/news/events/view.asp?num=59"; 
	}else if (str=="mf_valentine"){
		location.href = "/news/events/view.asp?num=65"; 
	}else if (str=="mf_easter"){
		location.href = "/news/events/view.asp?num=73&page=1"; 
	}
}

function mfhref(str) {
	if (str == "home" || str == "main") {
		location.href = "/index.asp";
	} else if (str == "news") {
		location.href = "/news/notice/list.asp";
	} else if (str == "notice") {
		location.href = "/news/notice/list.asp";
	} else if (str == "events") {
		location.href = "/news/events/list.asp";
	} else if (str == "guide") {
		location.href = "/guide/gameIntro/whatis.asp";
	} else if (str == "game_intro") {
		location.href = "/guide/gameIntro/whatis.asp";
	} else if (str == "install") {
		location.href = "/guide/install/requirements.asp";
	} else if (str == "interface") {
		location.href = "/guide/interface/mainlobby.asp";
	} else if (str == "control") {
		location.href = "/guide/control/key.asp";
	} else if (str == "download") {
		location.href = "/download/client/list.asp";
	} else if (str == "client") {
		location.href = "/download/client/list.asp";
	} else if (str == "movie") {
		location.href = "/download/movieclip/list.asp";
	} else if (str == "wall") {
		location.href = "/download/wallpaper/list.asp";
	} else if (str == "art") {
		location.href = "/download/artwork/list.asp";
	} else if (str == "community") {
		location.href = "http://forum.gamescampus.com/index.php?game=mangafighter";
	} else if (str == "forum") {
		location.href = "http://forum.gamescampus.com/index.php?game=mangafighter";
	} else if (str == "screen") {
		location.href = "/community/screenshot/list.asp";
	} else if (str == "fanart") {
		location.href = "/community/fanart/list.asp";
	} else if (str == "fansite") {
		location.href = "/community/fansite/list.asp";
	} else if (str == "ranking") {
		location.href = "/ranking/list.asp";
	} else if (str == "support") {
		location.href = "/support/faq/list.asp";
	} else if (str == "faq") {
		location.href = "/support/faq/list.asp";
	} else if (str == "dqa") {
		location.href = "/support/dqna/input.asp";
	} else if (str == "twitter"){
		location.href = "/community/twitter/twitterform.asp";	
	}
}

function domainsave() {
	var TextDomain;
	var TextArry;

	TextDomain = document.URL;
	TextDomain = TextDomain.replace("http://","");
	TextArry = TextDomain.split("/");
	TextDomain = TextArry[0];

	return TextDomain;
}

function _xmlGetData () {
 
  var _httpMethod = "GET";
  var _syncFlag = false;

  var tryThese = [
  function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
  function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
  function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
	];
	var virtual;

	for (var i = 0; i < tryThese.length; i++) {
		var func = tryThese[i];
		try {
			virtual= func();
			break;
		} catch (e) { }
	}

	var today = new Date();
	var millisec = parseInt(today.getTime() / 1000);
	
	virtual.open(_httpMethod, "http://" + domainsave() + "/user/gamestart.asp", _syncFlag);
	virtual.setRequestHeader("Content-type:", "text/html");   
	virtual.setRequestHeader("Referer:", document.URL);   
	virtual.send(); 

	if (virtual.status > 200) {
		//error
	}
	return virtual.responseText;
}

function getCookie(name) { 
	var Found = false 
	var start, end 
	var i = 0 
	 
	while(i <= document.cookie.length) { 
		start = i 
		end = start + name.length 
		 
		if(document.cookie.substring(start, end) == name) { 
			Found = true 
			break 
		} 
		i++ 
	} 
	 
	if(Found == true) { 
		start = end + 1 
		end = document.cookie.indexOf(";", start) 
		if(end < start) 
		end = document.cookie.length 
		return document.cookie.substring(start, end) 
	} 
	return "" 
} 

function copy() {
	meintext = "http://file.gamescampus.com/MA/movieclip/OpenBeta(320x240).wmv"
	var flashcopier = 'flashcopier';
	if(!document.getElementById(flashcopier)) {
	  var divholder = document.createElement('div');
	  divholder.id = flashcopier;
	  document.body.appendChild(divholder);
	}
	document.getElementById(flashcopier).innerHTML = '';
	var divinfo = '<embed src="/images/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(meintext)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	document.getElementById(flashcopier).innerHTML = divinfo;

	alert("The link to the game movie was automatically copied. \n\n You can find the address of the linked move by \n pasting(or with ctrl+v key) the site in a text note.");
}

function Login_Go(form) {
	var userid = form.userid.value;
	var pwd = form.pwd.value;
		
	if( userid == "" ) {
		alert("Please enter user id.");
		form.userid.focus();
		return false;
	} 
	
	if( pwd == "" ) {
		alert("Please enter user password.");		
		form.pwd.focus();
		return false;
	}
	
	return true;
}