var asahi = asahi || new Object();
/**************************************************************************
 * ■ieXLiquidWidth
 **************************************************************************/
ieXLiquidWidth = function () {
	if ( document.getElementById("TopPage") ) {
		if(document.body.clientWidth < 966){
		  return "960px";
		}else if(document.body.clientWidth > 1286){
		  return "1280px";
		}else{
		  return "auto";
		}
	} else {
		if(document.body.clientWidth < 966){
		  return "960px";
		}else if(document.body.clientWidth > 1286){
		  return "1280px";
		}else{
		  return "auto";
		}
	}
}

/**************************************************************************
 * ■Cookie
 **************************************************************************/
asahi.Agent = function()
{
	this.initialize.apply(this, arguments);
}

asahi.Agent.prototype =
{
	initialize: function()
	{
		this.agent = navigator.userAgent.toLowerCase();
		this.ver = navigator.appVersion;
		this.win = (this.agent.indexOf("windows") != -1);
		this.mac = (this.agent.indexOf("mac") != -1);
		this.opera = this.agent.indexOf("opera",0) != -1;
		this.safari = this.agent.indexOf("safari") != -1;
		this.ie = this.agent.indexOf("msie") != -1 && !this.opera;
		this.ie5win = (this.agent.indexOf("msie 5.0") != -1) && this.win;
		this.ie55win = (this.agent.indexOf("msie 5.5") != -1) && this.win;
		this.ie6win = (this.agent.indexOf("msie 6.") != -1) && this.win;
		this.ie5mac = (this.agent.indexOf("msie") != -1) && this.mac;
		this.ns = this.agent.indexOf("netscape") != -1 && !this.opera;
		this.ns6 = (this.agent.indexOf("netscape6/6.") != -1) && this.ns;
		this.ns7 = (this.agent.indexOf("netscape7/7.") != -1) && this.ns;
		this.ie50mac = (this.agent.indexOf("msie 5.0") != -1) && this.mac;
	},

	getVer: function()
	{
		if(RegExp)
		{
			if(this.ie)
			{
				return this.agent.match(/msie (\d(.\d+)?)/)[1];
			}
			if(this.ns || this.ns6 || this.ns7)
			{
				return this.agent.match(/netscape\/(\d(.\d+)?)/)[1];
			}
			if(this.opera)
			{
				return this.agent.match(/opera\/? ?(\d(\.\d+)?)/)[1];
			}
			return parseFloat(this.ver);
		}
		else
		{
			return undefined;
		}
	},
	
	getTarget: function()
	{
		if(this.ie)
		{
			return this.getVer() >= 6;
		}
		if(this.safari)
		{
			var ver = this.agent.match(/applewebkit\/(\d(.\d+)?)/)[1];
			return (ver > 130);
		}
		if(this.ns)
		{
			return this.getVer() >= 7;
		}
		if(this.opera)
		{
			return this.getVer() >= 8.5;
		}
		return true;
	}
}

/**************************************************************************
 * ■Cookie
 **************************************************************************/
asahi.Cookie = function()
{
	this.initialize.apply(this, arguments);
}

asahi.Cookie.prototype =
{
	initialize: function()
	{
	},
	
	create: function(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=/; domain=asahi.com";
	},
	
	read: function(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;
	},
	
	clear: function(name)
	{
		document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	},
	
	
	object2String: function(obj)
	{
		var val, output = "";
		if (obj){	
			output += "{";
			for (var i in obj) {
				val = obj[i];
				switch (typeof val) {
					case ("object"):
						if (val[0]) {
							output += i + ":" + this.array2String(val) + ",";
						} else {
							output += i + ":" + this.object2String(val) + ",";
						}
						break;
					case ("string"):
						output += i + ":'" + escape(val) + "',";
						break;
					default:
						output += i + ":" + val + ",";
				}
			}
			output = output.substring(0, output.length-1) + "}";
		}
		return output;
	},
	
	array2String: function(array)
	{
		var output = "";
		if (array) {
			output += "[";
			for (var i in array) {
				val = array[i];
				switch (typeof val) {
					case ("object"):
						if (val[0]) {
							output += this.array2String(val) + ",";
						} else {
							output += this.object2String(val) + ",";
						}
						break;
					case ("string"):
						output += "'" + escape(val) + "',";
						break;
					default:
						output += val + ",";
				}
			}
			output = output.substring(0, output.length-1) + "]";
		}
		return output;
	},
	
	string2Object: function(string)
	{
		eval("var result = " + string);
		return result;
	},
	   
	string2Array: function(string)
	{
		eval("var result = " + string);
		return result;
	}
}


