String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function start_page()
{
	startpage.style.behavior = 'url(#default#homepage)';
	startpage.setHomepage('http://www.shanghain.com');
}
function favorite(){
    window.external.AddFavorite('http://www.shanghain.com',document.title);    
}
function go_list(title_menu, uid)
{
    if(title_menu == "hotel")
       var link_url = "life/life_hotel_view.html";
    else if(title_menu == "food")
       var link_url = "life/life_food_view.html";

    location.href = link_url+ "?uid=" + uid;
}

function pop_img(img_url)
{
    if(img_url)
    {
        window.open(img_url, 'pop_img','width=500,height=350');
    }
    else
    {
        alert('이미지가 없습니다');
    }
}

function go_page(page)
{
    document.list_form.page.value = page;
    document.list_form.submit();     
}

function activemovie(str, wid, hei) {
    //document.write(" <object src='"+str+"' width='"+wid+"' height='"+hei+"'></object>");
    document.write(" <embed src='"+str+"' width='"+wid+"' height='"+hei+"' border='0'></embed>");
}

function del_value(obj) {
    obj.value='';
}



var tickerObj; 
var hex = 255;

function fadeText(divId) {
      if(tickerObj)
            {
                    if(hex>0) {
                              hex-=5; // 색을 점점 어둡게 한다.
                                    tickerObj.style.color="rgb("+hex+","+hex+","+hex+")";
                                          setTimeout("fadeText('" + divId + "')", fadeSpeed); 
                                              } else
                              hex=255; // 색의 명암 초기화
                      }
}

function initialiseList(divId) {
      tickerObj = document.getElementById(divId);
        if(!tickerObj)
                reportError(" \"" + divId + "\" 라는 아이디를 가진 div element를 찾을 수 없습니다.");
          list = tickerObj.childNodes;
            if(list.length <= 0)
                    reportError(" \"" + divId + "\" 라는 아이디를 가Á? div element는 아무 메시지도 가지고 있지 않습니다.");
              for (var i=0; i<list.length; i++) {
                      var node = list[i];
                          if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
                                            tickerObj.removeChild(node);
                            }
                run(divId, 0);
}

function run(divId, count) {
      fadeText(divId);
        list[count].style.display = "block";
          if(count > 0)
                  list[count-1].style.display = "none";
            else
                    list[list.length-1].style.display = "none";
              count++;
                if(count == list.length)
                        count = 0;
                  window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
function reportError(error) {
      alert("이 스크립트는 다음과 같은 에러로 실행 µ?? 수 없습니다. :\n\n" + error);
        return false;
}

var interval = 5; //다음 메시지로 넘어가는데 걸리는 ½챨??.
var fadeSpeed = 40; //텍스트가 페이드되는 속도. 숫자가 크면 페이드되는 속도가 느리다. 40이 제일 적당하다. 

var rolling_banner = function(ta){
    this.ta = ta;
//  this.ta.className = 'rolling_banner';   
    this.ta_id = 'roll_'+(this.ta.id||this.ta.name);
    this.gap = 5;                   //움직이는 픽셀단위
    this.gap_count=0;           //카운팅용:건들지 마세요
    this.gap_time = '1000';     //움직이는 단위시간
    this.gap_sleep = '2000';    //화면이 멈춰있을 단위시간
    this.over_stop = true;  //마우스를 올렸을 때 멈출 것인가?
    this.timer = null;
    eval(this.ta_id+'=this');
    var temp = eval(this.ta_id);
    this.init_div();    
}
rolling_banner.prototype.start = function(){    //롤링 시작
    this.ta.readonly =false;
    this.stop =false;   
    if(!this.timer){ this.rolling();     }
}
rolling_banner.prototype.stop = function(){ //롤링 시작
    this.stop =true;
}
rolling_banner.prototype.init_div = function(){ //<div> 빼고 전부 제거 , 스타일 초기화
    this.ta.style.position="relative";
    this.ta.style.overflow="hidden";
    this.ta.onmouseover=function(){ eval("this.readOnly=true;"); }
    this.ta.onmouseout=function(){ eval("this.readOnly=false;"); }

    var child = this.ta.childNodes;
    var ch = this.ta.firstChild;
    var ch2 = null;
    while(ch){
        ch2 = ch.nextSibling;
        if(ch.nodeName.toLowerCase() !='div'){
        this.ta.removeChild(ch);
        }else{
        ch.style.position = "relative";
        ch.style.borderStyle='none';
        ch.style.top='0px';
        }
        ch=ch2;
    }
}
rolling_banner.prototype.strtonum = function(str){
    var num = parseInt(str);
    if(isNaN(num)) num = '0';
    return num
}
rolling_banner.prototype.strtopx = function(str){
    var num = this.strtonum(str);
    return num+'px';
}
rolling_banner.prototype.rolling = function(){
    if(this.gap_count==0){
        this.sleep();
        this.gap_count+=1;
        return;
    }
    if(!this.ta.readOnly && !this.stop){
        this.rolling_top();
    }
    this.timer = null;
    var re = this.ta_id+'.rolling()';
    this.timer = setTimeout(re,this.gap_time);
}
rolling_banner.prototype.rolling_top = function(){
    this.gap_count+=parseInt(this.gap);
    var ch1 = this.ta.firstChild;
    var child = this.ta.childNodes;
    var ta_ch = null;
    var top_ori = this.strtonum(child[0].style.top);
    var top = this.strtopx(top_ori-parseInt(this.gap));         
    for(var i=0,m=child.length;i<m;i++){
        child[i].style.top=top;
    }
    if(this.gap_count >= this.strtonum(ch1.style.height)){
        var temp =ch1.cloneNode(true);  
        this.ta.removeChild(ch1);
        this.ta.appendChild(temp);
        for(var i=0,m=child.length;i<m;i++){
            child[i].style.top='0px';
        }       
    this.gap_count = 0      
    }
}
rolling_banner.prototype.sleep = function(){
    this.timer = null;
    var re = this.ta_id+'.rolling()';
    this.timer = setTimeout(re,this.gap_sleep);
}

