
//--- from common.js ---
function doSubmit(name, isSSL, formIndex) {

	var path = "";
	var protocol = "https://";
	var host = window.location.host;
	var contextPath ="";
	var fileName = name;
	var fi = formIndex;

	if (isSSL == true) {
		protocol= "https://";
	} else {
		protocol = "http://";
	}

	if (0 <= window.location.pathname.indexOf("insweb")) {
		contextPath = "/insweb";
	}
	
	if (name.indexOf(".") == -1) {
		fileName = name + ".htj";
	}
	
	if (name.substr(0, 1) != "/") {
		fileName = "/" + fileName;
	}
	
	if (formIndex == null || formIndex == "") {
		fi = 0;
	}
	path = protocol + host + contextPath + fileName;
	document.forms[fi].action = path;	
	document.forms[fi].submit();
}


function doSubmitNewWindow(name, isSSL, formIndex) {

	var path = "";
	var protocol = "https://";
	var host = window.location.host;
	var contextPath ="";
	var fileName = name;
	var fi = formIndex;

	if (isSSL == true) {
		protocol= "https://";
	} else {
		protocol = "http://";
	}

	if (0 <= window.location.pathname.indexOf("insweb")) {
		contextPath = "/insweb";
	}
	
	if (name.indexOf(".") == -1) {
		fileName = name + ".htj";
	}
	
	if (name.substr(0, 1) != "/") {
		fileName = "/" + fileName;
	}
	
	if (formIndex == null || formIndex == "") {
		fi = 0;
	}

	// action
	path = protocol + host + contextPath + fileName;
	
	//alert(path);

	document.forms[fi].action = path;	
	document.forms[fi].target = "_blandk";	
	document.forms[fi].submit();

}


//--- from auto.js ---

//REFFEREをクッキーにセット
function setReferrer()
{
	var refURL = document.referrer;
	if(refURL.indexOf("insweb.co.jp") == -1 && refURL.length != 0)
	{
		var str = document.URL;
		var n = str.length;
		var locURL;
		if(n == 0)
		{
			locURL = "ERROR";
		} else {
			var p = str.lastIndexOf(".jp", n);
			p = p + 3;
			locURL = str.substring(p, n);
		}
		setCookie("IWJREFURL",refURL,locURL);
	}
}

function setCookie(key,ref,loc)
{
	var expiresDate = new Date();
	expiresDate.setTime( expiresDate.getTime() + 60*60*24*1000*1 ); 
	tmp = key + "=" + escape(ref) + "," + escape(loc) + "; ";
	tmp += "expires=";
	tmp += expiresDate.toGMTString() + "; ";
	tmp += "path=/; ";
	tmp += "domain=insweb.co.jp";
	document.cookie = tmp;
}

//--- from rollover.js ---

// ロールオーバー
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 == 'imgover') {
			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);
			}
		}
	}
}
