var speed = 70;
var d = 90;
var blnIE = false;
var blnOp = false;
var blnNS = false;
var blnMac = false;
var browserVer = 0;
var blnIFrame = false;
//ブラウザ確定
if (navigator.userAgent.indexOf('Opera') > -1) {
	blnOp = true;
} else if (navigator.userAgent.indexOf('MSIE') > -1) {
	blnIE = true;
	navigator.userAgent.match(/MSIE ([\d.]*);/);
	ver = RegExp.$1;
} else {
	blnNS = true;
}

//OS確定
if (navigator.appVersion.indexOf("Mac") > -1) {
	blnMac = true;
}
if (!blnMac && blnIE && ver>=5.5) blnIFrame = true;

//プロトコル確定
if (location.href.match(/https/)) {
	domain = 'https://www.syngenta.co.jp';
} else {
	domain = 'http://www.syngenta.co.jp';
}

function Category(n,id,img,h,site,bgc) {
	this.site = site;
	this.categoryName = n;
	this.identifier = id;
	this.categoryImage = img;
	this.height = h;
	if (!blnIFrame) this.height+=25;
	this.currentHeight = 0;
	this.tblBackgroundColor = bgc;
	this.categoryBackgroundColor = '';
	this.blnStretch = false;
	this.name = new Array();
	this.url = new Array();
	this.newmark = new Array();
	this.initialSize = 0;
	this.popup=new Array();
	this.addSubCategory = function (n,u,nw,popup) {  // new parameter - popup. 20091001. Jem. 
		var l = this.name.length;
		this.name[l] = n;
		this.url[l] = u;
		this.newmark[l] = nw;
		this.popup[l]=popup; // added. 20091001. Jem. 
	}
	this.draw = function (l,t,w) {
		//HTML書き出し
		if (blnIFrame) document.write('<iframe border="0" frameborder="0" scrolling="no" style="position:absolute;z-index:0;top:'+t+';left:'+l+';visibility:hidden;width:'+w+';height:1px" id="if_'+this.identifier+'" src="'+domain+'/blank.html"></iframe>');
		document.write('<div id="'+this.identifier+'" class="divmenu" style="left:'+l+';top:'+t+';width:'+w+';height:1px;visibility:hidden">');
		document.write('<table class="subcategory" style="background-color:'+bgc+';" cellspacing="0" cellpadding="0" onmouseover="'+this.identifier+'.viewSub(true);" onmouseout="'+this.identifier+'.viewSub(false);">');
		document.write('<tr><td align="center"'+this.categoryBackgroundColor+' style="cursor:default"><a href="'+this.site+'"><img src="'+this.categoryImage+'" border="0" alt="'+this.categoryName+'"></a></td></tr>');
		for (i=0;i<this.name.length;i++) {
			var nwmk = '';
			var nwmksty = 'vertical-align:top;font-size:1px;position:relative;top:-2px'
			if (blnNS) nwmksty = 'font-size:1px';
			if (this.newmark[i]) nwmk = '<span style="'+nwmksty+'"><img src="/images/new.gif"></span>';
			
			// -- start - 20091001. Jem. 
			if (this.popup[i]){				
				document.write('<tr><td style="font-size:13px;padding:4px;color:#000066;text-align:left;height:28px" onmouseover="'+this.identifier+'.fillSub(this,\'#DDDDFF\');" onmouseout="'+this.identifier+'.fillSub(this,\'\');" onclick="window.open(\''+ this.url[i]  +  '\' ,\'_blank\',\'width=740,height=640,scrollbars=yes,location=no,menubar=no,resizable=yes,toolbar=no,status=no,\');return false;" >'+'<div style="margin-left:10px">'+nwmk+this.name[i]+'</div>'+'</td></tr>');
			}else{
				document.write('<tr><td style="font-size:13px;padding:4px;color:#000066;text-align:left;height:28px" onmouseover="'+this.identifier+'.fillSub(this,\'#DDDDFF\');" onmouseout="'+this.identifier+'.fillSub(this,\'\');" onclick="location.href=\''+this.url[i]+'\';">'+'<div style="margin-left:10px">'+nwmk+this.name[i]+'</div>'+'</td></tr>');
			}
			// -- end - 20091001. Jem. 
			
		}
		document.write('</table></div>');
	}
	this.preLoadImage = function () {
		//イメージ先読み
		var cimg = new Image();
		var scimg = new Image();
		cimg.src = this.categoryImage;
	}
	this.viewSub = function (TF) {
		var sty;
		sty = document.getElementById(this.identifier).style;
		if (TF) {
			this.blnStretch = true;
			sty.visibility = 'visible';
			if (blnIFrame) document.getElementById('if_'+this.identifier).style.visibility = 'visible';
			if (this.currentHeight == 1)this.currentHeight = this.initialSize;
			this.appearMenu(true);
			setTimeout(this.identifier+'.expandSub()',speed);
		} else {
			this.blnStretch = false;
			setTimeout(this.identifier+'.expandSub()',speed);
		}
	}
	this.expandSub = function (cat) {
		var sty;
		sty = document.getElementById(this.identifier).style;
		if (this.blnStretch) {
			//表示
			this.currentHeight+=d;
			if (this.currentHeight>=this.height) {
				this.currentHeight = this.height;
				this.expandIFrame(true);
				this.reachMenu(true);
				sty.height = this.currentHeight + 'px';
			} else {
				this.expandIFrame(true);
				this.reachMenu(true);
				sty.height = this.currentHeight + 'px';
				setTimeout(this.identifier+'.expandSub()', speed);
			}
		} else {
			//非表示
			this.currentHeight-=d;
			if (this.currentHeight<=this.initialSize) {
				this.currentHeight = 1;
				sty.height = this.currentHeight + 'px';
				this.expandIFrame(false);
				this.reachMenu(false);
				this.appearMenu(false);
			} else {
				sty.height = this.currentHeight + 'px';
				this.expandIFrame(false);
				this.reachMenu(false);
				setTimeout(this.identifier+'.expandSub()', speed);
			}
		}
	}
	this.fillSub = function (obj,bgc) {
		obj.style.backgroundColor = bgc;
	}
	this.setCategoryBackground = function (img,bgc) {
		this.categoryImage = img;
		if (bgc != '') {
			this.categoryBackgroundColor = ' bgcolor='+bgc;
		} else {
			this.categoryBackGroundColor = '';
		}
	}
	this.setInitialSize = function (sze) {
		this.initialSize = sze;
	}
	this.appearMenu = function(TF) {
		return;
	}
	this.reachMenu = function(TF) {
		return;
	}
	this.expandIFrame = function(TF) {
		if (!blnIFrame) return;
		var sty = document.getElementById('if_'+this.identifier).style;
		sty.height = (this.currentHeight)+'px';
	}
	this.changePosition = function (l,t,w) {
		var sty;
		var sty2;
		sty = document.getElementById(this.identifier).style;
		sty.left = l;
		sty.top = t;
		sty.width = w;
		if (blnIFrame) {
			sty2 = document.getElementById('if_'+this.identifier).style;
			sty2.left = l;
			sty2.top = t;
			sty2.width = w;
		}
	}

}

