﻿/**
* common.js
*
* @version		1.0.2.1
* @update		21:54 2008/11/25
* @extends		----
*
*/

( function() { if (!document.getElementById) return

/* ============================================================================== colorRows - 'rowTint'
	Automatic coloured rows | Bite Size Standards
	http://bitesizestandards.com/bites/automatic-coloured-rows
*/

var colorRows = function() {
	var tr = document.getElementsByTagName('tr');
	for (var i = 0; i < tr.length; i++) {
		if (i % 2) {
			tr[i].className = 'rowTint';
		}
	}
};

/* ============================================================================== initRollovers - 'imgover'
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

var initRollovers = function() {

	var aPreLoad = new Array();
	var sTempSrc;
	var img = document.getElementsByTagName('img');

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

			img[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			img[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			};

			img[i].onmouseout = img[i].onclick = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o' + ftype, ftype);
				this.setAttribute('src', sTempSrc);
			};
		}
	}
};

/* ============================================================================== createExternalLink - 'external'
	Author : Sakai
	Date   : 2008-01-19
*/

var createExternalLink = function() {
	var externalLink = document.getElementsByTagName('a');
	for (var i = 0, len = externalLink.length; i < len; i++) {
		var a = externalLink[i];
		if (a.getAttribute('rel') == 'external') {
			if (a.title) a.title += ' : 新しいウィンドウで開きます';
			a.onclick = function() {
				window.open(this.getAttribute('href'), '_blank');
				return false;
			}
		}
	}
};

/* ============================================================================== formAdjust
	Author : Sakai
	Date   : 2008-03-10
	Update : 2008-10-08
*/

var formAdjuster = function() {
	var inputForm = document.getElementsByTagName('input');
	for (var i = 0, len = inputForm.length; i < len; i++) {
		var iptFm = inputForm[i];
		if (iptFm.getAttribute('type') == 'text' && iptFm.size) {
			var inputSize = iptFm.size;
			if (0 < inputSize && inputSize <= 5) {
				if (iptFm.className != '') {
					iptFm.className += ' level1 typeText';
				} else {
					iptFm.className = 'level1 typeText';
				}
			} else if (inputSize <= 20) {
				if (iptFm.className != '') {
					iptFm.className += ' level2 typeText';
				} else {
					iptFm.className = 'level2 typeText';
				}
			} else if (inputSize <= 40) {
				if (iptFm.className != '') {
					iptFm.className += ' level3 typeText';
				} else {
					iptFm.className = 'level3 typeText';
				}
			} else {
				if (iptFm.className != '') {
					iptFm.className += ' level4 typeText';
				} else {
					iptFm.className = 'level4 typeText';
				}
			}
		}
	}
};




/* ==============================================================================
*/


var	addClass = function(element, value) {
	
	if (!element.className) element.className = value;
	else element.className += ' ' + value;
	
}



/* ============================================================================== addEvent
*/

function addEvent(elm, listener, fn){
	try {
		elm.addEventListener(listener, fn, false);
	} catch(e) {
		elm.attachEvent('on' + listener, fn);
	}
}

addEvent(window, 'load', function() {
	initRollovers();
	formAdjuster();
	createExternalLink();
});

}) ();




function open_access(){
	open_win('./access.html');
}

function open_cuisine(){
	open_win('./cuisine.html');
}

function open_contact(){
	open_win('./contact1.html');
}

function open_fair(){
	open_win('./bridal/');
}

function open_link(){
	open_win('./link.html');
}

function open_plan(){
	open_win('./plan/');
}

function open_privacy(){
	open_win('./privacy.html');
}

function open_reservation(){
	open_win('./reservation.html');
}


function open_recruit(){
	open_win_blank('http://www.escrit.jp/recruit/Page/TOP/');
}

function open_win(temp_url){
	window.location.href = temp_url;
}

function open_win_blank(temp_url){
	window.open(temp_url);
}