﻿//GA
var ua = '';
if(location.hostname == 'www.g-c.co.jp') {
	ua = 'UA-23375159-1';
	} else if(location.hostname == 'www.pin-japan.com') {
	ua = 'UA-23375159-2';
};
var _gaq = _gaq || [];
_gaq.push(['_setAccount', ua]);
_gaq.push(['_trackPageview']);

//__swf_area
var style = document.createElement("link"),
head =
document.getElementsByTagName('head')[0];
style.type = "text/css";
style.rel = "stylesheet";
style.href = "/css/jsStyle.css";
head.appendChild( style );


$(function(){
	$('#home #plugin').css('visibility','visible');
	$('#business #plugin #box').css('visibility','visible');

	//rollover
	$.rollover = function(){
		$("a > img[src*=_off]").mouseover(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"))
		}).mouseout(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
		}).each(function(){
			$("<img>").attr("src",$(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"))
		});
	};
	$.rollover();

	//infomationbar
	$.infomationbar_open = function(flag){
		//flag(if opening)
		var max = '0px';
		if(flag == 'opening') {
			max = '35px';
		};
		$('#informationbar').animate(
			{top: max},
			{duration: 500, easing: 'easeOutCirc',
			complete: function(){
				$('#informationbar h2 a img').attr('src','../images/index_btn_infomationtab_down_off.gif');
			}
		});
	};
	$.infomationbar_close = function(){
		//ie 6
		var tab_top = '111px';
		if(!jQuery.support.style){
			if (typeof document.documentElement.style.maxHeight == "undefined") {
				tab_top = '101px';
			}
		}
		$('#informationbar').animate(
			{top: tab_top},
			{duration: 500, easing: 'easeOutCirc',
			complete: function(){
				$('#informationbar h2 a img').attr('src','../images/index_btn_infomationtab_off.gif');
			}
		});
	};

	$.infomationbar_move = function(){
		$.infomationbar_open('opening');
		$('#informationbar').animate({top: '35px'},600);
		$.infomationbar_close();
	};
	//$.infomationbar_move();

	//infomationbar
	$('#informationbar h2 a').click(function() {
		//ie 6
		var tab_top = '111px';
		if(!jQuery.support.style){
			if (typeof document.documentElement.style.maxHeight == "undefined") {
				tab_top = '101px';
			}
		}

		if($('#informationbar').css('top') == '0px') {
			$.infomationbar_close();
		} else {
			$.infomationbar_open();
		}
		return false;
	});


	//work_tab
	$.work_tab = function() {
		if($('#works').length) {
			var ua =navigator.userAgent;
			if(ua.indexOf('iPhone') > -1 || ua.indexOf('iPad') > -1 || ua.indexOf('iPod')  > -1) {
				$('#works #tab_area #tab_panel #tab_panel_wrap').css('height','auto');
			}

			var parameter = location.search;
			parameter = parameter.substring(1, parameter.length);
			parameter = decodeURIComponent(parameter);
			if(parameter == 'pin') {
				var showCont = $('#tab_menu li').length;
				$('.motion').css('display','none');
				$('#motion_area'+(showCont)).slideDown('normal');
				$('#tab_menu li.gcc img').attr('src','images/index_navi_01_off.gif');
				$('#tab_menu li.pin img').attr('src','images/index_navi_02_here.gif');
				$('#topic_path dd span').text('（株式会社医薬情報ネット）');
			}
		}

		$('#tab_menu a').click(function(){
			var connectCont = $('#tab_menu a').index(this);
			var showCont = connectCont+1;
			$('.motion').css({display:'none'});
			$('#motion_area'+(showCont)).slideDown('normal');
		});
	};
	$.work_tab();


	//drop down menu
	$('#globalnavi').droppy({speed:200});

	//superbox
	$.superbox();

	//print_map
	$.jPrintArea=function(el){
		var iframe=document.createElement('IFRAME');
		var doc=null;
		$(iframe).attr('style','position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
		document.body.appendChild(iframe);
		doc=iframe.contentWindow.document;
		var links=window.document.getElementsByTagName('link');
		for(var i=0;i<links.length;i++)
		if(links[i].rel.toLowerCase()=='stylesheet')
		doc.write('<link type="text/css" rel="stylesheet" href="/css/import.css"></link>');
		doc.write('<div class="'+$(el).attr("class")+'">'+$(el).html()+'</div>');
		doc.close();
		iframe.contentWindow.focus();
		iframe.contentWindow.print();
		alert('印刷ダイアログからプリントを実行した後「OK」を押してください。');
		document.body.removeChild(iframe);
	}

	//mail_address
	$.mail_address = function(label) {
		var str = '';
		if(label == 'gcc') {
			str = String.fromCharCode(103,99,99,105,110,102,111,64,103,45,99,46,106,112);
			$('.mail_gcc').html('<a href="mailto:'+ str +'"><img src="/images/cmn_txt_mail_gcc_01_off.gif" width="101" height="13" alt="'+ str +'" /></a>');
		} else if(label == 'pin') {
			str = String.fromCharCode(105,110,102,111,64,112,105,110,45,106,97,112,97,110,46,99,111,46,106,112)
			$('.mail_pin').html('<a href="mailto:'+ str +'"><img src="/images/cmn_txt_mail_pin_01_off.gif" width="141" height="13" alt="'+ str +'" /></a>');
		};
		$.rollover();
	};

	//google analytics
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
});