asahi.agent = new asahi.Agent();
jQuery.noConflict();

if(asahi.agent.getTarget())
{
	asahi.cookie = new asahi.Cookie();
	jQuery(function()
	{
		
	});
}






/**************************************************************************
 * ■旧common.jsより転記 - added on 080506 by asahi
 **************************************************************************/
// フォトギャラリー用（660x590）
function photogwin(){
  w=window.open("","photowin","scrollbars=1,toolbar=0,menubar=0,location=0,directories=0,resizable=1,status=0,width=660,height=590,");
  if(navigator.appVersion.charAt(0)>=4) { w.focus() };
}


// 小窓汎用
var targetWin=0;
function openwin(wid,hei,tgt){
	var opt = "scrollbars=1,toolbar=0,menubar=1,location=1,directories=0,resizable=1,status=1,";
  if(targetWin){
    if(!targetWin.closed) targetWin.close();
  }
  windowFeatures = opt + "width=" + wid + ",height=" + hei; 
  targetWin = open("", tgt, windowFeatures);
  targetWin.focus();
}

function sethome() {
        if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
                document.write('<div id="sethome"><a href="/home.html" onClick="this.style.behavior=\'url(#default#homepage)\'; this.setHomePage(\'http://www.asahi.com/\');">asahi.comをホームに</a></div>');
}
}
function sethome2006() {
        if (navigator.userAgent.indexOf("Opera",0) < 0 && navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
                document.write('<li><a href="/home.html" onClick="this.style.behavior=\'url(#default#homepage)\'; this.setHomePage(\'http://www.asahi.com/\');"><img src="/imag/arrow01.gif" alt="">asahi.comをホームページにする</a></li>');
}
}

function setsearch2006() {
        if (navigator.userAgent.indexOf("Opera",0) < 0 && navigator.userAgent && navigator.userAgent.indexOf('MSIE 7.0')!=-1 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
                document.write('<a href="#" onClick="window.external.AddSearchProvider(&quot;http://www.asahi.com/tool/sitesearch/sitesearch.xml&quot;);">ＩＥ７にニュース検索を追加する</a> ');
}
} 

function setsearch2006a() {
        if (navigator.userAgent.indexOf("Opera",0) < 0 && navigator.userAgent && ( navigator.userAgent.indexOf('Firefox/2.0')!=-1 || navigator.userAgent.indexOf('Firefox/3.0')!=-1 )) {
                document.write('<a href="#" onClick="window.external.AddSearchProvider(&quot;http://www.asahi.com/tool/sitesearch/sitesearch.xml&quot;);" style="color:red"><strong>Ｆｘにニュース検索を追加する</strong></a> ');
}
}




/**************************************************************************
 * ■一記事印刷用　090424 by asahi  add 20090703
 **************************************************************************/
// 一記事印刷ボタンクリック時

function openPrintWin(){
	myWin = window.open(window.location.href,"printWin","toolbar=1,location=0,directories=0,status=0,scrollbars=1");
	window.blur();
}
if (window.name == "printWin") {
	document.write('<link rel="stylesheet" href="../css09/common/page_print_btn_senkyo.css" type="text/css" media="all" />');
	if( navigator.userAgent.indexOf('Safari/') != -1 ) {
			setTimeout(function(){print();}, 1500);
			window.focus();
		} else {
		window.focus();
		print();
		}
}

