/*
information = {
	filename: /js/generator/common/common.js ;
	description: define common function and basic function. ;
	company : Hitachi Construction Machinery Camino Co., Ltd.;
	copyright : (c) 2008 Hitachi Construction Machinery Camino Co., Ltd. All rights reserved. ;
}
*/
function addEvent(obj, type, listener) {
	if(window.addEventListener) window.addEventListener('load',listener,false);
	else {
		var prev  = obj[type];
		obj[type] = (prev) ? function() { prev(); listener(); } : listener;
	}
}
window.addOnload = function(listener){
	addEvent(window, 'onload', listener);
}

/*
gecko, opera, msie(ie:bugged Mac IE) , ie5, ie55, ie6, ie7, macie5, safari, js 
*/
var sethtmlCls = function(){
	var u = navigator.userAgent.toLowerCase(),
		is = function(t){ return u.indexOf(t) != -1;},
		hs = document.getElementsByTagName('html')[0],
		brw = (/msie ([\d.]{0,3})/i.test(u))? ("msie " + (is("mac")? "mac" : "") + "ie" + ((RegExp.$1.replace(".","")%55==0)? "55": RegExp.$1.substring(0,1))) : is('opera')? "opera" : is('safari')? "safari" : "gecko";
	brw += " js";
	hs.className = brw;
}();

/*
Emvironment Function
*/
function HcmacClass(){
	this.siteDir = "/";
	this.env  = {};
	this.env.ver = navigator.appVersion;
	this.env.agent = navigator.userAgent.toLowerCase();
	this.env.win = (this.env.agent.indexOf("windows") != -1);
	this.env.mac = (this.env.agent.indexOf("mac") != -1);
	this.env.dom = document.getElementById? true:false;
	this.env.gecko = this.env.agent.indexOf("gecko") != -1;
	this.env.opera = this.env.agent.indexOf("opera",0) != -1;
	this.env.safari = this.env.agent.indexOf("safari") != -1;
	this.env.ie = this.env.agent.indexOf("msie") != -1 && !this.env.opera;
	this.env.ie5win = (this.env.agent.indexOf("msie 5.0") != -1) && this.env.win;
	this.env.ie55win = (this.env.agent.indexOf("msie 5.5") != -1) && this.env.win;
	this.env.iewin = this.env.ie && this.env.win;
	this.env.ie5mac = (this.env.agent.indexOf("msie") != -1) && this.env.mac;
	this.env.ns = this.env.agent.indexOf("netscape") != -1 && !this.env.opera;
	this.env.ns6 = (this.env.agent.indexOf("netscape6/6.0") != -1) && this.env.ns;
	this.env.domain = new String(document.domain);
	this.env.path = new String(location.pathname);
	
}
HcmacClass.prototype = {
	getElementsByClsName : function(obj,clsName,tag){
		tag = tag || '*';
		var elms = new Array(),
			re = new RegExp('(^| )' + clsName + '( |$)'),
			tags = obj.getElementsByTagName('*');
		for(var i=0,j=0,f=tags.length ; i<f ; i++) {
			if(re.test(tags[i].className)) {
				elms[j]=tags[i];
				j++;
			}
		}
		return elms;
	}
}
var hcmac = new HcmacClass();

/*
Popup window Function
*/
function openWin(url,obj){
	var winStr = new Array();
	if(typeof obj == "object"){
		winStr.push( 'width=' + (obj.width || screen.width - 300));// width (numbar)
		winStr.push( 'height=' + (obj.height || screen.height - 300));// height (numbar)
		winStr.push( 'menubar=' + (obj.menubar ? 0 : ((obj.menubar == 0)? 0 : 1) ));// menubar (default : 1)
		winStr.push( 'toolbar=' + (obj.toolbar ? 0 : ((obj.toolbar == 0)? 0 : 1) ));// toolbar (default : 1)
		winStr.push( 'location=' + (obj.location ? 0 : ((obj.location == 0)? 0 : 1) ));// location (default : 1)
		winStr.push( 'status=' + (obj.status ? 0 : ((obj.status == 0)? 0 : 1) ));// status (default : 1)
		winStr.push( 'resizable=' + (obj.resizable ? 0 : ((obj.resizable == 0)? 0 : 1) )); //not resizeable (default : 1)
		winStr.push( 'scrollbars=' + (obj.scrollbars ? 0 : ((obj.scrollbars == 0)? 0 : 1) )); //not scrollbars (default : 1)
	}else{
		winStr.push( 'width=' + (screen.width - 500));
		winStr.push( 'height=' + (screen.height - 500));
		winStr.push( 'menubar=1,toolbar=1,location=1,status=1,resizable=1,scrollbars=1');
	}
	var popupWin = window.open(url,((!!obj)? obj.name : 'New'),new String(winStr));
	popupWin.focus();
}

/*
Fixed IE6 cache problem.
*/
try{
	document.execCommand("BackgroundImageCache", false, true);
}catch(err){}




