////////////common////////////
function setCookie(name,value,expire)
{
	var today = new Date();
	today.setDate(today.getDate()+expire);
	document.cookie = name+"="+escape(value)+"; domain=www.shinbiro.com; path=/;expires="+today.toGMTString()+";"
}

function getCookie( name )
{
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie.length )
    {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                endOfCookie = document.cookie.length;
            return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
            break;
    }
    return "";
}

function getRollingText(list)
{
	return list[getRollingNum(list.length)];
}

function getRollingNum(num)
{
	var a = Math.random();

	return Math.floor((a*10)%num);
}

////////////part_login////////////

//ÇÚµåÆù ¸Þ½ÃÁö º¸³»±â
function jsOpenSMS()
{
   var url = "http://mobile.shinbiro.com/mbl/sms_1/sms.jsp";
   window.open(url,'win','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=180,height=625,top=20,left=20');
   return false;
}

//ÂÊÁöº¸³»±â
function openPaper()
{
    window.open("http://club.shinbiro.com/clb/paper/sbrClbMember_Srh.jsp","PaperWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=650,height=500");
    return false;
}

function jsCallGuestLogin()
{
    document.location.href='/ath/sbrComGuestLogin_Main.jsp';
    return false;
}

function jsSetHomePage(obj)
{
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.shinbiro.com/');
	return false;
}

function jsSetId()
{
    var form = document.login;
    var saveid = getCookie("saveid");

	if (saveid!="")
	{
		form.sUserId.value=saveid;
		form.sIdSave.checked=true;
	}
}

var userid = getCookie("userid");

function getLogin1()
{
    if(userid == "")
    {
	document.write('                                <td colspan="3" height="10"></td>'
	+'                        </tr>'
	+'                        <tr>'
	+'                                <td width="106">'
	+'                                <table width="106" border="0" cellpadding="0" cellspacing="0">'
	+'                                <tr>'
	+'                                        <td width="32" style="padding-left:5pt"><img src="image/main7/id.gif" width="12" height="7"></td>'
	+'                                        <td width="74"><input type="text" name=sUserId size="9" style="width:69;border: 0px solid #89B3E0;background-color:#B9D8EC" tabstop=1></td>'
	+'                                </tr>'
	+'                                <tr>'
	+'                                        <td style="padding-left:5pt"><img src="image/main7/pass.gif" width="24" height="7"></td>'
	+'                                        <td><input type="password" name="sPasswd" size="9" style="width:69;border: 0px solid #89B3E0;background-color:#B9D8EC" tabstop=2></td>'
	+'                                </tr>'
	+'                                </table>'
	+'                                </td>'
	+'                                <td width="56" align="center"><input type="image" img src="image/main7/button/login.gif" width="47" height="44" border="0" tabstop=3></td>');
    }
    else {
	document.write('                                <td height="5"></td>'
	+'                        </tr>'
	+'                        <tr>'
	+'                                <td align="center" height="18"><b>'+userid+'</b>´Ô È¯¿µÇÕ´Ï´Ù.</td>'
	+'                        </tr>'
	+'                        <tr>'
	+'                                <td align="center" height="25"><a href="javascript:sbr_logout()"><img src="image/main7/button/logout.gif" width="81" height="17" border="0"></a></td>'
	+'                        </tr>'
	+'                        <tr>'
	+'                                <td align="center" height="18"><a href="http://mail.shinbiro.com"><img src="image/main7/button/newmail.gif" width="53" height="10" border="0"></a> &nbsp;&nbsp;&nbsp;<a href="http://www.shinbiro.com/html/usr/"><img src="image/main7/button/chageprofile.gif" width="63" height="10" border="0"></a></td>');
    }
}

function getLogin2()
{
    if(userid == "")
    {
	document.write('                                <td colspan="2" align="center" height="35"><a href="http://www.shinbiro.com/html/usr/index.html"><img src="image/main7/idsearch.gif" width="59" height="10" border="0" align="absmiddle"></a> <input type="checkbox" name="sIdSave" value="y"><img src="image/main7/idstore.gif" width="29" height="10" align="absmiddle"></td>');
	jsSetId();
   }else
   {
	document.write('                                <td align="center" height="26">'
	+'                                <iframe width=130 height=21 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no src="/ath/sbrComClubList.jsp"></iframe>'
	+'                                </td>');
   }
}

function getLogin3()
{
    if(userid == "")
    {
	document.write('                                <td colspan="2" align="center"><a href="http://www.shinbiro.com/html/member/index.html"><img src="image/main7/button/joinmember.gif" width="59" height="25" border="0"></a><a href="½ÃÀÛÆäÀÌÁö·Î¼³Á¤" onClick="return jsSetHomePage(this)"><img src="image/main7/button/makehome.gif" width="93" height="25" border="0"></a></td>'
	+'                        </tr>'
	+'                        <tr>'
	+'                                <td colspan="3" height="8"></td>');
    }else
    {
	document.write('                                <td align="center" height="30"><a href="http://payment.shinbiro.com"><img src="image/main7/button/shibicash.gif" width="56" height="21" border="0"></a><a href="¸Þ¼¼Áö º¸³»±â" onClick="return jsOpenSMS();"><img src="image/main7/button/sms.gif" width="40" height="21" border="0"></a><a href="http://www.shinbiro.com/ath/sbrComMyPageFrm.jsp"><img src="image/main7/button/log_mypage.gif" width="56" height="21" border="0"></a></td>');
    }
}

////////////part_search////////////

function jsChkSearch()  
{
	var frm = document.search;

	var search_domain = "http://find.shinbiro.com/";
 	var search_section = "xsearch.php";
 
 	if(frm.keyword.value.length < 1){
  		alert('°Ë»öÇÒ Å°¿öµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		frm.keyword.focus();
  		return false;
 	}
 
 	switch(frm.category[frm.category.selectedIndex].value){
  	 case "all" :
   		search_section = "xsearch.php";
  	 	break;
  	 case "site" :
   		search_section = "xsite.php";
   		break;
  	 case "club" :
   		search_section = "xclub.php";
   		break;
 	 case "pds" :
   		search_section = "xpds.php";
   		break;
  	 default :
   	    search_section = "xsearch.php";
        break;
     }
 
 	frm.action = search_domain + search_section;
 	frm.submit();
	return false;
}

function jsSearch() 
{
    var flag = jsChkSearch();

    if (flag) 
        document.search.submit();

    return false;
}
