
function preloadImages() {
    [
		'banner_partner_over.jpg',
		'banner_usa_over.jpg',
		'banner_usersroom_over.jpg',
		'banner_visit_over.jpg',
		'banner_wp1_over.jpg',
		'gnavi_cwat_over.jpg',
		'gnavi_download_over.jpg',
		'gnavi_event_over.jpg',
		'gnavi_partner_over.jpg',
		'gnavi_related_over.jpg',
		'gnavi_service_over.jpg',
		'gnavi_success_over.jpg',
		'icon_blank_g_over.gif',
		'icon_blank_over.gif',
    ].each(function(image){ new Image().src = '/common/imgs/' + image; });
}
preloadImages();

CWAT.WWW = {
	load: function() {		
		
		//$('menu-container-cwat').addClassName('show-menu-container');
		
		//$('sub-menu-container-cwat-product').toggleClassName('show-sub-menu-container');
		//$('sub-menu-container-cwat-training').toggleClassName('show-sub-menu-container');
		
		var cwatNavi = new CWAT.GlobalNavi('cwat', ['product', 'training']);
		var serviceNavi = new CWAT.GlobalNavi('service');
		var relatedNavi = new CWAT.GlobalNavi('related');
		var eventNavi = new CWAT.GlobalNavi('event');
		var partnerNavi = new CWAT.GlobalNavi('partner');
		var successNavi = new CWAT.GlobalNavi('success');
		var downloadNavi = new CWAT.GlobalNavi('download');
	}
};

