/*サブメニュー表示*/

var currentSubmenu=null;

function setMenuSlide() {
	$.each($(".gmenu-main a"),function(index,obj){
		slideMenu($(this),$(this).attr("rel"));
        if($("#"+$(this).attr("rel")).css("display") == "block"){
            $(this).css("background-position", "0 -55px");
            currentSubmenu = $(this).attr("rel");
        }
	});
}

function slideMenu(trigger,target) {
    
    trigger.bind('click',function(){
        if(currentSubmenu==target){
            $.each($(".gmenu-main a"),function(index,obj){
                $(this).css("background-position", "0 0");
            });
            $("#"+target).hide('fast',function(){
                currentSubmenu = null;
            });
        }else if(currentSubmenu!=null){
            $.each($(".gmenu-main a"),function(index,obj){
                $(this).css("background-position", "0 0");
            });
            $(this).css("background-position", "0 -55px");
            $("#"+currentSubmenu).hide('fast',function(){
                $("#"+target).show('slow',function(){
                    currentSubmenu = target;
                });
            });
        }else {
            $("#"+target).show('slow',function(){
                currentSubmenu = target;
            });
        }
    });

	trigger.bind('mouseover', function(){
		if(currentSubmenu!=$(this).attr("rel"))
		$(this).css("background-position", "0 -55px");
	});
	trigger.bind('mouseout', function(){
		if(currentSubmenu!=$(this).attr("rel"))
		$(this).css("background-position", "0 0");
	});
}

/*Hot topics移動*/

var timer=false;

function moveBlanch(){
    if($(document).height() > $(window).height()+200){
        $("#branch-float").css('top',Math.ceil(($(window).scrollTop()-parseInt($("#branch-float").css("top")))/10)+parseInt($("#branch-float").css("top"))+"px");
        setTimeout("moveBlanch()", 30);
    }
}

/*フォントサイズスタイルシート選択*/

function setStyleSheetSelecter(title) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	$.each($(".header-font a"),function(index,obj){
		$(this).bind('click', function(){
			setActiveStyleSheet($(this).attr("rel"));
			return false;
		});
	});
	setActiveStyleSheet(title);
}

function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getPreferredStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("rel").indexOf("alt") == -1
			&& a.getAttribute("title")
		) return a.getAttribute("title");
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 0);
}

/*ムービー*/
function playRotablator(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'rotablator',repeat:'0',cid:'1',seriesTitle:'ロータブレーター',series:'rotablator',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playKoalaMaeda(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 650, objectWidth: 650, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'koala_maeda',repeat:'0',cid:'10',seriesTitle:'ガンとしょくせいかつ',series:'koala_maeda',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playDietMaeda(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 650, objectWidth: 650, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'diet_maeda',repeat:'0',cid:'30',seriesTitle:'ただしいダイエット',series:'diet_maeda',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playMicroSurgery(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'micro_surgery',repeat:'0',cid:'2',seriesTitle:'マイクロサージャリー',series:'micro_surgery',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playPharmacy(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'pharmacy',repeat:'0',cid:'26',seriesTitle:'おくすりののみかた',series:'pharmacy',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playMisumiLecture1(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'nurse_education',repeat:'0',cid:'7',seriesTitle:'レクチャー１',series:'kango_misumi',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playMisumiLecture2(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'nurse_education',repeat:'0',cid:'25',seriesTitle:'レクチャー２',series:'kango_misumi2',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playMisumiLecture3(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'nurse_education',repeat:'0',cid:'29',seriesTitle:'レクチャー３',series:'kango_misumi3',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playCasDemo(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 320, objectWidth: 320, objectHeight: 250, swfOptions: {version: '8', params: {quality: 'high'} } } );
}

function playCasBoston(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 490, swfOptions: {version: '8', flashvars: { titleImage:'bostoncas',repeat:'0',cid:'49',seriesTitle:'bostoncas',series:'bostoncas',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playCardiology(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 320, objectWidth: 320, objectHeight: 240, swfOptions: {version: '8', params: {quality: 'high'} } } );
}

function playLaser(doc,hsobj) {
	return hsobj.htmlExpand(doc, { objectType:'swf', width: 550, objectWidth: 550, objectHeight: 460, swfOptions: {version: '8', flashvars: { titleImage:'aso_laser',repeat:'0',cid:'12',seriesTitle:'ASOレーザー',series:'aso_laser',dhost:'www',mhost:'www',domain:'chibanishi-hp.or.jp',extension:'flv' }, params: {quality: 'high'} } } );
}

function playStanfordA(doc,hsobj) {
    return hsobj.htmlExpand(doc, { objectType:'iframe', width: 640, height:390, objectWidth: 640, objectHeight: 390, preserveContent:false,objectLoadTime:'after'});
}
