
function getBread( node, path , breads ){
        var ret='';
        if( !node.tagName || node.tagName!='node' ){
                return '';
        }
        var _path=node.getAttribute( 'path' );
        var _title=node.getAttribute( 'title' );
        if( _title ){
                var tmp=( breads.path=='/' )?_path:breads.path+_path;

                if( path.indexOf( tmp )==0 ){
                        var b=new Object();
                        breads.target[breads.target.length]=b;
                        b.path=tmp.substring(1);
                        if( b.path=='' ){
                                b.path='/';
                        }
                        b.title=_title;
                        if( node.childNodes && node.childNodes.length ){
                                var len=node.childNodes.length;
                                breads.path=tmp;
                                for( var j=0 ; j<len ; j++ ){
                                        if( getBread( node.childNodes[j] , path, breads ) ){
 									       return true;
										}
                                }
                        }
                        return true;
                }
        }
        return false;
}

function getBreadCrumbs( path ){
        var breads=new Object();
        breads.target=new Array();
        breads.path='';

        var spath='/';
        for( var j=3 ; j<path.length ; j++ ){
		if( j!=3 ){
                spath+='/';
		}
                spath+=path[j];
        }
        var ret='/files/system/xml/breadcrumbs.xml';
        var ajax=new Ajax.Request( ret , {method:'get',asynchronous:false} );
        if( ajax && ajax._complete ){
                var dat=ajax.transport.responseXML.documentElement;
                if( dat && dat.childNodes ){
                        for( q=0 ; q<dat.childNodes.length ; q++ ){
                                if( getBread( dat.childNodes[q] , spath , breads ) ){
                                        break;
                                }
                        }
                }
        }
        var bread='';
        var len=breads.target.length;
        for( var j=0 ; j<len ; j++ ){
                if( j<(len-1) ){
if( breads.target[j].path!='/' ){
	breads.target[j].path='/'+breads.target[j].path;
}
                        bread+='<a href="'+breads.target[j].path+'">';
                        bread+=breads.target[j].title;
                        bread+='</a>';
                        bread+='&nbsp;&gt;&nbsp;';
                }else{
                        bread+=breads.target[j].title;
                }
        }
        return bread;
}


function writeHeader(){

	document.write( '<div id="headbinder">' );
	document.write( '	<div class="w990">' );
	document.write( '		<h1 id="dogatchjp"><a href="/"><span class="alt">テレビドガッチ</span></a></h1>' );
	document.write( '		<div class="clearfix">' );
	document.write( '			<div id="linkepg"><a href="/epg/"><span class="alt">テレビ番組表</span></a></div>' );
	document.write( '			<div id="memberregist"><a href="https://exe.dogatch.jp/member/registrationWindow.aspx"><span class="alt">ユーザ登録</span></a></div>' );
	document.write( '			<div id="changecolorfunction" class="clearfix"></div>' );
	document.write( '		</div>' );
	document.write( '	</div>' );
	document.write( '</div>' );

	document.write( '<div id="menubinder">' );
	document.write( '	<div class="w990">' );
	document.write( '		<div class="clearfix">' );
	document.write( '			<div id="menu7">' );
	document.write( '				<ul class="clearfix">' );
	document.write( '					<li id="menuid1"><a href="/"><span class="alt">TOP</span></a></li>' );
	document.write( '					<li id="menuid2"><a href="/drama/"><span class="alt">ドラマ</span></a></li>' );
	document.write( '					<li id="menuid3"><a href="/variety_music/"><span class="alt">バラエティ・音楽</span></a></li>' );
	document.write( '					<li id="menuid4"><a href="/news_info/"><span class="alt">報道・情報</span></a></li>' );
	document.write( '					<li id="menuid5"><a href="/sports_event/"><span class="alt">スポーツ・イベント</span></a></li>' );
	document.write( '					<li id="menuid6"><a href="/anime_kids/"><span class="alt">アニメ・キッズ</span></a></li>' );
	document.write( '					<li id="menuid7"><a href="/cinema/"><span class="alt">映画</span></a></li>' );
	document.write( '				</ul>' );
	document.write( '			</div>' );
	document.write( '			<div id="menu10">' );
	document.write( '				<ul class="clearfix">' );
	document.write( '					<li id="menuid8"><a href="/interview/"><span class="alt">インタビュー</span></a></li>' );
	document.write( '					<li id="menuid9"><a href="/video/"><span class="alt">動画</span></a></li>' );
	document.write( '					<li id="menuid10"><a href="/present/"><span class="alt">プレゼント</span></a></li>' );
	document.write( '				</ul>' );
	document.write( '			</div>' );
	document.write( '		</div>' );
	document.write( '	</div>' );
	document.write( '</div><hr />' );

	if( document.body.id && document.body.id!='dogatchidx' ){
		document.write( '<div id="breadcrumbbinder" class="w990">' );
		var loc=window.location.href;
		if( loc ){
		var ret='<div class="bcinner">';
		var path=loc.split( '/' );
		ret+=getBreadCrumbs(path);
		ret+='</div>';
		}
		document.write( ret );
		document.write( '</div>' );
	}
}

