/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 gCssUA = navigator.userAgent.toUpperCase();
gCssBrw = navigator.appName.toUpperCase();

with (document) {
		write("<style type=\"text/css\"><!--");


//WIN-IE
	if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
		write(".fs10 {font-size: 62.5%; line-height: 150%; letter-spacing:1px;}");
		write(".fs12 {font-size: 75%; line-height: 150%; letter-spacing:1.5px;}");
		write(".fs14 {font-size: 87.5%; line-height: 150%; letter-spacing:2px;}");
		write(".fs18 {font-size: 117.5%; line-height: 130%; letter-spacing:2.5px;}");
		write(".fs22 {font-size: 137.5%; line-height: 130%; letter-spacing:3px;}");
		write(".fs24 {font-size: 150%; line-height: 130%; letter-spacing:3px;}");
		write(".fs30 {font-size: 187.5%; line-height: 125%; letter-spacing:3.5px;}");
		write(".fs10n {font-size: 62.5%; letter-spacing:1px;}");
		write(".fs12n {font-size: 75%; letter-spacing:1.5px;}");
		write(".fs14n {font-size: 87.5%; letter-spacing:2px;}");
		write(".fs18n {font-size: 117.5%; letter-spacing:2.5px;}");
		write(".fs22n {font-size: 137.5%; letter-spacing:1px;}");
		write(".fs24n {font-size: 150%; letter-spacing:1px;}");
		write(".fs30n {font-size: 187.5%; letter-spacing:1px;}");
		write(".fs12st {font-size: 75%; line-height: 150%; letter-spacing:1.5px; font-weight: bold;}");
	}

//WIN-NN
	if (gCssUA.indexOf("WIN") != -1 && gCssBrw.indexOf("NETSCAPE") != -1) {
		write(".fs10 {font-size:72%; line-height:130%;}");
		write(".fs12 {font-size: 75%; line-height: 150%;}");
		write(".fs14 {font-size: 87.5%; line-height: 140%;}");
		write(".fs18 {font-size: 117.5%; line-height: 130%;}");
		write(".fs22 {font-size: 137.5%; line-height: 130%;}");
		write(".fs24 {font-size: 150%; line-height: 130%;}");
		write(".fs30 {font-size: 187.5%; line-height: 120%;}");
		write(".fs10n {font-size:72%;}");
		write(".fs12n {font-size: 75%;}");
		write(".fs14n {font-size: 87.5%;}");
		write(".fs18n {font-size: 117.5%;}");
		write(".fs22n {font-size: 137.5%;}");
		write(".fs24n {font-size: 150%;}");
		write(".fs30n {font-size: 187.5%;}");
		write(".fs12st {font-size: 75%; line-height: 150%; font-weight: bold;}");
	}

//WIN-NN4.x
	if ( navigator.appName == "Netscape" && navigator.appVersion.substr(0,2) == "4." ) {
		write(".fs10 {font-size:90%; line-height: 130%;}");
		write(".fs12 {font-size: 100%; line-height: 140%;}");
		write(".fs14 {font-size: 110%; line-height: 135%;}");
		write(".fs18 {font-size: 130%; line-height: 175%;}");
		write(".fs24 {font-size: 190%; line-height: 240%;}");
		write(".fs30 {font-size: 240%; line-height: 285%;}");
		write(".fs10n {font-size:90%;}");
		write(".fs12n {font-size: 100%;}");
		write(".fs14n {font-size: 110%;}");
		write(".fs18n {font-size: 130%;}");
		write(".fs24n {font-size: 190%;}");
		write(".fs30n {font-size: 240%;}");
		write(".fs12st {font-size: 100%; line-height: 140%; font-weight: bold;}");
	}

//MAC
	if (gCssUA.indexOf("MAC") != -1) {
		write(".fs10 {font-size: 10px; line-height: 14px;}");
		write(".fs12 {font-size: 12px; line-height: 18px;}");
		write(".fs14 {font-size: 14px; line-height: 18px;}");
		write(".fs18 {font-size: 18px; line-height: 23px;}");
		write(".fs22 {font-size: 22px; line-height: 27px;}");
		write(".fs24 {font-size: 24px; line-height: 30px;}");
		write(".fs30 {font-size: 30px; line-height: 35px;}");
		write(".fs10n {font-size: 10px;}");
		write(".fs12n {font-size: 12px;}");
		write(".fs14n {font-size: 14px;}");
		write(".fs18n {font-size: 18px;}");
		write(".fs22n {font-size: 22px;}");
		write(".fs24n {font-size: 24px;}");
		write(".fs30n {font-size: 30px;}");
		write(".fs12st {font-size: 12px; line-height: 18px; font-weight: bold;}");
	}

	write("--></style>");
}

//submenu.js
function MenuOn(x){ 
	obj=document.getElementById("submenu"+x).style.visibility="visible";
}
function MenuOff(x){ 
	obj=document.getElementById("submenu"+x).style.visibility="hidden"; 
}

//Rollover Menu
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'btn') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_O'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_O'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

//
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//商品一覧のボックス高さ揃え
/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}
