var shuncolleStrUrl = "";
var shuncolleTimeID = 0;
var browserType=new checkBrowserType();

function execSearch() {

    searchStrUrl = document.smove.word.value;
    
    if(searchStrUrl == "" || searchStrUrl == null || searchStrUrl == "検索したいキーワードをいれてください" || isBlank(searchStrUrl)) {
        shuncolleTimeID=setTimeout("hideBalloon('searchBalloon');",2000);
        showBalloon("searchBalloon");
        return false;
    }
}

function isBlank(str) {
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) != " " && str.charAt(i) != "　") {
			return false;
		}
	}
	return true;
}

function initSearchBalloon() {
    document.write('<div id="searchBalloon">');
    document.write('<div class="inner">');
    document.write('<p><span id="shuncolleBalloon" onmouseover="mouseoverBalloon();" onmouseout="mouseoutBalloon();"></span></p>');
    document.write('</div>');
    document.write('</div>');

    hideBalloon("searchBalloon");
}


function forwardErrorPage(httpObj) {
    hideBalloon("searchBalloon");
    location.href = "/colleguide/error/error_system.htm";
}

function mouseoverBalloon(){
    clearTimeout(shuncolleTimeID);
}

function mouseoutBalloon(){
    shuncolleTimeID=setTimeout("hideBalloon('searchBalloon');",3000);
}

function showBalloon(id) {
 	setStyle("searchBalloon");
    setDivVisibility(id,"visible");
    setDivDisplay(id,"block");
    writeBalloonString();
}

function hideBalloon(id) {
    clearTimeout(shuncolleTimeID);
    setDivVisibility(id,"hidden");
    setDivDisplay(id,"none");
    clearBalloonString();
}

function writeBalloonString() {
    document.getElementById("shuncolleBalloon").innerHTML = '検索キーワードを入力してください';
}

function clearBalloonString() {
    document.getElementById("shuncolleBalloon").innerHTML = null;
}

function setDivVisibility(objName,val){
    if(browserType.IE){
        document.all[objName].style.visibility=val;
    } else {
        document.getElementById(objName).style.visibility=val;
    }
}

function setDivDisplay(objName,val){
    if(browserType.IE){
        document.all[objName].style.display=val;
    } else {
        document.getElementById(objName).style.display=val;
    }
}
function checkBrowserType(){
	this.IE=(navigator.userAgent.indexOf("MSIE")!=-1);
	this.Gecko=(navigator.userAgent.indexOf("Gecko")!=-1);
	this.IE6=(navigator.userAgent.indexOf("MSIE 6.")!=-1);
	this.IE5=(navigator.userAgent.indexOf("MSIE 5.")!=-1);
	this.NC71=(navigator.userAgent.indexOf("Netscape/7.1")!=-1);
	this.NC70=(navigator.userAgent.indexOf("Netscape/7.0")!=-1);
	this.NC6=(navigator.userAgent.indexOf("Netscape/6.")!=-1);
	this.NC7=(navigator.userAgent.indexOf("Netscape/7.")!=-1);
	this.NC4=(navigator.userAgent.indexOf("Netscape/4.")!=-1);
}

function getElementPosition(element) {
	var offsetTrail = (typeof element == 'string') ? document.getElementById(element) : element;
	var offsetLeft = 0;
	var offsetTop = 0;

	while (offsetTrail) {
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}

	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != "undefined") {
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}

	return ({left: offsetLeft, top: offsetTop});
}

function setStyle(id){
	var offset =  getElementPosition("headSearchTxt");
	document.getElementById(id).style.left = offset.left + "px";
}