function writeFooter(){
	document.write( '<div id="globalfooter">' );
	document.write( '	<div class="w990">' );
	document.write( '		<div class="links"><a href="/info/aboutsite.html">テレビドガッチとは？</a>｜<a href="/info/requirement.html">推奨環境</a>｜<a href="/info/faq.html">ヘルプ</a>｜<a href="/info/contact.html">お問い合わせ</a>｜<a href="/info/policy.html">個人情報保護方針</a>｜<a href="/info/privacy.html">プライバシーステートメント</a>｜<a href="/info/term.html">利用規約</a>｜<a href="/info/company.html">運営会社について</a>｜<a href="/info/maintenance.html">メンテナンス情報</a>｜<a href="/info/sitemap.html">サイトマップ</a></div>' );
	document.write( '		<div class="credit"><a href="/blog/news/">テレビ関連ニュース</a>｜<a href="/blog/dogatch/">テレビドガッチスタッフブログ</a>　Copyright&copy; 2006-2009 PRESENTCAST INC. All Rights Reserved.</div>' );
	document.write( '	</div>' );
	document.write( '</div>' );
	var body = document.getElementsByTagName('BODY')[0];
	if (body) {
	    appendOnClick(body);
	}
}

function appendOnClick(elm) {
	var __fb=document.getElementById( '__full__banner' );
	if( __fb ){

	        __fb.style.lineHeight='90px';
	        __fb.style.height='90px';
	}
    if (elm == null || elm == 'undefined') {
        return;
    }
    for (var i = 0; i < elm.childNodes.length; i++) {
        var child = elm.childNodes[i];
        if (child.nodeName == 'A') {
            if (child.href == null || child.href == 'undefined') {
                continue;
            }
            var idx = child.href.indexOf('#', 0);
            if (idx != -1) {
                continue;
            }
            if (child.onclick == null || child.onclick == 'undefined') {
                child.onclick = function() {
                        if( typeof(forcePause)=='function' ){
                    if (!(forcePause == null || forcePause == 'undefined')) {
                        forcePause();
                    }
                        }
                }
            }
        } else {
            appendOnClick(child);
        }
    }
}

function writeYahooSearch(){
	document.write('				<div id="sitesearch"><div class="inner">' );
	document.write('					<h3 class="alt">サイト内検索</h3>' );
	document.write('					<form action="http://custom.search.yahoo.co.jp/search" method="get" id="srch" target="yjserp">' );
	document.write('					<div id="ssbind">' );
	document.write('						<label class="clearfix"><input type="text" name="p" id="srchInput" onfocus="searchfocus();" onblur="searchguide()" /><input type="image" id="srchBtn" src="/files/img/searchb1.gif" value="検索" onmouseover="this.src=\'/files/img/searchb2.gif\'" onmouseout="this.src=\'/files/img/searchb1.gif\'" /></label>' );
	document.write('						<p id="srchLogo"><a href="http://dogatch.jp/bin/redirect.php?url=http://www.yahoo.co.jp" target="_blank">powered by Yahoo! JAPAN</a></p>' );
	document.write('						<img src="http://custom.search.yahoo.co.jp/images/window/ekZiL09RGtwpNz6EwF0SqHyZmpQsk5c-.gif" />' );
	document.write('					</div>' );
	document.write('					<input type="hidden" id="fr" name="fr" value="cse">' );
	document.write('					<input type="hidden" id="ei" name="ei" value="UTF-8">' );
	document.write('					<input type="hidden" id="csid" name="csid" value="ekZiL09RGtwpNz6EwF0SqHyZmpQsk5c-">' );
	document.write('					<input type="hidden" name="vs" value="dogatch.jp" id="yjInsite">' );
	document.write('					</form>' );
	document.write('				</div></div>' );
				
}

