//winかMacか判定
pl = navigator.userAgent.match("Windows");
getUrl = location.href.replace("\\","/");
targetPath = "/jp/";
targetCssPath = "common/css/";
targetOldCssPath = "total/all/css/";
targetJsPath = "common/script/";
needpath_chk_location = getUrl.match(".aspx");
needpath_chk_site = getUrl.match("astellas.jp/jp/");
needpath_chk_aspx = getUrl.match("provide.aspx");

if(needpath_chk_location == null) {
	needpath = getUrl.substring(0,getUrl.lastIndexOf(targetPath)+targetPath.length);
}
else {
	if(needpath_chk_aspx == null && needpath_chk_site != null) {
		needpath = '/jp/provide.aspx?path=/med/jp/';	
	}
	else if(needpath_chk_aspx == null && needpath_chk_site == null) {
		needpath = '/med/jp/provide.aspx?path=/med/jp/';	
	}
	else {
		needpath = getUrl.substring(0,getUrl.lastIndexOf(targetPath)+targetPath.length);
	}
}

if(pl == null && navigator.appVersion.charAt(0) >= 4){
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_amn_common.css">');
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_opn_common.css">');
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_amn_mac.css">');
}

if(pl != null && navigator.appVersion.charAt(0) >= 4){
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_amn_common.css">');
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_opn_common.css">');
	document.write('<link rel="stylesheet" href="' + needpath + targetCssPath + 'con_amn_win.css">');
}

//--------------- JPフォルダ以下のアドレスを取得--------------
function ConGetunderTargetPath(){
	//！！！リンクアドレスを取得！！！
	//アドレスを取得しサーバーでもローカルでも大丈夫なように￥を/に置換
	getUrl = location.href.replace("\\","/");
	//基準ディレクトリ以下のみ取得
	underTargetPath = getUrl.substring(getUrl.lastIndexOf(targetPath)+targetPath.length,getUrl.length);
	//値を返す
	return underTargetPath;
}

//--------------- JPフォルダ以上のアドレスを取得--------------
function ConGetoverTargetPath(){
	//！！！リンクアドレスを取得！！！
	//アドレスを取得しサーバーでもローカルでも大丈夫なように￥を/に置換
	getUrl = location.href.replace("\\","/");
	//基準ディレクトリ以上のみ取得
	overTargetPath = getUrl.substring(0,getUrl.lastIndexOf(targetPath)+targetPath.length);
	//値を返す
	return overTargetPath;
}

//---------------プリロードキャッシュ画像　全ページ共通画像用---------------
function Con_AmnPreImages(){

	//基準ディレクトリ以上のみ取得
	overTargetPath = ConGetoverTargetPath();

	//イメージ格納用の配列宣言
	document.PreImage = new Array();

	//ページ内のonmouseover設定にSwapImage_2があるだけループ
	for(i=0; i<$("*[onmouseover*='SwapImage_2']").size(); i++) {
		//onmouseoverの中身を取得
		editSI = ($("*[onmouseover*='SwapImage_2']:eq("+ i +")").attr("onmouseover"));
		//文字列化しないと編集できないので文字列化
		editSI = String(editSI);
		//第二引数のファイル名だけを取得
		editSI = editSI.substring(editSI.lastIndexOf(",")+2, editSI.lastIndexOf(")")-1);
		//FireFoxで「"」が入ってしまうので削除
		editSI = editSI.replace('"', '');
		//イメージオブジェクトを宣言
		document.PreImage[i] = new Image();
		//パスを代入しプリロード
		document.PreImage[i].src= editSI;
	}

}

//---------------プリロードキャッシュ画像　固有画像用---------------
function Con_AmnPreImages_2(){

}

//---------------スワップイメージ　引数によるイメージ判定版---------------
function Con_AmnSwapImage(now){
	if(now == "GOBT") {
		url = needpath + 'common/images/base/button_go_o.gif'
	}
	Con_AmnSwapImage_2(now,url);
}

//---------------スワップイメージ 固有画像版---------------
function Con_AmnSwapImage_2(targobj,url){
	dd = eval('window.self.document.' + targobj);
	nowimg = dd.src;
	dd.src = url;
}

//---------------スワップイメージ画像戻し　引数によるイメージ判定版---------------
function Con_AmnReImage(now){
	Con_AmnReImage_2()
}

//---------------スワップイメージ画像戻し---------------
function Con_AmnReImage_2(){
	dd.src = nowimg;
}

//---------------ウインドオープン ハマーズ用---------------
function Con_AmnNewwin() {
	Nwin = window.open("http://www.hamers.co.jp/fsj/blank.html","fsjhamers","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=490,height=240,");
}

//---------------ウインドオープン スフィア用---------------
function Con_AmnMM_openBrWindow(theURL,winName,features) { 
	subWin = window.open( theURL, winName, features );
	subWin.focus();
}

//---------------プルダウンリンク機能---------------
function Con_AmnMM_jumpMenuGo(selName,targ,restore){ 
	arrSelObj = window.document.getElementsByName(selName);
	selUrl = arrSelObj[0].options[arrSelObj[0].selectedIndex].value;
	if (selUrl.match(/.htm/)) {
		location.href = selUrl;
	}
}

//---------------details_redirect機能---------------
function Con_AmnMM_LinkPage(){
	ConGetunderTargetPath();
	var_details_name = underTargetPath.split("/");
	details_path = '/jp/seihin/syuyaku.aspx?sr=' + var_details_name[2];
	
	if (document.location.href.match(".astellas.jp/") != null){ 
		location.replace(details_path);
	}
	else {
		alert(details_path);
	}
}
