function openChatRoom(){
	FRchatRoom = window.open('','FRchatRoom','left=0,top=0,screenX=0,screenY=0,width=1038,height=855,scrollbars=yes,resizable=yes,status=yes,directories=no,menubar=no');
	if (document.chatroomForm!=null){
		document.chatroomForm.submit();
	}
	return false;
}

function closeChatroom(){
  if (typeof(FRchatRoom)!='undefined' && FRchatRoom && FRchatRoom.open && !FRchatRoom.closed){
	  FRchatRoom.close();
  }
}

function toPage(url){
	//if(navigator.appName != "Microsoft Internet Explorer"){
//		op -= 0.1;
//		document.body.style.opacity = op;
		//xmlhttp=new XMLHttpRequest()
		//xmlhttp.onreadystatechange=xmlhttpChange
		//xmlhttp.open("GET",url,true)
		//xmlhttp.send(null)
//		trans(url);
//	}else{
		window.location.href = url;
//	}
}
function trans(url){
	destination = url;
	op -= 0.1;
	document.body.style.opacity = op;
	if(op < 0.2){
		window.clearTimeout(timerId);
		timerId=0;
		//document.body.style.opacity=1;
		//document.open();
		//document.write(xmlhttp.responseText);
		//document.close();
		//window.location.href = destination;
		window.location.replace(destination);
		//window.location.reload(true);
		return;
	}
	timerId = window.setTimeout("trans('"+url+"');",20);
}
function transBack(){
	op += 0.1;
	document.body.style.opacity = op;
	if(op > 0.9){
		document.body.style.opacity=1;
		return;
	}
	setTimeout("transBack()",40);
}
function setBackground(){
  var trial = 0;
  var expiry_date = new Date("June 16, 3000");
  var the_cookie = "screenWidth="+ screen.width;
  var the_cookie = the_cookie + ";expires=" + expiry_date.toGMTString();
  document.cookie=the_cookie
}
function showEffect(cell,image){
  cell.style.backgroundRepeat= 'no-repeat';
  cell.style.backgroundImage='url('+image.src+')';
  if (image.src.match('effect_submenu.png')){
	  cell.style.backgroundPosition= 'bottom center';
  }
}
function hideEffect(cell){
  cell.style.backgroundImage='';
}
function trim(str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

//for input fields to have different border
sfFocus = function() {
	var sfEls = document.getElementsByTagName("INPUT");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
	var sfEls = document.getElementsByTagName("TEXTAREA");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);