// JavaScript Document


var gsContextPath = getContextPath();
var gsDefaultImgFolder = gsContextPath+'img/';
preLoadImage();

function getContextPath(){
	var n=document.getElementsByTagName("script");
	var srcPath=n[n.length-1].src
	var resultValue=srcPath.slice(0, srcPath.lastIndexOf("/") + 1)
	
	return resultValue;
}

function preLoadImage(){
	(new Image()).src = gsDefaultImgFolder + "wait.gif";
}

function setFocus(){
  document.SEARCH.refValue0.focus();
}

function reloadPage(){
  document.location.reload();
}

function fontSizeReset(){
  SetCookie("FontSize",4);
  reloadStyleSheet();
}

function fontSizeMinus(){
  var nowSize=GetCookie("FontSize");
  if(nowSize==""){
  	nowSize=4;
  }
  if(nowSize>1 && nowSize<=11){
    SetCookie("FontSize",parseInt(nowSize)-1);
  }
  reloadStyleSheet();
}

function fontSizePlus(){
  var nowSize=GetCookie("FontSize");
  if(nowSize==""){
  	nowSize=4;
  }
  if(nowSize>=1 && nowSize<11){
    SetCookie("FontSize",parseInt(nowSize)+1);
  }
  reloadStyleSheet();
}

function GetCookie(key){
	var tmp = document.cookie + ";";
	var index1;
	if(getUserAgent()=="firefox"){
		index1 = tmp.lastIndexOf(key+"=");
	}
	else{
		index1 = tmp.indexOf(key+"=");
	}
	if(index1 != -1){
		tmp = tmp.substring(index1,tmp.length);
		var index2 = tmp.indexOf("=",0) + 1;
		var index3 = tmp.indexOf(";",index2);
		return(unescape(tmp.substring(index2,index3)));
	}
	return("");
}

function SetCookie(key, val){
	document.cookie = key + "=" + escape(val) + ";path=/;";
}

function changeColor(value)
{
	SetCookie("ColorMode", value);
	reloadStyleSheet();
}

function showMenu()
{
	SetCookie("MenuHide", "");
	reloadStyleSheet();
}

function hideMenu()
{
	SetCookie("MenuHide", "1");
	reloadStyleSheet();
}

function getUserAgent(){
	resultValue="";
	
	if(navigator.userAgent.indexOf("Opera") != -1){
		resultValue="opera";
	}
	else if(navigator.userAgent.indexOf("MSIE") != -1){
		resultValue="msie";
	}
	else if(navigator.userAgent.indexOf("Firefox") != -1){
		resultValue="firefox";
	}
	else if(navigator.userAgent.indexOf("Netscape") != -1){
		resultValue="netscape";
	}
	else if(navigator.userAgent.indexOf("Safari") != -1){
		resultValue="safari";
	}
	return resultValue;
}

function reloadStyleSheet(){
  var i,a,s;
  a=document.getElementsByTagName('link');
  for(i=0;i<a.length;i++){
    s=a[i];
    if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {
      var h=s.href.replace(/(&|\?)forceReload=\d+/,'');
      s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())
    }
  }
}

function doSubmitWithWait(formObj,waitDspId,waitText){

	var buttonObj=document.getElementById(waitDspId);
	if(buttonObj!=null){
		buttonObj.innerHTML='<span class="WaitMark"><img src="' +gsDefaultImgFolder+ 'wait.gif" border="0">'+waitText +'</span>';
	}

	if(formObj!=null){
		formObj.submit();
		formObj.onsubmit=function(){return false;}
	}
	
	return false;
}