CWAT.GlobalNavi = Class.create({
    timer: null,
    hideDelay: 0.0,
	initialize: function(sufix, subMenuSufixList){
		this.gNavi = $('gnavi-' + sufix);
		this.gNaviImage = $('gnavi-image-' + sufix);
		this.menu = $('menu-container-' + sufix);
		this.sufix = sufix;
		
		this.gNavi.observe('mouseover', this.show.bindAsEventListener(this));
		this.gNavi.observe('mouseover', this.keepAlive.bindAsEventListener(this));
		this.gNavi.observe('mouseout', this.setupTimer.bindAsEventListener(this));
		
		if(subMenuSufixList) subMenuSufixList.each(
			function(subMenuSufix){
				var s = sufix + '-' + subMenuSufix;
				var subMenu = $('sub-menu-container-' + s);
				var switchButton = $('switch-' + s);
				switchButton.observe('click', 
					function(){
						subMenu.toggleClassName('show-sub-menu-container');
						var img = switchButton.down('img');
						if(subMenu.hasClassName('show-sub-menu-container')) {
							img.src = img.src.replace('_collapse.','_expand.');			
						}else{
							img.src = img.src.replace('_expand.','_collapse.');	
						}
						DD_belatedPNG.fixPng(img);
					}
				);
			}
		);
		
		$$('#menu-container-' + sufix + ' a').each(
			function(anchor){
				if($(anchor).hasClassName('switch')) return;
				anchor.observe('click', this.close.bind(this));
			}.bindAsEventListener(this)
		);
	},
    show: function() {
        this.keepAlive();
		if(this.menu.hasClassName('show-menu-container')) return;
		this.menu.addClassName('show-menu-container');
		if(this.gNavi.up().hasClassName(this.sufix)) {
			this.gNaviImage.src = this.gNaviImage.src.replace('_selected.','_over.');
		}else{
			this.gNaviImage.src = this.gNaviImage.src.replace('_normal.','_over.');
		}
		if(Prototype.Browser.IE) $$('#' + this.gNavi.id + ' shape').each( function(shape){ $(shape).show(); });
	},
	close: function() {
		this.menu.removeClassName('show-menu-container');
		if(this.gNavi.up().hasClassName(this.sufix)) {
			this.gNaviImage.src = this.gNaviImage.src.replace('_over.','_selected.');
		}else{
			this.gNaviImage.src = this.gNaviImage.src.replace('_over.','_normal.');
		}
		if(Prototype.Browser.IE) $$('#' + this.gNavi.id + ' shape').each( function(shape){ $(shape).hide(); });
	},
    setupTimer: function() {
        this.timer = setTimeout(this.close.bind(this), this.hideDelay * 1000);
    },
    keepAlive: function() {
        clearTimeout(this.timer);
    }
});
CWAT.Map =  {
	show: function() {
		if (window.open) { window.open('/map.html', '', 'width=840,height=912,scrollbars=yes,resizable=yes'); return false; };
	}
};
CWAT.Inquiry =  {
	yubincheck: function() {
		txt = document.RegistForm.yubin.value;
		atai = txt.match(/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/);
		if(!atai) {
		alert("郵便番号が正しく入力されているかご確認ください");
		document.getElementById('yubin').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	check: function(){
		str=document.RegistForm.email.value;
		if(str.indexOf("@",0)<0){
			alert("メールアドレスが正しく入力されているかご確認ください");
			document.getElementById('email').style.backgroundColor = '#ffaaaa';
			return false;
		}
	},
	telcheck: function(){
		txt = document.RegistForm.tel.value;
		atai = txt.match(/^[0-9]+\-[0-9]+\-[0-9]+$/);
		if(!atai) {
			alert("電話番号はハイフン(-)を2つ入れた半角英数の形式でご入力願います。");
			document.getElementById('tel').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	DataCheck: function() {
		var EmptyItem = "";
		if(this.checkblank(document.RegistForm.kaisha) != 0) { EmptyItem = EmptyItem + " 会社名\r\n"; } 
		if(this.checkblank(document.RegistForm.kaishakana) != 0) { EmptyItem = EmptyItem + " 会社名カナ\r\n"; }
		if(this.checkblank(document.RegistForm.busho1) != 0) { EmptyItem = EmptyItem + " 部署名\r\n"; }
		if(this.checkblank(document.RegistForm.shi) != 0) { EmptyItem = EmptyItem + " 姓\r\n"; }
		if(this.checkblank(document.RegistForm.mei) != 0) { EmptyItem = EmptyItem + " 名\r\n"; }
		if(this.checkblank(document.RegistForm.shikana) != 0) { EmptyItem = EmptyItem + " 姓(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.meikana) != 0) { EmptyItem = EmptyItem + " 名(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.yubin) != 0) { EmptyItem = EmptyItem + " 郵便番号\r\n"; }
		if (
			(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex].value == "") ||
			(document.RegistForm.jyusho2.value == "") ||
			(document.RegistForm.jyusho3.value == "")
		 ) {
			this.checkblank(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex]);
			this.checkblank(document.RegistForm.jyusho2);
			this.checkblank(document.RegistForm.jyusho3);
			EmptyItem = EmptyItem + " 住所\r\n";
		} else {
			document.getElementById('jyusho1').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho2').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho3').style.backgroundColor = '#ffffff';
		}
		if(this.checkblank(document.RegistForm.tel) != 0) { EmptyItem = EmptyItem + " 電話番号\r\n"; }
		if(this.checkblank(document.RegistForm.email) != 0) { EmptyItem = EmptyItem + " E-Mail\r\n"; }
		if(this.checkblank(document.RegistForm.kategori[document.RegistForm.kategori.selectedIndex]) != 0) { EmptyItem = EmptyItem + " カテゴリ\r\n"; }
		if(this.checkblank(document.RegistForm.naiyo) != 0) { EmptyItem = EmptyItem + " 内容\r\n"; }
		if (EmptyItem != "") {
			ShowMessage =EmptyItem + "を入力して下さい\r\n";
			alert(ShowMessage);
			document.RegistForm.focus();
			return false;
		} else {
			document.RegistForm.submit();
		}
	},
	checkblank: function(data){
		 if(data.value == "" || data.value ==" " || data.value =="　"){
			 data.style.backgroundColor='#ffaaaa';
			 return(1);
		 } else {
			 data.style.backgroundColor='#ffffff';
			 return(0);
		 }
	}
};
CWAT.iwsd2009 =  {
	yubincheck: function() {
		txt = document.RegistForm.yubin.value;
		atai = txt.match(/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/);
		if(!atai) {
		alert("郵便番号が正しく入力されているかご確認ください");
		document.getElementById('yubin').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	check: function(){
		str=document.RegistForm.email.value;
		if(str.indexOf("@",0)<0){
			alert("メールアドレスが正しく入力されているかご確認ください");
			document.getElementById('email').style.backgroundColor = '#ffaaaa';
			return false;
		}
	},
	telcheck: function(){
		txt = document.RegistForm.tel.value;
		atai = txt.match(/^[0-9]+\-[0-9]+\-[0-9]+$/);
		if(!atai) {
			alert("電話番号はハイフン(-)を2つ入れた半角英数の形式でご入力願います。");
			document.getElementById('tel').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	DataCheck: function() {
		var EmptyItem = "";
		if(this.checkblank(document.RegistForm.kaisha) != 0) { EmptyItem = EmptyItem + " 会社名\r\n"; } 
		if(this.checkblank(document.RegistForm.kaishakana) != 0) { EmptyItem = EmptyItem + " 会社名カナ\r\n"; }
		if(this.checkblank(document.RegistForm.busho1) != 0) { EmptyItem = EmptyItem + " 部署名\r\n"; }
		if(this.checkblank(document.RegistForm.shi) != 0) { EmptyItem = EmptyItem + " 姓\r\n"; }
		if(this.checkblank(document.RegistForm.mei) != 0) { EmptyItem = EmptyItem + " 名\r\n"; }
		if(this.checkblank(document.RegistForm.shikana) != 0) { EmptyItem = EmptyItem + " 姓(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.meikana) != 0) { EmptyItem = EmptyItem + " 名(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.yubin) != 0) { EmptyItem = EmptyItem + " 郵便番号\r\n"; }
		if (
			(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex].value == "") ||
			(document.RegistForm.jyusho2.value == "") ||
			(document.RegistForm.jyusho3.value == "")
		 ) {
			this.checkblank(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex]);
			this.checkblank(document.RegistForm.jyusho2);
			this.checkblank(document.RegistForm.jyusho3);
			EmptyItem = EmptyItem + " 住所\r\n";
		} else {
			document.getElementById('jyusho1').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho2').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho3').style.backgroundColor = '#ffffff';
		}
		if(this.checkblank(document.RegistForm.tel) != 0) { EmptyItem = EmptyItem + " 電話番号\r\n"; }
		if(this.checkblank(document.RegistForm.email) != 0) { EmptyItem = EmptyItem + " E-Mail\r\n"; }
		if(document.RegistForm.shiryo[0].checked == false
			&& document.RegistForm.shiryo[1].checked == false
			&& document.RegistForm.shiryo[2].checked == false
			&& document.RegistForm.shiryo[3].checked == false
			&& document.RegistForm.shiryo[4].checked == false
			&& document.RegistForm.shiryo[5].checked == false
			&& document.RegistForm.shiryo[6].checked == false) {
			EmptyItem = EmptyItem + " 請求資料\r\n";
			document.getElementById('shiryo').style.backgroundColor = '#ffaaaa';
		} else {
			document.getElementById('shiryo').style.backgroundColor = '#ffffff';		
		}
		if (EmptyItem != "") {
			ShowMessage =EmptyItem + "を入力して下さい\r\n";
			alert(ShowMessage);
			document.RegistForm.focus();
			return false;
		} else {
			document.RegistForm.submit();
		}
	},
	checkblank: function(data){
		 if(data.value == "" || data.value ==" " || data.value =="　"){
			 data.style.backgroundColor='#ffaaaa';
			 return(1);
		 } else {
			 data.style.backgroundColor='#ffffff';
			 return(0);
		 }
	}
};
CWAT.Request =  {
	yubincheck: function() {
		txt = document.RegistForm.yubin.value;
		atai = txt.match(/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/);
		if(!atai) {
		alert("郵便番号が正しく入力されているかご確認ください");
		document.getElementById('yubin').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	check: function(){
		str=document.RegistForm.email.value;
		if(str.indexOf("@",0)<0){
			alert("メールアドレスが正しく入力されているかご確認ください");
			document.getElementById('email').style.backgroundColor = '#ffaaaa';
			return false;
		}
	},
	telcheck: function(){
		txt = document.RegistForm.tel.value;
		atai = txt.match(/^[0-9]+\-[0-9]+\-[0-9]+$/);
		if(!atai) {
			alert("電話番号はハイフン(-)を2つ入れた半角英数の形式でご入力願います。");
			document.getElementById('tel').style.backgroundColor = '#ffaaaa';
		}
		return false;
	},
	DataCheck: function() {	
		var EmptyItem = "";
		if(this.checkblank(document.RegistForm.kaisha) != 0) { EmptyItem = EmptyItem + " 会社名\r\n"; } 
		if(this.checkblank(document.RegistForm.kaishakana) != 0) { EmptyItem = EmptyItem + " 会社名カナ\r\n"; }
		if(this.checkblank(document.RegistForm.busho1) != 0) { EmptyItem = EmptyItem + " 部署名\r\n"; }
		if(this.checkblank(document.RegistForm.shi) != 0) { EmptyItem = EmptyItem + " 姓\r\n"; }
		if(this.checkblank(document.RegistForm.mei) != 0) { EmptyItem = EmptyItem + " 名\r\n"; }
		if(this.checkblank(document.RegistForm.shikana) != 0) { EmptyItem = EmptyItem + " 姓(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.meikana) != 0) { EmptyItem = EmptyItem + " 名(カナ)\r\n"; }
		if(this.checkblank(document.RegistForm.yubin) != 0) { EmptyItem = EmptyItem + " 郵便番号\r\n"; }
		if (
			(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex].value == "") ||
			(document.RegistForm.jyusho2.value == "") ||
			(document.RegistForm.jyusho3.value == "")
		 ) {
			this.checkblank(document.RegistForm.jyusho1[document.RegistForm.jyusho1.selectedIndex]);
			this.checkblank(document.RegistForm.jyusho2);
			this.checkblank(document.RegistForm.jyusho3);
			EmptyItem = EmptyItem + " 住所\r\n";
		} else {
			document.getElementById('jyusho1').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho2').style.backgroundColor = '#ffffff';
			document.getElementById('jyusho3').style.backgroundColor = '#ffffff';
		}
		if(this.checkblank(document.RegistForm.tel) != 0) { EmptyItem = EmptyItem + " 電話番号\r\n"; }
		if(this.checkblank(document.RegistForm.email) != 0) { EmptyItem = EmptyItem + " E-Mail\r\n"; }
		if(document.RegistForm.shiryo[0].checked == false && document.RegistForm.shiryo[1].checked == false) {
			EmptyItem = EmptyItem + " 請求資料\r\n";
			document.getElementById('shiryo').style.backgroundColor = '#ffaaaa';
		} else {
			document.getElementById('shiryo').style.backgroundColor = '#ffffff';		
		}
		if (EmptyItem != "") {
			ShowMessage =EmptyItem + "を入力して下さい\r\n";
			alert(ShowMessage);
			document.RegistForm.focus();
			return false;
		} else {
			document.RegistForm.submit();
		}
	},
	checkblank: function(data){
		 if(data.value == "" || data.value ==" " || data.value =="　"){
			 data.style.backgroundColor='#ffaaaa';
			 return(1);
		 } else {
			 data.style.backgroundColor='#ffffff';
			 return(0);
		 }
	}
};
document.observe('dom:loaded', function(){ CWAT.WWW.load(); });
